Mercurial > hg > xemacs-beta
comparison src/frame-x.c @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 182f72e8cd0d |
children | 6240c7796c7a |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
101 /* Like x_window_to_frame but also compares the window with the widget's | 101 /* Like x_window_to_frame but also compares the window with the widget's |
102 windows */ | 102 windows */ |
103 struct frame * | 103 struct frame * |
104 x_any_window_to_frame (struct device *d, Window wdesc) | 104 x_any_window_to_frame (struct device *d, Window wdesc) |
105 { | 105 { |
106 Widget w; | |
107 assert (DEVICE_X_P (d)); | |
108 | |
109 w = XtWindowToWidget (DEVICE_X_DISPLAY (d), wdesc); | |
110 | |
111 if (!w) | |
112 return 0; | |
113 | |
114 /* We used to map over all frames here and then map over all widgets | |
115 belonging to that frame. However it turns out that this was very fragile | |
116 as it requires our display stuctures to be in sync _and_ that the | |
117 loop is told about every new widget somebody adds. Therefore we | |
118 now let Xt find it for us (which does a bottom-up search which | |
119 could even be faster) */ | |
120 return x_any_widget_or_parent_to_frame (d, w); | |
121 } | |
122 | |
123 static struct frame * | |
124 x_find_frame_for_window (struct device *d, Window wdesc) | |
125 { | |
126 Lisp_Object tail, frame; | 106 Lisp_Object tail, frame; |
127 struct frame *f; | 107 struct frame *f; |
108 | |
109 assert (DEVICE_X_P (d)); | |
110 | |
128 /* This function was previously written to accept only a window argument | 111 /* This function was previously written to accept only a window argument |
129 (and to loop over all devices looking for a matching window), but | 112 (and to loop over all devices looking for a matching window), but |
130 that is incorrect because window ID's are not unique across displays. */ | 113 that is incorrect because window ID's are not unique across displays. */ |
131 | 114 |
132 for (tail = DEVICE_FRAME_LIST (d); CONSP (tail); tail = XCDR (tail)) | 115 for (tail = DEVICE_FRAME_LIST (d); CONSP (tail); tail = XCDR (tail)) |
133 { | 116 { |
117 int i; | |
118 | |
134 frame = XCAR (tail); | 119 frame = XCAR (tail); |
135 f = XFRAME (frame); | 120 f = XFRAME (frame); |
136 /* This frame matches if the window is any of its widgets. */ | 121 /* This frame matches if the window is any of its widgets. */ |
137 if (wdesc == XtWindow (FRAME_X_SHELL_WIDGET (f)) || | 122 if (wdesc == XtWindow (FRAME_X_SHELL_WIDGET (f)) || |
138 wdesc == XtWindow (FRAME_X_CONTAINER_WIDGET (f)) || | 123 wdesc == XtWindow (FRAME_X_CONTAINER_WIDGET (f)) || |
151 for this statement is that, in the old (broken) event loop, where | 136 for this statement is that, in the old (broken) event loop, where |
152 not all events went through XtDispatchEvent(), psheet events | 137 not all events went through XtDispatchEvent(), psheet events |
153 would incorrectly get sucked away by Emacs if this function matched | 138 would incorrectly get sucked away by Emacs if this function matched |
154 on psheet widgets. */ | 139 on psheet widgets. */ |
155 | 140 |
156 /* Note: that this called only from | 141 for (i = 0; i < FRAME_X_NUM_TOP_WIDGETS (f); i++) |
157 x_any_widget_or_parent_to_frame it is unnecessary to iterate | 142 { |
158 over the top level widgets. */ | 143 Widget wid = FRAME_X_TOP_WIDGETS (f)[i]; |
159 | 144 if (wid && XtIsManaged (wid) && wdesc == XtWindow (wid)) |
160 /* Note: we use to special case scrollbars but this turns out to be a bad idea | 145 return f; |
161 because | 146 } |
162 1. We sometimes get events for _unmapped_ scrollbars and our | 147 |
163 callers don't want us to fail. | 148 #ifdef HAVE_SCROLLBARS |
164 2. Starting with the 21.2 widget stuff there are now loads of | 149 /* Match if the window is one of this frame's scrollbars. */ |
165 widgets to check and it is easy to forget adding them in a loop here. | 150 if (x_window_is_scrollbar (f, wdesc)) |
166 See x_any_window_to_frame | 151 return f; |
167 3. We pick up all widgets now anyway. */ | 152 #endif |
168 } | 153 } |
169 | 154 |
170 return 0; | 155 return 0; |
171 } | 156 } |
172 | 157 |
173 struct frame * | 158 struct frame * |
174 x_any_widget_or_parent_to_frame (struct device *d, Widget widget) | 159 x_any_widget_or_parent_to_frame (struct device *d, Widget widget) |
175 { | 160 { |
176 while (widget) | 161 while (widget) |
177 { | 162 { |
178 struct frame *f = x_find_frame_for_window (d, XtWindow (widget)); | 163 struct frame *f = x_any_window_to_frame (d, XtWindow (widget)); |
179 if (f) | 164 if (f) |
180 return f; | 165 return f; |
181 widget = XtParent (widget); | 166 widget = XtParent (widget); |
182 } | 167 } |
183 | 168 |
2644 /* Destroy the X window of frame S. */ | 2629 /* Destroy the X window of frame S. */ |
2645 static void | 2630 static void |
2646 x_delete_frame (struct frame *f) | 2631 x_delete_frame (struct frame *f) |
2647 { | 2632 { |
2648 Widget w = FRAME_X_SHELL_WIDGET (f); | 2633 Widget w = FRAME_X_SHELL_WIDGET (f); |
2649 Display *dpy = XtDisplay (w); | |
2650 | 2634 |
2651 #ifndef HAVE_SESSION | 2635 #ifndef HAVE_SESSION |
2652 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) | 2636 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) |
2653 x_wm_maybe_move_wm_command (f); | 2637 x_wm_maybe_move_wm_command (f); |
2654 #endif /* HAVE_SESSION */ | 2638 #endif /* HAVE_SESSION */ |
2655 | 2639 |
2656 #ifdef EXTERNAL_WIDGET | 2640 #ifdef EXTERNAL_WIDGET |
2657 expect_x_error (dpy); | 2641 { |
2658 /* for obscure reasons having (I think) to do with the internal | 2642 Display *dpy = XtDisplay (w); |
2659 window-to-widget hierarchy maintained by Xt, we have to call | 2643 expect_x_error (dpy); |
2660 XtUnrealizeWidget() here. Xt can really suck. */ | 2644 /* for obscure reasons having (I think) to do with the internal |
2661 if (f->being_deleted) | 2645 window-to-widget hierarchy maintained by Xt, we have to call |
2662 XtUnrealizeWidget (w); | 2646 XtUnrealizeWidget() here. Xt can really suck. */ |
2663 XtDestroyWidget (w); | 2647 if (f->being_deleted) |
2664 x_error_occurred_p (dpy); | 2648 XtUnrealizeWidget (w); |
2649 XtDestroyWidget (w); | |
2650 x_error_occurred_p (dpy); | |
2651 } | |
2665 #else | 2652 #else |
2666 XtDestroyWidget (w); | 2653 XtDestroyWidget (w); |
2667 XFlush (dpy); /* make sure the windows are really gone! */ | |
2668 #endif /* EXTERNAL_WIDGET */ | 2654 #endif /* EXTERNAL_WIDGET */ |
2669 | 2655 |
2670 if (FRAME_X_GEOM_FREE_ME_PLEASE (f)) | 2656 if (FRAME_X_GEOM_FREE_ME_PLEASE (f)) |
2671 xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f)); | 2657 xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f)); |
2672 xfree (f->frame_data); | 2658 xfree (f->frame_data); |