Question

Is there a way to force a gtk.Window object to ignore the Window Manager's show/hide commands, such as "iconify" and "show desktop?"

I'm trying to create a persistent window, stuck to the desktop, that will not disappear with all other windows when the desktop is exposed.

EDIT: I guess what I'm wondering specifically is whether or not it's possible to reproduce the behavior found in applications such as docks, desktop widgets, system trays, etc. using PyGTK?

Was it helpful?

Solution

You've got it backwards; it's not the window manager telling the window to minimize, by sending it a command. The window manager owns the window, if it wants to stop mapping a window, it will just do it, without asking the window for permission.

So I would think that the answer is "no".

OTHER TIPS

Try setting the GdkWindowTypeHint on the GtkWindow:

gtk_window_set_type_hint(the_window, GDK_WINDOW_TYPE_HINT_UTILITY);

There's also various methods for not having your window listed in pagers or taskbars and have it show up on all desktop. Keep in mind that all this behavior depends on support from the window manager. Unless you use something really old, this should not pose a problem though.

From the list of window type hints, only a two are still shown when you click the show desktop button:

  • gtk.gdk.WINDOW_TYPE_HINT_DESKTOP
  • gtk.gdk.WINDOW_TYPE_HINT_DOCK

Both of these cause your window to lose decorations (i.e. no borders or titlebar) so moving/resizing is up to your app. DESKTOP causes the window to be always behind other windows. DOCK causes it to be always in front.

Choosing SPLASHSCREEN give you an undecorated window that still hides when you click show desktop.

If you want a borderless, immobile window that still shows when the user clicks "show desktop" use:

window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)

before you call window.show(). Once the window has been displayed, you can't change its type.

Not having received a "this is how to do this" answer and having done a bit more research I can say that -- as far as I know -- there is no easy way to achieve this sort of functionality with PyGTK. The best options are to set window manager hints and leave it up to the WM to do what you want (hopefully).

I think gtk_window_set_type_hint(window, GDK_WINDOW_TYPE_HINT_SPLASHSCREEN) is what you want. It is also GDK_WINDOW_TYPE_HINT_DOCK, but then the window stay on top of all, and you can't send it back.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top