struct frame *
x_any_window_to_frame (struct device *d, Window wdesc)
{
- Lisp_Object tail, frame;
- struct frame *f;
-
+ Widget w;
assert (DEVICE_X_P (d));
+ w = XtWindowToWidget (DEVICE_X_DISPLAY (d), wdesc);
+
+ if (!w)
+ return 0;
+
+ /* We used to map over all frames here and then map over all widgets
+ belonging to that frame. However it turns out that this was very fragile
+ as it requires our display stuctures to be in sync _and_ that the
+ loop is told about every new widget somebody adds. Therefore we
+ now let Xt find it for us (which does a bottom-up search which
+ could even be faster) */
+ return x_any_widget_or_parent_to_frame (d, w);
+}
+
+static struct frame *
+x_find_frame_for_window (struct device *d, Window wdesc)
+{
+ Lisp_Object tail, frame;
+ struct frame *f;
/* This function was previously written to accept only a window argument
(and to loop over all devices looking for a matching window), but
that is incorrect because window ID's are not unique across displays. */
for (tail = DEVICE_FRAME_LIST (d); CONSP (tail); tail = XCDR (tail))
{
- int i;
-
frame = XCAR (tail);
f = XFRAME (frame);
/* This frame matches if the window is any of its widgets. */
would incorrectly get sucked away by Emacs if this function matched
on psheet widgets. */
- for (i = 0; i < FRAME_X_NUM_TOP_WIDGETS (f); i++)
- {
- Widget wid = FRAME_X_TOP_WIDGETS (f)[i];
- if (wid && XtIsManaged (wid) && wdesc == XtWindow (wid))
- return f;
- }
-
-#ifdef HAVE_SCROLLBARS
- /* Match if the window is one of this frame's scrollbars. */
- if (x_window_is_scrollbar (f, wdesc))
- return f;
-#endif
+ /* Note: that this called only from
+ x_any_widget_or_parent_to_frame it is unnecessary to iterate
+ over the top level widgets. */
+
+ /* Note: we use to special case scrollbars but this turns out to be a bad idea
+ because
+ 1. We sometimes get events for _unmapped_ scrollbars and our
+ callers don't want us to fail.
+ 2. Starting with the 21.2 widget stuff there are now loads of
+ widgets to check and it is easy to forget adding them in a loop here.
+ See x_any_window_to_frame
+ 3. We pick up all widgets now anyway. */
}
return 0;
{
while (widget)
{
- struct frame *f = x_any_window_to_frame (d, XtWindow (widget));
+ struct frame *f = x_find_frame_for_window (d, XtWindow (widget));
if (f)
return f;
widget = XtParent (widget);
XSetClassHint (dpy, XtWindow (shell), &classhint);
}
-#ifndef HAVE_SESSION
+#ifndef HAVE_WMCOMMAND
static void
x_wm_maybe_store_wm_command (struct frame *f)
{
}
}
-#endif /* !HAVE_SESSION */
+#endif /* !HAVE_WMCOMMAND */
static int
x_frame_iconified_p (struct frame *f)
init_x_prop_symbols (void)
{
#define def(sym, rsrc) \
- pure_put (sym, Qx_resource_name, build_string (rsrc))
+ Fput (sym, Qx_resource_name, build_string (rsrc))
#define defi(sym,rsrc) \
- def (sym, rsrc); pure_put (sym, Qintegerp, Qt)
+ def (sym, rsrc); Fput (sym, Qintegerp, Qt)
#if 0 /* this interferes with things. #### fix this right */
def (Qminibuffer, XtNminibuffer);
char *string;
CHECK_STRING (lisp_window_id);
- string = (char *) (XSTRING_DATA (lisp_window_id));
+ string = (char *) XSTRING_DATA (lisp_window_id);
if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X'))
sscanf (string+2, "%lxu", &window_id);
#if 0
/* tell the window manager about us. */
x_wm_store_class_hints (shell_widget, XtName (frame_widget));
-#ifndef HAVE_SESSION
+#ifndef HAVE_WMCOMMAND
x_wm_maybe_store_wm_command (f);
-#endif /* HAVE_SESSION */
+#endif /* HAVE_WMCOMMAND */
x_wm_hack_wm_protocols (shell_widget);
}
}
static void
-x_mark_frame (struct frame *f, void (*markobj) (Lisp_Object))
+x_mark_frame (struct frame *f)
{
- markobj (FRAME_X_ICON_PIXMAP (f));
- markobj (FRAME_X_ICON_PIXMAP_MASK (f));
+ mark_object (FRAME_X_ICON_PIXMAP (f));
+ mark_object (FRAME_X_ICON_PIXMAP_MASK (f));
}
static void
static void
x_delete_frame (struct frame *f)
{
-#ifndef HAVE_SESSION
+ Display *dpy;
+
+#ifndef HAVE_WMCOMMAND
if (FRAME_X_TOP_LEVEL_FRAME_P (f))
x_wm_maybe_move_wm_command (f);
-#endif /* HAVE_SESSION */
+#endif /* HAVE_WMCOMMAND */
#ifdef HAVE_CDE
DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f));
#endif /* HAVE_CDE */
- assert (FRAME_X_SHELL_WIDGET (f));
- if (FRAME_X_SHELL_WIDGET (f))
- {
- Display *dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f));
- expect_x_error (dpy);
- /* for obscure reasons having (I think) to do with the internal
- window-to-widget hierarchy maintained by Xt, we have to call
- XtUnrealizeWidget() here. Xt can really suck. */
- if (f->being_deleted)
- XtUnrealizeWidget (FRAME_X_SHELL_WIDGET (f));
- XtDestroyWidget (FRAME_X_SHELL_WIDGET (f));
- x_error_occurred_p (dpy);
-
- /* make sure the windows are really gone! */
- /* ### Is this REALLY necessary? */
- XFlush (dpy);
-
- FRAME_X_SHELL_WIDGET (f) = 0;
- }
+ assert (FRAME_X_SHELL_WIDGET (f) != 0);
+ dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f));
+
+#ifdef EXTERNAL_WIDGET
+ expect_x_error (XtDisplay (FRAME_X_SHELL_WIDGET (f)));
+ /* for obscure reasons having (I think) to do with the internal
+ window-to-widget hierarchy maintained by Xt, we have to call
+ XtUnrealizeWidget() here. Xt can really suck. */
+ if (f->being_deleted)
+ XtUnrealizeWidget (FRAME_X_SHELL_WIDGET (f));
+ XtDestroyWidget (FRAME_X_SHELL_WIDGET (f));
+ x_error_occurred_p (XtDisplay (FRAME_X_SHELL_WIDGET (f)));
+#else
+ XtDestroyWidget (FRAME_X_SHELL_WIDGET (f));
+ /* make sure the windows are really gone! */
+ /* ### Is this REALLY necessary? */
+ XFlush (dpy);
+#endif /* EXTERNAL_WIDGET */
+
+ FRAME_X_SHELL_WIDGET (f) = 0;
if (FRAME_X_GEOM_FREE_ME_PLEASE (f))
{