4

I'm after a way to:

  1. get list of all application windows currently open, as a Gdk or Gtk window
  2. remove window decorations for selected windows (maximised in my case).

I'd like to do this using mutter, gdk, wnck or gtk (or GdkX11, ...) (i.e. anything with gobject introspection).

I've seen the following question: Remove titlebar from maximized terminal window but am struggling with converting it to something that works.

(The language I'm using is javascript, but this is somewhat irrelevant since it's all using gobject introspection).

I'm currently using GNOME 3.2 (am open to GNOME 3.4 solutions though).


As to 1., I know I can get all windows with wnck and mutter fairly easily (e.g. Wnck.Screen.get_default().get_windows()), but how do I then convert these into G(t or d?)k windows in order to remove decorations?

I can convert a mutter window to a Gdk one like so:

xwin = GdkX11.X11Window.foreign_new_for_display( 
                          Gdk.Display.get_default(), 
                          mutterWindow.get_compositor_private()['x-window'] );

However, this xwin object does not respond to commands such as xwin.unmaximize() and xwin.maximize(), so I feel that something went wrong in the conversion!

The reason I want to convert the window into Gdk or Gtk is so I can use Gdk's set_decorations or Gtk's set_hide_titlebar_when_maximized.

I have had a look at Gdk.Screen.get_default().get_toplevel_windows() and Gtk.Window.list_toplevels() but these return lists of more windows than I have open, and I am unsure if my actual application windows are in the list and how to match them up.


As to 2., if I first get the active window from within Gdk (since I know it's a Gdk window and it responds properly to events such as unmaximize and maximize, unlike when I use foreign_new_for_display) and then try to remove decoration as per the previously linked question, the window (& process) dies! I'm not sure what the error is.

const Gdk = imports.gi.Gdk;

// get current window. It's a terminal, not null.
// For now assume it's maximized.
curwin = Gdk.Screen.get_default().get_active_window();
// decorations don't seem to updated unless I unmaximize & re-maximize
curwin.unmaximize();
// try remove decorations: window + process dies!
curwin.set_decorations(0);
curwin.maximize();

If I use curwin.set_decorations(Gdk.WMDecoration.BORDER) (note: GDK window documentation here), the window appears as I wish when the window is unmaximized (title bar gone), but when maximized, space for the title bar is still left, although the text itself is not shown.


Would anyone be able to give me insight into how to achieve either of my goals? (Ultimately, automagic titlebar hiding of maximised windows, like maximus for Ubuntu's Unity netbook remix). I really do wish to use this using Gtk/Gdk/wnck/mutter/anything with gobject introspection, as opposed to an external app like compiz or modifying the metacity window theme's XML (which I know you can do to achieve this).

1
  • I think the mutter --> gdk window conversion might not be working because the window actor's x-window property appears not to be the correct xid: if I get the same window as a Wnck window, win.get_xid() is different to mutterWinActor['x-window'] and the wnck-->gdk window works! May 4, 2012 at 1:54

1 Answer 1

3

After a bit of discussion with the gnome-shell devs, this was resolved.

The conversion I attempted to do in 1. was never an option - that sort of thing doesn't work.

The version in 2. was the correct code, but would only work if run from outside a gnome-shell extension (i.e. run the javascript file using the gjs binary as opposed to from the looking glass or an extension). It turned out that mucking around with window decorations like that from within the gnome-shell/mutter process would cause the crash.

So the problem could be solved so long as the code was run from outside the extension. Launching an external process to run the script in option 2) worked (although it turned out to be easier to just spawn xprop and set the _GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED atom to true on the window (identified by its X ID, being the child of the window with the window actor's XID).

(If anyone is interested the end result is the Maximus gnome shell extension)

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .