Mercurial > vim
comparison src/gui_gtk_x11.c @ 26246:ed62078dfa30 v8.2.3654
patch 8.2.3654: GTK: a touch-drag does not update the selection
Commit: https://github.com/vim/vim/commit/ee93e327ba31e8efb1b7de6209bdc992778b809b
Author: Chris Dalton <csmartdalton@gmail.com>
Date: Tue Nov 23 12:27:48 2021 +0000
patch 8.2.3654: GTK: a touch-drag does not update the selection
Problem: GTK: a touch-drag does not update the selection.
Solution: Add GDK_BUTTON1_MASK to the state. (Chris Dalton, close https://github.com/vim/vim/issues/9196,
closes #9194)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 23 Nov 2021 13:30:04 +0100 |
parents | 2dd449b9c1c7 |
children | a2e6da79274d |
comparison
equal
deleted
inserted
replaced
26245:c0aea719e669 | 26246:ed62078dfa30 |
---|---|
395 #else | 395 #else |
396 # define using_gnome 0 | 396 # define using_gnome 0 |
397 #endif | 397 #endif |
398 | 398 |
399 /* | 399 /* |
400 * GTK doesn't set the GDK_BUTTON1_MASK state when dragging a touch. Add this | |
401 * state when dragging. | |
402 */ | |
403 static guint dragging_button_state = 0; | |
404 | |
405 /* | |
400 * Parse the GUI related command-line arguments. Any arguments used are | 406 * Parse the GUI related command-line arguments. Any arguments used are |
401 * deleted from argv, and *argc is decremented accordingly. This is called | 407 * deleted from argv, and *argc is decremented accordingly. This is called |
402 * when vim is started, whether or not the GUI has been started. | 408 * when vim is started, whether or not the GUI has been started. |
403 */ | 409 */ |
404 void | 410 void |
1583 { | 1589 { |
1584 int button; | 1590 int button; |
1585 int_u vim_modifiers; | 1591 int_u vim_modifiers; |
1586 GtkAllocation allocation; | 1592 GtkAllocation allocation; |
1587 | 1593 |
1594 // Need to add GDK_BUTTON1_MASK state when dragging a touch. | |
1595 state |= dragging_button_state; | |
1596 | |
1588 button = (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | | 1597 button = (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | |
1589 GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | | 1598 GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | |
1590 GDK_BUTTON5_MASK)) | 1599 GDK_BUTTON5_MASK)) |
1591 ? MOUSE_DRAG : ' '; | 1600 ? MOUSE_DRAG : ' '; |
1592 | 1601 |
1809 | 1818 |
1810 switch (event->button) | 1819 switch (event->button) |
1811 { | 1820 { |
1812 // Keep in sync with gui_x11.c. | 1821 // Keep in sync with gui_x11.c. |
1813 // Buttons 4-7 are handled in scroll_event() | 1822 // Buttons 4-7 are handled in scroll_event() |
1814 case 1: button = MOUSE_LEFT; break; | 1823 case 1: |
1824 button = MOUSE_LEFT; | |
1825 // needed for touch-drag | |
1826 dragging_button_state |= GDK_BUTTON1_MASK; | |
1827 break; | |
1815 case 2: button = MOUSE_MIDDLE; break; | 1828 case 2: button = MOUSE_MIDDLE; break; |
1816 case 3: button = MOUSE_RIGHT; break; | 1829 case 3: button = MOUSE_RIGHT; break; |
1817 case 8: button = MOUSE_X1; break; | 1830 case 8: button = MOUSE_X1; break; |
1818 case 9: button = MOUSE_X2; break; | 1831 case 9: button = MOUSE_X2; break; |
1819 default: | 1832 default: |
1903 y = event->y; | 1916 y = event->y; |
1904 | 1917 |
1905 vim_modifiers = modifiers_gdk2mouse(event->state); | 1918 vim_modifiers = modifiers_gdk2mouse(event->state); |
1906 | 1919 |
1907 gui_send_mouse_event(MOUSE_RELEASE, x, y, FALSE, vim_modifiers); | 1920 gui_send_mouse_event(MOUSE_RELEASE, x, y, FALSE, vim_modifiers); |
1921 | |
1922 switch (event->button) | |
1923 { | |
1924 case 1: // MOUSE_LEFT | |
1925 dragging_button_state = 0; | |
1926 break; | |
1927 } | |
1908 | 1928 |
1909 return TRUE; | 1929 return TRUE; |
1910 } | 1930 } |
1911 | 1931 |
1912 | 1932 |