mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Wayland: Put fallback decorations behind a boolean
This commit is contained in:
parent
6ac0835ad2
commit
4baeadbd66
@ -410,6 +410,7 @@ typedef struct _GLFWwindowWayland
|
|||||||
struct xdg_activation_token_v1* activationToken;
|
struct xdg_activation_token_v1* activationToken;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
GLFWbool decorations;
|
||||||
struct wl_buffer* buffer;
|
struct wl_buffer* buffer;
|
||||||
_GLFWdecorationWayland top, left, right, bottom;
|
_GLFWdecorationWayland top, left, right, bottom;
|
||||||
_GLFWdecorationSideWayland focus;
|
_GLFWdecorationSideWayland focus;
|
||||||
|
@ -247,6 +247,8 @@ static void createFallbackDecorations(_GLFWwindow* window)
|
|||||||
window->wl.fallback.buffer,
|
window->wl.fallback.buffer,
|
||||||
-GLFW_BORDER_SIZE, window->wl.height,
|
-GLFW_BORDER_SIZE, window->wl.height,
|
||||||
window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE);
|
window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE);
|
||||||
|
|
||||||
|
window->wl.fallback.decorations = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration)
|
static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration)
|
||||||
@ -264,6 +266,8 @@ static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration)
|
|||||||
|
|
||||||
static void destroyFallbackDecorations(_GLFWwindow* window)
|
static void destroyFallbackDecorations(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
window->wl.fallback.decorations = GLFW_FALSE;
|
||||||
|
|
||||||
destroyFallbackDecoration(&window->wl.fallback.top);
|
destroyFallbackDecoration(&window->wl.fallback.top);
|
||||||
destroyFallbackDecoration(&window->wl.fallback.left);
|
destroyFallbackDecoration(&window->wl.fallback.left);
|
||||||
destroyFallbackDecoration(&window->wl.fallback.right);
|
destroyFallbackDecoration(&window->wl.fallback.right);
|
||||||
@ -325,28 +329,32 @@ static void resizeWindow(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
resizeFramebuffer(window);
|
resizeFramebuffer(window);
|
||||||
|
|
||||||
if (!window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
return;
|
{
|
||||||
|
|
||||||
wp_viewport_set_destination(window->wl.fallback.top.viewport,
|
wp_viewport_set_destination(window->wl.fallback.top.viewport,
|
||||||
window->wl.width, GLFW_CAPTION_HEIGHT);
|
window->wl.width,
|
||||||
|
GLFW_CAPTION_HEIGHT);
|
||||||
wl_surface_commit(window->wl.fallback.top.surface);
|
wl_surface_commit(window->wl.fallback.top.surface);
|
||||||
|
|
||||||
wp_viewport_set_destination(window->wl.fallback.left.viewport,
|
wp_viewport_set_destination(window->wl.fallback.left.viewport,
|
||||||
GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT);
|
GLFW_BORDER_SIZE,
|
||||||
|
window->wl.height + GLFW_CAPTION_HEIGHT);
|
||||||
wl_surface_commit(window->wl.fallback.left.surface);
|
wl_surface_commit(window->wl.fallback.left.surface);
|
||||||
|
|
||||||
wl_subsurface_set_position(window->wl.fallback.right.subsurface,
|
wl_subsurface_set_position(window->wl.fallback.right.subsurface,
|
||||||
window->wl.width, -GLFW_CAPTION_HEIGHT);
|
window->wl.width, -GLFW_CAPTION_HEIGHT);
|
||||||
wp_viewport_set_destination(window->wl.fallback.right.viewport,
|
wp_viewport_set_destination(window->wl.fallback.right.viewport,
|
||||||
GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT);
|
GLFW_BORDER_SIZE,
|
||||||
|
window->wl.height + GLFW_CAPTION_HEIGHT);
|
||||||
wl_surface_commit(window->wl.fallback.right.surface);
|
wl_surface_commit(window->wl.fallback.right.surface);
|
||||||
|
|
||||||
wl_subsurface_set_position(window->wl.fallback.bottom.subsurface,
|
wl_subsurface_set_position(window->wl.fallback.bottom.subsurface,
|
||||||
-GLFW_BORDER_SIZE, window->wl.height);
|
-GLFW_BORDER_SIZE, window->wl.height);
|
||||||
wp_viewport_set_destination(window->wl.fallback.bottom.viewport,
|
wp_viewport_set_destination(window->wl.fallback.bottom.viewport,
|
||||||
window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE);
|
window->wl.width + GLFW_BORDER_SIZE * 2,
|
||||||
|
GLFW_BORDER_SIZE);
|
||||||
wl_surface_commit(window->wl.fallback.bottom.surface);
|
wl_surface_commit(window->wl.fallback.bottom.surface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwUpdateContentScaleWayland(_GLFWwindow* window)
|
void _glfwUpdateContentScaleWayland(_GLFWwindow* window)
|
||||||
@ -466,7 +474,7 @@ static void acquireMonitor(_GLFWwindow* window)
|
|||||||
|
|
||||||
setIdleInhibitor(window, GLFW_TRUE);
|
setIdleInhibitor(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
destroyFallbackDecorations(window);
|
destroyFallbackDecorations(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,7 +530,7 @@ static void xdgToplevelHandleConfigure(void* userData,
|
|||||||
|
|
||||||
if (width && height)
|
if (width && height)
|
||||||
{
|
{
|
||||||
if (window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
{
|
||||||
window->wl.pending.width = _glfw_max(0, width - GLFW_BORDER_SIZE * 2);
|
window->wl.pending.width = _glfw_max(0, width - GLFW_BORDER_SIZE * 2);
|
||||||
window->wl.pending.height =
|
window->wl.pending.height =
|
||||||
@ -882,7 +890,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window)
|
|||||||
int minwidth = window->minwidth;
|
int minwidth = window->minwidth;
|
||||||
int minheight = window->minheight;
|
int minheight = window->minheight;
|
||||||
|
|
||||||
if (window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
{
|
||||||
minwidth += GLFW_BORDER_SIZE * 2;
|
minwidth += GLFW_BORDER_SIZE * 2;
|
||||||
minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
||||||
@ -896,7 +904,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window)
|
|||||||
int maxwidth = window->maxwidth;
|
int maxwidth = window->maxwidth;
|
||||||
int maxheight = window->maxheight;
|
int maxheight = window->maxheight;
|
||||||
|
|
||||||
if (window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
{
|
||||||
maxwidth += GLFW_BORDER_SIZE * 2;
|
maxwidth += GLFW_BORDER_SIZE * 2;
|
||||||
maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
||||||
@ -1276,9 +1284,9 @@ static void pointerHandleEnter(void* userData,
|
|||||||
|
|
||||||
_GLFWwindow* window = wl_surface_get_user_data(surface);
|
_GLFWwindow* window = wl_surface_get_user_data(surface);
|
||||||
|
|
||||||
if (surface == window->wl.surface)
|
if (window->wl.fallback.decorations)
|
||||||
window->wl.hovered = GLFW_TRUE;
|
{
|
||||||
else if (surface == window->wl.fallback.top.surface)
|
if (surface == window->wl.fallback.top.surface)
|
||||||
window->wl.fallback.focus = GLFW_TOP_DECORATION;
|
window->wl.fallback.focus = GLFW_TOP_DECORATION;
|
||||||
else if (surface == window->wl.fallback.left.surface)
|
else if (surface == window->wl.fallback.left.surface)
|
||||||
window->wl.fallback.focus = GLFW_LEFT_DECORATION;
|
window->wl.fallback.focus = GLFW_LEFT_DECORATION;
|
||||||
@ -1286,13 +1294,15 @@ static void pointerHandleEnter(void* userData,
|
|||||||
window->wl.fallback.focus = GLFW_RIGHT_DECORATION;
|
window->wl.fallback.focus = GLFW_RIGHT_DECORATION;
|
||||||
else if (surface == window->wl.fallback.bottom.surface)
|
else if (surface == window->wl.fallback.bottom.surface)
|
||||||
window->wl.fallback.focus = GLFW_BOTTOM_DECORATION;
|
window->wl.fallback.focus = GLFW_BOTTOM_DECORATION;
|
||||||
|
}
|
||||||
|
|
||||||
_glfw.wl.serial = serial;
|
_glfw.wl.serial = serial;
|
||||||
_glfw.wl.pointerEnterSerial = serial;
|
_glfw.wl.pointerEnterSerial = serial;
|
||||||
_glfw.wl.pointerFocus = window;
|
_glfw.wl.pointerFocus = window;
|
||||||
|
|
||||||
if (window->wl.hovered)
|
if (surface == window->wl.surface)
|
||||||
{
|
{
|
||||||
|
window->wl.hovered = GLFW_TRUE;
|
||||||
_glfwSetCursorWayland(window, window->wl.currentCursor);
|
_glfwSetCursorWayland(window, window->wl.currentCursor);
|
||||||
_glfwInputCursorEnter(window, GLFW_TRUE);
|
_glfwInputCursorEnter(window, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
@ -1349,6 +1359,8 @@ static void pointerHandleMotion(void* userData,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->wl.fallback.decorations)
|
||||||
|
{
|
||||||
const char* cursorName = NULL;
|
const char* cursorName = NULL;
|
||||||
|
|
||||||
switch (window->wl.fallback.focus)
|
switch (window->wl.fallback.focus)
|
||||||
@ -1421,6 +1433,7 @@ static void pointerHandleMotion(void* userData,
|
|||||||
|
|
||||||
_glfw.wl.cursorPreviousName = cursorName;
|
_glfw.wl.cursorPreviousName = cursorName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointerHandleButton(void* userData,
|
static void pointerHandleButton(void* userData,
|
||||||
@ -1445,6 +1458,8 @@ static void pointerHandleButton(void* userData,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->wl.fallback.decorations)
|
||||||
|
{
|
||||||
if (button == BTN_LEFT)
|
if (button == BTN_LEFT)
|
||||||
{
|
{
|
||||||
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
||||||
@ -1494,6 +1509,7 @@ static void pointerHandleButton(void* userData,
|
|||||||
window->wl.cursorPosY);
|
window->wl.cursorPosY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointerHandleAxis(void* userData,
|
static void pointerHandleAxis(void* userData,
|
||||||
@ -2199,7 +2215,7 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window,
|
|||||||
minwidth = minheight = 0;
|
minwidth = minheight = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
{
|
||||||
minwidth += GLFW_BORDER_SIZE * 2;
|
minwidth += GLFW_BORDER_SIZE * 2;
|
||||||
minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
||||||
@ -2210,7 +2226,7 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window,
|
|||||||
maxwidth = maxheight = 0;
|
maxwidth = maxheight = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
{
|
||||||
maxwidth += GLFW_BORDER_SIZE * 2;
|
maxwidth += GLFW_BORDER_SIZE * 2;
|
||||||
maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE;
|
||||||
@ -2273,7 +2289,7 @@ void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window,
|
|||||||
int* left, int* top,
|
int* left, int* top,
|
||||||
int* right, int* bottom)
|
int* right, int* bottom)
|
||||||
{
|
{
|
||||||
if (window->wl.fallback.top.surface)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
{
|
||||||
if (top)
|
if (top)
|
||||||
*top = GLFW_CAPTION_HEIGHT;
|
*top = GLFW_CAPTION_HEIGHT;
|
||||||
|
Loading…
Reference in New Issue
Block a user