mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-19 00:20:09 +00:00
menu: Update to using GdkEvent API
To some extent, plenty of root coordinate calculations left...
This commit is contained in:
parent
1b6ff9df76
commit
e023367a8a
@ -58,23 +58,23 @@
|
|||||||
* my_popup_handler (GtkWidget *widget, GdkEvent *event)
|
* my_popup_handler (GtkWidget *widget, GdkEvent *event)
|
||||||
* {
|
* {
|
||||||
* GtkMenu *menu;
|
* GtkMenu *menu;
|
||||||
* GdkEventButton *event_button;
|
* guint button;
|
||||||
*
|
*
|
||||||
* g_return_val_if_fail (widget != NULL, FALSE);
|
* g_return_val_if_fail (widget != NULL, FALSE);
|
||||||
* g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
|
* g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
|
||||||
* g_return_val_if_fail (event != NULL, FALSE);
|
* g_return_val_if_fail (event != NULL, FALSE);
|
||||||
*
|
*
|
||||||
* // The "widget" is the menu that was supplied when
|
* // The "widget" is the menu that was supplied when
|
||||||
* // g_signal_connect_swapped() was called.
|
* // g_signal_connect_swapped() was called.
|
||||||
* menu = GTK_MENU (widget);
|
* menu = GTK_MENU (widget);
|
||||||
*
|
*
|
||||||
* if (event->type == GDK_BUTTON_PRESS)
|
* if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
|
||||||
* {
|
* {
|
||||||
* event_button = (GdkEventButton *) event;
|
* gdk_event_get_button (event, &button);
|
||||||
* if (event_button->button == GDK_BUTTON_SECONDARY)
|
* if (button == GDK_BUTTON_SECONDARY)
|
||||||
* {
|
* {
|
||||||
* gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
|
* gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
|
||||||
* event_button->button, event_button->time);
|
* button, gdk_event_get_time (event));
|
||||||
* return TRUE;
|
* return TRUE;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
@ -1127,7 +1127,7 @@ gtk_menu_window_event (GtkWidget *window,
|
|||||||
g_object_ref (window);
|
g_object_ref (window);
|
||||||
g_object_ref (menu);
|
g_object_ref (menu);
|
||||||
|
|
||||||
switch (event->type)
|
switch (gdk_event_get_event_type (event))
|
||||||
{
|
{
|
||||||
case GDK_WINDOW_STATE:
|
case GDK_WINDOW_STATE:
|
||||||
/* Window for the menu has been closed by the display server or by GDK.
|
/* Window for the menu has been closed by the display server or by GDK.
|
||||||
@ -1681,8 +1681,10 @@ gtk_menu_popup_internal (GtkMenu *menu,
|
|||||||
current_event = gtk_get_current_event ();
|
current_event = gtk_get_current_event ();
|
||||||
if (current_event)
|
if (current_event)
|
||||||
{
|
{
|
||||||
if ((current_event->type != GDK_BUTTON_PRESS) &&
|
GdkEventType event_type = gdk_event_get_event_type (current_event);
|
||||||
(current_event->type != GDK_ENTER_NOTIFY))
|
|
||||||
|
if ((event_type != GDK_BUTTON_PRESS) &&
|
||||||
|
(event_type != GDK_ENTER_NOTIFY))
|
||||||
menu_shell->priv->ignore_enter = TRUE;
|
menu_shell->priv->ignore_enter = TRUE;
|
||||||
|
|
||||||
source_device = gdk_event_get_source_device (current_event);
|
source_device = gdk_event_get_source_device (current_event);
|
||||||
@ -3618,7 +3620,7 @@ gtk_menu_captured_event (GtkWidget *widget,
|
|||||||
source_device = gdk_event_get_source_device (event);
|
source_device = gdk_event_get_source_device (event);
|
||||||
gdk_event_get_root_coords (event, &x_root, &y_root);
|
gdk_event_get_root_coords (event, &x_root, &y_root);
|
||||||
|
|
||||||
switch (event->type)
|
switch (gdk_event_get_event_type (event))
|
||||||
{
|
{
|
||||||
case GDK_TOUCH_BEGIN:
|
case GDK_TOUCH_BEGIN:
|
||||||
case GDK_BUTTON_PRESS:
|
case GDK_BUTTON_PRESS:
|
||||||
|
@ -411,8 +411,8 @@ gtk_menu_button_toggled (GtkToggleButton *button)
|
|||||||
popup_menu (menu_button, event);
|
popup_menu (menu_button, event);
|
||||||
|
|
||||||
if (!event ||
|
if (!event ||
|
||||||
event->type == GDK_KEY_PRESS ||
|
gdk_event_get_event_type (event) == GDK_KEY_PRESS ||
|
||||||
event->type == GDK_KEY_RELEASE)
|
gdk_event_get_event_type (event) == GDK_KEY_RELEASE)
|
||||||
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
|
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
|
||||||
|
|
||||||
if (event)
|
if (event)
|
||||||
|
Loading…
Reference in New Issue
Block a user