x11: use event constructors

This is not quite complete and only handles the
simple cases.
This commit is contained in:
Matthias Clasen 2020-02-15 09:33:53 -05:00
parent c9d9ccdb8c
commit 30740f0e2c
2 changed files with 16 additions and 28 deletions

View File

@ -1457,14 +1457,7 @@ _gdk_device_manager_xi2_handle_focus (GdkSurface *surface,
{ {
GdkEvent *event; GdkEvent *event;
event = gdk_event_new (GDK_FOCUS_CHANGE); event = gdk_event_focus_new (surface, device, source_device, focus_in);
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);
gdk_display_put_event (gdk_surface_get_display (surface), event); gdk_display_put_event (gdk_surface_get_display (surface), event);
g_object_unref (event); g_object_unref (event);
} }

View File

@ -115,12 +115,10 @@ handle_focus_change (GdkEventCrossing *event)
{ {
GdkEvent *focus_event; GdkEvent *focus_event;
focus_event = gdk_event_new (GDK_FOCUS_CHANGE); focus_event = gdk_event_focus_new (event->any.surface,
focus_event->any.surface = g_object_ref (event->any.surface); gdk_event_get_device ((GdkEvent *)event),
focus_event->any.send_event = FALSE; gdk_event_get_source_device ((GdkEvent *)event),
focus_event->focus_change.in = focus_in; focus_in);
gdk_event_set_device (focus_event, gdk_event_get_device ((GdkEvent *) event));
gdk_display_put_event (gdk_surface_get_display (event->any.surface), focus_event); gdk_display_put_event (gdk_surface_get_display (event->any.surface), focus_event);
g_object_unref (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); g_assert (evtype == GDK_ENTER_NOTIFY || evtype == GDK_LEAVE_NOTIFY);
event = gdk_event_new (evtype); gdk_event_get_state (real_event, &state);
event->any.send_event = TRUE; gdk_event_get_coords (real_event, &x, &y);
event->any.surface = g_object_ref (real_event->any.surface); event = gdk_event_crossing_new (evtype,
event->crossing.detail = GDK_NOTIFY_ANCESTOR; real_event->any.surface,
event->crossing.mode = mode; gdk_event_get_device (real_event),
event->crossing.time = gdk_event_get_time (real_event); gdk_event_get_source_device (real_event),
gdk_event_set_device (event, gdk_event_get_device (real_event)); gdk_event_get_time (real_event),
gdk_event_set_source_device (event, gdk_event_get_device (real_event)); state,
x, y,
if (gdk_event_get_state (real_event, &state)) mode,
event->crossing.state = state; GDK_NOTIFY_ANCESTOR);
if (gdk_event_get_coords (real_event, &x, &y))
gdk_event_set_coords (event, x, y);
return event; return event;
} }