summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Mainz <roland.mainz@nrubsig.org>2004-09-18 00:30:51 +0000
committerRoland Mainz <roland.mainz@nrubsig.org>2004-09-18 00:30:51 +0000
commit02050676964380bfd5edc5ffbfb87ad0dbbdc876 (patch)
tree47f36ab818f8b716b5624425ca8c6b917adaa921
parente2a6df6025e2fbecd24be7bd47b65f2f46736691 (diff)
Fix for http://freedesktop.org/bugzilla/show_bug.cgi?id=1372 - Initial part
of repairing XRX/Broadway support. This patch fixes both the libxrx.so plugin and the Xnest-based libxrxnest.so plugin and making them compatible to newer versions of Mozilla and removing the backwards compatibility hacks for old Netscape3.x versions with statically linked Motif.
-rw-r--r--plugin/Main.c71
-rw-r--r--plugin/PProcess.c2
-rw-r--r--xnest-plugin/NewNDest.c9
-rw-r--r--xnest-plugin/SetWin.c32
-rw-r--r--xnest-plugin/XnestDis.c43
5 files changed, 99 insertions, 58 deletions
diff --git a/plugin/Main.c b/plugin/Main.c
index 7f11777..834300e 100644
--- a/plugin/Main.c
+++ b/plugin/Main.c
@@ -52,11 +52,20 @@ The Open Group.
*
*/
-#include <ctype.h>
-#include <stdlib.h>
+
#include "RxPlugin.h"
-#include "X11/StringDefs.h"
+#include <X11/StringDefs.h>
+#ifdef USE_MOTIF
+extern WidgetClass xmLabelGadgetClass;
+extern WidgetClass xmPushButtonGadgetClass;
+#else
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/Command.h>
+#endif /* USE_MOTIF */
+
+#include <ctype.h>
+#include <stdlib.h>
/***********************************************************************
* Utility functions to deal with list of arguments
@@ -380,14 +389,6 @@ StartCB(Widget widget, XtPointer client_data, XtPointer call_data)
StartApplication(This);
}
-#if defined(linux) || (defined(sun) && !defined(SVR4))
-/* deficient linux linker semantics */
-static WidgetClass xmLabelGadgetClass;
-static WidgetClass xmPushButtonGadgetClass;
-#else
-extern WidgetClass xmLabelGadgetClass;
-extern WidgetClass xmPushButtonGadgetClass;
-#endif
void
RxpSetStatusWidget(PluginInstance* This, PluginState state)
@@ -415,35 +416,12 @@ RxpSetStatusWidget(PluginInstance* This, PluginState state)
XrmPutStringResource (&db, "*Rx_Start.labelString", "Start");
XrmPutStringResource (&db, "RxPlugin_BeenHere", "YES");
}
-#if defined(linux) || (defined(sun) && !defined(SVR4))
- /*
- lame loader semantics mean we have to go fishing around to
- come up with widget class records so we can create some widgets.
-
- Names of widgets changed in 4.x, so look for those names too
- for linux.
-
- If Microsoft ever does IE for Linux we'll have to figure out
- those names too.
- */
- if (xmLabelGadgetClass == NULL) {
- Widget w;
-
- w = XtNameToWidget (This->toplevel_widget, "*topLeftArea.urlLabel");
- if (w == NULL)
- w = XtNameToWidget (This->toplevel_widget, "*urlBar.urlLocationLabel");
- xmLabelGadgetClass = XtClass (w);
- w = XtNameToWidget (This->toplevel_widget, "*toolBar.abort");
- if (w == NULL)
- w = XtNameToWidget (This->toplevel_widget, "*PopupMenu.openCustomUrl");
- xmPushButtonGadgetClass = XtClass (w);
- }
-#endif
n = 0;
XtSetArg(args[n], "shadowThickness", 1); n++;
XtSetArg(args[n], XtNwidth, This->width); n++;
XtSetArg(args[n], XtNheight, This->height); n++;
+#ifdef USE_MOTIF
if (state == LOADING) {
/* create a label */
This->status_widget =
@@ -465,6 +443,29 @@ RxpSetStatusWidget(PluginInstance* This, PluginState state)
} else if (state == RUNNING) {
/* nothing else to be done */
}
+#else
+ if (state == LOADING) {
+ /* create a label */
+ This->status_widget =
+ XtCreateManagedWidget("Rx_Loading", labelWidgetClass,
+ This->plugin_widget, args, n);
+#ifndef NO_STARTING_STATE
+ } else if (state == STARTING) {
+ /* create a label */
+ This->status_widget =
+ XtCreateManagedWidget("Rx_Starting", labelWidgetClass,
+ This->plugin_widget, args, n);
+#endif
+ } else if (state == WAITING) {
+ /* create a push button */
+ This->status_widget =
+ XtCreateManagedWidget("Rx_Start", commandWidgetClass,
+ This->plugin_widget, args, n);
+ XtAddCallback(This->status_widget, XtNcallback, StartCB, This);
+ } else if (state == RUNNING) {
+ /* nothing else to be done */
+ }
+#endif /* USE_MOTIF */
This->state = state;
}
diff --git a/plugin/PProcess.c b/plugin/PProcess.c
index 2de5b39..8d067a8 100644
--- a/plugin/PProcess.c
+++ b/plugin/PProcess.c
@@ -686,6 +686,7 @@ void
RxpTeardown (PluginInstance* This)
{
if (This->toplevel_widget != NULL) {
+#if 0 /* this crashes mozilla/firefox */
/* ConfigureNotify on top level */
XtRemoveRawEventHandler (This->toplevel_widget,
StructureNotifyMask,
@@ -697,6 +698,7 @@ RxpTeardown (PluginInstance* This)
True,
RxpWmDelWinHandler,
(XtPointer) This);
+#endif
#if 0
XmRemoveWMProtocolCallback (This->toplevel_widget,
RxGlobal.wm_delete_window,
diff --git a/xnest-plugin/NewNDest.c b/xnest-plugin/NewNDest.c
index 52b038c..00c1b1c 100644
--- a/xnest-plugin/NewNDest.c
+++ b/xnest-plugin/NewNDest.c
@@ -59,7 +59,14 @@ RxpNew(PluginInstance *This)
void
RxpDestroy(PluginInstance *This)
{
+ int status;
+
/* kill child process */
- kill(This->child_pid, SIGKILL);
+ kill(This->child_pid, SIGTERM);
+
+ /* ... and fetch the status (to avoid dead process childs
+ * floating around) */
+ waitpid(This->child_pid, &status, 0);
+
RxpFreeXnestDisplayNumber(This->display_num);
}
diff --git a/xnest-plugin/SetWin.c b/xnest-plugin/SetWin.c
index 33e80a6..f2de45d 100644
--- a/xnest-plugin/SetWin.c
+++ b/xnest-plugin/SetWin.c
@@ -65,7 +65,6 @@ static void
DestroyCB (Widget widget, XtPointer client_data, XtPointer call_data)
{
PluginInstance* This = (PluginInstance*) client_data;
- int i;
#ifdef PLUGIN_TRACE
fprintf (stderr, "DestroyCB, This: 0x%x\n", This);
#endif
@@ -74,7 +73,7 @@ DestroyCB (Widget widget, XtPointer client_data, XtPointer call_data)
if (This->dont_reparent == RxFalse) {
XUnmapWindow(XtDisplay(widget), This->window);
XReparentWindow(XtDisplay(widget), This->window,
- RootWindowOfScreen(XtScreen(widget)), 0, 0);
+ XRootWindowOfScreen(XtScreen(widget)), 0, 0);
This->dont_reparent = RxTrue;
} else
This->dont_reparent = RxFalse;
@@ -177,20 +176,23 @@ NPP_SetWindow(NPP instance, NPWindow* window)
#endif
pid = fork();
if (pid == 0) { /* child process */
- static char *argv[] = {
- "Xnest",
- "-ac", /* no access control (sic!) */
- ":00", /* display number */
- "-parent",
- "01234567890123456789", /* parent window id */
- NULL
- };
- close(ConnectionNumber(display));
-
- sprintf(argv[2], ":%d", This->display_num);
- sprintf(argv[4], "%ld", This->window);
+ char buffer1[64],
+ buffer2[64];
+ char *xnest_argv[6];
+
+ xnest_argv[0] = "Xnest";
+ xnest_argv[1] = "-ac"; /* no access control (sic!) */
+ xnest_argv[2] = buffer1; /* display number */
+ xnest_argv[3] = "-parent";
+ xnest_argv[4] = buffer2; /* parent window id */
+ xnest_argv[5] = NULL;
+
+ close(XConnectionNumber(display));
+
+ sprintf(xnest_argv[2], ":%d", This->display_num);
+ sprintf(xnest_argv[4], "%ld", This->window);
/* exec Xnest */
- execvp("Xnest", argv);
+ execvp("Xnest", xnest_argv);
perror("Xnest");
return NPERR_GENERIC_ERROR;
} else { /* parent process */
diff --git a/xnest-plugin/XnestDis.c b/xnest-plugin/XnestDis.c
index b93a20f..a53203b 100644
--- a/xnest-plugin/XnestDis.c
+++ b/xnest-plugin/XnestDis.c
@@ -34,19 +34,47 @@ The Open Group.
* Utility functions and global variable to manage display numbers
***********************************************************************/
-/* maximum numbers of concurrent instances */
-#define MAX_PLUGINS 10
+/* maximum numbers of concurrent instances (per machine) */
+#define MAX_PLUGINS 128
-/* start from 5 to avoid possible conflict with multi-display X server */
-#define XNEST_OFFSET 5
+/* start from 80 to avoid possible conflict with multi-display X server
+ * like SunRay,LTSP, etc.*/
+#define XNEST_OFFSET 80
/* global allowing to know which display numbers are in use */
-static int16 xnest_display_numbers[MAX_PLUGINS];
+static char xnest_display_numbers[MAX_PLUGINS];
void
RxpInitXnestDisplayNumbers()
{
- memset(xnest_display_numbers, 0, sizeof(int16) * MAX_PLUGINS);
+ memset(xnest_display_numbers, 0, sizeof(char) * MAX_PLUGINS);
+}
+
+static
+Bool IsDisplayNumFree(int id)
+{
+ char fnamebuf[256];
+ struct stat sbuf;
+ int res;
+
+ /* /tmp/.X%d-lock is more or less the official way... */
+ sprintf(fnamebuf, "/tmp/.X%d-lock", id);
+ res = stat(fnamebuf, &sbuf);
+ if (res == 0)
+ return False;
+
+ /* ... but then we have to test for the old stuff, too... ;-( */
+ sprintf(fnamebuf, "/tmp/.X11-pipe/X%d", id);
+ res = stat(fnamebuf, &sbuf);
+ if (res == 0)
+ return False;
+
+ sprintf(fnamebuf, "/tmp/.X11-unix/X%d", id);
+ res = stat(fnamebuf, &sbuf);
+ if (res == 0)
+ return False;
+
+ return True;
}
/* function returning first display number available */
@@ -55,7 +83,8 @@ RxpXnestDisplayNumber()
{
int i;
for (i = 0; i < MAX_PLUGINS; i++)
- if (xnest_display_numbers[i] == 0) {
+ if ((xnest_display_numbers[i] == 0) &&
+ IsDisplayNumFree(i + XNEST_OFFSET)) {
xnest_display_numbers[i] = 1;
return i + XNEST_OFFSET;
}