[Xlib] Force Raise/Map/Focus a given Window
Owen Taylor
otaylor at redhat.com
Tue Aug 12 09:42:14 PDT 2008
On Mon, 2008-08-11 at 14:25 -0500, Andrew Troschinetz wrote:
> Hi,
>
> I'm trying to force raise/present/focus a window in Gnome/Metacity
> 2.18 (RHEL5) but it seems like a "don't steal focus" feature is
> preventing me from doing so. The following code works in Gnome/
> Metacity 2.8 (RHEL4), but note quite in RHEL5.
>
> What I mean is: If the window is minimized (unmapped) then the
> following code will map, raise, and focus the window correctly in
> either RHEL4 or RHEL5. But in RHEL5 only, if the window currently
> doesn't have focus, but is mapped and raised (say another window has
> focus and is ontop of the window I want to present), then the
> following code only results in the taskbar item for the window blinking.
>
> So my question is, is there a problem in my code? Is there a known
> workaround for this, some Xlib function I should be calling here? Or
> does anyone happen to know off the top of their head if this is a new
> feature in RHEL5 that can be easily disabled?
You can:
A) Get a current server timestamp by changing a property and looking
at the timestamp on the subsequent PropertyNotify event.
B) If mapping a new window, use that timestamp for _NET_WM_USER_TIME
C) To activate an existing window, send a _NET_ACTIVE_WINDOW message to
the root window with that timestamp
(See the extended window manager hints specification for details about
the _NET_* properties and messages.)
I think _NET_ACTIVE_WINDOW should be supported in RHEL4 as well, so you
don't need to check for a supporting window manager.
A little complicated to do maybe, but that's the nature of using Xlib
directly.
- Owen
More information about the xorg
mailing list