mirror of
				https://github.com/glfw/glfw.git
				synced 2025-11-04 06:15:07 +00:00 
			
		
		
		
	Wayland: Cache framebuffer size
The calculation of framebuffer size is about to get more complicated with the introduction of fractional-scale-v1, so only do it in one place. This is also a tiny preparation for eventually behaving better towards wl_egl_window_resize.
This commit is contained in:
		
							parent
							
								
									1be7bc546b
								
							
						
					
					
						commit
						9953f7ead1
					
				@ -348,6 +348,7 @@ typedef struct _GLFWscaleWayland
 | 
				
			|||||||
typedef struct _GLFWwindowWayland
 | 
					typedef struct _GLFWwindowWayland
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int                         width, height;
 | 
					    int                         width, height;
 | 
				
			||||||
 | 
					    int                         fbWidth, fbHeight;
 | 
				
			||||||
    GLFWbool                    visible;
 | 
					    GLFWbool                    visible;
 | 
				
			||||||
    GLFWbool                    maximized;
 | 
					    GLFWbool                    maximized;
 | 
				
			||||||
    GLFWbool                    activated;
 | 
					    GLFWbool                    activated;
 | 
				
			||||||
 | 
				
			|||||||
@ -312,17 +312,21 @@ static void setContentAreaOpaque(_GLFWwindow* window)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void resizeFramebuffer(_GLFWwindow* window)
 | 
					static void resizeFramebuffer(_GLFWwindow* window)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t scale = window->wl.bufferScale;
 | 
					    window->wl.fbWidth = window->wl.width * window->wl.bufferScale;
 | 
				
			||||||
    int scaledWidth = window->wl.width * scale;
 | 
					    window->wl.fbHeight = window->wl.height * window->wl.bufferScale;
 | 
				
			||||||
    int scaledHeight = window->wl.height * scale;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (window->wl.egl.window)
 | 
					    if (window->wl.egl.window)
 | 
				
			||||||
        wl_egl_window_resize(window->wl.egl.window, scaledWidth, scaledHeight, 0, 0);
 | 
					    {
 | 
				
			||||||
 | 
					        wl_egl_window_resize(window->wl.egl.window,
 | 
				
			||||||
 | 
					                             window->wl.fbWidth,
 | 
				
			||||||
 | 
					                             window->wl.fbHeight,
 | 
				
			||||||
 | 
					                             0, 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!window->wl.transparent)
 | 
					    if (!window->wl.transparent)
 | 
				
			||||||
        setContentAreaOpaque(window);
 | 
					        setContentAreaOpaque(window);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
 | 
					    _glfwInputFramebufferSize(window, window->wl.fbWidth, window->wl.fbHeight);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void resizeWindow(_GLFWwindow* window)
 | 
					static void resizeWindow(_GLFWwindow* window)
 | 
				
			||||||
@ -971,6 +975,8 @@ 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.fbWidth = wndconfig->width;
 | 
				
			||||||
 | 
					    window->wl.fbHeight = wndconfig->height;
 | 
				
			||||||
    window->wl.bufferScale = 1;
 | 
					    window->wl.bufferScale = 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);
 | 
				
			||||||
@ -2044,8 +2050,8 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,
 | 
				
			|||||||
            ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
 | 
					            ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            window->wl.egl.window = wl_egl_window_create(window->wl.surface,
 | 
					            window->wl.egl.window = wl_egl_window_create(window->wl.surface,
 | 
				
			||||||
                                                         wndconfig->width,
 | 
					                                                         window->wl.fbWidth,
 | 
				
			||||||
                                                         wndconfig->height);
 | 
					                                                         window->wl.fbHeight);
 | 
				
			||||||
            if (!window->wl.egl.window)
 | 
					            if (!window->wl.egl.window)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                _glfwInputError(GLFW_PLATFORM_ERROR,
 | 
					                _glfwInputError(GLFW_PLATFORM_ERROR,
 | 
				
			||||||
@ -2278,11 +2284,10 @@ void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height)
 | 
					void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    _glfwGetWindowSizeWayland(window, width, height);
 | 
					 | 
				
			||||||
    if (width)
 | 
					    if (width)
 | 
				
			||||||
        *width *= window->wl.bufferScale;
 | 
					        *width = window->wl.fbWidth;
 | 
				
			||||||
    if (height)
 | 
					    if (height)
 | 
				
			||||||
        *height *= window->wl.bufferScale;
 | 
					        *height = window->wl.fbHeight;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window,
 | 
					void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user