2008-10-29: Metacity Journal

Another day, another Metacity Journal, and your chronicler still has not resurrected the script.

Bugs

As ever, feel free to dive in with any of these.

  • GNOME bug 558058, Launchpad bug 258054, and possibly Launchpad bug 266929 were obscure bugs caused by dereferencing the values of GConf keys which are never null on a properly-configured system; changes in GDM allowed Metacity to be run sometimes without values for these keys, exposing the crashes.  Now fixed.
  • GNOME bug 558309: Leonardo Ferreira Fontenelle noted that some names of variables weren’t double-quoted in error messages.  Now fixed.
  • GNOME bug 557921: Lennart Poettering suggests adding sound effects to Metacity.  What are your thoughts, gentle reader?

Around the blogs

There was a lot of discussion about theme patriation on gtk-list for apps such as icanhasedit; almost all the responses were negative.  This diverged into a discussion about window matching, which Thomas has promised a blog post on soon.

Metacity Journal, 2008-10-23

Recent activity

  • GNOME bug 557536: Ka-Hing Cheung noted on this blog that wmctrl wasn’t able to make Metacity windows stick.  Thomas investigated and found that this is because that part of the EWMH had never been implemented.  It now has been.
  • Several bugs cropped up in 2.25.2 almost immediately, which have all been fixed, and we are now on 2.25.5.
  • Creating Metacity Themes, which began as a post on this blog, gets its first version on library.gnome.org thanks to Murray Cumming.
  • The double-click-to-close issue is still attracting comments.  Gentle reader, if you want this feature, please persuade your distro maintainers to consider it and not us, since we have done it to death here.  When they approve it, we’ll consider it.
  • We still haven’t come to much of a consensus over the present() issue, so it may need an overview of the overview.  Your chronicler suspects that the ultimate solution is going to be twofold: we probably need to change the default, and we also need to extend the EWMH to allow apps to hint which behaviour they prefer.

Around the blogs

Something to consider

  • Do you think it’s about time we flipped the default of the compositor switch to “enabled”?

Till next time…

2-25-5 released

What is it ?
Metacity is a simple compositing window manager that integrates nicely
with GNOME 2.

What’s changed ?
Thanks to Thomas Thurman for improvements in this version.

  • Allow third-party apps to decide whether a window appears on all workspaces (Thomas ) (GNOME bug 557536)
  • Fixed keybindings script (again) (Thomas)

Translations
David Planella (ca), Robert Millan (ca@valencia)

Where can I get it ?

bad30bc7a0e935a1dd0ed31f863dd05f  metacity-2.25.5.tar.bz2
9ff4b32d3255ad477ae1f1273b8e0abb  metacity-2.25.5.tar.gz

2.25.3

Brown paper bag release which fixes numerous build problems from last night’s release of 2.25.2.  Apologies.

Thanks to Murray Cumming, Thomas Thurman, and Götz Waschk for improvements in this version.

3b75c97082aa3a178d8cbb61c940cb59  metacity-2.25.3.tar.bz2
92be1a957eaef575e78e3410c004e92d  metacity-2.25.3.tar.gz

2.25.2 released

This release is broken.  Use 2.25.3 instead.

What is it ?
Metacity is a simple compositing window manager that integrates nicely with GNOME 2.

What’s changed ?
Thanks to Joe Marcus Clarke, Murray Cumming, Tomas Frydrych, William Lachance, Matthew Martin, Christian Persch, Thomas Thurman, and Vincent Untz for improvements in this version.

Translations
Yavor Doganov (bg), David Planella (ca), Kenneth Nielsen (da), Hendrik Richter (de), Ivar Smolin (et), Claude Paroz (fr), Seán de Búrca (ga), Launchpad Translations Administrators (hr), Gabor Kelemen (hu), Thomas Thurman (la), Žygimantas Beručka (lt), Kjartan Maraas (nb), Duarte Loreto (pt), Djavan Fagundes (pt_BR), Mugurel Tudor (ro), Pavol Šimo (sk), Laurent Dhima (sq), Горан Ракић (sr), Theppitak Karoonboonyanan (th), Funda Wang (zh_CN)

Where can I get it?
Don’t.  Use 2.25.3.

98f5039beebdb3bca5d3be7f0fd93d95  metacity-2.25.2.tar.bz2
f1fa487eea2213a2ac3e6c7c4d6fe3d0  metacity-2.25.2.tar.gz

Know all men by these presents…

sheep  &  her lambI tried to discuss the gtk_window_present() problem earlier, but I only managed to confuse myself. So here’s an extra rundown; perhaps we can move towards solving it.

The problem is that there’s a call, gtk_window_present(), which is very vaguely specified:

Presents a window to the user. This may mean raising the window in the stacking order, deiconifying it, moving it to the current desktop, and/or giving it the keyboard focus, possibly dependent on the user’s platform, window manager, and preferences.

There are at least four ways of dealing with this request.  I hope I can establish a consistent terminology for them here.  Suppose we are looking at workspace 1, and an application attempts to gtk_window_present() an existing window on workspace 2.  We can:

  • Summon: the window is moved to workspace 1, so now we’re looking at it.
  • Visit: the window stays still, but we move to workspace 2, so we’re looking at it.
  • Pulse: the window stays still, we stay on workspace 1, but we set “needs attention” so it pulses on the taskbar.
  • Nothing: we do nothing.  This is allowable, but I think we can discount it.

gtk_window_present() is implemented using _NET_ACTIVE_WINDOW, which according to its specification allows the WM to make the requested window active (which could mean either Summon or Visit), or Pulse, or Nothing.

Many applications use gtk_window_present(), and because of the vagueness of the spec, there’s no agreement on what they mean by it.  Three instances which have been identified are:

  • Firefox. If you click a link in your email program, it will summon your current browser.  If this is Firefox, and it’s appearing in a new tab, it will gtk_window_present().
  • Pidgin. If someone talks to you, it will gtk_window_present() the chat window.
  • Nautilus. If you use one window per directory, and you request a directory that is already open in another workspace, it will gtk_window_present() the window for that directory.

The disagreement extends even to what Metacity should do when asked to present windows in each of the cases above.  Here are some opinions; feel free to add your own in comments, or tell me where other people have asked for something, and I’ll update this:

  • Firefox: Kevin Downey says we want Pulse.
  • Pidgin: technicull says we want Summon. The devs themselves say they don’t care as long as it’s not Nothing.
  • Nautilus: I think we want Summon here.  David agrees.

Some things which Metacity should not do:

  • Decide which to do based on the application.  This is window matching, and thus a recipe for pain.
  • Add a switch somewhere.  As Havoc said, this boils down to asking “Do you want to break Firefox, or Pidgin?”  And many people (including me) run both.

When people complain about Metacity’s behaviour in this matter, it’s hard to tell whether they’re complaining about upstream or downstream Metacity.  Upstream Metacity does Summon in all cases.  Ubuntu has patched to do Pulse (except for dialogues, which do Summon), as has Fedora, and I believe SuSE has too.  As policy, we usually reconsider policy when several major distributions make the same change, and this means we should probably stop to consider what to do here.

It might be possible for the app itself to hint in the EWMH message which behaviour it wants, if it doesn’t want the default.  Patryk Zawadzki says that the behaviour should depend on the user’s action; if the user carried out some positive action to cause the gtk_window_present() (as in the Firefox case), it should result in Visit, but if it happened through some external event (as in the Pidgin case), it should always result in Pulse. Mathias Hasselmann concurs.  I think this seems a reasonable plan, but the distinction between events generated by the user and not is one which the app is best placed to make, and so we probably also need a hint here.  I’m happy to add hinting as a test; however, the default option will necessarily be “don’t care”, and therefore we will still have to choose a best option as default.

I think most applications may be happy with a default of Summon, and that a default of Pulse is at least better than Visit in most cases, but I’m entirely willing to be convinced otherwise.

What do you think?

Photo © jan glas, cc-by-nc-nd.

Annotations

Perfection in the MarginsMany people, from various programming communities, have come to the conclusion that if functions are first-class objects they should be allowed properties. For example, if a function in a test suite is checking for regression of the fix to a particular ticket, it could have a property for the ticket number. Then other parts of the code can deal with it in a consistent way through introspection, without keeping related information all over the place.

In Java, these are known as annotations and look like this:

@ticket(177177)
public static void testFrobulation () { ...

Python also calls them annotations (replacing the older system of decorators, which looked similar to the Java syntax but achieved its effect in a way more like Lisp macros). Annotations in Python look like this:

def testFrobulation(ticket: 177177): ...

In the past few months, two infelicities of the Metacity codebase presented themselves. Firstly, some translators complained, rather reasonably, in GNOME bug 469361 that the same information was repeated over and over again in the long descriptions of the keybindings.  Secondly, the same information about keybindings was repeated over and over in several places in the code, and in many of those places it was required to stay in the same order as the other places and would cause subtle breakage if it didn’t.  And of course, when anyone provided a patch to add a new keybinding it needed to modify several more files than would seem really necessary.  What would have been best is to be able to write something like

static void @keybinding ("Activate the window menu", "<Alt>Space")
handle_activate_window_menu (MetaDisplay    *display, ...

But you can’t really do annotations in C (despite a half-arsed attempt by Microsoft). Or can you?

In Dr Dobb’s Journal of May 2001, Randy Meyers introduced an idea called x-macros. This idea is the mildest of preprocessor abuse: you create a file containing lines of grouped data, like these:

item (switch_windows, "Move between windows, using a popup window", "<Alt>Tab")
item (switch_to_workspace_1, "Switch to workspace 1", NULL)
...

Then you #include the file anywhere you want to work with this data, but you #define item() as appropriate each time.  This way, the data only needs to be modified in one place, and it’s guaranteed to stay in order.  It occurs to me that what we have here is pretty close to annotation.  True, it’s in another file, but C also requires that the prototypes of public functions be in a separate file, and nobody minds about that.

So Metacity in trunk is now working fine using this system.  There are a few places it could be neater;  screen and window bindings have always been kept separate, but it would possibly make sense to keep them together and distinguish them (as they already are distinguished) by the cunning use of flags.  Also, the handler functions should probably be given by name and not calculated from root and suffix, because it’s just confusing.

This whole idea also means that the GConf schemas which concern keybindings can be generated during the build process, which solves GNOME bug 469361 rather neatly.  In conversation with Rodney Dawes it also came up that most of the short and long versions of the keybinding descriptions say the same thing in twice in different words, which is an unfair burden on the translators.  I have merged them as appropriate: the number of strings has gone down by about thirty, and the .pot file is now 70% of its former size.

Photo: Perfection in the Margin, © Adam Shaylor, cc-by-nd.

Metacity Journal: 2008-10-16

SalmiakkiWelcome back to the Metacity journal, your (more or less) daily roundup of all things Metacity. Okay, so it hasn’t happened for six months and I did this one by hand instead of with the script. Anyway, feel free to poke your nose into any of these conversations.

GNOME bug 556464: Michael Terry wanted to remove the dialogue box which says that an application doesn’t play nicely with the session manager.  The reason is that it stays up indefinitely and most users don’t care.  Michael provided a patch which added a GConf key to disable it.  Thomas said that a new key for something as trivial as this would be a bad idea, and it would be better just to disable it.  Havoc said that it had already been considered somewhere, but nobody’s yet found that bug.

GNOME bug 401028: Quite an old bug; unshading a shaded window doesn’t focus it as it should.  There was a patch which rotted; Thomas rewrote it to apply to trunk.  Shaun McCance tested it and reports that it fixes the bug but causes intermittent crashes, so it’s not going in quite yet

GNOME bug 96743: Okay, this is a REALLY old bug.  Should you be able to drag a window to an adjacent workspace by pushing it off the edge?  Calum has recently added that he believes you should, and since IIRC he’s on the HIG team, that carries quite some weight.

GNOME bug 555489: Luke Hutchison wants a generalised way to fullscreen any application, similar to the maximise button.  Havoc says this is really an app problem because there’s so much app-specific information the window manager would need to know in each case.

There was a GNOME doc list discussion about this theming tutorial from 2002. Murray Cumming asked whether it was current. Thomas said it was not particularly current and that this blog post was a better source, though there were some lacunae. Murray suggested that it could be changed into docbook and kept in the Metacity tarball, which Thomas thought was a good idea; Thomas further suggested that some of the other tarball information be changed to docbook at the same time.

And Metacity became the first GNOME program to have a (very partial) Latin translation.

What people are saying about Metacity:

That’s it for today, folks.  More next time.  Also to come: fun with annotations, rethinking the responsibility of themes, and being nice to translators.

Image: salmiakki, © Laurence Livermore, cc-by-nc.