compositor-x11: Move the x11 window close to an idle handler

The input loop is actually dispatched in the middle of the frame repaint.
When the X11 event results in closing the compositor, this can cause the
current output to be destroyed just prior to trying to process animations
on it.

We fix this by handling the window close event in an idle callback.

NOTE: this requires a patch for wayland that moves the idle handler
dispatch to after epoll_wait in the event loop processing.

Closes bug: https://bugs.freedesktop.org/show_bug.cgi?id=81314

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
dev
Derek Foreman 10 years ago committed by Bryce Harrington
parent 3e4d4bdd94
commit d540f4bb76
  1. 32
      src/compositor-x11.c

@ -117,6 +117,11 @@ struct x11_output {
int32_t scale; int32_t scale;
}; };
struct window_delete_data {
struct x11_compositor *compositor;
xcb_window_t window;
};
struct gl_renderer_interface *gl_renderer; struct gl_renderer_interface *gl_renderer;
static struct xkb_keymap * static struct xkb_keymap *
@ -941,6 +946,14 @@ x11_compositor_delete_window(struct x11_compositor *c, xcb_window_t window)
wl_display_terminate(c->base.wl_display); wl_display_terminate(c->base.wl_display);
} }
static void delete_cb(void *data)
{
struct window_delete_data *wd = data;
x11_compositor_delete_window(wd->compositor, wd->window);
free(wd);
}
#ifdef HAVE_XCB_XKB #ifdef HAVE_XCB_XKB
static void static void
update_xkb_state(struct x11_compositor *c, xcb_xkb_state_notify_event_t *state) update_xkb_state(struct x11_compositor *c, xcb_xkb_state_notify_event_t *state)
@ -1284,8 +1297,23 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
client_message = (xcb_client_message_event_t *) event; client_message = (xcb_client_message_event_t *) event;
atom = client_message->data.data32[0]; atom = client_message->data.data32[0];
window = client_message->window; window = client_message->window;
if (atom == c->atom.wm_delete_window) if (atom == c->atom.wm_delete_window) {
x11_compositor_delete_window(c, window); struct wl_event_loop *loop;
struct window_delete_data *data = malloc(sizeof *data);
/* if malloc failed we should at least try to
* delete the window, even if it may result in
* a crash.
*/
if (!data) {
x11_compositor_delete_window(c, window);
break;
}
data->compositor = c;
data->window = window;
loop = wl_display_get_event_loop(c->base.wl_display);
wl_event_loop_add_idle(loop, delete_cb, data);
}
break; break;
case XCB_FOCUS_IN: case XCB_FOCUS_IN:

Loading…
Cancel
Save