[gtk+/wip/carlosg/event-as-object: 5/23] gdk: Use allocated events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-as-object: 5/23] gdk: Use allocated events
- Date: Tue, 31 Oct 2017 16:02:33 +0000 (UTC)
commit 27ad37fc5c009ef8141638d21676940bb94e0534
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Oct 25 12:29:43 2017 +0200
gdk: Use allocated events
Stack allocated GdkEvent structs will not be ok when events become
objects.
gdk/gdkevents.c | 23 +++++++++++++----------
gdk/gdkwindow.c | 17 +++++++++--------
2 files changed, 22 insertions(+), 18 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 902bfe0..98d54ed 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -2062,20 +2062,21 @@ _gdk_set_window_state (GdkWindow *window,
GdkWindowState new_state)
{
GdkDisplay *display = gdk_window_get_display (window);
- GdkEvent temp_event;
+ GdkEvent *temp_event;
GdkWindowState old;
GList *pending_event_link;
g_return_if_fail (window != NULL);
- temp_event.any.window = window;
- temp_event.any.type = GDK_WINDOW_STATE;
- temp_event.any.send_event = FALSE;
- temp_event.window_state.new_window_state = new_state;
-
- if (temp_event.window_state.new_window_state == window->state)
+ if (new_state == window->state)
return; /* No actual work to do, nothing changed. */
+ temp_event = gdk_event_new (GDK_WINDOW_STATE);
+
+ temp_event->any.window = g_object_ref (window);
+ temp_event->any.send_event = FALSE;
+ temp_event->window_state.new_window_state = new_state;
+
pending_event_link = gdk_get_pending_window_state_event_link (window);
if (pending_event_link)
{
@@ -2090,7 +2091,7 @@ _gdk_set_window_state (GdkWindow *window,
window->old_state = old;
}
- temp_event.window_state.changed_mask = new_state ^ old;
+ temp_event->window_state.changed_mask = new_state ^ old;
/* Actually update the field in GdkWindow, this is sort of an odd
* place to do it, but seems like the safest since it ensures we expose no
@@ -2099,7 +2100,7 @@ _gdk_set_window_state (GdkWindow *window,
window->state = new_state;
- if (temp_event.window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN)
+ if (temp_event->window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN)
_gdk_window_update_viewable (window);
/* We only really send the event to toplevels, since
@@ -2111,7 +2112,7 @@ _gdk_set_window_state (GdkWindow *window,
{
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_TEMP: /* ? */
- gdk_display_put_event (display, &temp_event);
+ gdk_display_put_event (display, temp_event);
break;
case GDK_WINDOW_FOREIGN:
case GDK_WINDOW_ROOT:
@@ -2119,6 +2120,8 @@ _gdk_set_window_state (GdkWindow *window,
default:
break;
}
+
+ gdk_event_free (temp_event);
}
void
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 295c4a6..2818ab9 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2719,7 +2719,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
cairo_region_t *expose_region)
{
cairo_region_t *clipped_expose_region;
- GdkEvent event;
+ GdkEvent *event;
if (window->destroyed)
return;
@@ -2733,14 +2733,15 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
/* Paint the window before the children, clipped to the window region */
- event.any.type = GDK_EXPOSE;
- event.any.window = window; /* we already hold a ref */
- event.any.send_event = FALSE;
- event.expose.count = 0;
- event.expose.region = clipped_expose_region;
- cairo_region_get_extents (clipped_expose_region, &event.expose.area);
+ event = gdk_event_new (GDK_EXPOSE);
+ event->any.window = g_object_ref (window);
+ event->any.send_event = FALSE;
+ event->expose.count = 0;
+ event->expose.region = cairo_region_reference (clipped_expose_region);
+ cairo_region_get_extents (clipped_expose_region, &event->expose.area);
- _gdk_event_emit (&event);
+ _gdk_event_emit (event);
+ gdk_event_free (event);
out:
cairo_region_destroy (clipped_expose_region);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]