Skip to main content

Hints for X11 on Mac OS X

One of the lovely features of Mac OS X, being based on Unix technology, is that it's possible to run X11 based applications with an almost native look and feel. Unfortunately this doesn't translate completely due to the way the X11 server is implemented. It is a single app, and all X11 windows are considered children of it, so the OS X window manager treats all X11 windows as a large group. This does mean, however, that those of us used to working with X11 apps in a different way to OS X native apps can do so, as long as you don't mind the slight mismatch of behaviour.

One of the first things folk notice about the OS X window manager for X11, quartzwm, is that the mouse focus model is completely unintuitive. Focussing a window requires clicking within it, but then activating controls requires another click. You can't just move the mouse over to a window and click, and expect anything to happen. This is usually resolved in one of two ways; turning on "focus follows mouse", or enabling "click through" to allow the window to respond to the focussing click as if it were already focussed.

When I'm using a linux window manager, I am happy working in either of these modes. For Gnome, I like to have click-to-focus, and for more lightweight WMs like Fluxbox, I prefer focus-follows-mouse. Fortunately, enabling either of these options for quartzwm (for Snow Leopard, anyway) is as simple as opening the preferences pane and clicking a checkbox. For OS X, I find that click-to-focus matches the rest of the OS best, so I enable click-throughs.

When using X11 on OS X, it is usually to use the Gimp. This is bundled as a self-contained application, and will launch the X11 server on demand. Of course, all the Gimp's windows are still considered a part of the X11 app, but the Gimp dock icon responds to drag-and-drop and other OS X features. It's a bit weird, but easy to get used to.

Enabling click-through makes working with the Gimp a lot more fluid. The multi-window interface is a pain to work with otherwise, because even something as simple as changing which tool you're using requires clicking the toolbox window, then clicking again to select the tool. It is very frustrating to click a tool and then try to use it, only to realise that a) the tool never got selected, because the WM swallowed the click before the Gimp could respond, and b) the tool window is now focussed, so trying to use the tool on the image will not work until you refocus it with yet another click.

For those of you who don't like using nasty, icky GUIs for something like changing WM preferences (why are you using OS X again?) there is a command line way to do it. In a terminal (or Xterm if you're so inclined), type one of the following to enable focus-follows-mouse (ffm) or click-throughs:
defaults write org.x.X11 wm_ffm -bool true
defaults write org.x.X11 wm_click_through -bool true
Another useful feature built into quartzwm is the ability to shut down the X server automatically when no windows are left. For those of use who only use the occassional X11 program, and are somewhat obsessive about not leaving programs running in the Dock that aren't actually in use, this is very useful indeed. To enable it, enter the following command into a terminal:
defaults write org.x.X11 wm_auto_quit -bool true
A secondary option allows you to specify a short timeout, in which the WM will wait for a few seconds to see if you start any more windows. If you do, quartzwm doesn't shut down and continues until all windows really have gone. It is very important to use this option if you use the Gimp. With a 0 second timeout, the X11 server will close as soon as the Gimp splash screen disappears, because it takes a moment for the main image window to appear. This fraction of a second delay is enough to make the X11 server disappear and take the Gimp with it, making it impossible to start up. I would recommend a 5 second timeout to make sure that all windows really are closed, and more importantly, no more are on the way before shutting down the X11 server.

To enable this feature, enter this command in the terminal:
defaults write org.x.X11 wm_auto_quit_timeout -int 5

Note that all this options are available in earlier versions of Mac OS X than Snow Leopard. For Leopard users, they are identical. For Tiger users, replace all references to org.x.x11 with com.apple.x11. This is because versions of OS X prior to Leopard used the now mostly defunct XFree86, while Leopard and Snow Leopard have moved to the much sexier X.org.

Comments

Popular posts from this blog

Fairy Lights

Street lights at night can be very pretty. For someone who lives close to the centre of a large city, skirting round the edge of the town centre can provide a host of beautiful views at night. One advantage to using a wide open lens when taking these pictures is the capture of bokeh, or creative blur. An extreme example is shown to your right; a mass of coloured circles that roughly represent the city they are part of. A more subtle example, of course, is in the picture of the day at the top of this post. The lights cluster around the top of the leaves like fireflies, obviously part of a cityscape but at the same time abstract. The extreme out of focus image is a blurred version of the picture on the left. A view over Sheffield from Pitsmoor, looking up Netherthorpe Road and up to the university. Even when the buildings are focussed (roughly; I'm still practicing) the lights take on the shape of the lens's aperture. I try to incorporate some foreground focus wh...

In which I complain that coding standards are a waste of time

Just kidding. I'm not going to rail against coding standards. No, I'm going to rail against the absolute and dictatorial enforcement of coding style guidelines, to the point where a single misplaced curly bracket can fail the code review of a thousand line project before it's even started. I'm going to rail against the fact that many people these days don't actually know that coding style guidelines and coding standards are not the same thing. Coding style guidelines are not coding standards. Coding standards are rules on how to construct software. Rules that have practical and defined benefits. Rules than can be proven to assist in the structured and correct building of code. For example: Do not perform database access in the constructor. All database access should use the framework's DAL. Do not rely on complex instantiation instructions; provide a factory method. Do not inherit from a class in a different module or library; only encapsulate. Avoid sin...

DeCSS on Ubuntu 9.10 and later

It used to be the case that enabling DVD playback on Ubuntu was a case of installing ubuntu-restricted-extras and that was that. Unfortunately DMCA nonsense in the US has buggered that up for all of us and so now there's an additional step. So, without further ado, here are the commands that need to be run at a command line: sudo apt-get install libdvdread4 sudo /usr/share/doc/libdvdread4/install-css.sh Voila! DVD playback a-la Ubuntu.