emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114374: * frame.c (x_mouse_grabbed): New function.


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r114374: * frame.c (x_mouse_grabbed): New function.
Date: Wed, 18 Sep 2013 06:49:14 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114374
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2013-09-18 10:48:11 +0400
message:
  * 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.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/dispextern.h               
dispextern.h-20091113204419-o5vbwnq5f7feedwu-218
  src/frame.c                    frame.c-20091113204419-o5vbwnq5f7feedwu-243
  src/nsterm.h                   nsterm.h-20091113204419-o5vbwnq5f7feedwu-8746
  src/nsterm.m                   nsterm.m-20091113204419-o5vbwnq5f7feedwu-8747
  src/w32term.c                  w32term.c-20091113204419-o5vbwnq5f7feedwu-950
  src/w32term.h                  w32term.h-20091113204419-o5vbwnq5f7feedwu-954
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
  src/xterm.h                    xterm.h-20091113204419-o5vbwnq5f7feedwu-228
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-09-17 15:57:45 +0000
+++ b/src/ChangeLog     2013-09-18 06:48:11 +0000
@@ -1,3 +1,19 @@
+2013-09-18  Dmitry Antipov  <address@hidden>
+
+       * 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  <address@hidden>
 
        * w32term.c (w32_read_socket): Avoid temporary

=== modified file 'src/dispextern.h'
--- a/src/dispextern.h  2013-09-17 12:27:21 +0000
+++ b/src/dispextern.h  2013-09-18 06:48:11 +0000
@@ -3194,7 +3194,6 @@
 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 @@
   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,

=== modified file 'src/frame.c'
--- a/src/frame.c       2013-09-17 12:59:45 +0000
+++ b/src/frame.c       2013-09-18 06:48:11 +0000
@@ -3432,7 +3432,16 @@
   return;
 }
 
-
+/* 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.

=== modified file 'src/nsterm.h'
--- a/src/nsterm.h      2013-09-17 12:27:21 +0000
+++ b/src/nsterm.h      2013-09-18 06:48:11 +0000
@@ -597,6 +597,9 @@
 
   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.  */

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2013-09-16 15:55:02 +0000
+++ b/src/nsterm.m      2013-09-18 06:48:11 +0000
@@ -1812,8 +1812,9 @@
           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 @@
 /* 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 @@
   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)
     {

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2013-09-17 15:57:45 +0000
+++ b/src/w32term.c     2013-09-18 06:48:11 +0000
@@ -3404,6 +3404,7 @@
                    unsigned long *time)
 {
   struct frame *f1;
+  struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
 
   block_input ();
 
@@ -3426,19 +3427,11 @@
       /* 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 @@
           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 @@
            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 @@
            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 @@
        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 @@
                   ButtonPress.  */
                f->mouse_moved = 0;
              }
-           last_mouse_frame = f;
+           dpyinfo->last_mouse_frame = f;
            last_tool_bar_item = -1;
          }
          break;

=== modified file 'src/w32term.h'
--- a/src/w32term.h     2013-09-17 08:24:20 +0000
+++ b/src/w32term.h     2013-09-18 06:48:11 +0000
@@ -182,6 +182,9 @@
 
   /* 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.  */

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-09-17 07:39:54 +0000
+++ b/src/xdisp.c       2013-09-18 06:48:11 +0000
@@ -11454,10 +11454,6 @@
 
 #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 @@
   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;

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2013-09-17 15:57:45 +0000
+++ b/src/xterm.c       2013-09-18 06:48:11 +0000
@@ -3945,6 +3945,7 @@
                  Time *timestamp)
 {
   struct frame *f1;
+  struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
 
   block_input ();
 
@@ -4004,22 +4005,24 @@
 
        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 @@
                   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 @@
 #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 @@
         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 @@
        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 @@
         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;

=== modified file 'src/xterm.h'
--- a/src/xterm.h       2013-09-17 12:27:21 +0000
+++ b/src/xterm.h       2013-09-18 06:48:11 +0000
@@ -305,6 +305,9 @@
   /* 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;
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]