emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r117179: Refactor mouse positioning stuff to avoid c


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r117179: Refactor mouse positioning stuff to avoid code duplication.
Date: Wed, 28 May 2014 13:53:33 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117179
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2014-05-28 17:53:22 +0400
message:
  Refactor mouse positioning stuff to avoid code duplication.
  * frame.h (frame_char_to_pixel_position): New function.
  (x_set_mouse_position): Rename to...
  (frame_set_mouse_position): ...new function.
  (frame_set_mouse_pixel_position): Add prototype.
  * nsterm.m, w32term.c, xterm.c (x_set_mouse_pixel_position):
  Rename to frame_set_mouse_pixel_position.
  * frame.c (Fset_mouse_pixel_position, Fset_mouse_position):
  Adjust users.
  * xterm.h, w32term.h ( x_set_mouse_position)
  (x_set_mouse_pixel_position): Remove prototypes.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/frame.c                    frame.c-20091113204419-o5vbwnq5f7feedwu-243
  src/frame.h                    frame.h-20091113204419-o5vbwnq5f7feedwu-229
  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     2014-05-28 11:41:48 +0000
+++ b/src/ChangeLog     2014-05-28 13:53:22 +0000
@@ -1,5 +1,19 @@
 2014-05-28  Dmitry Antipov  <address@hidden>
 
+       Refactor mouse positioning stuff to avoid code duplication.
+       * frame.h (frame_char_to_pixel_position): New function.
+       (x_set_mouse_position): Rename to...
+       (frame_set_mouse_position): ...new function.
+       (frame_set_mouse_pixel_position): Add prototype.
+       * nsterm.m, w32term.c, xterm.c (x_set_mouse_pixel_position):
+       Rename to frame_set_mouse_pixel_position.
+       * frame.c (Fset_mouse_pixel_position, Fset_mouse_position):
+       Adjust users.
+       * xterm.h, w32term.h ( x_set_mouse_position)
+       (x_set_mouse_pixel_position): Remove prototypes.
+
+2014-05-28  Dmitry Antipov  <address@hidden>
+
        On X, always make pointer visible when deleting frame (Bug#17609).
        * frame.c (frame_make_pointer_visible, frame_make_pointer_invisible):
        Pass frame as arg.

=== modified file 'src/frame.c'
--- a/src/frame.c       2014-05-28 08:00:10 +0000
+++ b/src/frame.c       2014-05-28 13:53:22 +0000
@@ -1617,7 +1617,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (XFRAME (frame)))
     /* Warping the mouse will cause enternotify and focus events.  */
-    x_set_mouse_position (XFRAME (frame), XINT (x), XINT (y));
+    frame_set_mouse_position (XFRAME (frame), XINT (x), XINT (y));
 #else
 #if defined (MSDOS)
   if (FRAME_MSDOS_P (XFRAME (frame)))
@@ -1658,7 +1658,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (XFRAME (frame)))
     /* Warping the mouse will cause enternotify and focus events.  */
-    x_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y));
+    frame_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y));
 #else
 #if defined (MSDOS)
   if (FRAME_MSDOS_P (XFRAME (frame)))

=== modified file 'src/frame.h'
--- a/src/frame.h       2014-05-28 08:00:10 +0000
+++ b/src/frame.h       2014-05-28 13:53:22 +0000
@@ -1313,8 +1313,7 @@
 extern void x_set_window_size (struct frame *f, int change_grav,
                               int width, int height, bool pixelwise);
 extern Lisp_Object x_get_focus_frame (struct frame *);
-extern void x_set_mouse_position (struct frame *f, int h, int v);
-extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
+extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int 
pix_y);
 extern void x_make_frame_visible (struct frame *f);
 extern void x_make_frame_invisible (struct frame *f);
 extern void x_iconify_frame (struct frame *f);
@@ -1366,6 +1365,37 @@
     rif->flush_display (f);
 }
 
+/* Convert character coordinates X and Y to pixel
+   coordinates PIX_X and PIX_Y on frame F.  */
+
+INLINE void
+frame_char_to_pixel_position (struct frame *f, int x, int y, int *pix_x, int 
*pix_y)
+{
+  *pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
+  *pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
+
+  if (*pix_x < 0)
+    *pix_x = 0;
+  if (*pix_x > FRAME_PIXEL_WIDTH (f))
+    *pix_x = FRAME_PIXEL_WIDTH (f);
+
+  if (*pix_y < 0)
+    *pix_y = 0;
+  if (*pix_y > FRAME_PIXEL_HEIGHT (f))
+    *pix_y = FRAME_PIXEL_HEIGHT (f);
+}
+
+/* Reposition mouse pointer to character coordinates X and Y on frame F.  */
+
+INLINE
+void frame_set_mouse_position (struct frame *f, int x, int y)
+{
+  int pix_x, pix_y;
+
+  frame_char_to_pixel_position (f, x, y, &pix_x, &pix_y);
+  frame_set_mouse_pixel_position (f, pix_x, pix_y);
+}
+
 /***********************************************************************
                        Multimonitor data
  ***********************************************************************/

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2014-05-26 11:16:47 +0000
+++ b/src/nsterm.m      2014-05-28 13:53:22 +0000
@@ -1812,12 +1812,12 @@
 
 
 void
-x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
+frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
 /* --------------------------------------------------------------------------
      Programmatically reposition mouse pointer in pixel coordinates
    -------------------------------------------------------------------------- 
*/
 {
-  NSTRACE (x_set_mouse_pixel_position);
+  NSTRACE (frame_set_mouse_pixel_position);
   ns_raise_frame (f);
 #if 0
   /* FIXME: this does not work, and what about GNUstep? */
@@ -1829,28 +1829,6 @@
 #endif
 }
 
-
-void
-x_set_mouse_position (struct frame *f, int h, int v)
-/* --------------------------------------------------------------------------
-     Programmatically reposition mouse pointer in character coordinates
-   -------------------------------------------------------------------------- 
*/
-{
-  int pix_x, pix_y;
-
-  pix_x = FRAME_COL_TO_PIXEL_X (f, h) + FRAME_COLUMN_WIDTH (f) / 2;
-  pix_y = FRAME_LINE_TO_PIXEL_Y (f, v) + FRAME_LINE_HEIGHT (f) / 2;
-
-  if (pix_x < 0) pix_x = 0;
-  if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f);
-
-  if (pix_y < 0) pix_y = 0;
-  if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
-
-  x_set_mouse_pixel_position (f, pix_x, pix_y);
-}
-
-
 static int
 note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y)
 /*   ------------------------------------------------------------------------

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2014-05-26 12:31:46 +0000
+++ b/src/w32term.c     2014-05-28 13:53:22 +0000
@@ -5767,27 +5767,8 @@
 
 /* Mouse warping.  */
 
-void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
-
-void
-x_set_mouse_position (struct frame *f, int x, int y)
-{
-  int pix_x, pix_y;
-
-  pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
-  pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
-
-  if (pix_x < 0) pix_x = 0;
-  if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f);
-
-  if (pix_y < 0) pix_y = 0;
-  if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
-
-  x_set_mouse_pixel_position (f, pix_x, pix_y);
-}
-
-void
-x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
+void
+frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
 {
   RECT rect;
   POINT pt;

=== modified file 'src/w32term.h'
--- a/src/w32term.h     2014-02-04 16:13:51 +0000
+++ b/src/w32term.h     2014-05-28 13:53:22 +0000
@@ -219,8 +219,6 @@
 extern int x_display_pixel_height (struct w32_display_info *);
 extern int x_display_pixel_width (struct w32_display_info *);
 extern Lisp_Object x_get_focus_frame (struct frame *);
-extern void x_set_mouse_position (struct frame *f, int h, int v);
-extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
 extern void x_make_frame_visible (struct frame *f);
 extern void x_make_frame_invisible (struct frame *f);
 extern void x_iconify_frame (struct frame *f);

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2014-05-28 11:41:48 +0000
+++ b/src/xterm.c       2014-05-28 13:53:22 +0000
@@ -8735,34 +8735,11 @@
 
   unblock_input ();
 }
-
-/* Mouse warping.  */
-
-void
-x_set_mouse_position (struct frame *f, int x, int y)
-{
-  int pix_x, pix_y;
-
-  pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
-  pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
-
-  if (pix_x < 0) pix_x = 0;
-  if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f);
-
-  if (pix_y < 0) pix_y = 0;
-  if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
-
-  block_input ();
-
-  XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
-               0, 0, 0, 0, pix_x, pix_y);
-  unblock_input ();
-}
 
 /* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F.  */
 
 void
-x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
+frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
 {
   block_input ();
 

=== modified file 'src/xterm.h'
--- a/src/xterm.h       2014-05-13 14:18:54 +0000
+++ b/src/xterm.h       2014-05-28 13:53:22 +0000
@@ -931,8 +931,6 @@
 extern void x_uncatch_errors (void);
 extern void x_clear_errors (Display *);
 extern void x_set_window_size (struct frame *, int, int, int, bool);
-extern void x_set_mouse_position (struct frame *, int, int);
-extern void x_set_mouse_pixel_position (struct frame *, int, int);
 extern void xembed_request_focus (struct frame *);
 extern void x_ewmh_activate_frame (struct frame *);
 extern void x_delete_terminal (struct terminal *terminal);


reply via email to

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