Skip to content

x11: attach OpenGL views in windows with a scale factor - #241

Open
probonopd wants to merge 1 commit into
gnustep:masterfrom
probonopd:fix-gl-subwindow-scaled-window
Open

probonopd wants to merge 1 commit into
gnustep:masterfrom
probonopd:fix-gl-subwindow-scaled-window

Conversation

@probonopd

@probonopd probonopd commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

With a GSScaleFactor other than 1, every view counts as scaled from window base coordinates, so XGXSubWindow refused to attach an OpenGL context to any view ("Cannot attach an Xwindow to a view that is rotated or scaled"). An app with an NSOpenGLView then raised while building and drawing its window (-[NSOpenGLView openGLContext], -[NSOpenGLView _lockFocusInContext:inRect:]), and makeKeyAndOrderFront: never showed the window.

Fix: window base coordinates are already device pixels, the unit of the X subwindow. The subwindow is now placed from the view's rectangle in base coordinates (made relative to the content view when the window manager draws the decorations), in both -initWithView:visualinfo: and -update. Only rotated views are still refused.

Verified at -GSScaleFactor 1.1 on X11 with a window manager: an app with an NSOpenGLView in its content view now shows its window, and the GL subwindow covers exactly the view, also after resizing the window and after full screen. At scale factor 1 the placement is unchanged.

cc @pkgdemon

With a GSScaleFactor other than 1 every view is scaled from window base
coordinates, so XGXSubWindow refused to attach an OpenGL context to any
view and raised. Apps with an NSOpenGLView then failed while building and
drawing their window, which never appeared.

Window base coordinates are device pixels, the unit of the X subwindow.
Place the subwindow from the view's rectangle in base coordinates, made
relative to the content view when the window manager draws the
decorations, and refuse only rotated views.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant