aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2013-09-13 08:11:34 +0200
committerJoakim Verona2013-09-13 08:11:34 +0200
commit584bb3a913701a6324d020c87a39e03828fa0bd1 (patch)
tree9a474d375f7b784ad76afb1ea4a09b8ef176dda9 /src
parent4f6e32297ee0536354c3261027f6c65586c646f0 (diff)
parent35c3d36e0ed6c7f5104946dd966ca46d0495f640 (diff)
downloademacs-584bb3a913701a6324d020c87a39e03828fa0bd1.tar.gz
emacs-584bb3a913701a6324d020c87a39e03828fa0bd1.zip
merge from trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/xfns.c181
-rw-r--r--src/xterm.c175
-rw-r--r--src/xterm.h16
4 files changed, 187 insertions, 196 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f08395ae24f..960165a22f9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12013-09-13 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * xterm.h (x_window_to_frame, x_any_window_to_frame)
4 (x_menubar_window_to_frame): Remove prototypes.
5 * xfns.c (x_window_to_frame, x_any_window_to_frame)
6 (x_menubar_window_to_frame, x_top_window_to_frame):
7 Move from here...
8 * xterm.c (x_window_to_frame, x_any_window_to_frame)
9 (x_menubar_window_to_frame, x_top_window_to_frame):
10 ...to here and convert all but the last to static.
11
12013-09-12 Eli Zaretskii <eliz@gnu.org> 122013-09-12 Eli Zaretskii <eliz@gnu.org>
2 13
3 * lisp.mk (lisp): Add w32-common-fns.elc. 14 * lisp.mk (lisp): Add w32-common-fns.elc.
diff --git a/src/xfns.c b/src/xfns.c
index 74bc7a8b1d0..fa83b6faf1a 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -179,187 +179,6 @@ check_x_display_info (Lisp_Object object)
179 return dpyinfo; 179 return dpyinfo;
180} 180}
181 181
182
183/* Return the Emacs frame-object corresponding to an X window.
184 It could be the frame's main window or an icon window. */
185
186/* This function can be called during GC, so use GC_xxx type test macros. */
187
188struct frame *
189x_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
190{
191 Lisp_Object tail, frame;
192 struct frame *f;
193
194 if (wdesc == None)
195 return NULL;
196
197 FOR_EACH_FRAME (tail, frame)
198 {
199 f = XFRAME (frame);
200 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
201 continue;
202 if (f->output_data.x->hourglass_window == wdesc)
203 return f;
204#ifdef USE_X_TOOLKIT
205 if ((f->output_data.x->edit_widget
206 && XtWindow (f->output_data.x->edit_widget) == wdesc)
207 /* A tooltip frame? */
208 || (!f->output_data.x->edit_widget
209 && FRAME_X_WINDOW (f) == wdesc)
210 || f->output_data.x->icon_desc == wdesc)
211 return f;
212#else /* not USE_X_TOOLKIT */
213#ifdef USE_GTK
214 if (f->output_data.x->edit_widget)
215 {
216 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
217 struct x_output *x = f->output_data.x;
218 if (gwdesc != 0 && gwdesc == x->edit_widget)
219 return f;
220 }
221#endif /* USE_GTK */
222 if (FRAME_X_WINDOW (f) == wdesc
223 || f->output_data.x->icon_desc == wdesc)
224 return f;
225#endif /* not USE_X_TOOLKIT */
226 }
227 return 0;
228}
229
230#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
231/* Like x_window_to_frame but also compares the window with the widget's
232 windows. */
233
234struct frame *
235x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
236{
237 Lisp_Object tail, frame;
238 struct frame *f, *found = NULL;
239 struct x_output *x;
240
241 if (wdesc == None)
242 return NULL;
243
244 FOR_EACH_FRAME (tail, frame)
245 {
246 if (found)
247 break;
248 f = XFRAME (frame);
249 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
250 {
251 /* This frame matches if the window is any of its widgets. */
252 x = f->output_data.x;
253 if (x->hourglass_window == wdesc)
254 found = f;
255 else if (x->widget)
256 {
257#ifdef USE_GTK
258 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
259 if (gwdesc != 0
260 && gtk_widget_get_toplevel (gwdesc) == x->widget)
261 found = f;
262#else
263 if (wdesc == XtWindow (x->widget)
264 || wdesc == XtWindow (x->column_widget)
265 || wdesc == XtWindow (x->edit_widget))
266 found = f;
267 /* Match if the window is this frame's menubar. */
268 else if (lw_window_is_in_menubar (wdesc, x->menubar_widget))
269 found = f;
270#endif
271 }
272 else if (FRAME_X_WINDOW (f) == wdesc)
273 /* A tooltip frame. */
274 found = f;
275 }
276 }
277
278 return found;
279}
280
281/* Likewise, but consider only the menu bar widget. */
282
283struct frame *
284x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event)
285{
286 Window wdesc = event->xany.window;
287 Lisp_Object tail, frame;
288 struct frame *f;
289 struct x_output *x;
290
291 if (wdesc == None)
292 return NULL;
293
294 FOR_EACH_FRAME (tail, frame)
295 {
296 f = XFRAME (frame);
297 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
298 continue;
299 x = f->output_data.x;
300#ifdef USE_GTK
301 if (x->menubar_widget && xg_event_is_for_menubar (f, event))
302 return f;
303#else
304 /* Match if the window is this frame's menubar. */
305 if (x->menubar_widget
306 && lw_window_is_in_menubar (wdesc, x->menubar_widget))
307 return f;
308#endif
309 }
310 return 0;
311}
312
313/* Return the frame whose principal (outermost) window is WDESC.
314 If WDESC is some other (smaller) window, we return 0. */
315
316struct frame *
317x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
318{
319 Lisp_Object tail, frame;
320 struct frame *f;
321 struct x_output *x;
322
323 if (wdesc == None)
324 return NULL;
325
326 FOR_EACH_FRAME (tail, frame)
327 {
328 f = XFRAME (frame);
329 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
330 continue;
331 x = f->output_data.x;
332
333 if (x->widget)
334 {
335 /* This frame matches if the window is its topmost widget. */
336#ifdef USE_GTK
337 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
338 if (gwdesc == x->widget)
339 return f;
340#else
341 if (wdesc == XtWindow (x->widget))
342 return f;
343#if 0 /* I don't know why it did this,
344 but it seems logically wrong,
345 and it causes trouble for MapNotify events. */
346 /* Match if the window is this frame's menubar. */
347 if (x->menubar_widget
348 && wdesc == XtWindow (x->menubar_widget))
349 return f;
350#endif
351#endif
352 }
353 else if (FRAME_X_WINDOW (f) == wdesc)
354 /* Tooltip frame. */
355 return f;
356 }
357 return 0;
358}
359#endif /* USE_X_TOOLKIT || USE_GTK */
360
361
362
363/* Store the screen positions of frame F into XPTR and YPTR. 182/* Store the screen positions of frame F into XPTR and YPTR.
364 These are the positions of the containing window manager window, 183 These are the positions of the containing window manager window,
365 not Emacs's own window. */ 184 not Emacs's own window. */
diff --git a/src/xterm.c b/src/xterm.c
index 04949a3a1dc..52a2809ffbb 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3398,6 +3398,181 @@ x_focus_changed (int type, int state, struct x_display_info *dpyinfo, struct fra
3398 } 3398 }
3399} 3399}
3400 3400
3401/* Return the Emacs frame-object corresponding to an X window.
3402 It could be the frame's main window or an icon window. */
3403
3404static struct frame *
3405x_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
3406{
3407 Lisp_Object tail, frame;
3408 struct frame *f;
3409
3410 if (wdesc == None)
3411 return NULL;
3412
3413 FOR_EACH_FRAME (tail, frame)
3414 {
3415 f = XFRAME (frame);
3416 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
3417 continue;
3418 if (f->output_data.x->hourglass_window == wdesc)
3419 return f;
3420#ifdef USE_X_TOOLKIT
3421 if ((f->output_data.x->edit_widget
3422 && XtWindow (f->output_data.x->edit_widget) == wdesc)
3423 /* A tooltip frame? */
3424 || (!f->output_data.x->edit_widget
3425 && FRAME_X_WINDOW (f) == wdesc)
3426 || f->output_data.x->icon_desc == wdesc)
3427 return f;
3428#else /* not USE_X_TOOLKIT */
3429#ifdef USE_GTK
3430 if (f->output_data.x->edit_widget)
3431 {
3432 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
3433 struct x_output *x = f->output_data.x;
3434 if (gwdesc != 0 && gwdesc == x->edit_widget)
3435 return f;
3436 }
3437#endif /* USE_GTK */
3438 if (FRAME_X_WINDOW (f) == wdesc
3439 || f->output_data.x->icon_desc == wdesc)
3440 return f;
3441#endif /* not USE_X_TOOLKIT */
3442 }
3443 return 0;
3444}
3445
3446#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
3447
3448/* Like x_window_to_frame but also compares the window with the widget's
3449 windows. */
3450
3451static struct frame *
3452x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
3453{
3454 Lisp_Object tail, frame;
3455 struct frame *f, *found = NULL;
3456 struct x_output *x;
3457
3458 if (wdesc == None)
3459 return NULL;
3460
3461 FOR_EACH_FRAME (tail, frame)
3462 {
3463 if (found)
3464 break;
3465 f = XFRAME (frame);
3466 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
3467 {
3468 /* This frame matches if the window is any of its widgets. */
3469 x = f->output_data.x;
3470 if (x->hourglass_window == wdesc)
3471 found = f;
3472 else if (x->widget)
3473 {
3474#ifdef USE_GTK
3475 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
3476 if (gwdesc != 0
3477 && gtk_widget_get_toplevel (gwdesc) == x->widget)
3478 found = f;
3479#else
3480 if (wdesc == XtWindow (x->widget)
3481 || wdesc == XtWindow (x->column_widget)
3482 || wdesc == XtWindow (x->edit_widget))
3483 found = f;
3484 /* Match if the window is this frame's menubar. */
3485 else if (lw_window_is_in_menubar (wdesc, x->menubar_widget))
3486 found = f;
3487#endif
3488 }
3489 else if (FRAME_X_WINDOW (f) == wdesc)
3490 /* A tooltip frame. */
3491 found = f;
3492 }
3493 }
3494
3495 return found;
3496}
3497
3498/* Likewise, but consider only the menu bar widget. */
3499
3500static struct frame *
3501x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event)
3502{
3503 Window wdesc = event->xany.window;
3504 Lisp_Object tail, frame;
3505 struct frame *f;
3506 struct x_output *x;
3507
3508 if (wdesc == None)
3509 return NULL;
3510
3511 FOR_EACH_FRAME (tail, frame)
3512 {
3513 f = XFRAME (frame);
3514 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
3515 continue;
3516 x = f->output_data.x;
3517#ifdef USE_GTK
3518 if (x->menubar_widget && xg_event_is_for_menubar (f, event))
3519 return f;
3520#else
3521 /* Match if the window is this frame's menubar. */
3522 if (x->menubar_widget
3523 && lw_window_is_in_menubar (wdesc, x->menubar_widget))
3524 return f;
3525#endif
3526 }
3527 return 0;
3528}
3529
3530/* Return the frame whose principal (outermost) window is WDESC.
3531 If WDESC is some other (smaller) window, we return 0. */
3532
3533struct frame *
3534x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
3535{
3536 Lisp_Object tail, frame;
3537 struct frame *f;
3538 struct x_output *x;
3539
3540 if (wdesc == None)
3541 return NULL;
3542
3543 FOR_EACH_FRAME (tail, frame)
3544 {
3545 f = XFRAME (frame);
3546 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
3547 continue;
3548 x = f->output_data.x;
3549
3550 if (x->widget)
3551 {
3552 /* This frame matches if the window is its topmost widget. */
3553#ifdef USE_GTK
3554 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
3555 if (gwdesc == x->widget)
3556 return f;
3557#else
3558 if (wdesc == XtWindow (x->widget))
3559 return f;
3560#endif
3561 }
3562 else if (FRAME_X_WINDOW (f) == wdesc)
3563 /* Tooltip frame. */
3564 return f;
3565 }
3566 return 0;
3567}
3568
3569#else /* !USE_X_TOOLKIT && !USE_GTK */
3570
3571#define x_any_window_to_frame(d, i) x_window_to_frame (d, i)
3572#define x_top_window_to_frame(d, i) x_window_to_frame (d, i)
3573
3574#endif /* USE_X_TOOLKIT || USE_GTK */
3575
3401/* The focus may have changed. Figure out if it is a real focus change, 3576/* The focus may have changed. Figure out if it is a real focus change,
3402 by checking both FocusIn/Out and Enter/LeaveNotify events. 3577 by checking both FocusIn/Out and Enter/LeaveNotify events.
3403 3578
diff --git a/src/xterm.h b/src/xterm.h
index bdc8523009a..2f29667684d 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -376,20 +376,6 @@ struct x_display_info
376extern int use_xim; 376extern int use_xim;
377#endif 377#endif
378 378
379extern struct frame *x_window_to_frame (struct x_display_info *, int);
380extern struct frame *x_any_window_to_frame (struct x_display_info *, int);
381extern struct frame *x_menubar_window_to_frame (struct x_display_info *,
382 XEvent *);
383extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
384
385extern struct frame *x_menubar_window_to_frame (struct x_display_info *,
386 XEvent *);
387
388#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
389#define x_any_window_to_frame x_window_to_frame
390#define x_top_window_to_frame x_window_to_frame
391#endif
392
393/* This is a chain of structures for all the X displays currently in use. */ 379/* This is a chain of structures for all the X displays currently in use. */
394extern struct x_display_info *x_display_list; 380extern struct x_display_info *x_display_list;
395 381
@@ -400,7 +386,7 @@ extern struct x_display_info *x_display_list;
400extern Lisp_Object x_display_name_list; 386extern Lisp_Object x_display_name_list;
401 387
402extern struct x_display_info *x_display_info_for_display (Display *); 388extern struct x_display_info *x_display_info_for_display (Display *);
403 389extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
404extern struct x_display_info *x_term_init (Lisp_Object, char *, char *); 390extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);
405extern bool x_display_ok (const char *); 391extern bool x_display_ok (const char *);
406 392