mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 00:04:55 +00:00
Merge 40df42381f
into 1fe98a0d53
This commit is contained in:
commit
a56441b837
@ -376,6 +376,15 @@ static void createKeyTables(void)
|
||||
}
|
||||
}
|
||||
|
||||
static GLFWbool getScaleSetting(void)
|
||||
{
|
||||
const char* scaleEnvString = getenv("GLFW_SCALE_TO_MONITOR");
|
||||
if (scaleEnvString)
|
||||
return GLFW_TRUE;
|
||||
else
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
static GLFWbool loadCursorTheme(void)
|
||||
{
|
||||
int cursorSize = 16;
|
||||
@ -838,6 +847,8 @@ int _glfwInitWayland(void)
|
||||
if (!loadCursorTheme())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfw.wl.scaleToMonitor = getScaleSetting();
|
||||
|
||||
if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
|
||||
{
|
||||
_glfw.wl.dataDevice =
|
||||
|
@ -458,6 +458,7 @@ typedef struct _GLFWlibraryWayland
|
||||
int cursorTimerfd;
|
||||
uint32_t serial;
|
||||
uint32_t pointerEnterSerial;
|
||||
GLFWbool scaleToMonitor;
|
||||
|
||||
int keyRepeatTimerfd;
|
||||
int32_t keyRepeatRate;
|
||||
|
@ -1331,6 +1331,7 @@ static void pointerHandleMotion(void* userData,
|
||||
const double ypos = wl_fixed_to_double(sy);
|
||||
window->wl.cursorPosX = xpos;
|
||||
window->wl.cursorPosY = ypos;
|
||||
int scale = _glfw.wl.scaleToMonitor ? window->wl.contentScale : 1;
|
||||
|
||||
const char* cursorName = NULL;
|
||||
|
||||
@ -1338,7 +1339,7 @@ static void pointerHandleMotion(void* userData,
|
||||
{
|
||||
case GLFW_MAIN_WINDOW:
|
||||
_glfw.wl.cursorPreviousName = NULL;
|
||||
_glfwInputCursorPos(window, xpos, ypos);
|
||||
_glfwInputCursorPos(window, xpos * scale, ypos * scale);
|
||||
return;
|
||||
case GLFW_TOP_DECORATION:
|
||||
if (ypos < GLFW_BORDER_SIZE)
|
||||
@ -2146,10 +2147,11 @@ void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos)
|
||||
|
||||
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
int scale = _glfw.wl.scaleToMonitor ? window->wl.contentScale : 1;
|
||||
if (width)
|
||||
*width = window->wl.width;
|
||||
*width = window->wl.width * scale;
|
||||
if (height)
|
||||
*height = window->wl.height;
|
||||
*height = window->wl.height * scale;
|
||||
}
|
||||
|
||||
void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height)
|
||||
@ -2263,10 +2265,11 @@ void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom)
|
||||
void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
_glfwGetWindowSizeWayland(window, width, height);
|
||||
int scale = _glfw.wl.scaleToMonitor ? 1 : window->wl.contentScale;
|
||||
if (width)
|
||||
*width *= window->wl.contentScale;
|
||||
*width *= scale;
|
||||
if (height)
|
||||
*height *= window->wl.contentScale;
|
||||
*height *= scale;
|
||||
}
|
||||
|
||||
void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window,
|
||||
|
Loading…
Reference in New Issue
Block a user