From 30740f0e2cd43c08e595c8b0a2e5eb310f356804 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 15 Feb 2020 09:33:53 -0500 Subject: [PATCH] x11: use event constructors This is not quite complete and only handles the simple cases. --- gdk/x11/gdkdevicemanager-xi2.c | 9 +-------- gdk/x11/gdkeventsource.c | 35 +++++++++++++++------------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index aecfc04288..4c8a137bb5 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -1457,14 +1457,7 @@ _gdk_device_manager_xi2_handle_focus (GdkSurface *surface, { GdkEvent *event; - event = gdk_event_new (GDK_FOCUS_CHANGE); - event->any.surface = g_object_ref (surface); - event->any.send_event = FALSE; - event->focus_change.in = focus_in; - gdk_event_set_device (event, device); - if (source_device) - gdk_event_set_source_device (event, source_device); - + event = gdk_event_focus_new (surface, device, source_device, focus_in); gdk_display_put_event (gdk_surface_get_display (surface), event); g_object_unref (event); } diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c index 23ab3200b2..d32bd7a033 100644 --- a/gdk/x11/gdkeventsource.c +++ b/gdk/x11/gdkeventsource.c @@ -115,12 +115,10 @@ handle_focus_change (GdkEventCrossing *event) { GdkEvent *focus_event; - focus_event = gdk_event_new (GDK_FOCUS_CHANGE); - focus_event->any.surface = g_object_ref (event->any.surface); - focus_event->any.send_event = FALSE; - focus_event->focus_change.in = focus_in; - gdk_event_set_device (focus_event, gdk_event_get_device ((GdkEvent *) event)); - + focus_event = gdk_event_focus_new (event->any.surface, + gdk_event_get_device ((GdkEvent *)event), + gdk_event_get_source_device ((GdkEvent *)event), + focus_in); gdk_display_put_event (gdk_surface_get_display (event->any.surface), focus_event); g_object_unref (focus_event); } @@ -137,20 +135,17 @@ create_synth_crossing_event (GdkEventType evtype, g_assert (evtype == GDK_ENTER_NOTIFY || evtype == GDK_LEAVE_NOTIFY); - event = gdk_event_new (evtype); - event->any.send_event = TRUE; - event->any.surface = g_object_ref (real_event->any.surface); - event->crossing.detail = GDK_NOTIFY_ANCESTOR; - event->crossing.mode = mode; - event->crossing.time = gdk_event_get_time (real_event); - gdk_event_set_device (event, gdk_event_get_device (real_event)); - gdk_event_set_source_device (event, gdk_event_get_device (real_event)); - - if (gdk_event_get_state (real_event, &state)) - event->crossing.state = state; - - if (gdk_event_get_coords (real_event, &x, &y)) - gdk_event_set_coords (event, x, y); + gdk_event_get_state (real_event, &state); + gdk_event_get_coords (real_event, &x, &y); + event = gdk_event_crossing_new (evtype, + real_event->any.surface, + gdk_event_get_device (real_event), + gdk_event_get_source_device (real_event), + gdk_event_get_time (real_event), + state, + x, y, + mode, + GDK_NOTIFY_ANCESTOR); return event; }