From 640caf1d9c7510064c78ced9021c55611a6e66b0 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 27 Jun 2017 09:41:03 -0400 Subject: [PATCH] ecore-wl2: Add client-side event for Window Activate This patch adds and sends a client-side event when a window gets activated. '#divergence' @feature Signed-off-by: Chris Michael --- src/lib/ecore_wl2/Ecore_Wl2.h | 8 ++++++++ src/lib/ecore_wl2/ecore_wl2.c | 5 ++++- src/lib/ecore_wl2/ecore_wl2_window.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 5dac3d1..ccc4814 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -302,6 +302,13 @@ typedef struct _Ecore_Wl2_Event_Window_Hide unsigned int event_win; } Ecore_Wl2_Event_Window_Hide; +typedef struct _Ecore_Wl2_Event_Window_Activate +{ + unsigned int win; + unsigned int parent_win; + unsigned int event_win; +} Ecore_Wl2_Event_Window_Activate; + typedef enum _Ecore_Wl2_Window_Type { ECORE_WL2_WINDOW_TYPE_NONE, @@ -357,6 +364,7 @@ EAPI extern int ECORE_WL2_EVENT_WINDOW_ROTATION_CHANGE_DONE; /** @since 1.20 */ EAPI extern int ECORE_WL2_EVENT_AUX_HINT_ALLOWED; /** @since 1.20 */ EAPI extern int ECORE_WL2_EVENT_WINDOW_SHOW; /** @since 1.20 */ EAPI extern int ECORE_WL2_EVENT_WINDOW_HIDE; /** @since 1.20 */ +EAPI extern int ECORE_WL2_EVENT_WINDOW_ACTIVATE; /** @since 1.20 */ /** * @file diff --git a/src/lib/ecore_wl2/ecore_wl2.c b/src/lib/ecore_wl2/ecore_wl2.c index 767b5c1..4cecffa 100644 --- a/src/lib/ecore_wl2/ecore_wl2.c +++ b/src/lib/ecore_wl2/ecore_wl2.c @@ -48,6 +48,7 @@ EAPI int ECORE_WL2_EVENT_WINDOW_ROTATION_CHANGE_DONE = 0; EAPI int ECORE_WL2_EVENT_AUX_HINT_ALLOWED = 0; EAPI int ECORE_WL2_EVENT_WINDOW_SHOW = 0; EAPI int ECORE_WL2_EVENT_WINDOW_HIDE = 0; +EAPI int ECORE_WL2_EVENT_WINDOW_ACTIVATE = 0; EAPI int _ecore_wl2_event_window_www = -1; EAPI int _ecore_wl2_event_window_www_drag = -1; @@ -126,6 +127,7 @@ ecore_wl2_init(void) ECORE_WL2_EVENT_AUX_HINT_ALLOWED = ecore_event_type_new(); ECORE_WL2_EVENT_WINDOW_SHOW = ecore_event_type_new(); ECORE_WL2_EVENT_WINDOW_HIDE = ecore_event_type_new(); + ECORE_WL2_EVENT_WINDOW_ACTIVATE = ecore_event_type_new(); } if (!no_session_recovery) no_session_recovery = !!getenv("EFL_NO_WAYLAND_SESSION_RECOVERY"); @@ -191,7 +193,8 @@ ecore_wl2_shutdown(void) ECORE_WL2_EVENT_WINDOW_ROTATION_CHANGE_DONE, ECORE_WL2_EVENT_AUX_HINT_ALLOWED, ECORE_WL2_EVENT_WINDOW_SHOW, - ECORE_WL2_EVENT_WINDOW_HIDE); + ECORE_WL2_EVENT_WINDOW_HIDE, + ECORE_WL2_EVENT_WINDOW_ACTIVATE); /* shutdown Ecore_Event */ ecore_event_shutdown(); diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index 86a3315..d6180c7 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -54,6 +54,21 @@ _ecore_wl2_window_configure_send(Ecore_Wl2_Window *window, int w, int h, unsigne } static void +_ecore_wl2_window_activate_send(Ecore_Wl2_Window *window) +{ + Ecore_Wl2_Event_Window_Activate *ev; + + ev = calloc(1, sizeof(Ecore_Wl2_Event_Window_Activate)); + if (!ev) return; + + ev->win = window->id; + if (window->parent) + ev->parent_win = window->parent->id; + ev->event_win = window->id; + ecore_event_add(ECORE_WL2_EVENT_WINDOW_ACTIVATE, ev, NULL, NULL); +} + +static void _xdg_popup_cb_done(void *data, struct xdg_popup *xdg_popup EINA_UNUSED) { Ecore_Wl2_Window *win; @@ -118,6 +133,9 @@ _xdg_surface_cb_configure(void *data, struct xdg_surface *xdg_surface EINA_UNUSE _ecore_wl2_window_configure_send(win, w, h, !!win->resizing, win->fullscreen, win->maximized); + + if (win->focused) + _ecore_wl2_window_activate_send(win); } static void @@ -208,6 +226,9 @@ _zxdg_toplevel_cb_configure(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel E _ecore_wl2_window_configure_send(win, width, height, !!win->resizing, win->fullscreen, win->maximized); + + if (win->focused) + _ecore_wl2_window_activate_send(win); } static void -- 2.7.4