Report errors when attempts are made to perform actions the compositor doesnt support

This commit is contained in:
Kovid Goyal 2024-04-06 11:08:12 +05:30
parent 235b8dc2e4
commit d4cc5aa698
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 28 additions and 19 deletions

5
glfw/wl_init.c vendored
View file

@ -302,7 +302,10 @@ static void pointerHandleButton(void* data UNUSED,
{
if (window->wl.decorations.focus != CENTRAL_WINDOW && window->wl.xdg.toplevel)
{
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, _glfw.wl.seat, serial, (int32_t)x, (int32_t)y - window->wl.decorations.metrics.top);
if (window->wl.wm_capabilities.window_menu) xdg_toplevel_show_window_menu(
window->wl.xdg.toplevel, _glfw.wl.seat, serial, (int32_t)x, (int32_t)y - window->wl.decorations.metrics.top);
else
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland compositor does not support showing wndow menu");
return;
}
}

42
glfw/wl_window.c vendored
View file

@ -596,17 +596,19 @@ static bool createSurface(_GLFWwindow* window,
return true;
}
static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on)
{
if (window->wl.xdg.toplevel)
{
if (on) {
xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel, monitor ? monitor->wl.output : NULL);
csd_set_visible(window, false);
} else {
xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
csd_set_visible(window, true);
}
static void
setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on) {
if (!window->wl.xdg.toplevel) return;
if (!window->wl.wm_capabilities.fullscreen) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland compositor does not support fullscreen");
return;
}
if (on) {
xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel, monitor ? monitor->wl.output : NULL);
csd_set_visible(window, false);
} else {
xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
csd_set_visible(window, true);
}
}
@ -1093,8 +1095,10 @@ create_window_desktop_surface(_GLFWwindow* window)
window->maxwidth, window->maxheight);
if (window->monitor) {
xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel,
window->monitor->wl.output);
if (window->wl.wm_capabilities.fullscreen)
xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel, window->monitor->wl.output);
else
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland compositor does not support fullscreen");
} else {
if (window->wl.maximize_on_first_show) {
window->wl.maximize_on_first_show = false;
@ -1527,8 +1531,10 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
if (window->wl.xdg.toplevel)
xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
if (window->wl.xdg.toplevel) {
if (window->wl.wm_capabilities.minimize) xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
else _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland compositor does not support minimizing windows");
}
}
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
@ -1547,9 +1553,9 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
{
if (window->wl.xdg.toplevel)
{
xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
if (window->wl.xdg.toplevel) {
if (window->wl.wm_capabilities.maximize) xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
else _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland compositor does not support maximizing windows");
}
}