Re: Why is it impossible to move a window programmatically in GTK+ (C/C++)



On 30 May 2018 at 18:33, Tarie Nosworthy via gtk-app-devel-list <
gtk-app-devel-list gnome org> wrote:

I am writing an app in GTK+, and I wanted to center a splash screen.
Coming from a Windows background, where SetWindowPos does the job, I found
out the X Window Manager always ignores requests to move a window,
therefore eventually denying any attempt to manipulative the position of a
window.  I can resize it, even dynamically, and I can move it with the
mouse, but never in code.  Why?  It seems very strange that GTK would just
disallow it.  You have gravity properties, but not matter what gravity I
set, the position NEVER changes.  Why have the APIs if GTK is free to
ignore them.  I'm baffled by it.


Hi;

some of the GtkWindow API work on a "best effort" basis; on X11, window
managers are wholly in charge of managing windows according to their own
rules and constraints, and they can ignore the hints set by an application.
Additionally, you can have other client apps that manage the window for you
— see, for instance, Devil's Pie[0], which gives you the ability to match
windows and execute scripts for them.

Additionally, if there is no window manager present — for instance, because
you're running a single window kiosk-style appliance — some functionality
like fullscreen won't simply be available, as it's part of a IPC protocol
with the window manager.

If you want, you can manage the window yourself — use a GTK_WINDOW_POPUP as
the window type, and then use your own decorations; you'll be in charge of
reimplementing window repositioning and resizing, but you're guaranteed
that the window manager won't interfere with your application.

As a side note: when using Wayland as a display server, you won't really be
able to deal with global coordinates and positioning, given that every
client surface operates in isolation.

Ciao,
 Emmanuele.

[0]: http://www.nongnu.org/devilspie2/


-- 
https://www.bassi.io
[@] ebassi [@gmail.com]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]