]> git.eshelyaron.com Git - emacs.git/commitdiff
* frame.c (x_redo_mouse_highlight): New function
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 18 Sep 2013 09:23:10 +0000 (13:23 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Wed, 18 Sep 2013 09:23:10 +0000 (13:23 +0400)
to factor out common code used in W32 and X ports.
* dispextern.h (x_redo_mouse_highlight): Add prototype.
* xterm.h (struct x_display_info):
* w32term.h (struct w32_display_info):
* nsterm.h (struct ns_display_info): New members
last_mouse_motion_frame, last_mouse_motion_x and
last_mouse_motion_y, going to replace static variables below.
* xterm.c (last_mouse_motion_event, last_mouse_motion_frame)
(redo_mouse_highlight): Remove.
(note_mouse_movement, syms_of_xterm): Adjust user.
(handle_one_xevent): Likewise.  Use x_redo_mouse_highlight.
* w32term.c (last_mouse_motion_event, last_mouse_motion_frame)
(redo_mouse_highlight): Remove.
(note_mouse_movement, syms_of_w32term): Adjust user.
(w32_read_socket): Likewise.  Use x_redo_mouse_highlight.
* nsterm.m (last_mouse_motion_position, last_mouse_motion_frame):
Remove.
(note_mouse_movement, mouseMoved, syms_of_nsterm):
* nsfns.m (compute_tip_xy): Adjust user.

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

index b5bdf1dca702206785fe16d3897e376083ab54c3..55345027811cdf1910fe644db0858c2d5eb4ff25 100644 (file)
@@ -1,3 +1,26 @@
+2013-09-18  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * frame.c (x_redo_mouse_highlight): New function
+       to factor out common code used in W32 and X ports.
+       * dispextern.h (x_redo_mouse_highlight): Add prototype.
+       * xterm.h (struct x_display_info):
+       * w32term.h (struct w32_display_info):
+       * nsterm.h (struct ns_display_info): New members
+       last_mouse_motion_frame, last_mouse_motion_x and
+       last_mouse_motion_y, going to replace static variables below.
+       * xterm.c (last_mouse_motion_event, last_mouse_motion_frame)
+       (redo_mouse_highlight): Remove.
+       (note_mouse_movement, syms_of_xterm): Adjust user.
+       (handle_one_xevent): Likewise.  Use x_redo_mouse_highlight.
+       * w32term.c (last_mouse_motion_event, last_mouse_motion_frame)
+       (redo_mouse_highlight): Remove.
+       (note_mouse_movement, syms_of_w32term): Adjust user.
+       (w32_read_socket): Likewise.  Use x_redo_mouse_highlight.
+       * nsterm.m (last_mouse_motion_position, last_mouse_motion_frame):
+       Remove.
+       (note_mouse_movement, mouseMoved, syms_of_nsterm):
+       * nsfns.m (compute_tip_xy): Adjust user.
+
 2013-09-18  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * frame.c (x_mouse_grabbed): New function.
index c8af00ad91539b5438f157c3b915e8cc9a0a2c11..7244c84893d1f7d73196f67813b03eaced57d82b 100644 (file)
@@ -3545,6 +3545,7 @@ extern Lisp_Object x_default_parameter (struct frame *, Lisp_Object,
                                         enum resource_types);
 extern char *x_get_string_resource (XrmDatabase, const char *,
                                    const char *);
+extern void x_redo_mouse_highlight (Display_Info *);
 
 #endif /* HAVE_WINDOW_SYSTEM */
 
index a31bf35aa6b577a5d0dfd4e960165a9f02af7227..997cc9c73aeca0ea6644421445d298d531e053a1 100644 (file)
@@ -3442,6 +3442,19 @@ bool x_mouse_grabbed (Display_Info *dpyinfo)
          && FRAME_LIVE_P (dpyinfo->last_mouse_frame));
 }
 
+/* Re-highlight something with mouse-face properties
+   on DPYINFO using saved frame and mouse position.  */
+
+void
+x_redo_mouse_highlight (Display_Info *dpyinfo)
+{
+  if (dpyinfo->last_mouse_motion_frame
+      && FRAME_LIVE_P (dpyinfo->last_mouse_motion_frame))
+    note_mouse_highlight (dpyinfo->last_mouse_motion_frame,
+                         dpyinfo->last_mouse_motion_x,
+                         dpyinfo->last_mouse_motion_y);
+}
+
 /* Subroutines of creating an X frame.  */
 
 /* Make sure that Vx_resource_name is set to a reasonable value.
index 408e6d2176ea7c031e8bc6d3515d49ab6989e841..93b7d12becb519d509fb29ccb6cf04aa82ab8bbc 100644 (file)
@@ -2564,6 +2564,7 @@ compute_tip_xy (struct frame *f,
 {
   Lisp_Object left, top;
   EmacsView *view = FRAME_NS_VIEW (f);
+  struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   NSPoint pt;
 
   /* Start with user-specified or mouse position.  */
@@ -2572,7 +2573,8 @@ compute_tip_xy (struct frame *f,
 
   if (!INTEGERP (left) || !INTEGERP (top))
     {
-      pt = last_mouse_motion_position;
+      pt.x = dpyinfo->last_mouse_motion_x;
+      pt.y = dpyinfo->last_mouse_motion_y;
       /* Convert to screen coordinates */
       pt = [view convertPoint: pt toView: nil];
       pt = [[view window] convertBaseToScreen: pt];
index 373e06cefd2e0e34209b9b57fdfeaae09b02cad4..7a626c75fe637a12f808d468218dec391fc9a74c 100644 (file)
@@ -600,6 +600,14 @@ struct ns_display_info
 
   /* The frame where the mouse was last time we reported a mouse event.  */
   struct frame *last_mouse_frame;
+
+  /* The frame where the mouse was last time we reported a mouse motion.  */
+  struct frame *last_mouse_motion_frame;
+
+  /* Position where the mouse was last time we reported a motion.
+     This is a position on last_mouse_motion_frame.  */
+  int last_mouse_motion_x;
+  int last_mouse_motion_y;
 };
 
 /* This is a chain of structures for all the NS displays currently in use.  */
@@ -869,7 +877,6 @@ extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
                      sigset_t const *sigmask);
 extern unsigned long ns_get_rgb_color (struct frame *f,
                                        float r, float g, float b, float a);
-extern NSPoint last_mouse_motion_position;
 
 /* From nsterm.m, needed in nsfont.m. */
 #ifdef __OBJC__
index d41bd856b0c8bef69e618451f23128d037df78a0..dc27fd09e30ca3d1881fcb1c4b310f2de7baf635 100644 (file)
@@ -191,10 +191,8 @@ Lisp_Object ns_display_name_list;
 long context_menu_value = 0;
 
 /* display update */
-NSPoint last_mouse_motion_position;
 static NSRect last_mouse_glyph;
 static Time last_mouse_movement_time = 0;
-static Lisp_Object last_mouse_motion_frame;
 static EmacsScroller *last_mouse_scroll_bar = nil;
 static struct frame *ns_updating_frame;
 static NSView *focus_view = NULL;
@@ -1742,7 +1740,7 @@ note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y)
 {
 //  NSTRACE (note_mouse_movement);
 
-  XSETFRAME (last_mouse_motion_frame, frame);
+  FRAME_DISPLAY_INFO (frame)->last_mouse_motion_frame = frame;
 
   /* Note, this doesn't get called for enter/leave, since we don't have a
      position.  Those are taken care of in the corresponding NSView methods. */
@@ -5448,13 +5446,16 @@ not_in_argv (NSString *arg)
 - (void)mouseMoved: (NSEvent *)e
 {
   Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
+  struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
   Lisp_Object frame;
+  NSPoint pt;
 
 //  NSTRACE (mouseMoved);
 
   last_mouse_movement_time = EV_TIMESTAMP (e);
-  last_mouse_motion_position
-    = [self convertPoint: [e locationInWindow] fromView: nil];
+  pt = [self convertPoint: [e locationInWindow] fromView: nil];
+  dpyinfo->last_mouse_motion_x = pt.x;
+  dpyinfo->last_mouse_motion_y = pt.y;
 
   /* update any mouse face */
   if (hlinfo->mouse_face_hidden)
@@ -5471,9 +5472,8 @@ not_in_argv (NSString *arg)
     {
       NSTRACE (mouse_autoselect_window);
       static Lisp_Object last_mouse_window;
-      Lisp_Object window = window_from_coordinates
-       (emacsframe, last_mouse_motion_position.x,
-        last_mouse_motion_position.y, 0, 0);
+      Lisp_Object window
+       = window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0);
 
       if (WINDOWP (window)
           && !EQ (window, last_mouse_window)
@@ -5491,8 +5491,7 @@ not_in_argv (NSString *arg)
       last_mouse_window = window;
     }
 
-  if (!note_mouse_movement (emacsframe, last_mouse_motion_position.x,
-                            last_mouse_motion_position.y))
+  if (!note_mouse_movement (emacsframe, pt.x, pt.y))
     help_echo_string = previous_help_echo_string;
 
   XSETFRAME (frame, emacsframe);
@@ -7416,9 +7415,6 @@ allowing it to be used at a lower level for accented character entry.");
   staticpro (&ns_display_name_list);
   ns_display_name_list = Qnil;
 
-  staticpro (&last_mouse_motion_frame);
-  last_mouse_motion_frame = Qnil;
-
   DEFVAR_LISP ("ns-auto-hide-menu-bar", ns_auto_hide_menu_bar,
                doc: /* Non-nil means that the menu bar is hidden, but appears when the mouse is near.
 Only works on OSX 10.6 or later.  */);
index 97dda0e8c55e1c791e5df052145382e43f08bfeb..7c0a3987d1e26a95aa5fd9f7c81e4fb0c6f9361f 100644 (file)
@@ -3304,22 +3304,22 @@ queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f,
    the mainstream emacs code by setting mouse_moved.  If not, ask for
    another motion event, so we can check again the next time it moves.  */
 
-static MSG last_mouse_motion_event;
-static Lisp_Object last_mouse_motion_frame;
-
 static int
 note_mouse_movement (struct frame *frame, MSG *msg)
 {
+  struct w32_display_info *dpyinfo;
   int mouse_x = LOWORD (msg->lParam);
   int mouse_y = HIWORD (msg->lParam);
 
-  last_mouse_movement_time = msg->time;
-  memcpy (&last_mouse_motion_event, msg, sizeof (last_mouse_motion_event));
-  XSETFRAME (last_mouse_motion_frame, frame);
-
-  if (!FRAME_X_OUTPUT (frame))
+  if (!FRAME_W32_OUTPUT (frame))
     return 0;
 
+  dpyinfo = FRAME_DISPLAY_INFO (frame);
+  last_mouse_movement_time = msg->time;
+  dpyinfo->last_mouse_motion_frame = frame;
+  dpyinfo->last_mouse_motion_x = mouse_x;
+  dpyinfo->last_mouse_motion_y = mouse_y;
+
   if (msg->hwnd != FRAME_W32_WINDOW (frame))
     {
       frame->mouse_moved = 1;
@@ -3363,16 +3363,6 @@ static void x_scroll_bar_report_motion (struct frame **, Lisp_Object *,
                                        unsigned long *);
 static void x_check_fullscreen (struct frame *);
 
-static void
-redo_mouse_highlight (void)
-{
-  if (!NILP (last_mouse_motion_frame)
-      && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
-    note_mouse_highlight (XFRAME (last_mouse_motion_frame),
-                         LOWORD (last_mouse_motion_event.lParam),
-                         HIWORD (last_mouse_motion_event.lParam));
-}
-
 static void
 w32_define_cursor (Window window, Cursor cursor)
 {
@@ -4683,7 +4673,7 @@ w32_read_socket (struct terminal *terminal,
          if (!msg.msg.wParam && msg.msg.hwnd == tip_window)
            {
              tip_window = NULL;
-             redo_mouse_highlight ();
+             x_redo_mouse_highlight (dpyinfo);
            }
 
          /* If window has been obscured or exposed by another window
@@ -6649,9 +6639,6 @@ X toolkit.  Possible values are: gtk, motif, xaw, or xaw3d.
 With MS Windows or Nextstep, the value is t.  */);
   Vx_toolkit_scroll_bars = Qt;
 
-  staticpro (&last_mouse_motion_frame);
-  last_mouse_motion_frame = Qnil;
-
   /* Tell Emacs about this window system.  */
   Fprovide (Qw32, Qnil);
 }
index d29cab35dedfe5adcd50c7030552cb516f9e4f42..ef7f0842680b19d50721cd0e4d783321ecbbab0c 100644 (file)
@@ -185,6 +185,14 @@ struct w32_display_info
 
   /* The frame where the mouse was last time we reported a mouse event.  */
   struct frame *last_mouse_frame;
+
+  /* The frame where the mouse was last time we reported a mouse motion.  */
+  struct frame *last_mouse_motion_frame;
+
+  /* Position where the mouse was last time we reported a motion.
+     This is a position on last_mouse_motion_frame.  */
+  int last_mouse_motion_x;
+  int last_mouse_motion_y;
 };
 
 /* This is a chain of structures for all the displays currently in use.  */
index 7d8c40b8cf0b8ff232d2e8ee07cc946f63a2cfe5..9e10037685b4016f43a987b314779de405638748 100644 (file)
@@ -3860,19 +3860,20 @@ construct_mouse_click (struct input_event *result,
    the mainstream emacs code by setting mouse_moved.  If not, ask for
    another motion event, so we can check again the next time it moves.  */
 
-static XMotionEvent last_mouse_motion_event;
-static Lisp_Object last_mouse_motion_frame;
-
 static int
 note_mouse_movement (struct frame *frame, const XMotionEvent *event)
 {
-  last_mouse_movement_time = event->time;
-  last_mouse_motion_event = *event;
-  XSETFRAME (last_mouse_motion_frame, frame);
+  struct x_display_info *dpyinfo;
 
   if (!FRAME_X_OUTPUT (frame))
     return 0;
 
+  dpyinfo = FRAME_DISPLAY_INFO (frame);
+  last_mouse_movement_time = event->time;
+  dpyinfo->last_mouse_motion_frame = frame;
+  dpyinfo->last_mouse_motion_x = event->x;
+  dpyinfo->last_mouse_motion_y = event->y;
+
   if (event->window != FRAME_X_WINDOW (frame))
     {
       frame->mouse_moved = 1;
@@ -3902,23 +3903,6 @@ note_mouse_movement (struct frame *frame, const XMotionEvent *event)
   return 0;
 }
 
-\f
-/************************************************************************
-                             Mouse Face
- ************************************************************************/
-
-static void
-redo_mouse_highlight (void)
-{
-  if (!NILP (last_mouse_motion_frame)
-      && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
-    note_mouse_highlight (XFRAME (last_mouse_motion_frame),
-                         last_mouse_motion_event.x,
-                         last_mouse_motion_event.y);
-}
-
-
-
 /* Return the current position of the mouse.
    *FP should be a frame which indicates which display to ask about.
 
@@ -6223,7 +6207,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       if (event->xunmap.window == tip_window)
         {
           tip_window = 0;
-          redo_mouse_highlight ();
+          x_redo_mouse_highlight (dpyinfo);
         }
 
       f = x_top_window_to_frame (dpyinfo, event->xunmap.window);
@@ -10705,9 +10689,6 @@ With MS Windows or Nextstep, the value is t.  */);
   Vx_toolkit_scroll_bars = Qnil;
 #endif
 
-  staticpro (&last_mouse_motion_frame);
-  last_mouse_motion_frame = Qnil;
-
   Qmodifier_value = intern_c_string ("modifier-value");
   Qalt = intern_c_string ("alt");
   Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
index f1bfc883a64d700fa3519e55e88921f126cac8b5..9f01a840e534f5ef4da78b1cd0c0bc37576a8d27 100644 (file)
@@ -308,9 +308,17 @@ struct x_display_info
   /* The frame where the mouse was last time we reported a mouse event.  */
   struct frame *last_mouse_frame;
 
+  /* The frame where the mouse was last time we reported a mouse motion.  */
+  struct frame *last_mouse_motion_frame;
+
   /* Time of last user interaction as returned in X events on this display.  */
   Time last_user_time;
 
+  /* Position where the mouse was last time we reported a motion.
+     This is a position on last_mouse_motion_frame.  */
+  int last_mouse_motion_x;
+  int last_mouse_motion_y;
+
   /* The gray pixmap.  */
   Pixmap gray;