Metacity is Lame

Many years ago, back when I was a major fan of ctwm, one of many old window managers that provided multiple desktops and more configurable options than you'd ever need, I had installed linux on a laptop and apathetically allowed it to install gnome. This wasn't going to be a permanent installation, so I didn't really care much about having to use gnome for a little while. To my surprise, I found that I actually kind of liked it compared to my previous experience with gnome. This was probably because of 3 things: 1, computers are much faster than they were back then and gnome didn't seem insanely slow; 2, I didn't have to spend hours fiddling with my .ctwmrc file to make everything perfect; and 3, it was actually fairly usable and inoffensive. From this point on, I allowed linux installers to just install gnome and I'd simply use that instead of ctwm, partially out of laziness and partially because ctwm development seemed to have stopped. Now, I loved ctwm, it had everything I ever wanted in a window manager and I never really cared about things "looking nice", but the more that I used gnome/metacity (metacity is the actual window manager) the more I simply got used to it, quirks and all.

One of the first things I had to do was get rid of all those useless gnome-panels. I kept one of them, in the event that I want to check a calendar, see what the weather is outside, or see the temperature of my CPU/HD/Battery. But I couldn't make it hide completely. The remedy was quick and easy, find the auto_hide_size option in the panel gconf file and set it to 1. Now, I don't have to see that retarded thin white bar at the top of my screen anymore. I didn't need to be reminded that there was a gnome-panel hiding up there, I know it's there, I PUT it there.

This was when the many features which were not user configurable started to get on my nerves. First, I thought all the metacity themes were lame. Most were too flashy, and all of them took up too much desktop space. I ended up reluctantly using one that had the smallest borders and the smallest titlebar. I tried to make my own theme, specifically with 1 pixel borders (in order to see which window was in focus) and no titlebar, but metacity would always shit itself when I set the titlebar to be 1 pixel by attempting to draw text where no text (should) could be drawn. It wasn't until I discovered the has_title boolean option that I finally was able to live my life without useless titlebars and ugly oversized borders. You can download my theme, HERE and here's even a screenshot.

I don't think the majority of the features gnome/metacity provide even applies to me, I don't even startup nautilus. When I log in through gdm, all the windows that I use are started up for me, gaim (oh wait, it's called pidgin now), the 30 or so urxvtc terminals, firefox, and xload, all of which have a predetermined frame geometry and placement. The only other windows that I open from this point on is maybe the GIMP, some games, OO when I need to read a word doc, evince when I need to read a pdf, and mplayer when I'm watching video. There's not a lot of moving windows around and placing them in my daily user experience and 100% of all my desktop real estate is covered by windows upon gnome's startup. For the most part, metacity's "smart" placement doesn't even get to do any work. Also, I kind of like the resistance when moving a window off the screen or over other windows (a feature that grew on me from fvwm and something that I sometimes wished ctwm had thereafter). The problem I have is when I give something like rxvt a frame geometry and a placement, and metacity takes it upon itself to shrink the window in order to make it fit within the desktop. I stated that I wanted it to be placed that way, yet metacity thinks it knows better. I've yet to find a way to turn this off through the configurable options, and I've even seen bug reports filed to ask for a configurable option to turn off similar window placement behavior. Fed up with this, I finally went through the metacity code for a personal fix. While following the placement code, I came upon the constraints.c file:

typedef enum
{
  PRIORITY_MINIMUM = 0, // Dummy value used for loop start = min(all priorities)
  PRIORITY_ASPECT_RATIO = 0,
  PRIORITY_ENTIRELY_VISIBLE_ON_SINGLE_XINERAMA = 0,
  PRIORITY_ENTIRELY_VISIBLE_ON_WORKAREA = 1,
  PRIORITY_SIZE_HINTS_INCREMENTS = 1,
  PRIORITY_MAXIMIZATION = 2,
  PRIORITY_FULLSCREEN = 2,
  PRIORITY_SIZE_HINTS_LIMITS = 3,
  PRIORITY_TITLEBAR_VISIBLE = 4,
  PRIORITY_PARTIALLY_VISIBLE_ON_WORKAREA = 4,
  PRIORITY_MAXIMUM = 4  // Dummy value used for loop end = max(all priorities)
} ConstraintPriority;

All that needed to be done was change PRIORITY_ENTIRELY_VISIBLE_ON_WORKAREA to something small, and to play it safe, I changed it to -1. In other words, I don't care about this constraint, placing things off the desktop is OK. This solved half of the problem. Now I can make a window pop up that is taller than my desktop and metacity won't shrink it to fit, however, there is still the placement problem; metacity wants to make it flush to the top, even if I specifically place it otherwise (i.e. I want it to be flush at the bottom, a -geometry of -0-0). This was taken care of by simply setting PRIORITY_TITLEBAR_VISIBLE_ON_WORKAREA to -1 as well, since THERE ARE NO TITLEBARS! Note that setting these to 0 does not seem to have the desired effect. So now I have all my rxvt windows that are a little taller than my desktop (by 1 pixel) align themselves flush with the bottom of my screen and hang off the edge of the desktop along the top (by 1 pixel), and, I get one extra line of text in each one of my terminals, but more importantly, there is no more 10 pixels of wasted valuable desktop real estate. The setting these constraint priorities to -1 does have its unintended side-effects, however. On rare occasion a dialog window will pop up and some of it will be off the screen, but for me, this is a small price to pay. So far, the only occurrence is the GIMP's open file window, everything else seems to behave as if nothing has changed.

I'm sure there's a better way to do this. I didn't spend much time going through metacity's code and I'm definitely not very familiar with it. Maybe if I get bored, or if I get tired of constantly having to change these 2 numbers each time there's a new metacity ebuild in the gentoo portage tree, I'll look into a better solution, perhaps grab the dev source, perhaps add these values (for the entire enumeration) in the prefs.c file, perhaps making it configurable through more accessible means. I had originally thought that fiddling with the place.c file would solve my woes (and a better fix may exist there), but the quick and dirty I-just-want-this-to-do-what-I-want-now solution was to change these 2 values.

Filed under: Computers


HOME, CONTACT, TWITTER