I have gtk+3.0, does anyone know how to get the screen width and height? this seems like it should be simple, on x11 it works fine, but Wayland it doesn’t work. It’s such a basic requirement I’m sure it must work and I’m just doing something wrong.
I also tried gdk_monitor_get_geometry, the main problem it seams is that gdk_display_get_primary_monitor(display) returns null on Wayland. I read somewhere that it’s not implemented in Wayland. Ok, so how can I get width and height of the screen?
First of all, there’s no work area on Wayland. Second, as you noticed, there’s no primary monitor on Wayland either.
If you want to know the size and geometry of each monitor, you will need to iterate over them.
In practice, though, most of the cases in which you want to get the monitor geometry are generally suspicions, since you cannot do much with that knowledge; what are you trying to achieve?
im trying to provide my users an api to 1. get the width and height of the screen and then, if so desired 2. move the window within that space. Do you know of a simple example for iterating over them?
You can’t do that in Wayland. Each top level surface exist in an isolated coordinate space, with (0, 0) as the top-left corner of the surface itself. The only surfaces that can be moved around are popups, and they can only be moved within the coordinate space of their parent top level surface.
You cannot programmatically move a top level window in Wayland, because you don’t have access to the global coordinate space.
The idea is that malicious applications cannot create an override redirect window, place it upon the password entry of your web browser or password manager, grab the keyboard and pointer devices, and swipe your passwords.
Only privileged components can have access to the whole of the display, meaning: only the compositor.
what should i do to determine the initial size of my window? like, let’s say i want it to be 80% of the width and height of the screen. in that case should i iterate over the screens? if so, do you have a simple example or can you point me to one?