From 8b2a77122ad262d344fc72faff3e6b41ee649827 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 19 Feb 2014 16:56:43 -0800 Subject: active as a state --- clients/simple-egl.c | 12 ------------ clients/simple-shm.c | 12 ------------ clients/window.c | 19 +++---------------- desktop-shell/shell.c | 29 +++++++++++++++++++++++------ protocol/xdg-shell.xml | 25 +++---------------------- 5 files changed, 29 insertions(+), 68 deletions(-) diff --git a/clients/simple-egl.c b/clients/simple-egl.c index 5c6077da..fa0921c7 100644 --- a/clients/simple-egl.c +++ b/clients/simple-egl.c @@ -302,16 +302,6 @@ handle_surface_change_state(void *data, struct xdg_surface *xdg_surface, xdg_surface_ack_change_state(xdg_surface, serial); } -static void -handle_surface_activated(void *data, struct xdg_surface *xdg_surface) -{ -} - -static void -handle_surface_deactivated(void *data, struct xdg_surface *xdg_surface) -{ -} - static void handle_surface_delete(void *data, struct xdg_surface *xdg_surface) { @@ -321,8 +311,6 @@ handle_surface_delete(void *data, struct xdg_surface *xdg_surface) static const struct xdg_surface_listener xdg_surface_listener = { handle_surface_configure, handle_surface_change_state, - handle_surface_activated, - handle_surface_deactivated, handle_surface_delete, }; diff --git a/clients/simple-shm.c b/clients/simple-shm.c index 02960286..dce3c683 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -127,16 +127,6 @@ handle_change_state(void *data, struct xdg_surface *xdg_surface, { } -static void -handle_activated(void *data, struct xdg_surface *xdg_surface) -{ -} - -static void -handle_deactivated(void *data, struct xdg_surface *xdg_surface) -{ -} - static void handle_delete(void *data, struct xdg_surface *xdg_surface) { @@ -146,8 +136,6 @@ handle_delete(void *data, struct xdg_surface *xdg_surface) static const struct xdg_surface_listener xdg_surface_listener = { handle_configure, handle_change_state, - handle_activated, - handle_deactivated, handle_delete, }; diff --git a/clients/window.c b/clients/window.c index cf76929a..fa2c5ceb 100644 --- a/clients/window.c +++ b/clients/window.c @@ -3856,6 +3856,9 @@ handle_surface_change_state(void *data, struct xdg_surface *xdg_surface, case XDG_SURFACE_STATE_FULLSCREEN: window->fullscreen = value; break; + case XDG_SURFACE_STATE_ACTIVE: + window->focused = value; + break; } if (!window->fullscreen && !window->maximized) @@ -3867,20 +3870,6 @@ handle_surface_change_state(void *data, struct xdg_surface *xdg_surface, window_schedule_redraw(window); } -static void -handle_surface_activated(void *data, struct xdg_surface *xdg_surface) -{ - struct window *window = data; - window->focused = 1; -} - -static void -handle_surface_deactivated(void *data, struct xdg_surface *xdg_surface) -{ - struct window *window = data; - window->focused = 0; -} - static void handle_surface_delete(void *data, struct xdg_surface *xdg_surface) { @@ -3891,8 +3880,6 @@ handle_surface_delete(void *data, struct xdg_surface *xdg_surface) static const struct xdg_surface_listener xdg_surface_listener = { handle_surface_configure, handle_surface_change_state, - handle_surface_activated, - handle_surface_deactivated, handle_surface_delete, }; diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index c764a2c5..92476c21 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1961,17 +1961,29 @@ create_pointer_focus_listener(struct weston_seat *seat) static void shell_surface_lose_keyboard_focus(struct shell_surface *shsurf) { - if (--shsurf->focus_count == 0) - if (shell_surface_is_xdg_surface(shsurf)) - xdg_surface_send_deactivated(shsurf->resource); + struct weston_compositor *compositor = shsurf->shell->compositor; + uint32_t serial; + + if (--shsurf->focus_count == 0 && + shell_surface_is_xdg_surface(shsurf)) { + serial = wl_display_next_serial(compositor->wl_display); + xdg_surface_change_state(shsurf, XDG_SURFACE_STATE_ACTIVE, + 0, serial); + } } static void shell_surface_gain_keyboard_focus(struct shell_surface *shsurf) { - if (shsurf->focus_count++ == 0) - if (shell_surface_is_xdg_surface(shsurf)) - xdg_surface_send_activated(shsurf->resource); + struct weston_compositor *compositor = shsurf->shell->compositor; + uint32_t serial; + + if (shsurf->focus_count++ == 0 && + shell_surface_is_xdg_surface(shsurf)) { + serial = wl_display_next_serial(compositor->wl_display); + xdg_surface_change_state(shsurf, XDG_SURFACE_STATE_ACTIVE, + 1, serial); + } } static void @@ -3297,6 +3309,8 @@ xdg_surface_change_state(struct shell_surface *shsurf, break; case XDG_SURFACE_STATE_RESIZING: break; + case XDG_SURFACE_STATE_ACTIVE: + break; } } @@ -3319,6 +3333,9 @@ xdg_surface_request_change_state(struct wl_client *client, case XDG_SURFACE_STATE_MAXIMIZED: case XDG_SURFACE_STATE_FULLSCREEN: break; + case XDG_SURFACE_STATE_RESIZING: + case XDG_SURFACE_STATE_ACTIVE: + return; default: /* send error? ignore? send change state with value 0? */ return; diff --git a/protocol/xdg-shell.xml b/protocol/xdg-shell.xml index 06496655..dbf7c253 100644 --- a/protocol/xdg-shell.xml +++ b/protocol/xdg-shell.xml @@ -310,6 +310,9 @@ A non-zero value indicates the surface is being resized. + + A non-zero value indicates the surface is active. + @@ -363,28 +366,6 @@ - - - The activated_set event is sent when this surface has been - activated, which means that the surface has user attention. - Window decorations should be updated accordingly. You should - not use this event for anything but the style of decorations - you display, use wl_keyboard.enter and wl_keyboard.leave for - determining keyboard focus. - - - - - - The deactivate event is sent when this surface has been - deactivated, which means that the surface lost user attention. - Window decorations should be updated accordingly. You should - not use this event for anything but the style of decorations - you display, use wl_keyboard.enter and wl_keyboard.leave for - determining keyboard focus. - - - The delete event is sent by the compositor when the user -- cgit v1.2.3