main: Propagate event handled state up backend

Expose information about if an event is handled to the backends.
This will allow a backend to deal with unhandled events, such as
macOS' default key bindings.
This commit is contained in:
Arjan Molenaar 2024-01-13 12:50:34 +01:00
parent dcebddc908
commit d3666f7b28
6 changed files with 26 additions and 24 deletions

View File

@ -477,18 +477,18 @@ check_event_sanity (GdkEvent *event)
}
#endif
void
gboolean
_gdk_event_emit (GdkEvent *event)
{
#ifdef G_ENABLE_DEBUG
if (!check_event_sanity (event))
return;
return FALSE;
#endif
if (gdk_drag_handle_source_event (event))
return;
return TRUE;
gdk_surface_handle_event (event);
return gdk_surface_handle_event (event);
}
/*********************************************

View File

@ -619,7 +619,7 @@ typedef enum
GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
void _gdk_event_emit (GdkEvent *event);
gboolean _gdk_event_emit (GdkEvent *event);
GList* _gdk_event_queue_find_first (GdkDisplay *display);
void _gdk_event_queue_remove_link (GdkDisplay *display,
GList *node);

View File

@ -1553,7 +1553,7 @@ is_transient_for (GtkWindow *child,
return FALSE;
}
void
gboolean
gtk_main_do_event (GdkEvent *event)
{
GtkWidget *event_widget;
@ -1562,9 +1562,10 @@ gtk_main_do_event (GdkEvent *event)
GtkWindowGroup *window_group;
GdkEvent *rewritten_event = NULL;
GList *tmp_list;
gboolean handled_event = FALSE;
if (gtk_inspector_handle_event (event))
return;
return FALSE;
/* Find the widget which got the event. We store the widget
* in the user_data field of GdkSurface's. Ignore the event
@ -1572,7 +1573,7 @@ gtk_main_do_event (GdkEvent *event)
*/
event_widget = gtk_get_event_widget (event);
if (!event_widget)
return;
return FALSE;
target_widget = event_widget;
@ -1650,6 +1651,7 @@ gtk_main_do_event (GdkEvent *event)
if (GTK_IS_WINDOW (target_widget) &&
!gtk_window_emit_close_request (GTK_WINDOW (target_widget)))
gtk_window_destroy (GTK_WINDOW (target_widget));
handled_event = TRUE;
}
break;
@ -1657,7 +1659,7 @@ gtk_main_do_event (GdkEvent *event)
{
GtkWidget *root = GTK_WIDGET (gtk_widget_get_root (target_widget));
if (!_gtk_widget_captured_event (root, event, root))
gtk_widget_event (root, event, root);
handled_event = gtk_widget_event (root, event, root);
}
break;
@ -1682,7 +1684,7 @@ gtk_main_do_event (GdkEvent *event)
case GDK_PAD_STRIP:
case GDK_PAD_GROUP_MODE:
case GDK_GRAB_BROKEN:
gtk_propagate_event (grab_widget, event);
handled_event = gtk_propagate_event (grab_widget, event);
break;
case GDK_ENTER_NOTIFY:
@ -1690,6 +1692,7 @@ gtk_main_do_event (GdkEvent *event)
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
/* Crossing event propagation happens during picking */
handled_event = TRUE;
break;
case GDK_DRAG_MOTION:
@ -1697,7 +1700,7 @@ gtk_main_do_event (GdkEvent *event)
{
GdkDrop *drop = gdk_dnd_event_get_drop (event);
gtk_drop_begin_event (drop, gdk_event_get_event_type (event));
gtk_propagate_event (grab_widget, event);
handled_event = gtk_propagate_event (grab_widget, event);
gtk_drop_end_event (drop);
}
break;
@ -1719,6 +1722,7 @@ gtk_main_do_event (GdkEvent *event)
if (rewritten_event)
gdk_event_unref (rewritten_event);
return handled_event;
}
static GtkWindowGroup *

View File

@ -93,7 +93,7 @@ gboolean gtk_propagate_event_internal (GtkWidget *widget,
GtkWidget *topmost);
gboolean gtk_propagate_event (GtkWidget *widget,
GdkEvent *event);
void gtk_main_do_event (GdkEvent *event);
gboolean gtk_main_do_event (GdkEvent *event);
GtkWidget *gtk_get_event_widget (GdkEvent *event);

View File

@ -198,8 +198,7 @@ surface_event (GdkSurface *surface,
GdkEvent *event,
GtkWidget *widget)
{
gtk_main_do_event (event);
return TRUE;
return gtk_main_do_event (event);
}
static void

View File

@ -4770,8 +4770,7 @@ surface_event (GdkSurface *surface,
GdkEvent *event,
GtkWidget *widget)
{
gtk_main_do_event (event);
return TRUE;
return gtk_main_do_event (event);
}
static void