wayland: move window state

This commit is contained in:
Alexander Orzechowski
2022-02-28 19:26:55 -05:00
parent db57230987
commit e359094cff
4 changed files with 41 additions and 37 deletions

44
glfw/wl_window.c vendored
View File

@@ -206,7 +206,7 @@ static void setOpaqueRegion(_GLFWwindow* window)
if (!region)
return;
wl_region_add(region, 0, 0, window->wl.width, window->wl.height);
wl_region_add(region, 0, 0, window->wl.current.width, window->wl.current.height);
wl_surface_set_opaque_region(window->wl.surface, region);
wl_surface_commit(window->wl.surface);
wl_region_destroy(region);
@@ -216,9 +216,9 @@ static void setOpaqueRegion(_GLFWwindow* window)
static void
resizeFramebuffer(_GLFWwindow* window) {
int scale = window->wl.scale;
int scaledWidth = window->wl.width * scale;
int scaledHeight = window->wl.height * scale;
debug("Resizing framebuffer to: %dx%d at scale: %d\n", window->wl.width, window->wl.height, scale);
int scaledWidth = window->wl.current.width * scale;
int scaledHeight = window->wl.current.height * scale;
debug("Resizing framebuffer to: %dx%d at scale: %d\n", window->wl.current.width, window->wl.current.height, scale);
wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
if (!window->wl.transparent) setOpaqueRegion(window);
_glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
@@ -236,12 +236,12 @@ clipboard_mime(void) {
static void
dispatchChangesAfterConfigure(_GLFWwindow *window, int32_t width, int32_t height) {
bool size_changed = width != window->wl.width || height != window->wl.height;
bool size_changed = width != window->wl.current.width || height != window->wl.current.height;
bool scale_changed = checkScaleChange(window);
if (size_changed) {
_glfwInputWindowSize(window, width, height);
window->wl.width = width; window->wl.height = height;
window->wl.current.width = width; window->wl.current.height = height;
resizeFramebuffer(window);
}
@@ -274,7 +274,7 @@ xdgDecorationHandleConfigure(void* data,
debug("XDG decoration configure event received: has_server_side_decorations: %d\n", has_server_side_decorations);
if (has_server_side_decorations == window->wl.decorations.serverSide) return;
window->wl.decorations.serverSide = has_server_side_decorations;
int width = window->wl.width, height = window->wl.height;
int width = window->wl.current.width, height = window->wl.current.height;
if (window->wl.decorations.serverSide) {
free_csd_surfaces(window);
height += window->wl.decorations.metrics.visible_titlebar_height;
@@ -285,7 +285,7 @@ xdgDecorationHandleConfigure(void* data,
dispatchChangesAfterConfigure(window, width, height);
ensure_csd_resources(window);
wl_surface_commit(window->wl.surface);
debug("final window content size: %dx%d\n", window->wl.width, window->wl.height);
debug("final window content size: %dx%d\n", window->wl.current.width, window->wl.current.height);
inform_compositor_of_window_geometry(window, "configure-decorations");
}
@@ -384,8 +384,8 @@ static bool createSurface(_GLFWwindow* window,
if (!window->wl.native)
return false;
window->wl.width = wndconfig->width;
window->wl.height = wndconfig->height;
window->wl.current.width = wndconfig->width;
window->wl.current.height = wndconfig->height;
window->wl.user_requested_content_size.width = wndconfig->width;
window->wl.user_requested_content_size.height = wndconfig->height;
window->wl.scale = 1;
@@ -416,7 +416,7 @@ static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on)
bool
_glfwPlatformIsFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) {
return window->wl.toplevel_states & TOPLEVEL_STATE_FULLSCREEN;
return window->wl.current.toplevel_states & TOPLEVEL_STATE_FULLSCREEN;
}
bool
@@ -458,7 +458,7 @@ xdgToplevelHandleConfigure(void* data,
if (new_states & TOPLEVEL_STATE_RESIZING) {
if (width) window->wl.user_requested_content_size.width = width;
if (height) window->wl.user_requested_content_size.height = height;
if (!(window->wl.toplevel_states & TOPLEVEL_STATE_RESIZING)) _glfwInputLiveResize(window, true);
if (!(window->wl.current.toplevel_states & TOPLEVEL_STATE_RESIZING)) _glfwInputLiveResize(window, true);
}
if (width != 0 && height != 0)
{
@@ -475,12 +475,12 @@ xdgToplevelHandleConfigure(void* data,
}
}
}
bool live_resize_done = !(new_states & TOPLEVEL_STATE_RESIZING) && (window->wl.toplevel_states & TOPLEVEL_STATE_RESIZING);
window->wl.toplevel_states = new_states;
bool live_resize_done = !(new_states & TOPLEVEL_STATE_RESIZING) && (window->wl.current.toplevel_states & TOPLEVEL_STATE_RESIZING);
window->wl.current.toplevel_states = new_states;
set_csd_window_geometry(window, &width, &height);
dispatchChangesAfterConfigure(window, width, height);
debug("final window content size: %dx%d\n", window->wl.width, window->wl.height);
_glfwInputWindowFocus(window, window->wl.toplevel_states & TOPLEVEL_STATE_ACTIVATED);
debug("final window content size: %dx%d\n", window->wl.current.width, window->wl.current.height);
_glfwInputWindowFocus(window, window->wl.current.toplevel_states & TOPLEVEL_STATE_ACTIVATED);
ensure_csd_resources(window);
wl_surface_commit(window->wl.surface);
inform_compositor_of_window_geometry(window, "configure");
@@ -886,19 +886,19 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window UNUSED, int xpos UNUSED, int
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
{
if (width)
*width = window->wl.width;
*width = window->wl.current.width;
if (height)
*height = window->wl.height;
*height = window->wl.current.height;
}
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
if (width != window->wl.width || height != window->wl.height) {
if (width != window->wl.current.width || height != window->wl.current.height) {
window->wl.user_requested_content_size.width = width;
window->wl.user_requested_content_size.height = height;
int32_t w = 0, h = 0;
set_csd_window_geometry(window, &w, &h);
window->wl.width = w; window->wl.height = h;
window->wl.current.width = w; window->wl.current.height = h;
resizeFramebuffer(window);
ensure_csd_resources(window);
wl_surface_commit(window->wl.surface);
@@ -991,7 +991,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{
if (window->monitor)
xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
if (window->wl.toplevel_states & TOPLEVEL_STATE_MAXIMIZED)
if (window->wl.current.toplevel_states & TOPLEVEL_STATE_MAXIMIZED)
xdg_toplevel_unset_maximized(window->wl.xdg.toplevel);
// There is no way to unset minimized, or even to know if we are
// minimized, so there is nothing to do in this case.
@@ -1092,7 +1092,7 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
{
return window->wl.toplevel_states & TOPLEVEL_STATE_MAXIMIZED;
return window->wl.current.toplevel_states & TOPLEVEL_STATE_MAXIMIZED;
}
int _glfwPlatformWindowHovered(_GLFWwindow* window)