diff options
| author | Dmitry Antipov | 2014-05-28 17:53:22 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-05-28 17:53:22 +0400 |
| commit | 2b5113740643a2243e56d0878e179aef634adf38 (patch) | |
| tree | 22db63baeac1dc08bb339873d96b725c5d870965 /src | |
| parent | 8e6abb850674e59f5aba56bb28edade1a2ac0b47 (diff) | |
| download | emacs-2b5113740643a2243e56d0878e179aef634adf38.tar.gz emacs-2b5113740643a2243e56d0878e179aef634adf38.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/frame.c | 4 | ||||
| -rw-r--r-- | src/frame.h | 34 | ||||
| -rw-r--r-- | src/nsterm.m | 26 | ||||
| -rw-r--r-- | src/w32term.c | 21 | ||||
| -rw-r--r-- | src/w32term.h | 2 | ||||
| -rw-r--r-- | src/xterm.c | 25 | ||||
| -rw-r--r-- | src/xterm.h | 2 |
8 files changed, 52 insertions, 76 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 2c142c5edb7..1fe76c9c75f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,19 @@ | |||
| 1 | 2014-05-28 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2014-05-28 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | Refactor mouse positioning stuff to avoid code duplication. | ||
| 4 | * frame.h (frame_char_to_pixel_position): New function. | ||
| 5 | (x_set_mouse_position): Rename to... | ||
| 6 | (frame_set_mouse_position): ...new function. | ||
| 7 | (frame_set_mouse_pixel_position): Add prototype. | ||
| 8 | * nsterm.m, w32term.c, xterm.c (x_set_mouse_pixel_position): | ||
| 9 | Rename to frame_set_mouse_pixel_position. | ||
| 10 | * frame.c (Fset_mouse_pixel_position, Fset_mouse_position): | ||
| 11 | Adjust users. | ||
| 12 | * xterm.h, w32term.h ( x_set_mouse_position) | ||
| 13 | (x_set_mouse_pixel_position): Remove prototypes. | ||
| 14 | |||
| 15 | 2014-05-28 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 16 | |||
| 3 | On X, always make pointer visible when deleting frame (Bug#17609). | 17 | On X, always make pointer visible when deleting frame (Bug#17609). |
| 4 | * frame.c (frame_make_pointer_visible, frame_make_pointer_invisible): | 18 | * frame.c (frame_make_pointer_visible, frame_make_pointer_invisible): |
| 5 | Pass frame as arg. | 19 | Pass frame as arg. |
diff --git a/src/frame.c b/src/frame.c index ece0537a203..482e21bbfbc 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -1617,7 +1617,7 @@ before calling this function on it, like this. | |||
| 1617 | #ifdef HAVE_WINDOW_SYSTEM | 1617 | #ifdef HAVE_WINDOW_SYSTEM |
| 1618 | if (FRAME_WINDOW_P (XFRAME (frame))) | 1618 | if (FRAME_WINDOW_P (XFRAME (frame))) |
| 1619 | /* Warping the mouse will cause enternotify and focus events. */ | 1619 | /* Warping the mouse will cause enternotify and focus events. */ |
| 1620 | x_set_mouse_position (XFRAME (frame), XINT (x), XINT (y)); | 1620 | frame_set_mouse_position (XFRAME (frame), XINT (x), XINT (y)); |
| 1621 | #else | 1621 | #else |
| 1622 | #if defined (MSDOS) | 1622 | #if defined (MSDOS) |
| 1623 | if (FRAME_MSDOS_P (XFRAME (frame))) | 1623 | if (FRAME_MSDOS_P (XFRAME (frame))) |
| @@ -1658,7 +1658,7 @@ before calling this function on it, like this. | |||
| 1658 | #ifdef HAVE_WINDOW_SYSTEM | 1658 | #ifdef HAVE_WINDOW_SYSTEM |
| 1659 | if (FRAME_WINDOW_P (XFRAME (frame))) | 1659 | if (FRAME_WINDOW_P (XFRAME (frame))) |
| 1660 | /* Warping the mouse will cause enternotify and focus events. */ | 1660 | /* Warping the mouse will cause enternotify and focus events. */ |
| 1661 | x_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y)); | 1661 | frame_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y)); |
| 1662 | #else | 1662 | #else |
| 1663 | #if defined (MSDOS) | 1663 | #if defined (MSDOS) |
| 1664 | if (FRAME_MSDOS_P (XFRAME (frame))) | 1664 | if (FRAME_MSDOS_P (XFRAME (frame))) |
diff --git a/src/frame.h b/src/frame.h index c0c206d7c6a..c22b9c2a823 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -1313,8 +1313,7 @@ extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p); | |||
| 1313 | extern void x_set_window_size (struct frame *f, int change_grav, | 1313 | extern void x_set_window_size (struct frame *f, int change_grav, |
| 1314 | int width, int height, bool pixelwise); | 1314 | int width, int height, bool pixelwise); |
| 1315 | extern Lisp_Object x_get_focus_frame (struct frame *); | 1315 | extern Lisp_Object x_get_focus_frame (struct frame *); |
| 1316 | extern void x_set_mouse_position (struct frame *f, int h, int v); | 1316 | extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); |
| 1317 | extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); | ||
| 1318 | extern void x_make_frame_visible (struct frame *f); | 1317 | extern void x_make_frame_visible (struct frame *f); |
| 1319 | extern void x_make_frame_invisible (struct frame *f); | 1318 | extern void x_make_frame_invisible (struct frame *f); |
| 1320 | extern void x_iconify_frame (struct frame *f); | 1319 | extern void x_iconify_frame (struct frame *f); |
| @@ -1366,6 +1365,37 @@ flush_frame (struct frame *f) | |||
| 1366 | rif->flush_display (f); | 1365 | rif->flush_display (f); |
| 1367 | } | 1366 | } |
| 1368 | 1367 | ||
| 1368 | /* Convert character coordinates X and Y to pixel | ||
| 1369 | coordinates PIX_X and PIX_Y on frame F. */ | ||
| 1370 | |||
| 1371 | INLINE void | ||
| 1372 | frame_char_to_pixel_position (struct frame *f, int x, int y, int *pix_x, int *pix_y) | ||
| 1373 | { | ||
| 1374 | *pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2; | ||
| 1375 | *pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2; | ||
| 1376 | |||
| 1377 | if (*pix_x < 0) | ||
| 1378 | *pix_x = 0; | ||
| 1379 | if (*pix_x > FRAME_PIXEL_WIDTH (f)) | ||
| 1380 | *pix_x = FRAME_PIXEL_WIDTH (f); | ||
| 1381 | |||
| 1382 | if (*pix_y < 0) | ||
| 1383 | *pix_y = 0; | ||
| 1384 | if (*pix_y > FRAME_PIXEL_HEIGHT (f)) | ||
| 1385 | *pix_y = FRAME_PIXEL_HEIGHT (f); | ||
| 1386 | } | ||
| 1387 | |||
| 1388 | /* Reposition mouse pointer to character coordinates X and Y on frame F. */ | ||
| 1389 | |||
| 1390 | INLINE | ||
| 1391 | void frame_set_mouse_position (struct frame *f, int x, int y) | ||
| 1392 | { | ||
| 1393 | int pix_x, pix_y; | ||
| 1394 | |||
| 1395 | frame_char_to_pixel_position (f, x, y, &pix_x, &pix_y); | ||
| 1396 | frame_set_mouse_pixel_position (f, pix_x, pix_y); | ||
| 1397 | } | ||
| 1398 | |||
| 1369 | /*********************************************************************** | 1399 | /*********************************************************************** |
| 1370 | Multimonitor data | 1400 | Multimonitor data |
| 1371 | ***********************************************************************/ | 1401 | ***********************************************************************/ |
diff --git a/src/nsterm.m b/src/nsterm.m index ba94d28b797..f91b86daea6 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1812,12 +1812,12 @@ x_set_frame_alpha (struct frame *f) | |||
| 1812 | 1812 | ||
| 1813 | 1813 | ||
| 1814 | void | 1814 | void |
| 1815 | x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) | 1815 | frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) |
| 1816 | /* -------------------------------------------------------------------------- | 1816 | /* -------------------------------------------------------------------------- |
| 1817 | Programmatically reposition mouse pointer in pixel coordinates | 1817 | Programmatically reposition mouse pointer in pixel coordinates |
| 1818 | -------------------------------------------------------------------------- */ | 1818 | -------------------------------------------------------------------------- */ |
| 1819 | { | 1819 | { |
| 1820 | NSTRACE (x_set_mouse_pixel_position); | 1820 | NSTRACE (frame_set_mouse_pixel_position); |
| 1821 | ns_raise_frame (f); | 1821 | ns_raise_frame (f); |
| 1822 | #if 0 | 1822 | #if 0 |
| 1823 | /* FIXME: this does not work, and what about GNUstep? */ | 1823 | /* FIXME: this does not work, and what about GNUstep? */ |
| @@ -1829,28 +1829,6 @@ x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) | |||
| 1829 | #endif | 1829 | #endif |
| 1830 | } | 1830 | } |
| 1831 | 1831 | ||
| 1832 | |||
| 1833 | void | ||
| 1834 | x_set_mouse_position (struct frame *f, int h, int v) | ||
| 1835 | /* -------------------------------------------------------------------------- | ||
| 1836 | Programmatically reposition mouse pointer in character coordinates | ||
| 1837 | -------------------------------------------------------------------------- */ | ||
| 1838 | { | ||
| 1839 | int pix_x, pix_y; | ||
| 1840 | |||
| 1841 | pix_x = FRAME_COL_TO_PIXEL_X (f, h) + FRAME_COLUMN_WIDTH (f) / 2; | ||
| 1842 | pix_y = FRAME_LINE_TO_PIXEL_Y (f, v) + FRAME_LINE_HEIGHT (f) / 2; | ||
| 1843 | |||
| 1844 | if (pix_x < 0) pix_x = 0; | ||
| 1845 | if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f); | ||
| 1846 | |||
| 1847 | if (pix_y < 0) pix_y = 0; | ||
| 1848 | if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f); | ||
| 1849 | |||
| 1850 | x_set_mouse_pixel_position (f, pix_x, pix_y); | ||
| 1851 | } | ||
| 1852 | |||
| 1853 | |||
| 1854 | static int | 1832 | static int |
| 1855 | note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y) | 1833 | note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y) |
| 1856 | /* ------------------------------------------------------------------------ | 1834 | /* ------------------------------------------------------------------------ |
diff --git a/src/w32term.c b/src/w32term.c index 59e9b0ad8a1..5145c840c71 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -5767,27 +5767,8 @@ x_set_window_size (struct frame *f, int change_gravity, int width, int height, b | |||
| 5767 | 5767 | ||
| 5768 | /* Mouse warping. */ | 5768 | /* Mouse warping. */ |
| 5769 | 5769 | ||
| 5770 | void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); | ||
| 5771 | |||
| 5772 | void | ||
| 5773 | x_set_mouse_position (struct frame *f, int x, int y) | ||
| 5774 | { | ||
| 5775 | int pix_x, pix_y; | ||
| 5776 | |||
| 5777 | pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2; | ||
| 5778 | pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2; | ||
| 5779 | |||
| 5780 | if (pix_x < 0) pix_x = 0; | ||
| 5781 | if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f); | ||
| 5782 | |||
| 5783 | if (pix_y < 0) pix_y = 0; | ||
| 5784 | if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f); | ||
| 5785 | |||
| 5786 | x_set_mouse_pixel_position (f, pix_x, pix_y); | ||
| 5787 | } | ||
| 5788 | |||
| 5789 | void | 5770 | void |
| 5790 | x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) | 5771 | frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) |
| 5791 | { | 5772 | { |
| 5792 | RECT rect; | 5773 | RECT rect; |
| 5793 | POINT pt; | 5774 | POINT pt; |
diff --git a/src/w32term.h b/src/w32term.h index e3b65f0ffaf..561a280b65f 100644 --- a/src/w32term.h +++ b/src/w32term.h | |||
| @@ -219,8 +219,6 @@ extern void x_set_window_size (struct frame *f, int change_grav, | |||
| 219 | extern int x_display_pixel_height (struct w32_display_info *); | 219 | extern int x_display_pixel_height (struct w32_display_info *); |
| 220 | extern int x_display_pixel_width (struct w32_display_info *); | 220 | extern int x_display_pixel_width (struct w32_display_info *); |
| 221 | extern Lisp_Object x_get_focus_frame (struct frame *); | 221 | extern Lisp_Object x_get_focus_frame (struct frame *); |
| 222 | extern void x_set_mouse_position (struct frame *f, int h, int v); | ||
| 223 | extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); | ||
| 224 | extern void x_make_frame_visible (struct frame *f); | 222 | extern void x_make_frame_visible (struct frame *f); |
| 225 | extern void x_make_frame_invisible (struct frame *f); | 223 | extern void x_make_frame_invisible (struct frame *f); |
| 226 | extern void x_iconify_frame (struct frame *f); | 224 | extern void x_iconify_frame (struct frame *f); |
diff --git a/src/xterm.c b/src/xterm.c index ed5d0382eae..83d3cb1ab73 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -8735,34 +8735,11 @@ x_set_window_size (struct frame *f, int change_gravity, int width, int height, b | |||
| 8735 | 8735 | ||
| 8736 | unblock_input (); | 8736 | unblock_input (); |
| 8737 | } | 8737 | } |
| 8738 | |||
| 8739 | /* Mouse warping. */ | ||
| 8740 | |||
| 8741 | void | ||
| 8742 | x_set_mouse_position (struct frame *f, int x, int y) | ||
| 8743 | { | ||
| 8744 | int pix_x, pix_y; | ||
| 8745 | |||
| 8746 | pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2; | ||
| 8747 | pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2; | ||
| 8748 | |||
| 8749 | if (pix_x < 0) pix_x = 0; | ||
| 8750 | if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f); | ||
| 8751 | |||
| 8752 | if (pix_y < 0) pix_y = 0; | ||
| 8753 | if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f); | ||
| 8754 | |||
| 8755 | block_input (); | ||
| 8756 | |||
| 8757 | XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), | ||
| 8758 | 0, 0, 0, 0, pix_x, pix_y); | ||
| 8759 | unblock_input (); | ||
| 8760 | } | ||
| 8761 | 8738 | ||
| 8762 | /* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */ | 8739 | /* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */ |
| 8763 | 8740 | ||
| 8764 | void | 8741 | void |
| 8765 | x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) | 8742 | frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) |
| 8766 | { | 8743 | { |
| 8767 | block_input (); | 8744 | block_input (); |
| 8768 | 8745 | ||
diff --git a/src/xterm.h b/src/xterm.h index 3e79de10976..8f71cefb02b 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -931,8 +931,6 @@ extern bool x_had_errors_p (Display *); | |||
| 931 | extern void x_uncatch_errors (void); | 931 | extern void x_uncatch_errors (void); |
| 932 | extern void x_clear_errors (Display *); | 932 | extern void x_clear_errors (Display *); |
| 933 | extern void x_set_window_size (struct frame *, int, int, int, bool); | 933 | extern void x_set_window_size (struct frame *, int, int, int, bool); |
| 934 | extern void x_set_mouse_position (struct frame *, int, int); | ||
| 935 | extern void x_set_mouse_pixel_position (struct frame *, int, int); | ||
| 936 | extern void xembed_request_focus (struct frame *); | 934 | extern void xembed_request_focus (struct frame *); |
| 937 | extern void x_ewmh_activate_frame (struct frame *); | 935 | extern void x_ewmh_activate_frame (struct frame *); |
| 938 | extern void x_delete_terminal (struct terminal *terminal); | 936 | extern void x_delete_terminal (struct terminal *terminal); |