Re: Some interesting questions.



Stephane Duguay wrote:

Hi,

I have 2 questions.

1) I want to make a window always on top.  I've tried using
gtk_window_set_transient_for(...);  I'm using KDE and my window doesn't stay
on top.  Even If it had worked, the window would only be "on top" of that
window... I would like to have a "always on top" window for all windows.
There's maybe a lower level way to do it... any help welcome :-)

Assuming your window manager supports hints, you can use XSendEvent() to sent a
hint to the root window to request a layer change for your application window.

It goes something like this:

#include <gdk/gdkx.h>
#include <X11/Xlib.h>

XEvent xev;

xev.type = ClientMessage;
xev.window = GDK_WINDOW_XWINDOW(your_window->window);
xev.message_type = XInternAtom(GDK_DISPLAY(), "_WIN_LAYER", False);
xev.format = 32;
xev.data.l[0] = 10;

XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), False,
           SubstructureNotifyMask, (XEvent *) &xev);

where xev.data.l[0] is the layer.  4 is the normal window layer - just use a
number higher than that to keep your application window above all other normal
application windows.  Under GNOME, 10 is the "above dock" layer which will keep
a window above the GNOME panel, as well.  The "_WIN_LAYER" property is what
GNOME-compliant window managers use... for KDE it may be different.

I just tested the above code and it works under GNOME and Sawfish.  I don't
have KDE installed on my machine, so I don't know if this will also work with
the KDE window manager.


-Josh




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