mirror of
https://github.com/glfw/glfw.git
synced 2026-09-19 15:25:50 +00:00
committed by
Camilla Löwy
parent
b5e24676a4
commit
65166858ff
@@ -189,6 +189,24 @@ static void setOpaqueRegion(_GLFWwindow* window)
|
||||
wl_region_destroy(region);
|
||||
}
|
||||
|
||||
static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable)
|
||||
{
|
||||
if (enable && !window->wl.idleInhibitor && _glfw.wl.idleInhibitManager)
|
||||
{
|
||||
window->wl.idleInhibitor =
|
||||
zwp_idle_inhibit_manager_v1_create_inhibitor(
|
||||
_glfw.wl.idleInhibitManager, window->wl.surface);
|
||||
if (!window->wl.idleInhibitor)
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Idle inhibitor creation failed");
|
||||
}
|
||||
else if (!enable && window->wl.idleInhibitor)
|
||||
{
|
||||
zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
|
||||
window->wl.idleInhibitor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static GLFWbool createSurface(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig)
|
||||
{
|
||||
@@ -239,14 +257,17 @@ static GLFWbool createShellSurface(_GLFWwindow* window)
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
0,
|
||||
window->monitor->wl.output);
|
||||
setIdleInhibitor(window, GLFW_TRUE);
|
||||
}
|
||||
else if (window->wl.maximized)
|
||||
{
|
||||
wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
|
||||
setIdleInhibitor(window, GLFW_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wl_shell_surface_set_toplevel(window->wl.shellSurface);
|
||||
setIdleInhibitor(window, GLFW_FALSE);
|
||||
}
|
||||
|
||||
wl_surface_commit(window->wl.surface);
|
||||
@@ -452,6 +473,9 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
}
|
||||
|
||||
if (window->wl.idleInhibitor)
|
||||
zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
|
||||
|
||||
if (window->context.destroy)
|
||||
window->context.destroy(window);
|
||||
|
||||
@@ -637,10 +661,12 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
refreshRate * 1000, // Convert Hz to mHz.
|
||||
monitor->wl.output);
|
||||
setIdleInhibitor(window, GLFW_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wl_shell_surface_set_toplevel(window->wl.shellSurface);
|
||||
setIdleInhibitor(window, GLFW_FALSE);
|
||||
}
|
||||
_glfwInputWindowMonitor(window, monitor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user