1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 12:18:51 -05:00

Wayland: Fix reporting of monitor scale changes

Content scale events would be emitted when a window surface entered or
left an output, but not when one of a window's current outputs had its
scale changed.
This commit is contained in:
Camilla Löwy 2022-06-14 18:46:47 +02:00
parent c3ad3d49ed
commit e37ba80b13
4 changed files with 18 additions and 3 deletions

View File

@ -353,6 +353,8 @@ information on what to include when reporting a bug.
changed changed
- [Wayland] Bugfix: `glfwTerminate` would segfault if any monitor had changed - [Wayland] Bugfix: `glfwTerminate` would segfault if any monitor had changed
scale scale
- [Wayland] Bugfix: Window content scale events were not emitted when monitor
scale changed
- [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Removed use of deprecated function `gettimeofday`
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)

View File

@ -113,6 +113,18 @@ static void outputHandleScale(void* userData,
struct _GLFWmonitor* monitor = userData; struct _GLFWmonitor* monitor = userData;
monitor->wl.scale = factor; monitor->wl.scale = factor;
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
{
for (int i = 0; i < window->wl.monitorsCount; i++)
{
if (window->wl.monitors[i] == monitor)
{
_glfwUpdateContentScaleWayland(window);
break;
}
}
}
} }
#ifdef WL_OUTPUT_NAME_SINCE_VERSION #ifdef WL_OUTPUT_NAME_SINCE_VERSION

View File

@ -507,6 +507,7 @@ GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
void _glfwAddOutputWayland(uint32_t name, uint32_t version); void _glfwAddOutputWayland(uint32_t name, uint32_t version);
void _glfwUpdateContentScaleWayland(_GLFWwindow* window);
GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode); GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode);
void _glfwAddSeatListenerWayland(struct wl_seat* seat); void _glfwAddSeatListenerWayland(struct wl_seat* seat);

View File

@ -334,7 +334,7 @@ static void resizeWindow(_GLFWwindow* window)
wl_surface_commit(window->wl.decorations.bottom.surface); wl_surface_commit(window->wl.decorations.bottom.surface);
} }
static void checkScaleChange(_GLFWwindow* window) void _glfwUpdateContentScaleWayland(_GLFWwindow* window)
{ {
if (_glfw.wl.compositorVersion < WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION) if (_glfw.wl.compositorVersion < WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
return; return;
@ -372,7 +372,7 @@ static void surfaceHandleEnter(void* userData,
window->wl.monitors[window->wl.monitorsCount++] = monitor; window->wl.monitors[window->wl.monitorsCount++] = monitor;
checkScaleChange(window); _glfwUpdateContentScaleWayland(window);
} }
static void surfaceHandleLeave(void* userData, static void surfaceHandleLeave(void* userData,
@ -392,7 +392,7 @@ static void surfaceHandleLeave(void* userData,
} }
window->wl.monitors[--window->wl.monitorsCount] = NULL; window->wl.monitors[--window->wl.monitorsCount] = NULL;
checkScaleChange(window); _glfwUpdateContentScaleWayland(window);
} }
static const struct wl_surface_listener surfaceListener = static const struct wl_surface_listener surfaceListener =