emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r114375: * frame.c (x_redo_mouse_highlight): New fun


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r114375: * frame.c (x_redo_mouse_highlight): New function
Date: Wed, 18 Sep 2013 09:23:43 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114375
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2013-09-18 13:23:10 +0400
message:
  * 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.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/dispextern.h               
dispextern.h-20091113204419-o5vbwnq5f7feedwu-218
  src/frame.c                    frame.c-20091113204419-o5vbwnq5f7feedwu-243
  src/nsfns.m                    nsfns.m-20091113204419-o5vbwnq5f7feedwu-8741
  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/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
  src/xterm.h                    xterm.h-20091113204419-o5vbwnq5f7feedwu-228
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-09-18 06:48:11 +0000
+++ b/src/ChangeLog     2013-09-18 09:23:10 +0000
@@ -1,5 +1,28 @@
 2013-09-18  Dmitry Antipov  <address@hidden>
 
+       * 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  <address@hidden>
+
        * frame.c (x_mouse_grabbed): New function.
        * dispextern.h (x_mouse_grabbed): Add prototype.
        (last_mouse_frame): Remove declaration.

=== modified file 'src/dispextern.h'
--- a/src/dispextern.h  2013-09-18 06:48:11 +0000
+++ b/src/dispextern.h  2013-09-18 09:23:10 +0000
@@ -3545,6 +3545,7 @@
                                         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 */
 

=== modified file 'src/frame.c'
--- a/src/frame.c       2013-09-18 06:48:11 +0000
+++ b/src/frame.c       2013-09-18 09:23:10 +0000
@@ -3442,6 +3442,19 @@
          && 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.

=== modified file 'src/nsfns.m'
--- a/src/nsfns.m       2013-09-17 12:27:21 +0000
+++ b/src/nsfns.m       2013-09-18 09:23:10 +0000
@@ -2564,6 +2564,7 @@
 {
   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 @@
 
   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];

=== modified file 'src/nsterm.h'
--- a/src/nsterm.h      2013-09-18 06:48:11 +0000
+++ b/src/nsterm.h      2013-09-18 09:23:10 +0000
@@ -600,6 +600,14 @@
 
   /* 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 @@
                      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__

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2013-09-18 06:48:11 +0000
+++ b/src/nsterm.m      2013-09-18 09:23:10 +0000
@@ -191,10 +191,8 @@
 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 @@
 {
 //  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 @@
 - (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 @@
     {
       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 @@
       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 @@
   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.  */);

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2013-09-18 06:48:11 +0000
+++ b/src/w32term.c     2013-09-18 09:23:10 +0000
@@ -3304,21 +3304,21 @@
    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);
 
+  if (!FRAME_W32_OUTPUT (frame))
+    return 0;
+
+  dpyinfo = FRAME_DISPLAY_INFO (frame);
   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))
-    return 0;
+  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))
     {
@@ -3364,16 +3364,6 @@
 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)
 {
   PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0);
@@ -4683,7 +4673,7 @@
          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 @@
 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);
 }

=== modified file 'src/w32term.h'
--- a/src/w32term.h     2013-09-18 06:48:11 +0000
+++ b/src/w32term.h     2013-09-18 09:23:10 +0000
@@ -185,6 +185,14 @@
 
   /* 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.  */

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2013-09-18 06:48:11 +0000
+++ b/src/xterm.c       2013-09-18 09:23:10 +0000
@@ -3860,19 +3860,20 @@
    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 @@
   return 0;
 }
 
-
-/************************************************************************
-                             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 @@
       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 @@
   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));

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


reply via email to

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