aboutsummaryrefslogtreecommitdiff
blob: 09b7c468749f155daeeac163e3158bf30cd1ae9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
http://bugs.gentoo.org/292007
http://emacsbugs.donarmstrong.com/4122
http://bugs.gentoo.org/292492
http://emacsbugs.donarmstrong.com/4336
Fix updating of menus with GTK+ 2.18
Patch by Jan Djärv <jan.h.d@swipnet.se>, backported from upstream CVS

--- emacs-22.3-orig/src/xfns.c
+++ emacs-22.3/src/xfns.c
@@ -374,10 +374,7 @@
 #ifdef USE_GTK
               GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
               if (gwdesc != 0
-                  && (gwdesc == x->widget
-                      || gwdesc == x->edit_widget
-                      || gwdesc == x->vbox_widget
-                      || gwdesc == x->menubar_widget))
+                  && gtk_widget_get_toplevel (gwdesc) == x->widget)
                 found = f;
 #else
 	      if (wdesc == XtWindow (x->widget)
@@ -398,54 +395,6 @@
   return found;
 }
 
-/* Likewise, but exclude the menu bar widget.  */
-
-struct frame *
-x_non_menubar_window_to_frame (dpyinfo, wdesc)
-     struct x_display_info *dpyinfo;
-     int wdesc;
-{
-  Lisp_Object tail, frame;
-  struct frame *f;
-  struct x_output *x;
-
-  if (wdesc == None) return 0;
-
-  for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
-    {
-      frame = XCAR (tail);
-      if (!GC_FRAMEP (frame))
-        continue;
-      f = XFRAME (frame);
-      if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
-	continue;
-      x = f->output_data.x;
-      /* This frame matches if the window is any of its widgets.  */
-      if (x->hourglass_window == wdesc)
-	return f;
-      else if (x->widget)
-	{
-#ifdef USE_GTK
-          GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
-          if (gwdesc != 0
-              && (gwdesc == x->widget
-                  || gwdesc == x->edit_widget
-                  || gwdesc == x->vbox_widget))
-            return f;
-#else
-	  if (wdesc == XtWindow (x->widget)
-	      || wdesc == XtWindow (x->column_widget)
-	      || wdesc == XtWindow (x->edit_widget))
-	    return f;
-#endif
-	}
-      else if (FRAME_X_WINDOW (f) == wdesc)
-	/* A tooltip frame.  */
-	return f;
-    }
-  return 0;
-}
-
 /* Likewise, but consider only the menu bar widget.  */
 
 struct frame *
@@ -473,15 +422,14 @@
       if (x->menubar_widget)
         {
           GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
-          int found = 0;
 
-          BLOCK_INPUT;
+	  /* This gives false positives, but the rectangle check in xterm.c
+	     where this is called takes care of that.  */
           if (gwdesc != 0
               && (gwdesc == x->menubar_widget
-                  || gtk_widget_get_parent (gwdesc) == x->menubar_widget))
-            found = 1;
-          UNBLOCK_INPUT;
-          if (found) return f;
+                  || gtk_widget_is_ancestor (x->menubar_widget, gwdesc)
+		  || gtk_widget_is_ancestor (gwdesc, x->menubar_widget)))
+            return f;
         }
 #else
       if (x->menubar_widget
--- emacs-22.3-orig/src/xterm.c
+++ emacs-22.3/src/xterm.c
@@ -110,8 +110,6 @@
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
 
 extern void free_frame_menubar P_ ((struct frame *));
-extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *,
-						    int));
 #endif
 
 #ifdef USE_X_TOOLKIT
@@ -144,11 +142,6 @@
 
 #endif /* USE_X_TOOLKIT */
 
-#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
-#define x_any_window_to_frame x_window_to_frame
-#define x_top_window_to_frame x_window_to_frame
-#endif
-
 #ifdef USE_X_TOOLKIT
 #include "widget.h"
 #ifndef XtNinitialState
@@ -3789,6 +3782,14 @@
 		if (child == None || child == win)
 		  break;
 
+#ifdef USE_GTK
+		/* We don't wan't to know the innermost window.  We
+		   want the edit window.  For non-Gtk+ the innermost
+		   window is the edit window.  For Gtk+ it might not
+		   be.  It might be the tool bar for example.  */
+		if (x_window_to_frame (FRAME_X_DISPLAY_INFO (*fp), win))
+		  break;
+#endif
 		win = child;
 		parent_x = win_x;
 		parent_y = win_y;
@@ -3805,8 +3806,14 @@
 	       parent_{x,y} are invalid, but that's okay, because we'll
 	       never use them in that case.)  */
 
+#ifdef USE_GTK
+	    /* We don't wan't to know the innermost window.  We
+	       want the edit window.  */
+	    f1 = x_window_to_frame (FRAME_X_DISPLAY_INFO (*fp), win);
+#else
 	    /* Is win one of our frames?  */
 	    f1 = x_any_window_to_frame (FRAME_X_DISPLAY_INFO (*fp), win);
+#endif
 
 #ifdef USE_X_TOOLKIT
 	    /* If we end up with the menu bar window, say it's not
--- emacs-22.3-orig/src/xterm.h
+++ emacs-22.3/src/xterm.h
@@ -412,10 +412,13 @@
 
 extern struct frame *x_window_to_frame P_ ((struct x_display_info *, int));
 
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
 extern struct frame *x_any_window_to_frame P_ ((struct x_display_info *, int));
-extern struct frame *x_non_menubar_window_to_frame P_ ((struct x_display_info *, int));
+extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *, int));
 extern struct frame *x_top_window_to_frame P_ ((struct x_display_info *, int));
+
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
+#define x_any_window_to_frame x_window_to_frame
+#define x_top_window_to_frame x_window_to_frame
 #endif
 
 /* This is a chain of structures for all the X displays currently in use.  */