@ -312,7 +312,7 @@ static void setContentAreaOpaque(_GLFWwindow* window)
static void resizeFramebuffer ( _GLFWwindow * window )
static void resizeFramebuffer ( _GLFWwindow * window )
{
{
int scale = window - > wl . content Scale;
int scale = window - > wl . buffer Scale;
int scaledWidth = window - > wl . width * scale ;
int scaledWidth = window - > wl . width * scale ;
int scaledHeight = window - > wl . height * scale ;
int scaledHeight = window - > wl . height * scale ;
@ -357,7 +357,7 @@ static void resizeWindow(_GLFWwindow* window)
}
}
}
}
void _glfwUpdateContentScale Wayland ( _GLFWwindow * window )
void _glfwUpdateBufferScaleFromOutputs Wayland ( _GLFWwindow * window )
{
{
if ( wl_compositor_get_version ( _glfw . wl . compositor ) <
if ( wl_compositor_get_version ( _glfw . wl . compositor ) <
WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION )
WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION )
@ -368,13 +368,13 @@ void _glfwUpdateContentScaleWayland(_GLFWwindow* window)
// Get the scale factor from the highest scale monitor.
// Get the scale factor from the highest scale monitor.
int maxScale = 1 ;
int maxScale = 1 ;
for ( int i = 0 ; i < window - > wl . s caleCount; i + + )
for ( int i = 0 ; i < window - > wl . outputS caleCount; i + + )
maxScale = _glfw_max ( window - > wl . s cales[ i ] . factor , maxScale ) ;
maxScale = _glfw_max ( window - > wl . outputS cales[ i ] . factor , maxScale ) ;
// Only change the framebuffer size if the scale changed.
// Only change the framebuffer size if the scale changed.
if ( window - > wl . content Scale ! = maxScale )
if ( window - > wl . buffer Scale ! = maxScale )
{
{
window - > wl . content Scale = maxScale ;
window - > wl . buffer Scale = maxScale ;
wl_surface_set_buffer_scale ( window - > wl . surface , maxScale ) ;
wl_surface_set_buffer_scale ( window - > wl . surface , maxScale ) ;
_glfwInputWindowContentScale ( window , maxScale , maxScale ) ;
_glfwInputWindowContentScale ( window , maxScale , maxScale ) ;
resizeFramebuffer ( window ) ;
resizeFramebuffer ( window ) ;
@ -396,19 +396,19 @@ static void surfaceHandleEnter(void* userData,
if ( ! window | | ! monitor )
if ( ! window | | ! monitor )
return ;
return ;
if ( window - > wl . s caleCount + 1 > window - > wl . s caleSize)
if ( window - > wl . outputS caleCount + 1 > window - > wl . outputS caleSize)
{
{
window - > wl . s caleSize+ + ;
window - > wl . outputS caleSize+ + ;
window - > wl . s cales =
window - > wl . outputS cales =
_glfw_realloc ( window - > wl . s cales,
_glfw_realloc ( window - > wl . outputS cales,
window - > wl . s caleSize * sizeof ( _GLFWscaleWayland ) ) ;
window - > wl . outputS caleSize * sizeof ( _GLFWscaleWayland ) ) ;
}
}
window - > wl . s caleCount+ + ;
window - > wl . outputS caleCount+ + ;
window - > wl . s cales[ window - > wl . s caleCount - 1 ] . factor = monitor - > wl . contentScale ;
window - > wl . outputS cales[ window - > wl . outputS caleCount - 1 ] =
window - > wl . scales [ window - > wl . scaleCount - 1 ] . output = output ;
( _GLFWscaleWayland ) { output , monitor - > wl . scale } ;
_glfwUpdateContentScale Wayland ( window ) ;
_glfwUpdateBufferScaleFromOutputs Wayland ( window ) ;
}
}
static void surfaceHandleLeave ( void * userData ,
static void surfaceHandleLeave ( void * userData ,
@ -420,17 +420,18 @@ static void surfaceHandleLeave(void* userData,
_GLFWwindow * window = userData ;
_GLFWwindow * window = userData ;
for ( int i = 0 ; i < window - > wl . s caleCount; i + + )
for ( int i = 0 ; i < window - > wl . outputS caleCount; i + + )
{
{
if ( window - > wl . s cales[ i ] . output = = output )
if ( window - > wl . outputS cales[ i ] . output = = output )
{
{
window - > wl . scales [ i ] = window - > wl . scales [ window - > wl . scaleCount - 1 ] ;
window - > wl . outputScales [ i ] =
window - > wl . scaleCount - - ;
window - > wl . outputScales [ window - > wl . outputScaleCount - 1 ] ;
window - > wl . outputScaleCount - - ;
break ;
break ;
}
}
}
}
_glfwUpdateContentScale Wayland ( window ) ;
_glfwUpdateBufferScaleFromOutputs Wayland ( window ) ;
}
}
static const struct wl_surface_listener surfaceListener =
static const struct wl_surface_listener surfaceListener =
@ -970,7 +971,7 @@ static GLFWbool createNativeSurface(_GLFWwindow* window,
window - > wl . width = wndconfig - > width ;
window - > wl . width = wndconfig - > width ;
window - > wl . height = wndconfig - > height ;
window - > wl . height = wndconfig - > height ;
window - > wl . content Scale = 1 ;
window - > wl . buffer Scale = 1 ;
window - > wl . title = _glfw_strdup ( wndconfig - > title ) ;
window - > wl . title = _glfw_strdup ( wndconfig - > title ) ;
window - > wl . appId = _glfw_strdup ( wndconfig - > wl . appId ) ;
window - > wl . appId = _glfw_strdup ( wndconfig - > wl . appId ) ;
@ -997,7 +998,7 @@ static void setCursorImage(_GLFWwindow* window,
buffer = cursorWayland - > buffer ;
buffer = cursorWayland - > buffer ;
else
else
{
{
if ( window - > wl . content Scale > 1 & & cursorWayland - > cursorHiDPI )
if ( window - > wl . buffer Scale > 1 & & cursorWayland - > cursorHiDPI )
{
{
wlCursor = cursorWayland - > cursorHiDPI ;
wlCursor = cursorWayland - > cursorHiDPI ;
scale = 2 ;
scale = 2 ;
@ -1398,7 +1399,7 @@ static void pointerHandleMotion(void* userData,
struct wl_cursor_theme * theme = _glfw . wl . cursorTheme ;
struct wl_cursor_theme * theme = _glfw . wl . cursorTheme ;
int scale = 1 ;
int scale = 1 ;
if ( window - > wl . content Scale > 1 & & _glfw . wl . cursorThemeHiDPI )
if ( window - > wl . buffer Scale > 1 & & _glfw . wl . cursorThemeHiDPI )
{
{
// We only support up to scale=2 for now, since libwayland-cursor
// We only support up to scale=2 for now, since libwayland-cursor
// requires us to load a different theme for each size.
// requires us to load a different theme for each size.
@ -2120,7 +2121,7 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
_glfw_free ( window - > wl . title ) ;
_glfw_free ( window - > wl . title ) ;
_glfw_free ( window - > wl . appId ) ;
_glfw_free ( window - > wl . appId ) ;
_glfw_free ( window - > wl . s cales) ;
_glfw_free ( window - > wl . outputS cales) ;
}
}
void _glfwSetWindowTitleWayland ( _GLFWwindow * window , const char * title )
void _glfwSetWindowTitleWayland ( _GLFWwindow * window , const char * title )
@ -2279,9 +2280,9 @@ void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height
{
{
_glfwGetWindowSizeWayland ( window , width , height ) ;
_glfwGetWindowSizeWayland ( window , width , height ) ;
if ( width )
if ( width )
* width * = window - > wl . content Scale;
* width * = window - > wl . buffer Scale;
if ( height )
if ( height )
* height * = window - > wl . content Scale;
* height * = window - > wl . buffer Scale;
}
}
void _glfwGetWindowFrameSizeWayland ( _GLFWwindow * window ,
void _glfwGetWindowFrameSizeWayland ( _GLFWwindow * window ,
@ -2305,9 +2306,9 @@ void _glfwGetWindowContentScaleWayland(_GLFWwindow* window,
float * xscale , float * yscale )
float * xscale , float * yscale )
{
{
if ( xscale )
if ( xscale )
* xscale = ( float ) window - > wl . content Scale;
* xscale = ( float ) window - > wl . buffer Scale;
if ( yscale )
if ( yscale )
* yscale = ( float ) window - > wl . content Scale;
* yscale = ( float ) window - > wl . buffer Scale;
}
}
void _glfwIconifyWindowWayland ( _GLFWwindow * window )
void _glfwIconifyWindowWayland ( _GLFWwindow * window )