Off-screen windows with Inkscape on MacOS and XQuartz

My go-to editor for vector images is Inkscape. So much so that I use it in the creation of my cartoons and comic strips, and have been writing a monthly column about it in Full Circle Magazine for over six years now!

Just recently I’ve switched jobs and have to use a Mac as my day-to-day work machine, rather than the Linux box I’m used to. Whilst Inkscape is available for the Mac, there is no maintainer to release native builds. For most releases, therefore, the Mac offering is a straight port of the Linux version, and uses XQuartz as its X Server. Unfortunately XQuartz has more than a few “issues” – not least of which is a significant problem with multi-screen setups. At my new job they suffer from the delusion that more screens are better, so I have to work with a 3-screen arrangement that would make an air traffic controller proud.

The biggest problem with XQuartz on a multi-screen setup is that it has an annoying tendency to place new windows off-screen. This manifests itself in Inkscape as dialogs disappearing into the ether before you ever get a chance to see them. Open the Document Properties dialog and there’s a good chance it will be placed at some obnoxious coordinates that render it invisible to the user. The same with the Fill & Stroke dialog, the Inkscape Preferences, the Align & Distribute dialog, and all the others. If you get lucky some might appear where you can use them, but enough will go missing that it makes working with the program virtually impossible for anything but the simplest of uses.

This issue is well known to MacOS users of Inkscape, and has been reported on Launchpad at least twice, has its own entry in the Inkscape FAQ, and also crops up on the main Inkscape forum. There are various workarounds mentioned on those sites, but they’re all a little clunky, to say the least.

So I’ve crafted my own clunky (but hopefully slightly less clunky than the others) solution to the problem: a shell script to find all the Inkscape windows and move them to the top-left of the XQuartz screen. But that seemed like overkill when it’s usually just the last dialog you tried to open that you need to move. And what about other applications? Surely Inkscape can’t be the only program that XQuartz has problems with. So I expanded the script to cover all those cases.

1) You’ll need to install the ‘wmctrl’ program, which does the hard work of repositioning the windows. I installed it using Homebrew. (brew install wmctrl)

2) Download the script using this link

3) Please take a look at the script (it’s not that long) to confirm that it’s not sending all your bitcoins to me, or anything equally dodgy. Then you’ll need to make it executable by running:

chmod +x gather_windows.sh

4) To use it, open a terminal within XQuartz and run it with either no options, or a single option, as follows (this is the result of running with the -h option):

Usage: gather_windows.sh [option]
With no options : move the last opened window to the top left of the screen
-1, -p, --previous : move the previously opened window to the top left of the screen
-i, --inkscape : move all the Inkscape windows to the top left of the screen
-a, --all : move all the windows from all applications to the top left of the screen
-h, --help : show this help text
With any other option, try to find windows that match the string provided as part of their WM_CLASS property, and move them to the top left.

Note: the -1 option lets you open a terminal to run this script *after* your window has gone missing

E.g. gather_windows.sh xterm will move all your Xterm windows to the top left, gather_windows.sh -i will move only the Inkscape windows, and gather_windows.sh will just move the last window you opened. As the note in the help text suggests, if you try to open a dialog in Inkscape (or some other program) and it doesn’t appear due to rendering off-screen, you can then open a terminal and run gather_windows.sh -1 (or -p or –previous) to move the window to the top left.

Please note that this script probably isn’t very robust, and any efforts to move the “last” or “previous” windows are purely based on the assumption that wmctrl -l lists windows in the order they were opened. It has worked well enough for my purposes, but that doesn’t mean it will work for you.

For bonus points you can add the script to the ‘Applications’ menu in XQuartz, so it’s always readily available when you lose a dialog. In that case it’s best to call it with no options, so you can select it as soon as a dialog goes AWOL.

Leave a comment