Repository navigation
[Linux] Add window rendering and drag controls - #192356
Conversation
Add Linux specific calls that give an app more control over how its window is rendered and let it move and resize itself: * setDecorated() turns off the titlebar and border drawn by GTK. * setAppPaintable() stops GTK filling the window with the background color of the theme, and setBackgroundColor() sets the color the view clears to instead, so a window can be transparent where the app does not paint. * beginMoveDrag() and beginResizeDrag() hand a pointer press over to the window manager, which then moves or resizes the window itself. Resizing takes a WindowDragEdge saying which edge or corner is being dragged. Windows are also given a visual with an alpha channel where the screen is composited, as one can only be chosen before a window is realized.
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Code Review
This pull request adds Linux-specific windowing features, including window resizing, dragging, transparency support, and background color configuration via GTK/GDK FFI bindings. Feedback suggests adding a destruction check in setDecorated to prevent crashes, using an explicit switch expression instead of .index mapping for enums to improve safety, and wrapping FFI memory allocations in a try-finally block to avoid memory leaks.
Using a destroyed window passes a freed pointer to GTK. The other calls on a window controller check for this first, so make setDecorated() do the same, and document it as the others are.
Add Linux specific calls that give an app more control over how its window is rendered and let it move and resize itself:
setDecorated() turns off the titlebar and border drawn by GTK.
setAppPaintable() stops GTK filling the window with the background color of the theme, and setBackgroundColor() sets the color the view clears to instead, so a window can be transparent where the app does not paint.
beginMoveDrag() and beginResizeDrag() hand a pointer press over to the window manager, which then moves or resizes the window itself. Resizing takes a WindowDragEdge saying which edge or corner is being dragged.
Windows are also given a visual with an alpha channel where the screen is composited, as one can only be chosen before a window is realized.