diff options
author | Dima Ryazanov <dima@gmail.com> | 2015-05-18 23:14:16 -0700 |
---|---|---|
committer | Bryce Harrington <bryce@osg.samsung.com> | 2015-05-19 16:42:53 -0700 |
commit | 01d5c02c041818cde5b246b62bf2a3c0b7a6fc1a (patch) | |
tree | 0782556409f29bd33ab1f8de93b496d439913bd7 /src | |
parent | 7dd12ec713c3e5c90999ded787c1ef83031ecda4 (diff) | |
download | weston-01d5c02c041818cde5b246b62bf2a3c0b7a6fc1a.tar.gz weston-01d5c02c041818cde5b246b62bf2a3c0b7a6fc1a.tar.bz2 weston-01d5c02c041818cde5b246b62bf2a3c0b7a6fc1a.zip |
compositor-wayland: Handle window close events more gracefully
When a compositor window is closed, remove the output instead of just exiting.
(The "if (!input->output)" checks are kind of ugly - but I couldn't find
a better way to handle the output going away.)
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/compositor-wayland.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index c9983e01..aaf205ba 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -1307,6 +1307,9 @@ input_handle_pointer_leave(void *data, struct wl_pointer *pointer, { struct wayland_input *input = data; + if (!input->output) + return; + if (input->output->frame) { frame_pointer_leave(input->output->frame, input); @@ -1327,6 +1330,9 @@ input_handle_motion(void *data, struct wl_pointer *pointer, int32_t fx, fy; enum theme_location location; + if (!input->output) + return; + if (input->output->frame) { location = frame_pointer_motion(input->output->frame, input, wl_fixed_to_int(x), @@ -1368,6 +1374,9 @@ input_handle_button(void *data, struct wl_pointer *pointer, enum frame_button_state fstate; enum theme_location location; + if (!input->output) + return; + if (input->output->frame) { fstate = state == WL_POINTER_BUTTON_STATE_PRESSED ? FRAME_BUTTON_PRESSED : FRAME_BUTTON_RELEASED; @@ -1384,8 +1393,15 @@ input_handle_button(void *data, struct wl_pointer *pointer, return; } - if (frame_status(input->output->frame) & FRAME_STATUS_CLOSE) - wl_display_terminate(input->compositor->base.wl_display); + if (frame_status(input->output->frame) & FRAME_STATUS_CLOSE) { + wayland_output_destroy(&input->output->base); + input->output = input->keyboard_focus = NULL; + + if (wl_list_empty(&input->compositor->base.output_list)) + wl_display_terminate(input->compositor->base.wl_display); + + return; + } if (frame_status(input->output->frame) & FRAME_STATUS_REPAINT) weston_output_schedule_repaint(&input->output->base); @@ -1521,7 +1537,7 @@ input_handle_keyboard_leave(void *data, focus = input->keyboard_focus; if (!focus) - return; /* This shouldn't happen */ + return; focus->keyboard_count--; if (!focus->keyboard_count && focus->frame) { |