-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to influence where new windows are created? #58
Comments
There's definitely no way to do this cross-platform, as the window manager has complete control over where windows appear. On Linux Wayland or x11 you can get the native pointer to the window and call a Wayland or x11 function on it, but on Windows I'm not aware of a mechanism to set the exact positions. Mousetrap lacks this feature because of GNOMEs (the developers of GTK4, which Mousetrap is just a wrapper of) design choices, see here for one of the main developers' justification for removing this feature. I personally agree, as being able to set the exact position would violate modern operating systems window layouts, like pinning the window to one side of the screen or next to another window. The window manager should have full control, not the app. On my Linux fedora and Windows 10 machine, your example spawns the window at the same position every time, so I can't reproduce the random position behavior. Either way, the correct way to do this is to use the transience property of a window to make sure a window is always spawned on top of another. You have to remember that most GUI apps will have a mostly full-screen window, not a tiny window with just one button, so when spawning a window on the screen, as long as that window isn't tiny and is spawned on top of all other windows, the users will be able to adapt and not get disoriented. |
Interesting. I agree that the window manager should control the exact window positions. I just hoped to get the smaller window spawn to spawn "inside" the main one or to at least get rid of the randomness (whereever that comes from). As for the the transience property, running main() do app::Application
main_window = Window(app)
other_window = Window(app)
set_transient_for!(other_window, main_window)
end gives me the error
|
Wait what, there's a typo, how have I or someone else not found that yet, let me fix that real quick |
Until #59 is merged you can use this function instead: function set_transient_for!(self::Window, other::Window)
detail.set_transient_for!(self._internal, other._internal)
end It just makes it so Thank you for finding the typo |
I just gave you a stacktrace, you found the typo ;) I can confirm that using this function not only works but also got rid of any randomness for me. |
When opening a new window, say via an action set to a button the new window opens up at a rather random place. Closing the window and opening it again, it appears in a entirely different place every time. Is there some way to influence this?
A small example:
Device specifivations:
Device name: DESKTOP-Q9AJ3HU
Processor: Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz 4.10 GHz
Installed RAM: 16,0 GB
System type: 64-bit operating system, x64-based processor
Pen and touch: No pen or touch input is available for this display
Windows specifications:
Edition: Windows 10 Pro
Version: 22H2
Installed on: 16/12/2020
OS build: 19045.3930
Experience: Windows Feature Experience Pack 1000.19053.1000.0
The text was updated successfully, but these errors were encountered: