With GTK (GIMP Toolkit), an application toolkit for creating graphical user interfaces, you generally don't have direct control over the exact position of top-level windows when using Wayland because Wayland enforces strong separation between the client (the application) and the display server (the compositor). However, there are still ways you can suggest positions or manage how your GTK windows are handled.
Here's what you can do within the limitations of GTK and Wayland:
1. Dialogs and Transients:
For dialog windows associated with a parent window, you can use gtk_window_set_transient_for() to make one window a transient for another. This will hint to the compositor that this window is related to the parent window and should be positioned relative to it.
2. Window Placement:
Although you can't directly control the window position, you can set the initial size of a GTK window using gtk_window_set_default_size() which might indirectly influence the initial position based on the compositor's algorithm for placing new windows.
3. Fullscreen and Maximized States:
For certain use cases, you might want your application to take up the entire screen or be maximized. GTK allows you to start your application in a fullscreen state using gtk_window_fullscreen() or maximized with gtk_window_maximize().
4. Pop-up and Menu Positioning:
For pop-up menus or similar temporary surfaces, you can give the Wayland compositor hints about placement using APIs like gtk_menu_popup_at_pointer() or gtk_menu_popup_at_widget(), which allow the menu to be positioned in relation to a mouse event or a widget.
5. Fixed Containers:
Inside your window, you can position child widgets in a fixed manner using GtkFixed or GtkLayout containers. These do not affect the window position but allow you to control the placement of elements within the window itself. Use gtk_fixed_put() to place widgets at a fixed position within the container.
6. Custom Wayland Extensions:
If you absolutely must control the window positioning, and none of the standard GTK or Wayland methods work for your use case, you might need to create a custom Wayland protocol extension. However, this is complex and requires coordination with the compositor you are working with (such as Weston).
Here’s a small example using GTK to create a window and set it to a specific size: