Ali Bahrami
2011-04-11 ad87733e6b8def208cbb5216a9681d9bfdf9c3aa
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
*** emacs-23.1/src/ChangeLog.orig    Wed Oct 14 16:57:29 2009
--- emacs-23.1/src/ChangeLog    Wed Oct 14 17:35:12 2009
***************
*** 1,3 ****
--- 1,19 ----
+ 2009-09-02  Jan Djärv  <jan.h.d@swipnet.se>
+     * 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.
+     
  2009-07-29  Chong Yidong  <cyd@stupidchicken.com>
  
      * Version 23.1 released.
*** emacs-23.1/src/xfns.c.orig    Wed Oct 14 16:50:22 2009
--- emacs-23.1/src/xfns.c    Wed Oct 14 17:35:12 2009
***************
*** 374,383 ****
  #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))
                  found = f;
  #else
            if (wdesc == XtWindow (x->widget)
--- 374,380 ----
  #ifdef USE_GTK
                GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
                if (gwdesc != 0
!                   && gtk_widget_get_toplevel(gwdesc) == x->widget)
                  found = f;
  #else
            if (wdesc == XtWindow (x->widget)
***************
*** 398,451 ****
    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; CONSP (tail); tail = XCDR (tail))
-     {
-       frame = XCAR (tail);
-       if (!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 *
--- 395,400 ----
***************
*** 473,487 ****
        if (x->menubar_widget)
          {
            GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
-           int found = 0;
  
!           BLOCK_INPUT;
            if (gwdesc != 0
                && (gwdesc == x->menubar_widget
!                   || gtk_widget_get_parent (gwdesc) == x->menubar_widget))
!             found = 1;
!           UNBLOCK_INPUT;
!           if (found) return f;
          }
  #else
        if (x->menubar_widget
--- 422,435 ----
        if (x->menubar_widget)
          {
            GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
  
!       /* 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_is_ancestor (x->menubar_widget, gwdesc)
!           || gtk_widget_is_ancestor (gwdesc, x->menubar_widget)))
!         return f;
          }
  #else
        if (x->menubar_widget
*** emacs-23.1/src/xterm.c.orig    Wed Oct 14 16:37:20 2009
--- emacs-23.1/src/xterm.c    Wed Oct 14 17:35:12 2009
***************
*** 109,116 ****
  #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
--- 109,114 ----
***************
*** 143,153 ****
  
  #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
--- 141,146 ----
***************
*** 3916,3921 ****
--- 3909,3923 ----
          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;
***************
*** 3932,3939 ****
--- 3934,3947 ----
             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-23.1/src/xterm.h.orig    Wed Oct 14 15:08:03 2009
--- emacs-23.1/src/xterm.h    Wed Oct 14 17:35:12 2009
***************
*** 374,380 ****
  
  #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_top_window_to_frame P_ ((struct x_display_info *, int));
  #endif
  
--- 374,380 ----
  
  #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_menubar_window_to_frame P_ ((struct x_display_info *, int));
  extern struct frame *x_top_window_to_frame P_ ((struct x_display_info *, int));
  #endif