Showing posts with label X11. Show all posts
Showing posts with label X11. Show all posts

Tuesday, 16 January 2018

XQuartz move offscreen windows back on-screen in macOS/OS X

Problem:

I have several XQuartz/X11 windows in macOS/OS X that are offscreen. I want to move them on-screen so I can save my work.

Example scenario:

You can create an example of off-screen X11 windows when using macOS/OS X with an external monitor and a screen geometry where one monitor is higher and further left to another (scroll down to see a screenshot example).

In the lower-right monitor, when opening certain windows in programs like Inkscape, those windows will be created at coordinate that you cannot access with your mouse cursor.

Workaround:

Pre:

  • If not already installed, then install xdotool (easiest way is to use Homebrew)

To find out window ids and geometry:

  • In Terminal, you can use:
    xwininfo -tree -root
  • If you want to filter by an application, you can pipe to grep, for example:
    xwininfo -tree -root | grep "inkscape"

To move a window to a visible coordinate:

  • If not already installed, then install xdotool (easiest way is to use Homebrew)
  • Make note of a valid coordinate. Use the output of xwininfo from the above step to find a visible top-left coordinate for your window (e.g. it can be an existing window that you can already see and use with your mouse. In the screenshot below, a visible coordinate is 1070 1102)
  • In Terminal, use the following command and replace [options] [window] [x] [y] with the appropriate values:
    xdotool windowmove [options] [window] [x] [y]

Example:

Consider the following window geometry:

Inkscape has spawned the "document properties" window to a coordinate that is out of desktop 1:

Use xwininfo to find out window IDs, geometry, as well as to to find a set of on-screen coordinates:

Use xdotool to move off-screen window to an on-screen coordinate on desktop 1:

If all goes well, the window should now be visible.

Now would be a good time to save your work.

Also note that there might be some unexpected behaviour for XQuartz windows moved this way (e.g. "show all windows" still shows incorrect placement, etc.)

Where to go from here?

Some ideas:

  • write a script to automatically collect all windows of a certain app into visible coordinates if they're not visible
  • if you're able to and have the time to volunteer, contribute to the XQuartz project a feature to collect or clamp all windows to a given desktop :) (thanks in advance!)

Notes:

This workaround was verified to work with macOS Sierra 10.12.6, XQuartz 2.7.11, xdotool 3.20160805.1. Other versions may have different results.

References:

Thursday, 5 December 2013

Workaround to place XQuartz/X11 apps on second monitor in OS X Mavericks (apps like Inkscape)

Problem:

I've upgraded to OS X Mavericks and I can't place apps such as Inkscape on my second monitor any longer. I don't want to turn off "Displays have separate Spaces."

Before trying this workaround ...

This workaround was written as a reminder for myself. Even if you get it to work, X11 programs will be riddled with bugs because of how Mavericks currently treats Spaces coordinates, gravity, etc., with XQuartz. Thus, I'd recommend not following it for the time being unless you're curious. A better workaround is to simply turn off "Displays have separate Spaces" in: System Preferences ... -> Mission Control

This workaround only works under very specific conditions right now, and there is no guarantee that it will work under other conditions. The following are the conditions under which this workaround worked:

  • The OS X Team nor the XQuartz team have not addressed the issue yet (test this out to make sure that you're not using a workaround when things actually work)
  • OS X version is 10.9
  • XQuartz is installed and works
  • XQuartz version is XQuartz 2.7.4 (xorg-server 1.13.0) or under (haven't tested it with newer versions, and newer versions may fix this problem rendering this workaround pointless)
  • Inkscape and other X11 apps run
  • "Displays have separate Spaces" is checked under: System Preferences -> Mission Control
  • You haven't already dragged the application window out of bounds in one of your spaces (in which case you'll need to figure out how to reset its position first -- can't help there at the moment since each app handles its position in different ways. Advanced: Try resetting or reinstalling the X11 app, or editing its config file?)
  • You know what the following terms mean: "dock", "desktop", "mission control", "spaces", "X11", "XQuartz", "secondary click"

If you're here to try to get Inkscape or other X11 apps to work in Mavericks in the first place, try this post first: http://grammarofdev.blogspot.ca/2013/10/how-to-run-inkscape-in-os-x-109.html

Disclaimer:

This is hardly a permanent solution, nor is it guaranteed to work under all versions of OS X, XQuartz, etc. This workaround is just posted here in case anyone else finds it useful to be able to use X11 apps on their second monitor once again after upgrading to Mavericks, and doesn't mind jumping through a few hoops. Hopefully by the time you read this, someone at Apple or XQuartz would have fixed this issue. (If you're one of said Apple or XQuartz people, please fix this =) lol.)

Also note that because the bug seems to be related to coordinates, weird things can happen with this workaround, such as windows, child-windows, etc., opening out of bounds and therefore off-screen. Hopefully someone out there will be able to debug this problem as this workaround can't work around bugs like that.

Workaround:

  • Launch the X11 app so that XQuartz and the app's icon show up in the OS X dock
  • In the dock, secondary click the XQuartz icon and select: Options -> Assign To: None
  • In the dock, secondary click the app icon and select: Options -> Assign To: None
  • Go to mission control (hit f3 on most Macs, or triple-swipe upwards if that gesture is enabled)
  • Do NOT attempt to drag the app to the space/desktop on the other monitor as you do with native apps, as all this will do is set the window out of bounds on the current space/desktop. (At least, as of XQuartz 2.7.4 (xorg-server 1.13.0) or earlier.)
  • Drag the X11 app window (such as Inkscape's window) to the desktop/space mini-window on top of the other monitor (the one on top with the labelled "Desktop __" with the desktop number in place of __ -- not to the big desktop area below)
  • If all worked out, the app should now actually display on your second monitor
  • (Optional step - if you work for Apple) Program a patch to allow drag-and-drop of X11 apps to spaces residing on second monitor
  • (Optional step - if you work on the XQuartz project) Detect bounds of monitors and imitate native drag-and-drop behaviour (I'd like to help out, but I'm not entirely sure how to right now =/)

More:

As this issue hasn't been solved yet as of the time this post was written, I've decided instead to link to the closest bug report that I could find: https://discussions.apple.com/message/23717540#23717540

If you happen to have a better fix, please feel free to update us all in the comments below! =)

Monday, 28 October 2013

How to run Inkscape in OS X 10.9 Mavericks

Problem:

After upgrading to OS X 10.9, Inkscape, as well as other X11 apps do not seem to work any longer. How can I run Inkscape?

Solution:

  • Install Inkscape (if haven't done so already) from http://inkscape.org/
  • Install XQuartz from http://xquartz.macosforge.org/landing/
  • Run Inkscape.app
  • When asked for "Where is X11?", click "browse ..." and select /Applications/Utilities/XQuartz.app (or just /Applications/Utilities/XQuartz)

Explanation:

As of OS X Mountain Lion, Apple no longer installs the X11.app by default, which was previously needed to run any X11 applications. XQuartz or another compatible X Server is now needed to run any X11 apps as a result. A full explanation can be found in the Apple knowledge base article here: http://support.apple.com/kb/HT5293

Additional comments:

This solution was tested to work with the default installation of OS X 10.9 and Inkscape 0.48.2.

Note that if XQuartz starts up when launching Inkscape, but Inkscape doesn't launch the first time along with XQuartz, (or the Inkscape window doesn't show up), you can try to quit both Inkscape and XQuartz, then launch Inkscape once more (which should also launch XQuartz). This bug occurred on the system that the above fix was tested on, and the workaround seems to have worked. Your mileage might vary.

Addendum:

(Added in 2014)

A useful post from commenter @Birtanish below seems to have helped a few people when the above instructions weren't sufficient, so it's reproduced below in case it helps. Best of luck!:

"Hi! I tried the above solution which in the end did not work at all unfortunately. Another solution is to launch Inkscape from within XQuartz, this is done by opening a terminal and type: open /Applications/Inkscape.app Additionally it is possible to create a shortcut for this in the XQuartz menu, by clicking on Applications -> Customize and the above command as the command and set name to Inkscape for instance. This worked for me, hope it can help somebody else as well. Good luck."

Thursday, 29 March 2012

Workaround for copy & paste with Inkscape in OS X

There is a bug in OS X with X11 that affects copy and paste between X11 windows when using Inkscape. Basically, vector snippets that are copied in one window paste in another as bitmap rather than vector.

Solution (workaround):

Go into the X11 preferences (click on X11 icon in your dock, then in the menu bar X11->preferences...), and go to the tab that says pasteboard and uncheck: Update Pasteboard when CLIPBOARD changes.