Inkscape (or other XQuartz) window disappears when using external screen

screenx11xquartz

I have this issue where Inkscape does not appear when my MacBook Pro is plugged to an external screen. I tried several windows management tools (like Spectable, or Stay) but these did not work for the XQuartz app.

Best Answer

It seems like the issue is that when I plug the external screen, it messes with the coordinate system of my Mac's screen, effectively shifting the origin of my screen by the resolution of the external screen.

In other words, from the point of view of XQuartz the origin of my Mac's screen changes from 0,0 to 2560,1440 (which is the resolution of my external screen).

This means that if Inkscape is somewhere near origin (0,0) but still associated with my Mac's main screen then it doesn't appear on the external screen nor in my main screen. It is basically in "limbo" between the 2 screens.

The solution is to move the Inkscape window to a new coordinate that takes into account the size of the external screen, and this is where wmctrl comes in useful:

brew install wmctrl
wmctrl -r Inkscape -e 0,2560,1440,1200,700

Of course you need to replace 2560,1440 with your own external screen's resolution and 1200,700 to suit your main screen resolution.

In order to make it more convenient I created 2 alias, to fix the coordinates for my Mac screen and for the external screen, respectively:

alias fixInkscape='wmctrl -r Inkscape -e 0,2560,1440,1200,700'
alias fixInkscapeExt='wmctrl -r Inkscape -e 0,0,0,2560,1300'

Remember that each alias only works for the screen that Inkscape is associated with, you still need to drag-and-drop the window in order to switch screens. wmctrl won't do it automatically, but it certainly helps in "fishing" it from limbo.