diff options
| author | Paul Eggert | 2014-05-28 21:47:01 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-05-28 21:47:01 -0700 |
| commit | 6b5d3a51723b463eaac49c4a5d3c96d7b5973a16 (patch) | |
| tree | 611243639edf65d42f1f0adbb0c8f7f7adb841d6 /src | |
| parent | 4d05fe986c0ce9f5c06f9655961e56eb80db7e63 (diff) | |
| download | emacs-6b5d3a51723b463eaac49c4a5d3c96d7b5973a16.tar.gz emacs-6b5d3a51723b463eaac49c4a5d3c96d7b5973a16.zip | |
* frame.c, frame.h (frame_char_to_pixel_position)
(frame_set_mouse_position): Now static, and made private in
frame.c rather than public in frame.h.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/frame.c | 36 | ||||
| -rw-r--r-- | src/frame.h | 32 |
3 files changed, 42 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1fe76c9c75f..a71d34209b2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-05-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * frame.c, frame.h (frame_char_to_pixel_position) | ||
| 4 | (frame_set_mouse_position): Now static, and made private in | ||
| 5 | frame.c rather than public in frame.h. | ||
| 6 | |||
| 1 | 2014-05-28 Dmitry Antipov <dmantipov@yandex.ru> | 7 | 2014-05-28 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 8 | ||
| 3 | Refactor mouse positioning stuff to avoid code duplication. | 9 | Refactor mouse positioning stuff to avoid code duplication. |
diff --git a/src/frame.c b/src/frame.c index 482e21bbfbc..1d5312b4758 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -1593,6 +1593,42 @@ and nil for X and Y. */) | |||
| 1593 | return Fcons (lispy_dummy, Fcons (x, y)); | 1593 | return Fcons (lispy_dummy, Fcons (x, y)); |
| 1594 | } | 1594 | } |
| 1595 | 1595 | ||
| 1596 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 1597 | |||
| 1598 | /* On frame F, convert character coordinates X and Y to pixel | ||
| 1599 | coordinates *PIX_X and *PIX_Y. */ | ||
| 1600 | |||
| 1601 | static void | ||
| 1602 | frame_char_to_pixel_position (struct frame *f, int x, int y, | ||
| 1603 | int *pix_x, int *pix_y) | ||
| 1604 | { | ||
| 1605 | *pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2; | ||
| 1606 | *pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2; | ||
| 1607 | |||
| 1608 | if (*pix_x < 0) | ||
| 1609 | *pix_x = 0; | ||
| 1610 | if (*pix_x > FRAME_PIXEL_WIDTH (f)) | ||
| 1611 | *pix_x = FRAME_PIXEL_WIDTH (f); | ||
| 1612 | |||
| 1613 | if (*pix_y < 0) | ||
| 1614 | *pix_y = 0; | ||
| 1615 | if (*pix_y > FRAME_PIXEL_HEIGHT (f)) | ||
| 1616 | *pix_y = FRAME_PIXEL_HEIGHT (f); | ||
| 1617 | } | ||
| 1618 | |||
| 1619 | /* On frame F, reposition mouse pointer to character coordinates X and Y. */ | ||
| 1620 | |||
| 1621 | static void | ||
| 1622 | frame_set_mouse_position (struct frame *f, int x, int y) | ||
| 1623 | { | ||
| 1624 | int pix_x, pix_y; | ||
| 1625 | |||
| 1626 | frame_char_to_pixel_position (f, x, y, &pix_x, &pix_y); | ||
| 1627 | frame_set_mouse_pixel_position (f, pix_x, pix_y); | ||
| 1628 | } | ||
| 1629 | |||
| 1630 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 1631 | |||
| 1596 | DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0, | 1632 | DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0, |
| 1597 | doc: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME. | 1633 | doc: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME. |
| 1598 | Coordinates are relative to the frame, not a window, | 1634 | Coordinates are relative to the frame, not a window, |
diff --git a/src/frame.h b/src/frame.h index 60d3e3680f1..0ee97f0b3f3 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -1353,38 +1353,6 @@ x_set_bitmap_icon (struct frame *f) | |||
| 1353 | } | 1353 | } |
| 1354 | 1354 | ||
| 1355 | #endif /* !HAVE_NS */ | 1355 | #endif /* !HAVE_NS */ |
| 1356 | |||
| 1357 | /* Convert character coordinates X and Y to pixel | ||
| 1358 | coordinates PIX_X and PIX_Y on frame F. */ | ||
| 1359 | |||
| 1360 | INLINE void | ||
| 1361 | frame_char_to_pixel_position (struct frame *f, int x, int y, int *pix_x, int *pix_y) | ||
| 1362 | { | ||
| 1363 | *pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2; | ||
| 1364 | *pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2; | ||
| 1365 | |||
| 1366 | if (*pix_x < 0) | ||
| 1367 | *pix_x = 0; | ||
| 1368 | if (*pix_x > FRAME_PIXEL_WIDTH (f)) | ||
| 1369 | *pix_x = FRAME_PIXEL_WIDTH (f); | ||
| 1370 | |||
| 1371 | if (*pix_y < 0) | ||
| 1372 | *pix_y = 0; | ||
| 1373 | if (*pix_y > FRAME_PIXEL_HEIGHT (f)) | ||
| 1374 | *pix_y = FRAME_PIXEL_HEIGHT (f); | ||
| 1375 | } | ||
| 1376 | |||
| 1377 | /* Reposition mouse pointer to character coordinates X and Y on frame F. */ | ||
| 1378 | |||
| 1379 | INLINE | ||
| 1380 | void frame_set_mouse_position (struct frame *f, int x, int y) | ||
| 1381 | { | ||
| 1382 | int pix_x, pix_y; | ||
| 1383 | |||
| 1384 | frame_char_to_pixel_position (f, x, y, &pix_x, &pix_y); | ||
| 1385 | frame_set_mouse_pixel_position (f, pix_x, pix_y); | ||
| 1386 | } | ||
| 1387 | |||
| 1388 | #endif /* HAVE_WINDOW_SYSTEM */ | 1356 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 1389 | 1357 | ||
| 1390 | INLINE void | 1358 | INLINE void |