+ {
+ char *s = get_string_resource ("windowID", "WindowID");
+ if (s && *s)
+ on_window = get_integer_resource ("windowID", "WindowID");
+ if (s) free (s);
+ }
+
+ if (on_window)
+ {
+ XWindowAttributes xgwa;
+ window = (Window) on_window;
+ XtDestroyWidget (toplevel);
+ XGetWindowAttributes (dpy, window, &xgwa);
+ cmap = xgwa.colormap;
+ visual = xgwa.visual;
+ visual_warning (screen, window, visual, cmap, True);
+
+ /* Select KeyPress events on the external window.
+ */
+ xgwa.your_event_mask |= KeyPressMask;
+ XSelectInput (dpy, window, xgwa.your_event_mask);
+
+ /* Select ButtonPress and ButtonRelease events on the external window,
+ if no other app has already selected them (only one app can select
+ ButtonPress at a time: BadAccess results.)
+ */
+ if (! (xgwa.all_event_masks & (ButtonPressMask | ButtonReleaseMask)))
+ XSelectInput (dpy, window,
+ (xgwa.your_event_mask |
+ ButtonPressMask | ButtonReleaseMask));
+ }
+ else if (root_p)