comparison src/xfns.c @ 104815:b3c991e42448

* xterm.h: Rename x_non_menubar_window_to_frame to x_menubar_window_to_frame * xterm.c: Remove declarations also in xterm.h (XTmouse_position): Do not return valid positions for clicks in the menubar and the toolbar for Gtk+. * xfns.c (x_any_window_to_frame): Assume less about Gtk+ internals, if the widget for the event has the same top level as a frame, return the frame. (x_menubar_window_to_frame): Detect menu bar even with Gtk+ internal windows, bug #4122. (x_non_menubar_window_to_frame): Remove.
author Jan Djärv <jan.h.d@swipnet.se>
date Wed, 02 Sep 2009 17:03:20 +0000
parents a9bb4a9d0ebd
children d0a6d64c3cfc
comparison
equal deleted inserted replaced
104814:927de3d0c010 104815:b3c991e42448
375 else if (x->widget) 375 else if (x->widget)
376 { 376 {
377 #ifdef USE_GTK 377 #ifdef USE_GTK
378 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); 378 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
379 if (gwdesc != 0 379 if (gwdesc != 0
380 && (gwdesc == x->widget 380 && gtk_widget_get_toplevel (gwdesc) == x->widget)
381 || gwdesc == x->edit_widget
382 || gwdesc == x->vbox_widget
383 || gwdesc == x->menubar_widget))
384 found = f; 381 found = f;
385 #else 382 #else
386 if (wdesc == XtWindow (x->widget) 383 if (wdesc == XtWindow (x->widget)
387 || wdesc == XtWindow (x->column_widget) 384 || wdesc == XtWindow (x->column_widget)
388 || wdesc == XtWindow (x->edit_widget)) 385 || wdesc == XtWindow (x->edit_widget))
399 } 396 }
400 397
401 return found; 398 return found;
402 } 399 }
403 400
404 /* Likewise, but exclude the menu bar widget. */
405
406 struct frame *
407 x_non_menubar_window_to_frame (dpyinfo, wdesc)
408 struct x_display_info *dpyinfo;
409 int wdesc;
410 {
411 Lisp_Object tail, frame;
412 struct frame *f;
413 struct x_output *x;
414
415 if (wdesc == None) return 0;
416
417 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
418 {
419 frame = XCAR (tail);
420 if (!FRAMEP (frame))
421 continue;
422 f = XFRAME (frame);
423 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
424 continue;
425 x = f->output_data.x;
426 /* This frame matches if the window is any of its widgets. */
427 if (x->hourglass_window == wdesc)
428 return f;
429 else if (x->widget)
430 {
431 #ifdef USE_GTK
432 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
433 if (gwdesc != 0
434 && (gwdesc == x->widget
435 || gwdesc == x->edit_widget
436 || gwdesc == x->vbox_widget))
437 return f;
438 #else
439 if (wdesc == XtWindow (x->widget)
440 || wdesc == XtWindow (x->column_widget)
441 || wdesc == XtWindow (x->edit_widget))
442 return f;
443 #endif
444 }
445 else if (FRAME_X_WINDOW (f) == wdesc)
446 /* A tooltip frame. */
447 return f;
448 }
449 return 0;
450 }
451
452 /* Likewise, but consider only the menu bar widget. */ 401 /* Likewise, but consider only the menu bar widget. */
453 402
454 struct frame * 403 struct frame *
455 x_menubar_window_to_frame (dpyinfo, wdesc) 404 x_menubar_window_to_frame (dpyinfo, wdesc)
456 struct x_display_info *dpyinfo; 405 struct x_display_info *dpyinfo;
474 /* Match if the window is this frame's menubar. */ 423 /* Match if the window is this frame's menubar. */
475 #ifdef USE_GTK 424 #ifdef USE_GTK
476 if (x->menubar_widget) 425 if (x->menubar_widget)
477 { 426 {
478 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); 427 GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
479 int found = 0; 428
480 429 /* This gives false positives, but the rectangle check in xterm.c
481 BLOCK_INPUT; 430 where this is called takes care of that. */
482 if (gwdesc != 0 431 if (gwdesc != 0
483 && (gwdesc == x->menubar_widget 432 && (gwdesc == x->menubar_widget
484 || gtk_widget_get_parent (gwdesc) == x->menubar_widget)) 433 || gtk_widget_is_ancestor (x->menubar_widget, gwdesc)
485 found = 1; 434 || gtk_widget_is_ancestor (gwdesc, x->menubar_widget)))
486 UNBLOCK_INPUT; 435 return f;
487 if (found) return f;
488 } 436 }
489 #else 437 #else
490 if (x->menubar_widget 438 if (x->menubar_widget
491 && lw_window_is_in_menubar (wdesc, x->menubar_widget)) 439 && lw_window_is_in_menubar (wdesc, x->menubar_widget))
492 return f; 440 return f;