diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2005-02-11 10:58:33 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2005-02-11 10:58:33 +0000 |
commit | 70d0b6ffec63fc2adf73a9f5714ba75d7324c5c8 (patch) | |
tree | 4f705cd001aa1231b47a0671fc76ab013847fbba | |
parent | d76653289216e6f6061e629b74be35003bd29156 (diff) |
Import changes from XORG-6.8.2CYGWIN-6_8_2-MERGECYGWIN
-rw-r--r-- | helper/helper.c | 2 | ||||
-rw-r--r-- | plugin/Main.c | 71 | ||||
-rw-r--r-- | plugin/PProcess.c | 2 | ||||
-rw-r--r-- | plugin/include/npapi.h | 3 | ||||
-rw-r--r-- | xnest-plugin/NewNDest.c | 9 | ||||
-rw-r--r-- | xnest-plugin/SetWin.c | 32 | ||||
-rw-r--r-- | xnest-plugin/XnestDis.c | 44 |
7 files changed, 105 insertions, 58 deletions
diff --git a/helper/helper.c b/helper/helper.c index 9842623..cd65b07 100644 --- a/helper/helper.c +++ b/helper/helper.c @@ -526,4 +526,6 @@ main(int argc, char *argv[]) /* then wait for it... */ XtAppMainLoop(app_context); + + return EXIT_SUCCESS; } 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/plugin/include/npapi.h b/plugin/include/npapi.h index a45b264..00be015 100644 --- a/plugin/include/npapi.h +++ b/plugin/include/npapi.h @@ -40,12 +40,15 @@ typedef unsigned short uint16; #ifndef _UINT32 typedef unsigned int uint32; #endif + +#if !(defined(_AIX) && defined(_H_INTTYPES) && defined(_ALL_SOURCE)) #ifndef _INT16 typedef short int16; #endif #ifndef _INT32 typedef int int32; #endif +#endif #ifndef FALSE #define FALSE (0) 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..a30c79e 100644 --- a/xnest-plugin/XnestDis.c +++ b/xnest-plugin/XnestDis.c @@ -29,24 +29,53 @@ The Open Group. /* $XFree86$ */ #include "RxPlugin.h" +#include <sys/stat.h> /*********************************************************************** * 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 +84,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; } |