/*********************************************************************** * Setup various event handlers on the plugin widget ***********************************************************************/ void RxpSetupPluginEventHandlers (PluginInstance* This) { int i; /* Get ConfigureNotify and GravityNotify on the plugin */ XtAddEventHandler (This->plugin_widget, StructureNotifyMask, False, StructureNotifyHandler, (XtPointer) This); /* Arrange to receive DestroyNotify events on the clients windows. */ XtAddEventHandler (This->plugin_widget, SubstructureNotifyMask, False, SubstructureNotifyHandler, (XtPointer) This); /* Arrange to receive MapRequest and ConfigureRequest events on the * netscape plug-in widget. */ XtAddRawEventHandler(This->plugin_widget, SubstructureRedirectMask, False, SubstructureRedirectHandler, (XtPointer) This); XtRegisterDrawable (RxGlobal.dpy, This->app_group, This->plugin_widget); /* Arrange to receive Enter and Leave Notify events on application's toplevel windows */ XtAddRawEventHandler(This->plugin_widget, EnterWindowMask | LeaveWindowMask, False, CrossingHandler, (XtPointer) This); for (i = 0; i < This->nclient_windows; i++) { XtRegisterDrawable (RxGlobal.dpy, This->client_windows[i].win, This->plugin_widget); } }
void InitialiseSelection() { #if XtSpecificationRelease >= 6 XtRegisterDrawable(dpy, DefaultRootWindow(dpy), toplevel); #else _XtRegisterWindow(DefaultRootWindow(dpy), toplevel); #endif XSelectInput(dpy, DefaultRootWindow(dpy), PropertyChangeMask); XtAddRawEventHandler(toplevel, PropertyChangeMask, False, CutBufferChange, NULL); XtGetSelectionValue(toplevel, XA_PRIMARY, XInternAtom(dpy, "TIMESTAMP", False), GetInitialSelectionTimeCallback, NULL, CurrentTime); }
/* Create the Xt client widgets * */ static void xt_client_create ( XtClient* xtclient , Window embedderid, int height, int width ) { int n; Arg args[6]; Widget child_widget; Widget top_widget; #ifdef DEBUG_XTBIN printf("xt_client_create() \n"); #endif top_widget = XtAppCreateShell("drawingArea", "Wrapper", applicationShellWidgetClass, xtclient->xtdisplay, NULL, 0); xtclient->top_widget = top_widget; /* set size of Xt window */ n = 0; XtSetArg(args[n], XtNheight, height);n++; XtSetArg(args[n], XtNwidth, width);n++; XtSetValues(top_widget, args, n); child_widget = XtVaCreateWidget("form", compositeWidgetClass, top_widget, NULL); n = 0; XtSetArg(args[n], XtNheight, height);n++; XtSetArg(args[n], XtNwidth, width);n++; XtSetArg(args[n], XtNvisual, xtclient->xtvisual ); n++; XtSetArg(args[n], XtNdepth, xtclient->xtdepth ); n++; XtSetArg(args[n], XtNcolormap, xtclient->xtcolormap ); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetValues(child_widget, args, n); XSync(xtclient->xtdisplay, FALSE); xtclient->oldwindow = top_widget->core.window; top_widget->core.window = embedderid; /* this little trick seems to finish initializing the widget */ #if XlibSpecificationRelease >= 6 XtRegisterDrawable(xtclient->xtdisplay, embedderid, top_widget); #else _XtRegisterWindow( embedderid, top_widget); #endif XtRealizeWidget(child_widget); /* listen to all Xt events */ XSelectInput(xtclient->xtdisplay, XtWindow(top_widget), 0x0FFFFF); xt_client_set_info (child_widget, 0); XtManageChild(child_widget); xtclient->child_widget = child_widget; /* set the event handler */ XtAddEventHandler(child_widget, 0x0FFFFF & ~ResizeRedirectMask, TRUE, (XtEventHandler)xt_client_event_handler, xtclient); XtAddEventHandler(child_widget, SubstructureNotifyMask | ButtonReleaseMask, TRUE, (XtEventHandler)xt_client_focus_listener, xtclient); XSync(xtclient->xtdisplay, FALSE); }
/*********************************************************************** * Event Handler to reparent client window under plugin window ***********************************************************************/ /* static */ void SubstructureRedirectHandler ( Widget widget, XtPointer client_data, XEvent* event, Boolean* cont) { windowrec* new_list; PluginInstance* This = (PluginInstance*) client_data; #ifdef PLUGIN_TRACE fprintf (stderr, "%s\n", "SubstructureRedirectHandler"); fprintf (stderr, "This: 0x%x\n", This); #endif switch (event->type) { case ConfigureRequest: { XWindowChanges config; config.x = event->xconfigurerequest.x; config.y = event->xconfigurerequest.y; config.width = event->xconfigurerequest.width; config.height = event->xconfigurerequest.height; config.border_width = event->xconfigurerequest.border_width; config.sibling = event->xconfigurerequest.above; config.stack_mode = event->xconfigurerequest.detail; #if 0 fprintf (stderr, "configuring at %dx%d+%d+%d\n", config.width, config.height, config.x, config.y); #endif XConfigureWindow (RxGlobal.dpy, event->xconfigurerequest.window, event->xconfigurerequest.value_mask, &config); } break; case MapRequest: RxpSetStatusWidget(This, RUNNING); { Window for_win; int i; if (XGetTransientForHint (RxGlobal.dpy, event->xmaprequest.window, &for_win)) { for (i = 0; i < This->nclient_windows; i++) if (for_win == This->client_windows[i].win) XMapWindow (RxGlobal.dpy, event->xmaprequest.window); return; } } new_list = (windowrec*) NPN_MemAlloc (sizeof (windowrec) * (This->nclient_windows + 1)); if (new_list) { Position x, y; Dimension width, height; Dimension border_width; Colormap cmap; int n; Atom* wm_proto; windowrec* wp; Window destwin = XtWindow (This->plugin_widget); This->nclient_windows++; if (This->nclient_windows > 1) memcpy ((void*) new_list, (void*) This->client_windows, (This->nclient_windows - 1) * sizeof (windowrec)); if (This->client_windows) NPN_MemFree (This->client_windows); This->client_windows = new_list; x = y = 0; width = height = border_width = 0; GetWindowGeometry (RxGlobal.dpy, event->xmaprequest.window, &x, &y, &width, &height, &border_width, &cmap); wp = &This->client_windows[This->nclient_windows - 1]; wp->win = event->xmaprequest.window; wp->x = x; wp->y = y; wp->width = width; wp->height = height; wp->border_width = border_width; wp->flags = RxpMapped; wp->colormap = cmap; if (XGetWMProtocols (RxGlobal.dpy, wp->win, &wm_proto, &n)) { int i; Atom* ap; for (i = 0, ap = wm_proto; i < n; i++, ap++) { if (*ap == RxGlobal.wm_delete_window) wp->flags |= RxpWmDelWin; } if (wm_proto) XFree ((char*) wm_proto); } XSelectInput(RxGlobal.dpy, wp->win, EnterWindowMask | LeaveWindowMask); XtRegisterDrawable (RxGlobal.dpy, wp->win, This->plugin_widget); XReparentWindow (RxGlobal.dpy, wp->win, destwin, wp->x, wp->y); XMapWindow (RxGlobal.dpy, wp->win); } break; } }
void xtbin::xtbin_realize() { Arg args[2]; int n; Widget top_widget; Widget embedded; XSetWindowAttributes attr; unsigned long mask; attr.bit_gravity = NorthWestGravity; attr.event_mask = ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask | KeyReleaseMask | LeaveWindowMask | PointerMotionMask | StructureNotifyMask | VisibilityChangeMask | FocusChangeMask; attr.colormap = xxlib_rgb_get_cmap(mXlibRgbHandle); attr.background_pixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, 0xFFC0C0C0); attr.border_pixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, 0xFF646464); #ifdef DEBUG printf("attr.background_pixel = %lx, attr.border_pixel = %lx, parent_window = %x\n", (long)attr.background_pixel, (long)attr.border_pixel, (int)parent_window); #endif /* DEBUG */ mask = CWBitGravity | CWEventMask | CWBorderPixel | CWBackPixel; if (attr.colormap) mask |= CWColormap; window = XCreateWindow(xtdisplay, parent_window, x, y, width, height, 0, xxlib_rgb_get_depth(mXlibRgbHandle), InputOutput, xxlib_rgb_get_visual(mXlibRgbHandle), mask, &attr); XSetWindowBackgroundPixmap(xtdisplay, window, None); XSelectInput(xtdisplay, window, ExposureMask); XMapWindow(xtdisplay, window); XFlush(xtdisplay); top_widget = XtAppCreateShell("drawingArea", "Wrapper", applicationShellWidgetClass, xtdisplay, NULL, 0); xtwidget = top_widget; n = 0; XtSetArg(args[n], XtNheight, height); n++; XtSetArg(args[n], XtNwidth, width); n++; XtSetValues(top_widget, args, n); embedded = XtVaCreateWidget("form", compositeWidgetClass, top_widget, NULL); n = 0; XtSetArg(args[n], XtNheight, height); n++; XtSetArg(args[n], XtNwidth, width); n++; XtSetValues(embedded, args, n); oldwindow = top_widget->core.window; top_widget->core.window = window; XtRegisterDrawable(xtdisplay, window, top_widget); XtRealizeWidget(embedded); XtRealizeWidget(top_widget); XtManageChild(embedded); /* Now fill out the xtbin info */ xtwindow = XtWindow(embedded); /* Suppress background refresh flashing */ XSetWindowBackgroundPixmap(xtdisplay, XtWindow(top_widget), None); XSetWindowBackgroundPixmap(xtdisplay, XtWindow(embedded), None); /* Listen to all Xt events */ XSelectInput(xtdisplay, XtWindow(top_widget), 0x0fffff); XSelectInput(xtdisplay, XtWindow(embedded), 0x0fffff); sync(); }
static void RealizeWidget( Widget widget) { XtValueMask value_mask; XSetWindowAttributes values; XtRealizeProc realize; Window window; Display* display; String class_name; Widget hookobj; if (!XtIsWidget(widget) || XtIsRealized(widget)) return; display = XtDisplay(widget); _XtInstallTranslations(widget); ComputeWindowAttributes (widget, &value_mask, &values); LOCK_PROCESS; realize = widget->core.widget_class->core_class.realize; class_name = widget->core.widget_class->core_class.class_name; UNLOCK_PROCESS; if (realize == NULL) XtAppErrorMsg(XtWidgetToApplicationContext(widget), "invalidProcedure","realizeProc",XtCXtToolkitError, "No realize class procedure defined", (String *)NULL, (Cardinal *)NULL); else { CALLGEOTAT(_XtGeoTrace(widget,"Call \"%s\"[%d,%d]'s realize proc\n", XtName(widget), widget->core.width, widget->core.height)); (*realize) (widget, &value_mask, &values); } window = XtWindow(widget); hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); if (XtHasCallbacks(hookobj,XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHrealizeWidget; call_data.widget = widget; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } #ifndef NO_IDENTIFY_WINDOWS if (_XtGetPerDisplay(display)->appContext->identify_windows) { int len_nm, len_cl; char *s; len_nm = widget->core.name ? strlen(widget->core.name) : 0; len_cl = strlen(class_name); s = __XtMalloc((unsigned) (len_nm + len_cl + 2)); s[0] = '\0'; if (len_nm) strcpy(s, widget->core.name); strcpy(s + len_nm + 1, class_name); XChangeProperty(display, window, XInternAtom(display, "_MIT_OBJ_CLASS", False), XA_STRING, 8, PropModeReplace, (unsigned char *) s, len_nm + len_cl + 2); XtFree(s); } #endif #ifdef notdef _XtRegisterAsyncHandlers(widget); #endif /* (re)register any grabs extant in the translations */ _XtRegisterGrabs(widget); /* reregister any grabs added with XtGrab{Button,Key} */ _XtRegisterPassiveGrabs(widget); XtRegisterDrawable (display, window, widget); _XtExtensionSelect(widget); if (XtIsComposite (widget)) { Cardinal i; CompositePart *cwp = &(((CompositeWidget)widget)->composite); WidgetList children = cwp->children; /* Realize all children */ for (i = cwp->num_children; i != 0; --i) { RealizeWidget (children[i-1]); } /* Map children that are managed and mapped_when_managed */ if (cwp->num_children != 0) { if (ShouldMapAllChildren(cwp)) { XMapSubwindows (display, window); } else { MapChildren(cwp); } } } /* If this is the application's popup shell, map it */ if (widget->core.parent == NULL && widget->core.mapped_when_managed) { XtMapWidget (widget); } } /* RealizeWidget */