]> git.eshelyaron.com Git - emacs.git/commitdiff
* frame.c (x_mouse_grabbed): New function.
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 18 Sep 2013 06:48:11 +0000 (10:48 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Wed, 18 Sep 2013 06:48:11 +0000 (10:48 +0400)
* dispextern.h (x_mouse_grabbed): Add prototype.
(last_mouse_frame): Remove declaration.
* xterm.h (struct x_display_info):
* w32term.h (struct w32_display_info):
* nsterm.h (struct ns_display_info): New member
last_mouse_frame, going to replace...
* xdisp.c (last_mouse_frame): ...global variable.
(note_tool_bar_highlight):
* w32term.c (w32_mouse_position, w32_read_socket):
* xterm.c (XTmouse_position, handle_one_xevent):
Use x_mouse_grabbed.
* nsterm.m (ns_mouse_position, mouseDown): Adjust user.

src/ChangeLog
src/dispextern.h
src/frame.c
src/nsterm.h
src/nsterm.m
src/w32term.c
src/w32term.h
src/xdisp.c
src/xterm.c
src/xterm.h

index 4223573a6ff66dfb4fb7e16026aaa629a307d8bb..b5bdf1dca702206785fe16d3897e376083ab54c3 100644 (file)
@@ -1,3 +1,19 @@
+2013-09-18  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * frame.c (x_mouse_grabbed): New function.
+       * dispextern.h (x_mouse_grabbed): Add prototype.
+       (last_mouse_frame): Remove declaration.
+       * xterm.h (struct x_display_info):
+       * w32term.h (struct w32_display_info):
+       * nsterm.h (struct ns_display_info): New member
+       last_mouse_frame, going to replace...
+       * xdisp.c (last_mouse_frame): ...global variable.
+       (note_tool_bar_highlight):
+       * w32term.c (w32_mouse_position, w32_read_socket):
+       * xterm.c (XTmouse_position, handle_one_xevent):
+       Use x_mouse_grabbed.
+       * nsterm.m (ns_mouse_position, mouseDown): Adjust user.
+
 2013-09-17  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * w32term.c (w32_read_socket): Avoid temporary
index e91403bce6861c0ecb668a78860397e86dc9827a..c8af00ad91539b5438f157c3b915e8cc9a0a2c11 100644 (file)
@@ -3194,7 +3194,6 @@ extern int help_echo_showing_p;
 extern Lisp_Object help_echo_string, help_echo_window;
 extern Lisp_Object help_echo_object, previous_help_echo_string;
 extern ptrdiff_t help_echo_pos;
-extern struct frame *last_mouse_frame;
 extern int last_tool_bar_item;
 extern void reseat_at_previous_visible_line_start (struct it *);
 extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
@@ -3531,6 +3530,7 @@ enum resource_types
   RES_TYPE_BOOLEAN_NUMBER
 };
 
+extern bool x_mouse_grabbed (Display_Info *);
 extern Display_Info *check_x_display_info (Lisp_Object);
 extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object,
                               Lisp_Object, const char *, const char *class,
index 365629d0f48edfdd02a8a8c74a48c3c97dbfbd1d..a31bf35aa6b577a5d0dfd4e960165a9f02af7227 100644 (file)
@@ -3432,7 +3432,16 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
   return;
 }
 
-\f
+/* Non-zero if mouse is grabbed on DPYINFO
+   and we know the frame where it is.  */
+
+bool x_mouse_grabbed (Display_Info *dpyinfo)
+{
+  return (dpyinfo->grabbed
+         && dpyinfo->last_mouse_frame
+         && FRAME_LIVE_P (dpyinfo->last_mouse_frame));
+}
+
 /* Subroutines of creating an X frame.  */
 
 /* Make sure that Vx_resource_name is set to a reasonable value.
index 30ae871da8375e00bb4d1063b4d272b377345b60..373e06cefd2e0e34209b9b57fdfeaae09b02cad4 100644 (file)
@@ -597,6 +597,9 @@ struct ns_display_info
 
   struct frame *x_highlight_frame;
   struct frame *x_focus_frame;
+
+  /* The frame where the mouse was last time we reported a mouse event.  */
+  struct frame *last_mouse_frame;
 };
 
 /* This is a chain of structures for all the NS displays currently in use.  */
index 6c5f5f54cb93f07a49ff7e0d4d2e9220cbb608ce..d41bd856b0c8bef69e618451f23128d037df78a0 100644 (file)
@@ -1812,8 +1812,9 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
           XFRAME (frame)->mouse_moved = 0;
 
       last_mouse_scroll_bar = nil;
-      if (last_mouse_frame && FRAME_LIVE_P (last_mouse_frame))
-        f = last_mouse_frame;
+      if (dpyinfo->last_mouse_frame
+         && FRAME_LIVE_P (dpyinfo->last_mouse_frame))
+        f = dpyinfo->last_mouse_frame;
       else
         f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame
                                     : SELECTED_FRAME ();
@@ -5362,6 +5363,7 @@ not_in_argv (NSString *arg)
 /* This is what happens when the user presses a mouse button.  */
 - (void)mouseDown: (NSEvent *)theEvent
 {
+  struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
   NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
 
   NSTRACE (mouseDown);
@@ -5371,10 +5373,10 @@ not_in_argv (NSString *arg)
   if (!emacs_event)
     return;
 
-  last_mouse_frame = emacsframe;
+  dpyinfo->last_mouse_frame = emacsframe;
   /* appears to be needed to prevent spurious movement events generated on
      button clicks */
-  last_mouse_frame->mouse_moved = 0;
+  emacsframe->mouse_moved = 0;
 
   if ([theEvent type] == NSScrollWheel)
     {
index 331a86ef7d7eef7a9649d5e54eed3de86c12a4e8..97dda0e8c55e1c791e5df052145382e43f08bfeb 100644 (file)
@@ -3404,6 +3404,7 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
                    unsigned long *time)
 {
   struct frame *f1;
+  struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
 
   block_input ();
 
@@ -3426,19 +3427,11 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
       /* Now we have a position on the root; find the innermost window
         containing the pointer.  */
       {
-       if (FRAME_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
-           && FRAME_LIVE_P (last_mouse_frame))
-         {
-           /* If mouse was grabbed on a frame, give coords for that frame
-              even if the mouse is now outside it.  */
-           f1 = last_mouse_frame;
-         }
-       else
-         {
-           /* Is window under mouse one of our frames?  */
-           f1 = x_any_window_to_frame (FRAME_DISPLAY_INFO (*fp),
-                                    WindowFromPoint (pt));
-         }
+       /* If mouse was grabbed on a frame, give coords for that
+          frame even if the mouse is now outside it.  Otherwise
+          check for window under mouse on one of our frames.  */
+       f1 = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+             : x_any_window_to_frame (dpyinfo, WindowFromPoint (pt)));
 
        /* If not, is it one of our scroll bars?  */
        if (! f1)
@@ -4479,11 +4472,8 @@ w32_read_socket (struct terminal *terminal,
           previous_help_echo_string = help_echo_string;
          help_echo_string = Qnil;
 
-         if (dpyinfo->grabbed && last_mouse_frame
-             && FRAME_LIVE_P (last_mouse_frame))
-           f = last_mouse_frame;
-         else
-           f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+              : x_window_to_frame (dpyinfo, msg.msg.hwnd));
 
          if (hlinfo->mouse_face_hidden)
            {
@@ -4559,11 +4549,8 @@ w32_read_socket (struct terminal *terminal,
            int button;
            int up;
 
-           if (dpyinfo->grabbed && last_mouse_frame
-               && FRAME_LIVE_P (last_mouse_frame))
-             f = last_mouse_frame;
-           else
-             f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+           f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+                : x_window_to_frame (dpyinfo, msg.msg.hwnd));
 
            if (f)
              {
@@ -4602,7 +4589,7 @@ w32_read_socket (struct terminal *terminal,
            else
              {
                dpyinfo->grabbed |= (1 << button);
-               last_mouse_frame = f;
+               dpyinfo->last_mouse_frame = f;
                 /* Ignore any mouse motion that happened
                    before this event; any subsequent mouse-movement
                    Emacs events should reflect only motion after
@@ -4619,11 +4606,8 @@ w32_read_socket (struct terminal *terminal,
        case WM_MOUSEWHEEL:
         case WM_MOUSEHWHEEL:
          {
-           if (dpyinfo->grabbed && last_mouse_frame
-               && FRAME_LIVE_P (last_mouse_frame))
-             f = last_mouse_frame;
-           else
-             f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+           f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+                : x_window_to_frame (dpyinfo, msg.msg.hwnd));
 
            if (f)
              {
@@ -4640,7 +4624,7 @@ w32_read_socket (struct terminal *terminal,
                   ButtonPress.  */
                f->mouse_moved = 0;
              }
-           last_mouse_frame = f;
+           dpyinfo->last_mouse_frame = f;
            last_tool_bar_item = -1;
          }
          break;
index 99253627e649003d52b67966a5222313d373dc13..d29cab35dedfe5adcd50c7030552cb516f9e4f42 100644 (file)
@@ -182,6 +182,9 @@ struct w32_display_info
 
   /* The frame waiting to be auto-raised in w32_read_socket.  */
   struct frame *w32_pending_autoraise_frame;
+
+  /* The frame where the mouse was last time we reported a mouse event.  */
+  struct frame *last_mouse_frame;
 };
 
 /* This is a chain of structures for all the displays currently in use.  */
index b07aad51bc9886f41cbcb5ff03e05d8c0bdf37b4..c4f7b205119f4d50bc8a561c1a91c0aedfd9d646 100644 (file)
@@ -11454,10 +11454,6 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run)
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-/* Where the mouse was last time we reported a mouse event.  */
-
-struct frame *last_mouse_frame;
-
 /* Tool-bar item index of the item on which a mouse button was pressed
    or -1.  */
 
@@ -12320,9 +12316,9 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
   clear_mouse_face (hlinfo);
 
   /* Mouse is down, but on different tool-bar item?  */
-  mouse_down_p = (dpyinfo->grabbed
-                 && f == last_mouse_frame
-                 && FRAME_LIVE_P (f));
+  mouse_down_p = (x_mouse_grabbed (dpyinfo)
+                 && f == dpyinfo->last_mouse_frame);
+
   if (mouse_down_p
       && last_tool_bar_item != prop_idx)
     return;
index 08a360fd52cce924c5f0b9793ef954961d2273c8..7d8c40b8cf0b8ff232d2e8ee07cc946f63a2cfe5 100644 (file)
@@ -3945,6 +3945,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
                  Time *timestamp)
 {
   struct frame *f1;
+  struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
 
   block_input ();
 
@@ -4004,22 +4005,24 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
 
        x_catch_errors (FRAME_X_DISPLAY (*fp));
 
-       if (FRAME_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
-           && FRAME_LIVE_P (last_mouse_frame))
+       if (x_mouse_grabbed (dpyinfo))
          {
            /* If mouse was grabbed on a frame, give coords for that frame
               even if the mouse is now outside it.  */
            XTranslateCoordinates (FRAME_X_DISPLAY (*fp),
 
-                                  /* From-window, to-window.  */
-                                  root, FRAME_X_WINDOW (last_mouse_frame),
+                                  /* From-window.  */
+                                  root,
+                                  
+                                  /* To-window.  */
+                                  FRAME_X_WINDOW (dpyinfo->last_mouse_frame),
 
                                   /* From-position, to-position.  */
                                   root_x, root_y, &win_x, &win_y,
 
                                   /* Child of win.  */
                                   &child);
-           f1 = last_mouse_frame;
+           f1 = dpyinfo->last_mouse_frame;
          }
        else
          {
@@ -4043,7 +4046,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
                   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_DISPLAY_INFO (*fp), win))
+               if (x_window_to_frame (dpyinfo, win))
                  break;
 #endif
                win = child;
@@ -4065,10 +4068,10 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
 #ifdef USE_GTK
            /* We don't wan't to know the innermost window.  We
               want the edit window.  */
-           f1 = x_window_to_frame (FRAME_DISPLAY_INFO (*fp), win);
+           f1 = x_window_to_frame (dpyinfo, win);
 #else
            /* Is win one of our frames?  */
-           f1 = x_any_window_to_frame (FRAME_DISPLAY_INFO (*fp), win);
+           f1 = x_any_window_to_frame (dpyinfo, win);
 #endif
 
 #ifdef USE_X_TOOLKIT
@@ -6704,11 +6707,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         previous_help_echo_string = help_echo_string;
         help_echo_string = Qnil;
 
-        if (dpyinfo->grabbed && last_mouse_frame
-            && FRAME_LIVE_P (last_mouse_frame))
-          f = last_mouse_frame;
-        else
-          f = x_window_to_frame (dpyinfo, event->xmotion.window);
+       f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+            : x_window_to_frame (dpyinfo, event->xmotion.window));
 
         if (hlinfo->mouse_face_hidden)
           {
@@ -6845,12 +6845,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
        last_mouse_glyph_frame = 0;
        dpyinfo->last_user_time = event->xbutton.time;
 
-        if (dpyinfo->grabbed
-            && last_mouse_frame
-            && FRAME_LIVE_P (last_mouse_frame))
-          f = last_mouse_frame;
-        else
-          f = x_window_to_frame (dpyinfo, event->xbutton.window);
+        f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+            : x_window_to_frame (dpyinfo, event->xbutton.window));
 
 #ifdef USE_GTK
         if (f && xg_event_is_for_scrollbar (f, event))
@@ -6923,7 +6919,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         if (event->type == ButtonPress)
           {
             dpyinfo->grabbed |= (1 << event->xbutton.button);
-            last_mouse_frame = f;
+            dpyinfo->last_mouse_frame = f;
 
             if (!tool_bar_p)
               last_tool_bar_item = -1;
index e1556de36b9fdd731e0eeab9e46f303ecb415731..f1bfc883a64d700fa3519e55e88921f126cac8b5 100644 (file)
@@ -305,6 +305,9 @@ struct x_display_info
   /* The frame waiting to be auto-raised in XTread_socket.  */
   struct frame *x_pending_autoraise_frame;
 
+  /* The frame where the mouse was last time we reported a mouse event.  */
+  struct frame *last_mouse_frame;
+
   /* Time of last user interaction as returned in X events on this display.  */
   Time last_user_time;