Re: Which toplevel window is on top?



On Sun, 2015-12-20 at 19:22 +0000, Emmanuele Bassi wrote:
Hi;

On 20 December 2015 at 18:01, Richard Shann <richard rshann plus com> wrote:
I would like to know which of the top-level windows in my application is
on top. Is there a way of doing this? I see that

You can only see if your window has focus or contains the pointer —
i.e. it's the one that the user is interacting with at this very
moment. That usually implies that the window is at the top of the
stack maintained by the window manager. You could also check if the
"always-on-top" bit is set, but obviously that does not guarantee that
the user is interacting with the window.

Any other information about the window stack is maintained by the
window manager itself, and you'll have to ask that component, using
window manager and platform specific API, if an API is even exposed.

------------------------------------------------------------------------
GdkEventVisibility has been deprecated since version 3.12 and should not
be used in newly-written code.

Modern composited windowing systems with pervasive transparency make it
impossible to track the visibility of a window reliably, so this event
can not be guaranteed to provide useful information.
-------------------------------------------------------------------------
but is there an alternative for my (simpler) question?

There is, sadly, nothing "simple" about your question. It truly
depends on the platform, and on top of that, it depends on how your
windows are managed.

For instance, in a tiled window management policy, windows are not
stacked — hence, there is no conventional "on top". Compositing window
managers on X11, such as Mutter or Compiz, may re-arrange the windows
as displayed to the user, even if the user cannot interact with them
outside of the existing stacking order; again, "on top" is not
something that can be conveyed to an API, when your windows are in
"exposé" or laid out on the faces of a 3D solid. Finally, on Wayland,
each surface has no knowledge of anything outside its own coordinate
space; there is no way to access the windows stacking, and for all
intent and purposes, your window manager may put the application's
window on Mars.

The only reliable way thing you can know is if the user is currently
interacting with a window you're presenting, via pointer, touch, or
keyboard events; either because the pointer or a finger entered the
window, or because the window has key focus. GTK+ provides you with
events to let you know when any of those things happens.

Thank you for your clear and comprehensive explanation. I think I will
need to provide an option to move all the windows inside a single
application window, or two if there are two screens.

Richard




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