fix(linux): use gtk_window_set_geometry_hints instead of gdk_window_set_geometry_hints to enforce size limits#587
Open
axel10 wants to merge 1 commit into
Open
fix(linux): use gtk_window_set_geometry_hints instead of gdk_window_set_geometry_hints to enforce size limits#587axel10 wants to merge 1 commit into
axel10 wants to merge 1 commit into
Conversation
Using `gdk_window_set_geometry_hints` on the lower-level `GdkWindow` causes two major issues in GTK applications: 1. If window size limits (like `setMinimumSize` or `setMaximumSize`) are set before the window is realized (which is common during application startup), `get_gdk_window` returns `nullptr` and the sizing hints are silently ignored. 2. Even after realization, GTK's high-level layout cycle can bypass or override direct changes to the low-level `GdkWindow` hints. This commit replaces `gdk_window_set_geometry_hints` with the GTK-level `gtk_window_set_geometry_hints` on the `GtkWindow` directly. This allows GTK to cache the constraints internally, applying them correctly upon window realization and respecting them during GTK layout calculation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request fixes sizing constraint issues on Linux/GTK.
Previously, constraints such as:
setMinimumSizesetMaximumSizesetAspectRatiowere not taking effect correctly.
Problem
Currently, the Linux plugin implementation uses the low-level GDK function:
This approach has two major flaws:
1. Silent Failure during Window Initialization
If size limits are configured before the window is realized (which is the standard practice during application setup),:
get_gdk_window(self)(which calls
gtk_widget_get_window) returnsnullptr.As a result, geometry hints are silently discarded and never applied.
2. GTK Layout Override
Since GTK maintains its own layout and window state abstraction, raw constraints sent to the underlying
GdkWindoware often:Solution
Replace
gdk_window_set_geometry_hintswith the high-level GTK APIgtk_window_set_geometry_hints, targeting theGtkWindowdirectly:When targeting the
GtkWindowdirectly:This ensures that window sizing constraints work correctly and consistently on Linux/GTK.