xdg-shell: Add a "delete" event
This is equivalent to WM_DELETE_WINDOW request under X11, or equivalent to pressing the "close" button under CSD. Weston currently doesn't have a compositor-side way to close the window, so no new code is needed on its side.
This commit is contained in:
committed by
Kristian Høgsberg
parent
e5b4dce642
commit
2097fe12d4
+20
-12
@@ -1363,6 +1363,15 @@ window_has_focus(struct window *window)
|
|||||||
return window->focused;
|
return window->focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
window_close(struct window *window)
|
||||||
|
{
|
||||||
|
if (window->close_handler)
|
||||||
|
window->close_handler(window->user_data);
|
||||||
|
else
|
||||||
|
display_exit(window->display);
|
||||||
|
}
|
||||||
|
|
||||||
struct display *
|
struct display *
|
||||||
window_get_display(struct window *window)
|
window_get_display(struct window *window)
|
||||||
{
|
{
|
||||||
@@ -2261,10 +2270,7 @@ frame_menu_func(struct window *window,
|
|||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: /* close */
|
case 0: /* close */
|
||||||
if (window->close_handler)
|
window_close(window);
|
||||||
window->close_handler(window->user_data);
|
|
||||||
else
|
|
||||||
display_exit(window->display);
|
|
||||||
break;
|
break;
|
||||||
case 1: /* move to workspace above */
|
case 1: /* move to workspace above */
|
||||||
display = window->display;
|
display = window->display;
|
||||||
@@ -2378,10 +2384,7 @@ frame_handle_status(struct window_frame *frame, struct input *input,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status & FRAME_STATUS_CLOSE) {
|
if (status & FRAME_STATUS_CLOSE) {
|
||||||
if (window->close_handler)
|
window_close(window);
|
||||||
window->close_handler(window->user_data);
|
|
||||||
else
|
|
||||||
display_exit(window->display);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2909,10 +2912,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
|||||||
} else if (sym == XKB_KEY_F4 &&
|
} else if (sym == XKB_KEY_F4 &&
|
||||||
input->modifiers == MOD_ALT_MASK &&
|
input->modifiers == MOD_ALT_MASK &&
|
||||||
state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||||
if (window->close_handler)
|
window_close(window);
|
||||||
window->close_handler(window->user_data);
|
|
||||||
else
|
|
||||||
display_exit(window->display);
|
|
||||||
} else if (window->key_handler) {
|
} else if (window->key_handler) {
|
||||||
(*window->key_handler)(window, input, time, key,
|
(*window->key_handler)(window, input, time, key,
|
||||||
sym, state, window->user_data);
|
sym, state, window->user_data);
|
||||||
@@ -3902,6 +3902,13 @@ handle_surface_request_unset_fullscreen(void *data, struct xdg_surface *xdg_surf
|
|||||||
window_set_fullscreen(window, 0);
|
window_set_fullscreen(window, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_surface_delete(void *data, struct xdg_surface *xdg_surface)
|
||||||
|
{
|
||||||
|
struct window *window = data;
|
||||||
|
window_close(window);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct xdg_surface_listener xdg_surface_listener = {
|
static const struct xdg_surface_listener xdg_surface_listener = {
|
||||||
handle_surface_ping,
|
handle_surface_ping,
|
||||||
handle_surface_configure,
|
handle_surface_configure,
|
||||||
@@ -3911,6 +3918,7 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
|||||||
handle_surface_request_unset_fullscreen,
|
handle_surface_request_unset_fullscreen,
|
||||||
handle_surface_focused_set,
|
handle_surface_focused_set,
|
||||||
handle_surface_focused_unset,
|
handle_surface_focused_unset,
|
||||||
|
handle_surface_delete,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -373,6 +373,19 @@
|
|||||||
decorations should be updated accordingly.
|
decorations should be updated accordingly.
|
||||||
</description>
|
</description>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
<event name="delete">
|
||||||
|
<description summary="surface wants to be closed">
|
||||||
|
The delete event is sent by the compositor when the user
|
||||||
|
wants the surface to be closed. This should be equivalent to
|
||||||
|
the user clicking the close button in client-side decorations,
|
||||||
|
if your application has any...
|
||||||
|
|
||||||
|
This is only a request that the user intends to close your
|
||||||
|
window. The client may choose to ignore this request, or show
|
||||||
|
a dialog to ask the user to save their data...
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<interface name="xdg_popup" version="1">
|
<interface name="xdg_popup" version="1">
|
||||||
|
|||||||
Reference in New Issue
Block a user