Commit 526486da authored by Carlos Garnacho's avatar Carlos Garnacho

gdk: Use allocated events

Stack allocated GdkEvent structs will not be ok when events become
objects.
parent 33330ad0
...@@ -1869,20 +1869,21 @@ _gdk_set_window_state (GdkWindow *window, ...@@ -1869,20 +1869,21 @@ _gdk_set_window_state (GdkWindow *window,
GdkWindowState new_state) GdkWindowState new_state)
{ {
GdkDisplay *display = gdk_window_get_display (window); GdkDisplay *display = gdk_window_get_display (window);
GdkEvent temp_event; GdkEvent *temp_event;
GdkWindowState old; GdkWindowState old;
GList *pending_event_link; GList *pending_event_link;
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
temp_event.any.window = window; if (new_state == window->state)
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)
return; /* No actual work to do, nothing changed. */ 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); pending_event_link = gdk_get_pending_window_state_event_link (window);
if (pending_event_link) if (pending_event_link)
{ {
...@@ -1897,7 +1898,7 @@ _gdk_set_window_state (GdkWindow *window, ...@@ -1897,7 +1898,7 @@ _gdk_set_window_state (GdkWindow *window,
window->old_state = old; 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 /* 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 * place to do it, but seems like the safest since it ensures we expose no
...@@ -1906,7 +1907,7 @@ _gdk_set_window_state (GdkWindow *window, ...@@ -1906,7 +1907,7 @@ _gdk_set_window_state (GdkWindow *window,
window->state = new_state; 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); _gdk_window_update_viewable (window);
/* We only really send the event to toplevels, since /* We only really send the event to toplevels, since
...@@ -1918,7 +1919,7 @@ _gdk_set_window_state (GdkWindow *window, ...@@ -1918,7 +1919,7 @@ _gdk_set_window_state (GdkWindow *window,
{ {
case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_TEMP: /* ? */ case GDK_WINDOW_TEMP: /* ? */
gdk_display_put_event (display, &temp_event); gdk_display_put_event (display, temp_event);
break; break;
case GDK_WINDOW_FOREIGN: case GDK_WINDOW_FOREIGN:
case GDK_WINDOW_ROOT: case GDK_WINDOW_ROOT:
...@@ -1926,6 +1927,8 @@ _gdk_set_window_state (GdkWindow *window, ...@@ -1926,6 +1927,8 @@ _gdk_set_window_state (GdkWindow *window,
default: default:
break; break;
} }
gdk_event_free (temp_event);
} }
void void
......
...@@ -2525,7 +2525,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window, ...@@ -2525,7 +2525,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
cairo_region_t *expose_region) cairo_region_t *expose_region)
{ {
cairo_region_t *clipped_expose_region; cairo_region_t *clipped_expose_region;
GdkEvent event; GdkEvent *event;
if (window->destroyed) if (window->destroyed)
return; return;
...@@ -2539,14 +2539,15 @@ _gdk_window_process_updates_recurse (GdkWindow *window, ...@@ -2539,14 +2539,15 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
/* Paint the window before the children, clipped to the window region */ /* Paint the window before the children, clipped to the window region */
event.any.type = GDK_EXPOSE; event = gdk_event_new (GDK_EXPOSE);
event.any.window = window; /* we already hold a ref */ event->any.window = g_object_ref (window);
event.any.send_event = FALSE; event->any.send_event = FALSE;
event.expose.count = 0; event->expose.count = 0;
event.expose.region = clipped_expose_region; event->expose.region = cairo_region_reference (clipped_expose_region);
cairo_region_get_extents (clipped_expose_region, &event.expose.area); cairo_region_get_extents (clipped_expose_region, &event->expose.area);
_gdk_event_emit (&event); _gdk_event_emit (event);
gdk_event_free (event);
out: out:
cairo_region_destroy (clipped_expose_region); cairo_region_destroy (clipped_expose_region);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment