Skip to content

Commit

Permalink
Wayland: Assume 96 DPI if physical size is <= 0
Browse files Browse the repository at this point in the history
  • Loading branch information
caramelli authored and linkmauve committed Oct 14, 2020
1 parent a506a8d commit 0ef149c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/wl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@ int _glfwPlatformInit(void)
char *cursorSizeEnd;
long cursorSizeLong;
int cursorSize;
int i;
_GLFWmonitor* monitor;

_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
if (!_glfw.wl.cursor.handle)
Expand Down Expand Up @@ -1146,6 +1148,17 @@ int _glfwPlatformInit(void)
// Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display);

for (i = 0; i < _glfw.monitorCount; ++i)
{
monitor = _glfw.monitors[i];
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
{
// If Wayland does not provide a physical size, assume the default 96 DPI
monitor->widthMM = (int) (monitor->modes[monitor->wl.currentMode].width * 25.4f / 96.f);
monitor->heightMM = (int) (monitor->modes[monitor->wl.currentMode].height * 25.4f / 96.f);
}
}

_glfwInitTimerPOSIX();

_glfw.wl.timerfd = -1;
Expand Down

0 comments on commit 0ef149c

Please sign in to comment.