diff options
| author | Richard M. Stallman | 1993-12-23 00:57:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-12-23 00:57:11 +0000 |
| commit | 693882381216116de1cc113a565a5a6df1fadc8e (patch) | |
| tree | 0e9eba4ac36eef12fe08f5d16d42a0df5a59a1eb /src | |
| parent | 5c40edb4bf3fb241006bfae81b848abe8ac23c8e (diff) | |
| download | emacs-693882381216116de1cc113a565a5a6df1fadc8e.tar.gz emacs-693882381216116de1cc113a565a5a6df1fadc8e.zip | |
(XTread_socket): Don't offset keysym here.
Special handling for "dead accent" keysyms.
(construct_mouse_click, x_scroll_bar_handle_click)
(XTread_socket): `code' of an event is now an int.
(pixel_to_glyph_coords): New arg NOCLIP. Callers changed.
(XTread_socket): For MotionNotify, if x_mouse_grabbed, use last_mouse_frame.
(construct_mouse_click): Set last_mouse_frame.
(XTmouse_position): If x_mouse_grabbed, use last_mouse_frame.
(x_calc_absolute_position): Borderwidth must be doubled
before subtracting from width to get correct value.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 268 |
1 files changed, 173 insertions, 95 deletions
diff --git a/src/xterm.c b/src/xterm.c index 5d8470296b3..7937e15a442 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -119,7 +119,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 119 | 119 | ||
| 120 | #define min(a,b) ((a)<(b) ? (a) : (b)) | 120 | #define min(a,b) ((a)<(b) ? (a) : (b)) |
| 121 | #define max(a,b) ((a)>(b) ? (a) : (b)) | 121 | #define max(a,b) ((a)>(b) ? (a) : (b)) |
| 122 | 122 | ||
| 123 | /* Nonzero means we must reprint all windows | 123 | /* Nonzero means we must reprint all windows |
| 124 | because 1) we received an ExposeWindow event | 124 | because 1) we received an ExposeWindow event |
| 125 | or 2) we received too many ExposeRegion events to record. | 125 | or 2) we received too many ExposeRegion events to record. |
| @@ -137,7 +137,7 @@ static int expose_all_icons; | |||
| 137 | 137 | ||
| 138 | static struct event_queue x_expose_queue; | 138 | static struct event_queue x_expose_queue; |
| 139 | 139 | ||
| 140 | /* ButtonPressed and ButtonReleased events, when received, | 140 | /* ButtonPress and ButtonReleased events, when received, |
| 141 | are copied into this queue for later processing. */ | 141 | are copied into this queue for later processing. */ |
| 142 | 142 | ||
| 143 | struct event_queue x_mouse_queue; | 143 | struct event_queue x_mouse_queue; |
| @@ -215,6 +215,50 @@ static int highlight; | |||
| 215 | static int curs_x; | 215 | static int curs_x; |
| 216 | static int curs_y; | 216 | static int curs_y; |
| 217 | 217 | ||
| 218 | /* Mouse movement. | ||
| 219 | |||
| 220 | In order to avoid asking for motion events and then throwing most | ||
| 221 | of them away or busy-polling the server for mouse positions, we ask | ||
| 222 | the server for pointer motion hints. This means that we get only | ||
| 223 | one event per group of mouse movements. "Groups" are delimited by | ||
| 224 | other kinds of events (focus changes and button clicks, for | ||
| 225 | example), or by XQueryPointer calls; when one of these happens, we | ||
| 226 | get another MotionNotify event the next time the mouse moves. This | ||
| 227 | is at least as efficient as getting motion events when mouse | ||
| 228 | tracking is on, and I suspect only negligibly worse when tracking | ||
| 229 | is off. | ||
| 230 | |||
| 231 | The silly O'Reilly & Associates Nutshell guides barely document | ||
| 232 | pointer motion hints at all (I think you have to infer how they | ||
| 233 | work from an example), and the description of XQueryPointer doesn't | ||
| 234 | mention that calling it causes you to get another motion hint from | ||
| 235 | the server, which is very important. */ | ||
| 236 | |||
| 237 | /* Where the mouse was last time we reported a mouse event. */ | ||
| 238 | static FRAME_PTR last_mouse_frame; | ||
| 239 | static XRectangle last_mouse_glyph; | ||
| 240 | |||
| 241 | /* The scroll bar in which the last X motion event occurred. | ||
| 242 | |||
| 243 | If the last X motion event occurred in a scroll bar, we set this | ||
| 244 | so XTmouse_position can know whether to report a scroll bar motion or | ||
| 245 | an ordinary motion. | ||
| 246 | |||
| 247 | If the last X motion event didn't occur in a scroll bar, we set this | ||
| 248 | to Qnil, to tell XTmouse_position to return an ordinary motion event. */ | ||
| 249 | static Lisp_Object last_mouse_scroll_bar; | ||
| 250 | |||
| 251 | /* Record which buttons are currently pressed. */ | ||
| 252 | unsigned int x_mouse_grabbed; | ||
| 253 | |||
| 254 | /* This is a hack. We would really prefer that XTmouse_position would | ||
| 255 | return the time associated with the position it returns, but there | ||
| 256 | doesn't seem to be any way to wrest the timestamp from the server | ||
| 257 | along with the position query. So, we just keep track of the time | ||
| 258 | of the last movement we received, and return that in hopes that | ||
| 259 | it's somewhat accurate. */ | ||
| 260 | static Time last_mouse_movement_time; | ||
| 261 | |||
| 218 | #ifdef HAVE_X11 | 262 | #ifdef HAVE_X11 |
| 219 | /* `t' if a mouse button is depressed. */ | 263 | /* `t' if a mouse button is depressed. */ |
| 220 | 264 | ||
| @@ -1593,14 +1637,24 @@ x_is_vendor_fkey (sym) | |||
| 1593 | 1637 | ||
| 1594 | /* Given a pixel position (PIX_X, PIX_Y) on the frame F, return | 1638 | /* Given a pixel position (PIX_X, PIX_Y) on the frame F, return |
| 1595 | glyph co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle | 1639 | glyph co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle |
| 1596 | that the glyph at X, Y occupies, if BOUNDS != 0. */ | 1640 | that the glyph at X, Y occupies, if BOUNDS != 0. |
| 1641 | If NOCLIP is nonzero, do not force the value into range. */ | ||
| 1642 | |||
| 1597 | static void | 1643 | static void |
| 1598 | pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds) | 1644 | pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip) |
| 1599 | FRAME_PTR f; | 1645 | FRAME_PTR f; |
| 1600 | register unsigned int pix_x, pix_y; | 1646 | register int pix_x, pix_y; |
| 1601 | register int *x, *y; | 1647 | register int *x, *y; |
| 1602 | XRectangle *bounds; | 1648 | XRectangle *bounds; |
| 1649 | int noclip; | ||
| 1603 | { | 1650 | { |
| 1651 | /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down | ||
| 1652 | even for negative values. */ | ||
| 1653 | if (pix_x < 0) | ||
| 1654 | pix_x -= FONT_WIDTH ((f)->display.x->font) - 1; | ||
| 1655 | if (pix_y < 0) | ||
| 1656 | pix_y -= FONT_HEIGHT ((f)->display.x->font) - 1; | ||
| 1657 | |||
| 1604 | pix_x = PIXEL_TO_CHAR_COL (f, pix_x); | 1658 | pix_x = PIXEL_TO_CHAR_COL (f, pix_x); |
| 1605 | pix_y = PIXEL_TO_CHAR_ROW (f, pix_y); | 1659 | pix_y = PIXEL_TO_CHAR_ROW (f, pix_y); |
| 1606 | 1660 | ||
| @@ -1612,19 +1666,23 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds) | |||
| 1612 | bounds->y = CHAR_TO_PIXEL_ROW (f, pix_y); | 1666 | bounds->y = CHAR_TO_PIXEL_ROW (f, pix_y); |
| 1613 | } | 1667 | } |
| 1614 | 1668 | ||
| 1615 | if (pix_x < 0) pix_x = 0; | 1669 | if (!noclip) |
| 1616 | else if (pix_x > f->width) pix_x = f->width; | 1670 | { |
| 1617 | 1671 | if (pix_x < 0) | |
| 1618 | if (pix_y < 0) pix_y = 0; | 1672 | pix_x = 0; |
| 1619 | else if (pix_y > f->height) pix_y = f->height; | 1673 | else if (pix_x > f->width) |
| 1674 | pix_x = f->width; | ||
| 1675 | |||
| 1676 | if (pix_y < 0) | ||
| 1677 | pix_y = 0; | ||
| 1678 | else if (pix_y > f->height) | ||
| 1679 | pix_y = f->height; | ||
| 1680 | } | ||
| 1620 | 1681 | ||
| 1621 | *x = pix_x; | 1682 | *x = pix_x; |
| 1622 | *y = pix_y; | 1683 | *y = pix_y; |
| 1623 | } | 1684 | } |
| 1624 | 1685 | ||
| 1625 | /* Any buttons grabbed. */ | ||
| 1626 | unsigned int x_mouse_grabbed; | ||
| 1627 | |||
| 1628 | /* Prepare a mouse-event in *RESULT for placement in the input queue. | 1686 | /* Prepare a mouse-event in *RESULT for placement in the input queue. |
| 1629 | 1687 | ||
| 1630 | If the event is a button press, then note that we have grabbed | 1688 | If the event is a button press, then note that we have grabbed |
| @@ -1639,7 +1697,7 @@ construct_mouse_click (result, event, f) | |||
| 1639 | /* Make the event type no_event; we'll change that when we decide | 1697 | /* Make the event type no_event; we'll change that when we decide |
| 1640 | otherwise. */ | 1698 | otherwise. */ |
| 1641 | result->kind = mouse_click; | 1699 | result->kind = mouse_click; |
| 1642 | XSET (result->code, Lisp_Int, event->button - Button1); | 1700 | result->code = event->button - Button1; |
| 1643 | result->timestamp = event->time; | 1701 | result->timestamp = event->time; |
| 1644 | result->modifiers = (x_x_to_emacs_modifiers (event->state) | 1702 | result->modifiers = (x_x_to_emacs_modifiers (event->state) |
| 1645 | | (event->type == ButtonRelease | 1703 | | (event->type == ButtonRelease |
| @@ -1652,6 +1710,7 @@ construct_mouse_click (result, event, f) | |||
| 1652 | if (! x_mouse_grabbed) | 1710 | if (! x_mouse_grabbed) |
| 1653 | Vmouse_depressed = Qt; | 1711 | Vmouse_depressed = Qt; |
| 1654 | x_mouse_grabbed |= (1 << event->button); | 1712 | x_mouse_grabbed |= (1 << event->button); |
| 1713 | last_mouse_frame = f; | ||
| 1655 | } | 1714 | } |
| 1656 | else if (event->type == ButtonRelease) | 1715 | else if (event->type == ButtonRelease) |
| 1657 | { | 1716 | { |
| @@ -1663,55 +1722,13 @@ construct_mouse_click (result, event, f) | |||
| 1663 | { | 1722 | { |
| 1664 | int row, column; | 1723 | int row, column; |
| 1665 | 1724 | ||
| 1666 | pixel_to_glyph_coords (f, event->x, event->y, &column, &row, NULL); | 1725 | pixel_to_glyph_coords (f, event->x, event->y, &column, &row, NULL, 0); |
| 1667 | XFASTINT (result->x) = column; | 1726 | XFASTINT (result->x) = column; |
| 1668 | XFASTINT (result->y) = row; | 1727 | XFASTINT (result->y) = row; |
| 1669 | XSET (result->frame_or_window, Lisp_Frame, f); | 1728 | XSET (result->frame_or_window, Lisp_Frame, f); |
| 1670 | } | 1729 | } |
| 1671 | } | 1730 | } |
| 1672 | 1731 | ||
| 1673 | |||
| 1674 | /* Mouse movement. Rah. | ||
| 1675 | |||
| 1676 | In order to avoid asking for motion events and then throwing most | ||
| 1677 | of them away or busy-polling the server for mouse positions, we ask | ||
| 1678 | the server for pointer motion hints. This means that we get only | ||
| 1679 | one event per group of mouse movements. "Groups" are delimited by | ||
| 1680 | other kinds of events (focus changes and button clicks, for | ||
| 1681 | example), or by XQueryPointer calls; when one of these happens, we | ||
| 1682 | get another MotionNotify event the next time the mouse moves. This | ||
| 1683 | is at least as efficient as getting motion events when mouse | ||
| 1684 | tracking is on, and I suspect only negligibly worse when tracking | ||
| 1685 | is off. | ||
| 1686 | |||
| 1687 | The silly O'Reilly & Associates Nutshell guides barely document | ||
| 1688 | pointer motion hints at all (I think you have to infer how they | ||
| 1689 | work from an example), and the description of XQueryPointer doesn't | ||
| 1690 | mention that calling it causes you to get another motion hint from | ||
| 1691 | the server, which is very important. */ | ||
| 1692 | |||
| 1693 | /* Where the mouse was last time we reported a mouse event. */ | ||
| 1694 | static FRAME_PTR last_mouse_frame; | ||
| 1695 | static XRectangle last_mouse_glyph; | ||
| 1696 | |||
| 1697 | /* The scroll bar in which the last X motion event occurred. | ||
| 1698 | |||
| 1699 | If the last X motion event occurred in a scroll bar, we set this | ||
| 1700 | so XTmouse_position can know whether to report a scroll bar motion or | ||
| 1701 | an ordinary motion. | ||
| 1702 | |||
| 1703 | If the last X motion event didn't occur in a scroll bar, we set this | ||
| 1704 | to Qnil, to tell XTmouse_position to return an ordinary motion event. */ | ||
| 1705 | static Lisp_Object last_mouse_scroll_bar; | ||
| 1706 | |||
| 1707 | /* This is a hack. We would really prefer that XTmouse_position would | ||
| 1708 | return the time associated with the position it returns, but there | ||
| 1709 | doesn't seem to be any way to wrest the timestamp from the server | ||
| 1710 | along with the position query. So, we just keep track of the time | ||
| 1711 | of the last movement we received, and return that in hopes that | ||
| 1712 | it's somewhat accurate. */ | ||
| 1713 | static Time last_mouse_movement_time; | ||
| 1714 | |||
| 1715 | /* Function to report a mouse movement to the mainstream Emacs code. | 1732 | /* Function to report a mouse movement to the mainstream Emacs code. |
| 1716 | The input handler calls this. | 1733 | The input handler calls this. |
| 1717 | 1734 | ||
| @@ -1828,40 +1845,60 @@ XTmouse_position (f, bar_window, part, x, y, time) | |||
| 1828 | int parent_x, parent_y; | 1845 | int parent_x, parent_y; |
| 1829 | 1846 | ||
| 1830 | win = root; | 1847 | win = root; |
| 1831 | for (;;) | 1848 | |
| 1849 | if (x_mouse_grabbed) | ||
| 1832 | { | 1850 | { |
| 1851 | /* If mouse was grabbed on a frame, give coords for that frame | ||
| 1852 | even if the mouse is now outside it. */ | ||
| 1833 | XTranslateCoordinates (x_current_display, | 1853 | XTranslateCoordinates (x_current_display, |
| 1834 | 1854 | ||
| 1835 | /* From-window, to-window. */ | 1855 | /* From-window, to-window. */ |
| 1836 | root, win, | 1856 | root, FRAME_X_WINDOW (last_mouse_frame), |
| 1837 | 1857 | ||
| 1838 | /* From-position, to-position. */ | 1858 | /* From-position, to-position. */ |
| 1839 | root_x, root_y, &win_x, &win_y, | 1859 | root_x, root_y, &win_x, &win_y, |
| 1840 | 1860 | ||
| 1841 | /* Child of win. */ | 1861 | /* Child of win. */ |
| 1842 | &child); | 1862 | &child); |
| 1863 | f1 = last_mouse_frame; | ||
| 1864 | } | ||
| 1865 | else | ||
| 1866 | { | ||
| 1867 | while (1) | ||
| 1868 | { | ||
| 1869 | XTranslateCoordinates (x_current_display, | ||
| 1843 | 1870 | ||
| 1844 | if (child == None) | 1871 | /* From-window, to-window. */ |
| 1845 | break; | 1872 | root, win, |
| 1846 | 1873 | ||
| 1847 | win = child; | 1874 | /* From-position, to-position. */ |
| 1848 | parent_x = win_x; | 1875 | root_x, root_y, &win_x, &win_y, |
| 1849 | parent_y = win_y; | 1876 | |
| 1850 | } | 1877 | /* Child of win. */ |
| 1878 | &child); | ||
| 1879 | |||
| 1880 | if (child == None) | ||
| 1881 | break; | ||
| 1882 | |||
| 1883 | win = child; | ||
| 1884 | parent_x = win_x; | ||
| 1885 | parent_y = win_y; | ||
| 1886 | } | ||
| 1851 | 1887 | ||
| 1852 | /* Now we know that: | 1888 | /* Now we know that: |
| 1853 | win is the innermost window containing the pointer | 1889 | win is the innermost window containing the pointer |
| 1854 | (XTC says it has no child containing the pointer), | 1890 | (XTC says it has no child containing the pointer), |
| 1855 | win_x and win_y are the pointer's position in it | 1891 | win_x and win_y are the pointer's position in it |
| 1856 | (XTC did this the last time through), and | 1892 | (XTC did this the last time through), and |
| 1857 | parent_x and parent_y are the pointer's position in win's parent. | 1893 | parent_x and parent_y are the pointer's position in win's parent. |
| 1858 | (They are what win_x and win_y were when win was child. | 1894 | (They are what win_x and win_y were when win was child. |
| 1859 | If win is the root window, it has no parent, and | 1895 | If win is the root window, it has no parent, and |
| 1860 | parent_{x,y} are invalid, but that's okay, because we'll | 1896 | parent_{x,y} are invalid, but that's okay, because we'll |
| 1861 | never use them in that case.) */ | 1897 | never use them in that case.) */ |
| 1862 | 1898 | ||
| 1863 | /* Is win one of our frames? */ | 1899 | /* Is win one of our frames? */ |
| 1864 | f1 = x_window_to_frame (win); | 1900 | f1 = x_window_to_frame (win); |
| 1901 | } | ||
| 1865 | 1902 | ||
| 1866 | /* If not, is it one of our scroll bars? */ | 1903 | /* If not, is it one of our scroll bars? */ |
| 1867 | if (! f1) | 1904 | if (! f1) |
| @@ -1882,7 +1919,7 @@ XTmouse_position (f, bar_window, part, x, y, time) | |||
| 1882 | and store all the values. */ | 1919 | and store all the values. */ |
| 1883 | 1920 | ||
| 1884 | pixel_to_glyph_coords (f1, win_x, win_y, &win_x, &win_y, | 1921 | pixel_to_glyph_coords (f1, win_x, win_y, &win_x, &win_y, |
| 1885 | &last_mouse_glyph); | 1922 | &last_mouse_glyph, x_mouse_grabbed); |
| 1886 | 1923 | ||
| 1887 | *bar_window = Qnil; | 1924 | *bar_window = Qnil; |
| 1888 | *part = 0; | 1925 | *part = 0; |
| @@ -2361,7 +2398,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event) | |||
| 2361 | abort (); | 2398 | abort (); |
| 2362 | 2399 | ||
| 2363 | emacs_event->kind = scroll_bar_click; | 2400 | emacs_event->kind = scroll_bar_click; |
| 2364 | XSET (emacs_event->code, Lisp_Int, event->xbutton.button - Button1); | 2401 | emacs_event->code = event->xbutton.button - Button1; |
| 2365 | emacs_event->modifiers = | 2402 | emacs_event->modifiers = |
| 2366 | (x_x_to_emacs_modifiers (event->xbutton.state) | 2403 | (x_x_to_emacs_modifiers (event->xbutton.state) |
| 2367 | | (event->type == ButtonRelease | 2404 | | (event->type == ButtonRelease |
| @@ -2989,6 +3026,45 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 2989 | || ((unsigned) (keysym) >= XK_Select | 3026 | || ((unsigned) (keysym) >= XK_Select |
| 2990 | && (unsigned)(keysym) < XK_KP_Space) | 3027 | && (unsigned)(keysym) < XK_KP_Space) |
| 2991 | #endif | 3028 | #endif |
| 3029 | #ifdef XK_dead_circumflex | ||
| 3030 | || orig_keysym == XK_dead_circumflex | ||
| 3031 | #endif | ||
| 3032 | #ifdef XK_dead_grave | ||
| 3033 | || orig_keysym == XK_dead_grave | ||
| 3034 | #endif | ||
| 3035 | #ifdef XK_dead_tilde | ||
| 3036 | || orig_keysym == XK_dead_tilde | ||
| 3037 | #endif | ||
| 3038 | #ifdef XK_dead_diaeresis | ||
| 3039 | || orig_keysym == XK_dead_diaeresis | ||
| 3040 | #endif | ||
| 3041 | #ifdef XK_dead_macron | ||
| 3042 | || orig_keysym == XK_dead_macron | ||
| 3043 | #endif | ||
| 3044 | #ifdef XK_dead_degree | ||
| 3045 | || orig_keysym == XK_dead_degree | ||
| 3046 | #endif | ||
| 3047 | #ifdef XK_dead_acute | ||
| 3048 | || orig_keysym == XK_dead_acute | ||
| 3049 | #endif | ||
| 3050 | #ifdef XK_dead_cedilla | ||
| 3051 | || orig_keysym == XK_dead_cedilla | ||
| 3052 | #endif | ||
| 3053 | #ifdef XK_dead_breve | ||
| 3054 | || orig_keysym == XK_dead_breve | ||
| 3055 | #endif | ||
| 3056 | #ifdef XK_dead_ogonek | ||
| 3057 | || orig_keysym == XK_dead_ogonek | ||
| 3058 | #endif | ||
| 3059 | #ifdef XK_dead_caron | ||
| 3060 | || orig_keysym == XK_dead_caron | ||
| 3061 | #endif | ||
| 3062 | #ifdef XK_dead_doubleacute | ||
| 3063 | || orig_keysym == XK_dead_doubleacute | ||
| 3064 | #endif | ||
| 3065 | #ifdef XK_dead_abovedot | ||
| 3066 | || orig_keysym == XK_dead_abovedot | ||
| 3067 | #endif | ||
| 2992 | || IsKeypadKey (keysym) /* 0xff80 <= x < 0xffbe */ | 3068 | || IsKeypadKey (keysym) /* 0xff80 <= x < 0xffbe */ |
| 2993 | || IsFunctionKey (keysym) /* 0xffbe <= x < 0xffe1 */ | 3069 | || IsFunctionKey (keysym) /* 0xffbe <= x < 0xffe1 */ |
| 2994 | || x_is_vendor_fkey (orig_keysym)) | 3070 | || x_is_vendor_fkey (orig_keysym)) |
| @@ -3007,7 +3083,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 3007 | temp_index = 0; | 3083 | temp_index = 0; |
| 3008 | temp_buffer[temp_index++] = keysym; | 3084 | temp_buffer[temp_index++] = keysym; |
| 3009 | bufp->kind = non_ascii_keystroke; | 3085 | bufp->kind = non_ascii_keystroke; |
| 3010 | XSET (bufp->code, Lisp_Int, (unsigned) keysym - 0xff00); | 3086 | bufp->code = keysym; |
| 3011 | XSET (bufp->frame_or_window, Lisp_Frame, f); | 3087 | XSET (bufp->frame_or_window, Lisp_Frame, f); |
| 3012 | bufp->modifiers = x_x_to_emacs_modifiers (modifiers); | 3088 | bufp->modifiers = x_x_to_emacs_modifiers (modifiers); |
| 3013 | bufp->timestamp = event.xkey.time; | 3089 | bufp->timestamp = event.xkey.time; |
| @@ -3025,7 +3101,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 3025 | temp_index = 0; | 3101 | temp_index = 0; |
| 3026 | temp_buffer[temp_index++] = copy_buffer[i]; | 3102 | temp_buffer[temp_index++] = copy_buffer[i]; |
| 3027 | bufp->kind = ascii_keystroke; | 3103 | bufp->kind = ascii_keystroke; |
| 3028 | XSET (bufp->code, Lisp_Int, copy_buffer[i]); | 3104 | bufp->code = copy_buffer[i]; |
| 3029 | XSET (bufp->frame_or_window, Lisp_Frame, f); | 3105 | XSET (bufp->frame_or_window, Lisp_Frame, f); |
| 3030 | bufp->modifiers = x_x_to_emacs_modifiers (modifiers); | 3106 | bufp->modifiers = x_x_to_emacs_modifiers (modifiers); |
| 3031 | bufp->timestamp = event.xkey.time; | 3107 | bufp->timestamp = event.xkey.time; |
| @@ -3079,7 +3155,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 3079 | for (i = 0; i < nbytes; i++) | 3155 | for (i = 0; i < nbytes; i++) |
| 3080 | { | 3156 | { |
| 3081 | bufp->kind = ascii_keystroke; | 3157 | bufp->kind = ascii_keystroke; |
| 3082 | XSET (bufp->code, Lisp_Int, where_mapping[i]); | 3158 | bufp->code = where_mapping[i]; |
| 3083 | XSET (bufp->time, Lisp_Int, event.xkey.time); | 3159 | XSET (bufp->time, Lisp_Int, event.xkey.time); |
| 3084 | XSET (bufp->frame_or_window, Lisp_Frame, f); | 3160 | XSET (bufp->frame_or_window, Lisp_Frame, f); |
| 3085 | bufp++; | 3161 | bufp++; |
| @@ -3194,13 +3270,16 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 3194 | #ifdef HAVE_X11 | 3270 | #ifdef HAVE_X11 |
| 3195 | case MotionNotify: | 3271 | case MotionNotify: |
| 3196 | { | 3272 | { |
| 3197 | f = x_window_to_frame (event.xmotion.window); | 3273 | if (x_mouse_grabbed) |
| 3274 | f = last_mouse_frame; | ||
| 3275 | else | ||
| 3276 | f = x_window_to_frame (event.xmotion.window); | ||
| 3198 | if (f) | 3277 | if (f) |
| 3199 | note_mouse_movement (f, &event.xmotion); | 3278 | note_mouse_movement (f, &event.xmotion); |
| 3200 | else | 3279 | else |
| 3201 | { | 3280 | { |
| 3202 | struct scroll_bar *bar = | 3281 | struct scroll_bar *bar |
| 3203 | x_window_to_scroll_bar (event.xmotion.window); | 3282 | = x_window_to_scroll_bar (event.xmotion.window); |
| 3204 | 3283 | ||
| 3205 | if (bar) | 3284 | if (bar) |
| 3206 | x_scroll_bar_note_movement (bar, &event); | 3285 | x_scroll_bar_note_movement (bar, &event); |
| @@ -3273,8 +3352,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 3273 | if (f) | 3352 | if (f) |
| 3274 | { | 3353 | { |
| 3275 | if (!x_focus_frame || (f == x_focus_frame)) | 3354 | if (!x_focus_frame || (f == x_focus_frame)) |
| 3276 | construct_mouse_click (&emacs_event, | 3355 | construct_mouse_click (&emacs_event, &event, f); |
| 3277 | &event, f); | ||
| 3278 | } | 3356 | } |
| 3279 | else | 3357 | else |
| 3280 | { | 3358 | { |
| @@ -3319,13 +3397,13 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 3319 | if (numchars >= 2) | 3397 | if (numchars >= 2) |
| 3320 | { | 3398 | { |
| 3321 | bufp->kind = ascii_keystroke; | 3399 | bufp->kind = ascii_keystroke; |
| 3322 | bufp->code = (char) 'X' & 037; /* C-x */ | 3400 | bufp->code = 'X' & 037; /* C-x */ |
| 3323 | XSET (bufp->frame_or_window, Lisp_Frame, f); | 3401 | XSET (bufp->frame_or_window, Lisp_Frame, f); |
| 3324 | XSET (bufp->time, Lisp_Int, event.xkey.time); | 3402 | XSET (bufp->time, Lisp_Int, event.xkey.time); |
| 3325 | bufp++; | 3403 | bufp++; |
| 3326 | 3404 | ||
| 3327 | bufp->kind = ascii_keystroke; | 3405 | bufp->kind = ascii_keystroke; |
| 3328 | bufp->code = (char) 0; /* C-@ */ | 3406 | bufp->code = 0; /* C-@ */ |
| 3329 | XSET (bufp->frame_or_window, Lisp_Frame, f); | 3407 | XSET (bufp->frame_or_window, Lisp_Frame, f); |
| 3330 | XSET (bufp->time, Lisp_Int, event.xkey.time); | 3408 | XSET (bufp->time, Lisp_Int, event.xkey.time); |
| 3331 | bufp++; | 3409 | bufp++; |
| @@ -4210,13 +4288,13 @@ x_calc_absolute_position (f) | |||
| 4210 | position that fits on the screen. */ | 4288 | position that fits on the screen. */ |
| 4211 | if (f->display.x->left_pos < 0) | 4289 | if (f->display.x->left_pos < 0) |
| 4212 | f->display.x->left_pos = (x_screen_width | 4290 | f->display.x->left_pos = (x_screen_width |
| 4213 | - f->display.x->border_width - win_x | 4291 | - 2 * f->display.x->border_width - win_x |
| 4214 | - PIXEL_WIDTH (f) | 4292 | - PIXEL_WIDTH (f) |
| 4215 | + f->display.x->left_pos); | 4293 | + f->display.x->left_pos); |
| 4216 | 4294 | ||
| 4217 | if (f->display.x->top_pos < 0) | 4295 | if (f->display.x->top_pos < 0) |
| 4218 | f->display.x->top_pos = (x_screen_height | 4296 | f->display.x->top_pos = (x_screen_height |
| 4219 | - f->display.x->border_width - win_y | 4297 | - 2 * f->display.x->border_width - win_y |
| 4220 | - PIXEL_HEIGHT (f) | 4298 | - PIXEL_HEIGHT (f) |
| 4221 | + f->display.x->top_pos); | 4299 | + f->display.x->top_pos); |
| 4222 | 4300 | ||
| @@ -4617,7 +4695,7 @@ x_destroy_window (f) | |||
| 4617 | of certain kinds into our private queues. | 4695 | of certain kinds into our private queues. |
| 4618 | 4696 | ||
| 4619 | All ExposeRegion events are put in x_expose_queue. | 4697 | All ExposeRegion events are put in x_expose_queue. |
| 4620 | All ButtonPressed and ButtonReleased events are put in x_mouse_queue. */ | 4698 | All ButtonPress and ButtonRelease events are put in x_mouse_queue. */ |
| 4621 | 4699 | ||
| 4622 | 4700 | ||
| 4623 | /* Write the event *P_XREP into the event queue *QUEUE. | 4701 | /* Write the event *P_XREP into the event queue *QUEUE. |