summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2010-02-20 00:48:50 +0100
committerSamuel Lidén Borell <samuel@slbdata.se>2010-02-20 00:48:50 +0100
commit3e95ab256185edd4b05e1325a3422102b0067a08 (patch)
tree6b1bee56f1a6c1b212de686693ff0bf95e649a0e
parent044097f7d6857b8bc91e216ab8a3503a93c89e1d (diff)
downloadfribid-3e95ab256185edd4b05e1325a3422102b0067a08.tar.gz
fribid-3e95ab256185edd4b05e1325a3422102b0067a08.tar.bz2
fribid-3e95ab256185edd4b05e1325a3422102b0067a08.zip
Fixed a few more window id problems on 64-bit platforms
This commit fixes the code outside of the plugin to work properly with 64-bit windows ids. I also simplified the plugin code a bit by using the None value instead of having a separate parameter and a boolean return value.
-rw-r--r--client/gtk.c4
-rw-r--r--client/main.c4
-rw-r--r--client/platform.h7
-rw-r--r--plugin/ipc.c4
-rw-r--r--plugin/npobject.c18
5 files changed, 19 insertions, 18 deletions
diff --git a/client/gtk.c b/client/gtk.c
index 138b5a9..8c08eee 100644
--- a/client/gtk.c
+++ b/client/gtk.c
@@ -176,7 +176,7 @@ static void selectDefaultSignature() {
}
void platform_startSign(const char *url, const char *hostname, const char *ip,
- const char *subjectFilter, int parentWindowId) {
+ const char *subjectFilter, unsigned long parentWindowId) {
currentSubjectFilter = (subjectFilter != NULL ?
strdup(subjectFilter) : NULL);
@@ -237,7 +237,7 @@ void platform_startSign(const char *url, const char *hostname, const char *ip,
signDialog = GTK_DIALOG(gtk_builder_get_object(builder, "dialog_sign"));
bool transientOk = false;
- if (parentWindowId != -1) {
+ if (parentWindowId != PLATFORM_NO_WINDOW) {
GdkWindow *parent = gdk_window_foreign_new((GdkNativeWindow)parentWindowId);
if (parent != NULL) {
gtk_widget_realize(GTK_WIDGET(signDialog));
diff --git a/client/main.c b/client/main.c
index d6d102c..4e48927 100644
--- a/client/main.c
+++ b/client/main.c
@@ -35,7 +35,7 @@
#include "misc.h"
static const char version[] = PACKAGEVERSION;
-static int browserWindowId = -1;
+static unsigned long browserWindowId = PLATFORM_NO_WINDOW;
/**
* pipeData is called when the plugin has sent some data.
@@ -201,7 +201,7 @@ int main(int argc, char **argv) {
error = true;
break;
}
- browserWindowId = atoi(argv[i]);
+ browserWindowId = atol(argv[i]);
} else {
fprintf(stderr, BINNAME ": Invalid option: %s\n", argv[i]);
error = true;
diff --git a/client/platform.h b/client/platform.h
index 7e41198..151af36 100644
--- a/client/platform.h
+++ b/client/platform.h
@@ -81,11 +81,16 @@ void platform_asyncCall(AsyncCallFunction *function, void *param);
uint32_t platform_lookupTypeARecord(const char *hostname);
/* User interface */
+
+// This value has to match the value in the window system
+// (for example, None on X11)
+#define PLATFORM_NO_WINDOW 0
+
void platform_mainloop();
void platform_leaveMainloop();
void platform_startSign(const char *url, const char *hostname, const char *ip,
- const char *subjectFilter, int parentWindowId);
+ const char *subjectFilter, unsigned long parentWindowId);
void platform_endSign();
void platform_setMessage(const char *message);
bool platform_sign(char **signature, int *siglen, char **person, char **password);
diff --git a/plugin/ipc.c b/plugin/ipc.c
index efd68d5..3d618f2 100644
--- a/plugin/ipc.c
+++ b/plugin/ipc.c
@@ -93,12 +93,12 @@ static void openVersionPipes(PipeInfo *pipeinfo) {
}
static void openInteractivePipes(PipeInfo *pipeinfo, Plugin *plugin) {
- char windowId[11]; // This holds a native window id (such as an XID)
+ char windowId[21]; // This holds a native window id (such as an XID)
const char *argv[] = {
mainBinary, ipcOption, windowIdOption, windowId, (char *)NULL,
};
- snprintf(windowId, 11, "%d", plugin->windowId);
+ snprintf(windowId, 21, "%ld", plugin->windowId);
openPipes(pipeinfo, argv);
}
diff --git a/plugin/npobject.c b/plugin/npobject.c
index d25706a..17688f7 100644
--- a/plugin/npobject.c
+++ b/plugin/npobject.c
@@ -155,16 +155,14 @@ static char *getDocumentIP(NPP instance) {
}
/**
- * Returns the native ID of the browser window, or -1 on error.
+ * Returns the native ID of the browser window, or None (= 0) on error.
*/
-static bool getWindowId(NPP instance, Window *id) {
- if (id == NULL) {
- return false;
- }
- if (NPN_GetValue(instance, NPNVnetscapeWindow, id) == NPERR_NO_ERROR) {
- return true;
+static Window getWindowId(NPP instance) {
+ Window id;
+ if (NPN_GetValue(instance, NPNVnetscapeWindow, &id) == NPERR_NO_ERROR) {
+ return id;
} else {
- return false;
+ return None;
}
}
@@ -336,7 +334,6 @@ static NPClass baseClass = {
/* Object construction */
static NPObject *npobject_new(NPP instance, PluginType pluginType) {
PluginObject *obj;
- Window windowId;
obj = (PluginObject*)NPN_CreateObject(instance, &baseClass);
if (!obj) return NULL;
@@ -345,13 +342,12 @@ static NPObject *npobject_new(NPP instance, PluginType pluginType) {
char *url = getDocumentURL(instance);
char *hostname = getDocumentHostname(instance);
char *ip = getDocumentIP(instance);
- getWindowId(instance, &windowId);
obj->plugin = plugin_new(pluginType,
(url != NULL ? url : ""),
(hostname != NULL ? hostname : ""),
(ip != NULL ? ip : ""),
- windowId);
+ getWindowId(instance));
free(ip);
free(hostname);
free(url);