From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/winewayland.drv/wayland_surface.c | 33 ++++++++++--------- dlls/winewayland.drv/waylanddrv.h | 30 ++++++++++-------- dlls/winewayland.drv/window.c | 44 +++++++++++++------------- 3 files changed, 57 insertions(+), 50 deletions(-) diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index f51fcd97142..7ccdf2998d9 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -83,43 +83,46 @@ static void xdg_toplevel_handle_configure(void *private, int32_t width, int32_t height, struct wl_array *states) { + RECT rect; + enum surface_state config_state = 0; struct wayland_surface *surface; HWND hwnd = private; uint32_t *state; - enum wayland_surface_config_state config_state = 0; struct wayland_win_data *data; + SetRect(&rect, 0, 0, width, height); + wl_array_for_each(state, states) { switch(*state) { case XDG_TOPLEVEL_STATE_MAXIMIZED: - config_state |= WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED; + config_state |= SURFACE_STATE_MAXIMIZED; break; case XDG_TOPLEVEL_STATE_RESIZING: - config_state |= WAYLAND_SURFACE_CONFIG_STATE_RESIZING; + config_state |= SURFACE_STATE_RESIZING; break; case XDG_TOPLEVEL_STATE_TILED_LEFT: case XDG_TOPLEVEL_STATE_TILED_RIGHT: case XDG_TOPLEVEL_STATE_TILED_TOP: case XDG_TOPLEVEL_STATE_TILED_BOTTOM: - config_state |= WAYLAND_SURFACE_CONFIG_STATE_TILED; + config_state |= SURFACE_STATE_TILED; break; case XDG_TOPLEVEL_STATE_FULLSCREEN: - config_state |= WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN; + config_state |= SURFACE_STATE_FULLSCREEN; break; default: break; } } - TRACE("hwnd=%p %dx%d,%#x\n", hwnd, width, height, config_state); + TRACE("hwnd=%p rect=%s state=%#x\n", hwnd, wine_dbgstr_rect(&rect), config_state); if (!(data = wayland_win_data_get(hwnd))) return; if ((surface = data->wayland_surface) && wayland_surface_is_toplevel(surface)) { - SetRect(&surface->pending.rect, 0, 0, width, height); + surface->pending.rect = rect; surface->pending.state = config_state; } @@ -559,7 +562,7 @@ static BOOL is_rect_smaller(RECT a, RECT b) * Checks whether a wayland_surface_config object is compatible with the * the provided arguments. */ -BOOL wayland_surface_config_is_compatible(struct wayland_surface *surface, struct wayland_surface_config *conf) +BOOL wayland_surface_config_is_compatible(struct wayland_surface *surface, struct surface_config *conf) { RECT rect = map_rect_to_surface(surface, surface->window.rect); @@ -568,16 +571,16 @@ BOOL wayland_surface_config_is_compatible(struct wayland_surface *surface, struc * surface reconfiguration to provide the smaller size, so we are always * compatible with a fullscreen state. * NOTE: Fullscreen combined with maximized is the same as fullscreen. */ - if (conf->state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN) + if (conf->state & SURFACE_STATE_FULLSCREEN) return TRUE; /* We require the same state. */ - if ((surface->window.state ^ conf->state) & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED) return FALSE; + if ((surface->window.state ^ conf->state) & SURFACE_STATE_MAXIMIZED) return FALSE; /* The maximized state requires the configured size. During surface * reconfiguration we can use surface geometry to provide smaller areas * from larger sizes, so only smaller sizes are incompatible. */ - if ((conf->state & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED) && is_rect_smaller(rect, conf->rect)) return FALSE; + if ((conf->state & SURFACE_STATE_MAXIMIZED) && is_rect_smaller(rect, conf->rect)) return FALSE; return TRUE; } @@ -617,8 +620,8 @@ static void wayland_surface_reconfigure_geometry(struct wayland_surface *surface /* If the window size is bigger than the current state accepts, use the * largest visible (from Windows' perspective) subregion of the window. */ - if ((surface->current.state & (WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED | - WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN)) && + if ((surface->current.state & (SURFACE_STATE_MAXIMIZED | + SURFACE_STATE_FULLSCREEN)) && is_rect_bigger(rect, surface->current.rect)) { wayland_surface_get_rect_in_monitor(surface, &rect); @@ -627,8 +630,8 @@ static void wayland_surface_reconfigure_geometry(struct wayland_surface *surface /* If the window rect in the monitor is smaller than required, * fall back to an appropriately sized rect at the top-left. */ - if ((surface->current.state & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED) && - !(surface->current.state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN) && + if ((surface->current.state & SURFACE_STATE_MAXIMIZED) && + !(surface->current.state & SURFACE_STATE_FULLSCREEN) && is_rect_smaller(rect, surface->current.rect)) { SetRect(&rect, 0, 0, surface->current.rect.right - surface->current.rect.left, diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 1aae646d2a9..551f14e76e9 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -72,12 +72,12 @@ enum wayland_window_message WM_WAYLAND_SET_FOREGROUND, }; -enum wayland_surface_config_state +enum surface_state { - WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED = (1 << 0), - WAYLAND_SURFACE_CONFIG_STATE_RESIZING = (1 << 1), - WAYLAND_SURFACE_CONFIG_STATE_TILED = (1 << 2), - WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN = (1 << 3) + SURFACE_STATE_MAXIMIZED = (1 << 0), + SURFACE_STATE_RESIZING = (1 << 1), + SURFACE_STATE_TILED = (1 << 2), + SURFACE_STATE_FULLSCREEN = (1 << 3) }; enum wayland_surface_role @@ -224,19 +224,19 @@ struct wayland_output struct wayland_output_state current; }; -struct wayland_surface_config +struct surface_config { - RECT rect; - enum wayland_surface_config_state state; - uint32_t serial; - BOOL processed; + RECT rect; /* rect of the compositor surface (in surface coordinates) */ + enum surface_state state; /* state of the compositor surface */ + uint32_t serial; /* serial of the corresponding xdg_surface_configure event */ + BOOL processed; /* config has been fully applied to the surface win32 window */ }; struct wayland_window_config { RECT rect; RECT client_rect; - enum wayland_surface_config_state state; + enum surface_state state; /* The scale (i.e., normalized dpi) the window is rendering at. */ double scale; BOOL visible; @@ -297,7 +297,11 @@ struct wayland_surface }; struct wp_alpha_modifier_surface_v1 *wp_alpha_modifier_surface_v1; - struct wayland_surface_config pending, requested, processing, current; + struct surface_config pending; /* incomplete surface config being received from the compositor */ + struct surface_config requested; /* latest complete surface config received from the compositor */ + struct surface_config processing; /* surface config being applied to the surface win32 window */ + struct surface_config current; /* latest config that has been applied to the surface win32 window */ + BOOL resizing; struct wayland_window_config window; int content_width, content_height; @@ -332,7 +336,7 @@ void wayland_surface_attach_shm(struct wayland_surface *surface, struct wayland_shm_buffer *shm_buffer, HRGN surface_damage_region); BOOL wayland_surface_reconfigure(struct wayland_surface *surface); -BOOL wayland_surface_config_is_compatible(struct wayland_surface *surface, struct wayland_surface_config *conf); +BOOL wayland_surface_config_is_compatible(struct wayland_surface *surface, struct surface_config *conf); RECT map_rect_to_surface(struct wayland_surface *surface, RECT rect); POINT map_point_to_surface(struct wayland_surface *surface, POINT point); RECT map_rect_from_surface(struct wayland_surface *surface, RECT rect); diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index 000f8001710..b3cc1e135aa 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -135,7 +135,7 @@ void wayland_win_data_release(struct wayland_win_data *data) static void wayland_win_data_get_config(struct wayland_win_data *data, struct wayland_window_config *conf) { - enum wayland_surface_config_state window_state = 0; + enum surface_state window_state = 0; DWORD style; conf->rect = data->rects.window; @@ -150,13 +150,13 @@ static void wayland_win_data_get_config(struct wayland_win_data *data, if (data->is_fullscreen) { if ((style & WS_MAXIMIZE) && (style & WS_CAPTION) == WS_CAPTION) - window_state |= WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED; + window_state |= SURFACE_STATE_MAXIMIZED; else if (!(style & WS_MINIMIZE)) - window_state |= WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN; + window_state |= SURFACE_STATE_FULLSCREEN; } else if (style & WS_MAXIMIZE) { - window_state |= WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED; + window_state |= SURFACE_STATE_MAXIMIZED; } conf->resizeable = data->resizeable; @@ -254,26 +254,26 @@ static void wayland_surface_update_state_toplevel(struct wayland_surface *surfac { /* First do all state unsettings, before setting new state. Some * Wayland compositors misbehave if the order is reversed. */ - if (!(surface->window.state & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED) && - (surface->current.state & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED) && + if (!(surface->window.state & SURFACE_STATE_MAXIMIZED) && + (surface->current.state & SURFACE_STATE_MAXIMIZED) && !surface->window.minimized) { xdg_toplevel_unset_maximized(surface->xdg_toplevel); } - if (!(surface->window.state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN) && - (surface->current.state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN) && + if (!(surface->window.state & SURFACE_STATE_FULLSCREEN) && + (surface->current.state & SURFACE_STATE_FULLSCREEN) && !surface->window.minimized) { xdg_toplevel_unset_fullscreen(surface->xdg_toplevel); } - if ((surface->window.state & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED) && - !(surface->current.state & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED)) + if ((surface->window.state & SURFACE_STATE_MAXIMIZED) && + !(surface->current.state & SURFACE_STATE_MAXIMIZED)) { xdg_toplevel_set_maximized(surface->xdg_toplevel); } - if ((surface->window.state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN) && - !(surface->current.state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN)) + if ((surface->window.state & SURFACE_STATE_FULLSCREEN) && + !(surface->current.state & SURFACE_STATE_FULLSCREEN)) { xdg_toplevel_set_fullscreen(surface->xdg_toplevel, NULL); } @@ -513,13 +513,13 @@ static void wayland_configure_window(HWND hwnd) * size adherence, in order to avoid spurious resizes. */ if (!state) flags |= SWP_NOSIZE; - if ((state & WAYLAND_SURFACE_CONFIG_STATE_RESIZING) && !surface->resizing) + if ((state & SURFACE_STATE_RESIZING) && !surface->resizing) { surface->resizing = TRUE; needs_enter_size_move = TRUE; } - if (!(state & WAYLAND_SURFACE_CONFIG_STATE_RESIZING) && surface->resizing) + if (!(state & SURFACE_STATE_RESIZING) && surface->resizing) { surface->resizing = FALSE; needs_exit_size_move = TRUE; @@ -527,8 +527,8 @@ static void wayland_configure_window(HWND hwnd) /* Transitions between normal/max/fullscreen may entail a frame change. */ if ((state ^ surface->current.state) & - (WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED | - WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN)) + (SURFACE_STATE_MAXIMIZED | + SURFACE_STATE_FULLSCREEN)) { flags |= SWP_FRAMECHANGED; } @@ -537,7 +537,7 @@ static void wayland_configure_window(HWND hwnd) * the compositor is requesting, don't force a resize, since some applications * are very insistent on a particular fullscreen size (which may not match * the monitor size). */ - if ((surface->window.state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN) && + if ((surface->window.state & SURFACE_STATE_FULLSCREEN) && wayland_surface_config_is_compatible(surface, &surface->processing)) { flags |= SWP_NOSIZE; @@ -573,17 +573,17 @@ static void wayland_configure_window(HWND hwnd) if (needs_exit_size_move) send_message(hwnd, WM_EXITSIZEMOVE, 0, 0); style = NtUserGetWindowLongW(hwnd, GWL_STYLE); - if (!(state & WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED) != !(style & WS_MAXIMIZE) - && !(state & WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN)) + if (!(state & SURFACE_STATE_MAXIMIZED) != !(style & WS_MAXIMIZE) + && !(state & SURFACE_STATE_FULLSCREEN)) NtUserSetWindowLong(hwnd, GWL_STYLE, style ^ WS_MAXIMIZE, FALSE); /* The Wayland maximized and fullscreen states are very strict about * surface size, so don't let the application override it. The tiled state * is not as strict, but it indicates a strong size preference, so try to * respect it. */ - if (state & (WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED | - WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN | - WAYLAND_SURFACE_CONFIG_STATE_TILED)) + if (state & (SURFACE_STATE_MAXIMIZED | + SURFACE_STATE_FULLSCREEN | + SURFACE_STATE_TILED)) { flags |= SWP_NOSENDCHANGING; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11321