comparison src/gui_gtk.c @ 10390:6c8a4d21b873 v8.0.0089

commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 17 19:11:55 2016 +0100 patch 8.0.0089 Problem: Various problems with GTK 3.22.2. Solution: Fix the problems, add #ifdefs. (Kazunobu Kuriyama)
author Christian Brabandt <cb@256bit.org>
date Thu, 17 Nov 2016 19:15:04 +0100
parents 4aead6a9b7a9
children a3cef16bea27
comparison
equal deleted inserted replaced
10389:31c0537eab4e 10390:6c8a4d21b873
1879 "vim-has-im-menu", GINT_TO_POINTER(TRUE)); 1879 "vim-has-im-menu", GINT_TO_POINTER(TRUE));
1880 } 1880 }
1881 # endif 1881 # endif
1882 # endif /* FEAT_XIM */ 1882 # endif /* FEAT_XIM */
1883 1883
1884 # if GTK_CHECK_VERSION(3,22,2)
1885 {
1886 GdkEventButton trigger;
1887
1888 /* A pseudo event to have gtk_menu_popup_at_pointer() work. Since the
1889 * function calculates the popup menu position on the basis of the
1890 * actual pointer position when it is invoked, the fields x, y, x_root
1891 * and y_root are set to zero for convenience. */
1892 trigger.type = GDK_BUTTON_PRESS;
1893 trigger.window = gtk_widget_get_window(gui.drawarea);
1894 trigger.send_event = FALSE;
1895 trigger.time = gui.event_time;
1896 trigger.x = 0.0;
1897 trigger.y = 0.0;
1898 trigger.axes = NULL;
1899 trigger.state = 0;
1900 trigger.button = 3;
1901 trigger.device = NULL;
1902 trigger.x_root = 0.0;
1903 trigger.y_root = 0.0;
1904
1905 gtk_menu_popup_at_pointer(GTK_MENU(menu->submenu_id),
1906 (GdkEvent *)&trigger);
1907 }
1908 #else
1884 gtk_menu_popup(GTK_MENU(menu->submenu_id), 1909 gtk_menu_popup(GTK_MENU(menu->submenu_id),
1885 NULL, NULL, 1910 NULL, NULL,
1886 (GtkMenuPositionFunc)NULL, NULL, 1911 (GtkMenuPositionFunc)NULL, NULL,
1887 3U, gui.event_time); 1912 3U, gui.event_time);
1913 #endif
1888 } 1914 }
1889 1915
1890 /* Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to 1916 /* Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to
1891 * popup_menu_position_func(). */ 1917 * popup_menu_position_func(). */
1892 static int popup_mouse_pos; 1918 static int popup_mouse_pos;
1940 1966
1941 menu = gui_find_menu(path_name); 1967 menu = gui_find_menu(path_name);
1942 1968
1943 if (menu != NULL && menu->submenu_id != NULL) 1969 if (menu != NULL && menu->submenu_id != NULL)
1944 { 1970 {
1971 # if GTK_CHECK_VERSION(3,22,2)
1972 GdkWindow * const win = gtk_widget_get_window(gui.drawarea);
1973 GdkEventButton trigger;
1974
1975 /* A pseudo event to have gtk_menu_popup_at_*() functions work. Since
1976 * the position where the menu pops up is automatically adjusted by
1977 * the functions, none of the fields x, y, x_root and y_root has to be
1978 * set to a specific value here; therefore, they are set to zero for
1979 * convenience.*/
1980 trigger.type = GDK_BUTTON_PRESS;
1981 trigger.window = win;
1982 trigger.send_event = FALSE;
1983 trigger.time = GDK_CURRENT_TIME;
1984 trigger.x = 0.0;
1985 trigger.y = 0.0;
1986 trigger.axes = NULL;
1987 trigger.state = 0;
1988 trigger.button = 0;
1989 trigger.device = NULL;
1990 trigger.x_root = 0.0;
1991 trigger.y_root = 0.0;
1992
1993 if (mouse_pos)
1994 gtk_menu_popup_at_pointer(GTK_MENU(menu->submenu_id),
1995 (GdkEvent *)&trigger);
1996 else
1997 {
1998 gint origin_x, origin_y;
1999 GdkRectangle rect = { 0, 0, 0, 0 };
2000
2001 gdk_window_get_origin(win, &origin_x, &origin_y);
2002 popup_menu_position_func(NULL, &rect.x, &rect.y, NULL, NULL);
2003
2004 rect.x -= origin_x;
2005 rect.y -= origin_y;
2006
2007 gtk_menu_popup_at_rect(GTK_MENU(menu->submenu_id),
2008 win,
2009 &rect,
2010 GDK_GRAVITY_SOUTH_EAST,
2011 GDK_GRAVITY_NORTH_WEST,
2012 (GdkEvent *)&trigger);
2013 }
2014 # else
1945 gtk_menu_popup(GTK_MENU(menu->submenu_id), 2015 gtk_menu_popup(GTK_MENU(menu->submenu_id),
1946 NULL, NULL, 2016 NULL, NULL,
1947 &popup_menu_position_func, NULL, 2017 &popup_menu_position_func, NULL,
1948 0U, (guint32)GDK_CURRENT_TIME); 2018 0U, (guint32)GDK_CURRENT_TIME);
2019 # endif
1949 } 2020 }
1950 } 2021 }
1951 2022
1952 #endif /* FEAT_MENU */ 2023 #endif /* FEAT_MENU */
1953 2024