From 0badc0522b1d08fddf9676883d37da06a264db28 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 4 Oct 2017 12:12:55 -0500 Subject: [PATCH] ecore_wl2: Split configurations into client set and compositor requested This should lead to clearer and more maintainable code than having one pile of state that's asynchronously fiddled with by both client and compositor. --- src/lib/ecore_wl2/ecore_wl2_display.c | 3 +- src/lib/ecore_wl2/ecore_wl2_private.h | 3 +- src/lib/ecore_wl2/ecore_wl2_window.c | 138 ++++++++++----------- .../engines/wayland/ecore_evas_wayland_common.c | 30 ++--- 4 files changed, 89 insertions(+), 85 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index dca7b68..365658c 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -471,7 +471,8 @@ _recovery_timer_add(Ecore_Wl2_Display *ewd) EINA_INLIST_FOREACH_SAFE(window->subsurfs, tmp2, subsurf) _ecore_wl2_subsurf_unmap(subsurf); _ecore_wl2_window_semi_free(window); - window->config.serial = 0; + window->set_config.serial = 0; + window->req_config.serial = 0; window->zxdg_configure_ack = NULL; window->zxdg_set_min_size = NULL; window->zxdg_set_max_size = NULL; diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index d89fb9c..743c05b 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -202,7 +202,8 @@ struct _Ecore_Wl2_Window Eina_List *supported_aux_hints; Eina_List *frame_callbacks; - Ecore_Wl2_Window_Configure_State config; + Ecore_Wl2_Window_Configure_State set_config; + Ecore_Wl2_Window_Configure_State req_config; Eina_Bool moving : 1; Eina_Bool alpha : 1; diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index dc032e6..ed9732d 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -99,7 +99,7 @@ _zxdg_surface_cb_configure(void *data, struct zxdg_surface_v6 *zxdg_surface EINA Ecore_Wl2_Window *window; window = data; - window->config.serial = serial; + window->req_config.serial = serial; if (!window->pending.configure) return; _configure_complete(window); @@ -117,52 +117,49 @@ _zxdg_toplevel_cb_configure(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel E uint32_t *s; Eina_Bool fs, max; - if ((!win->config.maximized) && (!win->config.fullscreen)) - win->saved = win->config.geometry; + fs = win->req_config.fullscreen; + max = win->req_config.maximized; - fs = win->config.fullscreen; - max = win->config.maximized; - - win->config.minimized = EINA_FALSE; - win->config.maximized = EINA_FALSE; - win->config.fullscreen = EINA_FALSE; - win->config.focused = EINA_FALSE; - win->config.resizing = EINA_FALSE; + win->req_config.minimized = EINA_FALSE; + win->req_config.maximized = EINA_FALSE; + win->req_config.fullscreen = EINA_FALSE; + win->req_config.focused = EINA_FALSE; + win->req_config.resizing = EINA_FALSE; wl_array_for_each(s, states) { switch (*s) { case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED: - win->config.maximized = EINA_TRUE; + win->req_config.maximized = EINA_TRUE; break; case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN: - win->config.fullscreen = EINA_TRUE; + win->req_config.fullscreen = EINA_TRUE; break; case ZXDG_TOPLEVEL_V6_STATE_RESIZING: - win->config.resizing = EINA_TRUE; + win->req_config.resizing = EINA_TRUE; break; case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED: - win->config.focused = EINA_TRUE; - win->config.minimized = EINA_FALSE; + win->req_config.focused = EINA_TRUE; + win->req_config.minimized = EINA_FALSE; default: break; } } - if ((win->config.geometry.w == width) && - (win->config.geometry.h == height)) + if ((win->set_config.geometry.w == width) && + (win->set_config.geometry.h == height)) width = height = 0; - else if ((!width) && (!height) && (!win->config.fullscreen) && - (!win->config.maximized) && - ((win->config.fullscreen != fs) || - (win->config.maximized != max))) + else if ((!width) && (!height) && (!win->req_config.fullscreen) && + (!win->req_config.maximized) && + ((win->req_config.fullscreen != fs) || + (win->req_config.maximized != max))) width = win->saved.w, height = win->saved.h; - _ecore_wl2_window_configure_send(win, width, height, !!win->config.resizing, - win->config.fullscreen, win->config.maximized); + _ecore_wl2_window_configure_send(win, width, height, !!win->req_config.resizing, + win->req_config.fullscreen, win->req_config.maximized); - if (win->config.focused) + if (win->req_config.focused) _ecore_wl2_window_activate_send(win); else _ecore_wl2_window_deactivate_send(win); @@ -217,9 +214,11 @@ _ecore_wl2_window_zxdg_popup_create(Ecore_Wl2_Window *win) pos = zxdg_shell_v6_create_positioner(win->display->wl.zxdg_shell); if (!pos) return; - zxdg_positioner_v6_set_anchor_rect(pos, win->config.geometry.x, win->config.geometry.y, + zxdg_positioner_v6_set_anchor_rect(pos, win->set_config.geometry.x, + win->set_config.geometry.y, 1, 1); - zxdg_positioner_v6_set_size(pos, win->config.geometry.w, win->config.geometry.h); + zxdg_positioner_v6_set_size(pos, win->set_config.geometry.w, + win->set_config.geometry.h); zxdg_positioner_v6_set_anchor(pos, ZXDG_POSITIONER_V6_ANCHOR_TOP | ZXDG_POSITIONER_V6_ANCHOR_LEFT); zxdg_positioner_v6_set_gravity(pos, ZXDG_POSITIONER_V6_ANCHOR_BOTTOM | @@ -345,10 +344,10 @@ _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window) if (ptop) zxdg_toplevel_v6_set_parent(window->zxdg_toplevel, ptop); - if (window->config.maximized) + if (window->set_config.maximized) zxdg_toplevel_v6_set_maximized(window->zxdg_toplevel); - if (window->config.fullscreen) + if (window->set_config.fullscreen) zxdg_toplevel_v6_set_fullscreen(window->zxdg_toplevel, NULL); if (window->aspect.set && window->display->wl.efl_hints) efl_hints_set_aspect(window->display->wl.efl_hints, window->zxdg_toplevel, @@ -366,10 +365,10 @@ _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window) window->surface, window->uuid); if (window->zxdg_surface) zxdg_surface_v6_set_window_geometry(window->zxdg_surface, - window->config.geometry.x, - window->config.geometry.y, - window->config.geometry.w, - window->config.geometry.h); + window->set_config.geometry.x, + window->set_config.geometry.y, + window->set_config.geometry.w, + window->set_config.geometry.h); ecore_wl2_window_opaque_region_set(window, window->opaque.x, @@ -457,10 +456,10 @@ ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x win->parent = parent; win->id = _win_id++; - win->config.geometry.x = x; - win->config.geometry.y = y; - win->config.geometry.w = w; - win->config.geometry.h = h; + win->set_config.geometry.x = x; + win->set_config.geometry.y = y; + win->set_config.geometry.w = w; + win->set_config.geometry.h = h; win->opaque.x = x; win->opaque.y = y; @@ -554,7 +553,8 @@ ecore_wl2_window_hide(Ecore_Wl2_Window *window) window->callback = NULL; } - window->config.serial = 0; + window->set_config.serial = 0; + window->req_config.serial = 0; window->zxdg_configure_ack = NULL; window->zxdg_set_min_size = NULL; window->zxdg_set_max_size = NULL; @@ -655,8 +655,8 @@ ecore_wl2_window_raise(Ecore_Wl2_Window *window) s = wl_array_add(&states, sizeof(*s)); *s = ZXDG_TOPLEVEL_V6_STATE_ACTIVATED; _zxdg_toplevel_cb_configure(window, window->zxdg_toplevel, - window->config.geometry.w, - window->config.geometry.h, &states); + window->set_config.geometry.w, + window->set_config.geometry.h, &states); wl_array_release(&states); } } @@ -849,7 +849,7 @@ ecore_wl2_window_maximized_get(Ecore_Wl2_Window *window) { EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE); - return window->config.maximized; + return window->set_config.maximized; } EAPI void @@ -859,16 +859,15 @@ ecore_wl2_window_maximized_set(Ecore_Wl2_Window *window, Eina_Bool maximized) EINA_SAFETY_ON_NULL_RETURN(window); - prev = window->config.maximized; + prev = window->set_config.maximized; maximized = !!maximized; if (prev == maximized) return; - if (!ecore_wl2_window_shell_surface_exists(window)) - window->config.maximized = maximized; + window->set_config.maximized = maximized; if (maximized) { - window->saved = window->config.geometry; + window->saved = window->set_config.geometry; if (window->zxdg_toplevel) zxdg_toplevel_v6_set_maximized(window->zxdg_toplevel); @@ -885,7 +884,7 @@ ecore_wl2_window_fullscreen_get(Ecore_Wl2_Window *window) { EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE); - return window->config.fullscreen; + return window->set_config.fullscreen; } EAPI void @@ -895,16 +894,15 @@ ecore_wl2_window_fullscreen_set(Ecore_Wl2_Window *window, Eina_Bool fullscreen) EINA_SAFETY_ON_NULL_RETURN(window); - prev = window->config.fullscreen; + prev = window->set_config.fullscreen; fullscreen = !!fullscreen; if (prev == fullscreen) return; - if (!ecore_wl2_window_shell_surface_exists(window)) - window->config.fullscreen = fullscreen; + window->set_config.fullscreen = fullscreen; if (fullscreen) { - window->saved = window->config.geometry; + window->saved = window->set_config.geometry; if (window->zxdg_toplevel) zxdg_toplevel_v6_set_fullscreen(window->zxdg_toplevel, NULL); @@ -961,10 +959,10 @@ ecore_wl2_window_geometry_get(Ecore_Wl2_Window *window, int *x, int *y, int *w, { EINA_SAFETY_ON_NULL_RETURN(window); - if (x) *x = window->config.geometry.x; - if (y) *y = window->config.geometry.y; - if (w) *w = window->config.geometry.w; - if (h) *h = window->config.geometry.h; + if (x) *x = window->set_config.geometry.x; + if (y) *y = window->set_config.geometry.y; + if (w) *w = window->set_config.geometry.w; + if (h) *h = window->set_config.geometry.h; } EAPI void @@ -972,14 +970,16 @@ ecore_wl2_window_geometry_set(Ecore_Wl2_Window *window, int x, int y, int w, int { EINA_SAFETY_ON_NULL_RETURN(window); - if ((window->config.geometry.x == x) && (window->config.geometry.y == y) && - (window->config.geometry.w == w) && (window->config.geometry.h == h)) + if ((window->set_config.geometry.x == x) && + (window->set_config.geometry.y == y) && + (window->set_config.geometry.w == w) && + (window->set_config.geometry.h == h)) return; - window->config.geometry.x = x; - window->config.geometry.y = y; - window->config.geometry.w = w; - window->config.geometry.h = h; + window->set_config.geometry.x = x; + window->set_config.geometry.y = y; + window->set_config.geometry.w = w; + window->set_config.geometry.h = h; if (window->zxdg_toplevel) zxdg_surface_v6_set_window_geometry(window->zxdg_surface, x, y, w, h); @@ -990,7 +990,7 @@ ecore_wl2_window_iconified_get(Ecore_Wl2_Window *window) { EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE); - return window->config.minimized; + return window->set_config.minimized; } EAPI void @@ -1000,11 +1000,11 @@ ecore_wl2_window_iconified_set(Ecore_Wl2_Window *window, Eina_Bool iconified) EINA_SAFETY_ON_NULL_RETURN(window); - prev = window->config.minimized; + prev = window->set_config.minimized; iconified = !!iconified; if (prev == iconified) return; - window->config.minimized = iconified; + window->set_config.minimized = iconified; if (iconified) { @@ -1022,8 +1022,8 @@ ecore_wl2_window_iconified_set(Ecore_Wl2_Window *window, Eina_Bool iconified) s = wl_array_add(&states, sizeof(*s)); *s = ZXDG_TOPLEVEL_V6_STATE_ACTIVATED; _zxdg_toplevel_cb_configure(window, window->zxdg_toplevel, - window->config.geometry.w, - window->config.geometry.h, &states); + window->set_config.geometry.w, + window->set_config.geometry.h, &states); wl_array_release(&states); } } @@ -1063,7 +1063,7 @@ EAPI Eina_Bool ecore_wl2_window_activated_get(const Ecore_Wl2_Window *window) { EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE); - return window->config.focused; + return window->req_config.focused; } EAPI Ecore_Wl2_Output * @@ -1075,8 +1075,8 @@ ecore_wl2_window_output_find(Ecore_Wl2_Window *window) EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL); - x = window->config.geometry.x; - y = window->config.geometry.y; + x = window->set_config.geometry.x; + y = window->set_config.geometry.y; EINA_INLIST_FOREACH_SAFE(window->display->outputs, tmp, out) { @@ -1466,5 +1466,5 @@ ecore_wl2_window_resizing_get(Ecore_Wl2_Window *window) { EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE); - return window->config.resizing; + return window->req_config.resizing; } diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c index 6326904..e2e6cec 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c @@ -508,8 +508,8 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_ nw = ev->w; nh = ev->h; - pfw = fw = wdata->win->config.geometry.w - wdata->content.w; - pfh = fh = wdata->win->config.geometry.h - wdata->content.h; + pfw = fw = wdata->win->set_config.geometry.w - wdata->content.w; + pfh = fh = wdata->win->set_config.geometry.h - wdata->content.h; if ((prev_max != ee->prop.maximized) || (prev_full != ee->prop.fullscreen) || @@ -517,19 +517,20 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_ { state_change = EINA_TRUE; _ecore_evas_wl_common_state_update(ee); - fw = wdata->win->config.geometry.w - wdata->content.w; - fh = wdata->win->config.geometry.h - wdata->content.h; + fw = wdata->win->set_config.geometry.w - wdata->content.w; + fh = wdata->win->set_config.geometry.h - wdata->content.h; } if ((!nw) && (!nh)) { - if (wdata->win->config.serial && wdata->win->surface && + if ((wdata->win->set_config.serial != wdata->win->req_config.serial) && + wdata->win->req_config.serial && wdata->win->surface && ((!state_change) || ((pfw == fw) && (pfh == fh)))) { if (wdata->win->zxdg_configure_ack) wdata->win->zxdg_configure_ack(wdata->win->zxdg_surface, - wdata->win->config.serial); - wdata->win->config.serial = 0; + wdata->win->req_config.serial); + wdata->win->set_config.serial = wdata->win->req_config.serial; } return ECORE_CALLBACK_RENEW; } @@ -1709,18 +1710,19 @@ _ecore_evas_wl_common_render_flush_pre(void *data, Evas *evas, void *event EINA_ if (!ecore_wl2_window_shell_surface_exists(wdata->win)) return; - if (wdata->win->zxdg_configure_ack && wdata->win->config.serial) + if (wdata->win->zxdg_configure_ack && wdata->win->req_config.serial && + (wdata->win->req_config.serial != wdata->win->set_config.serial)) wdata->win->zxdg_configure_ack(wdata->win->zxdg_surface, - wdata->win->config.serial); - wdata->win->config.serial = 0; + wdata->win->req_config.serial); + wdata->win->set_config.serial = wdata->win->req_config.serial; /* Surviving bits of WWW - track interesting state we might want * to pass to clients to do client side effects */ - einfo->window.x = wdata->win->config.geometry.x; - einfo->window.y = wdata->win->config.geometry.y; - einfo->window.w = wdata->win->config.geometry.w; - einfo->window.h = wdata->win->config.geometry.h; + einfo->window.x = wdata->win->set_config.geometry.x; + einfo->window.y = wdata->win->set_config.geometry.y; + einfo->window.w = wdata->win->set_config.geometry.w; + einfo->window.h = wdata->win->set_config.geometry.h; if (einfo->resizing) { einfo->x_rel = 0; -- 2.7.4