Stretch window over two monitors with “gap” in between

compizmonitorswindowwmctrlxrandr

I have a dual monitor setup with Compiz as window manager on Ubuntu 14.04. I can resize a window to stretch over both windows. However, while the physical display panels are a few centimeters apart, the software by default thinks of them to be right next to each other without a gap in between. This means, e.g. a diagonal line ends up looking like this:

+----------+ +----------+
|          | |   /      |
|          | |  /       |
|          | | /        |
|          | |/         |
|         /| |          |
|        / | |          |
+----------+ +----------+

What I'd like to achieve is something more like this:

+----------+ +----------+
|          | | /        |
|          | |/         |
|          | |          |
|          | |          |
|         /| |          |
|        / | |          |
+----------+ +----------+

This would result in part of the window being hidden, but that's acceptable.

I can make X regard the displays to have a gap in between as follows:

$ xrandr
Screen 0: minimum 320 x 200, current 2048 x 1280, maximum 32767 x 32767
LVDS1 connected (normal left inverted right x axis y axis)
   1366x768       60.0 +
   1360x768       59.8     60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 connected primary 1024x1280+0+0 left (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024      60.0*+   75.0  
   1280x960       60.0  
   1152x864       75.0  
   1024x768       75.1     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   640x480        75.0     72.8     66.7     60.0  
   720x400        70.1  
HDMI3 connected 1024x1280+1024+0 right (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024      60.0*+   75.0  
   1280x960       60.0  
   1152x864       75.0  
   1024x768       75.1     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   640x480        75.0     72.8     66.7     60.0  
   720x400        70.1  
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
$ xrandr --fb 2184x1280
$ xrandr --output HDMI3 --pos 1160x0

At first sight, this seems to work perfectly – when I move the mouse in a diagonal line across the gap between the monitors, it disappears "behind" the monitor bezels and re-appears where I'd expect the diagonal line to continue.

However, I can no longer move or resize a window to stretch across both monitors. Neither the mouse nor wmctrl seem to be able to do that.

Is there a way to achieve what I want?

Best Answer

I found a related question on Ask Ubuntu which sort of did the trick for me. Instructions for the whole process, including creating the "gap" between monitors (works at least on Ubuntu 14.04):

  • Find out the current total screen size (assuming there's currently no virtual gap between monitors):
    $ xrandr | grep Screen Screen 0: minimum 320 x 200, current2048 x 1280, maximum 32767 x 32767
  • Add the desired gap size in pixels to the width (first value displayed after current – in my case, 2048). I chose a gap of 136 pixels, so I'd have a new screen width of 2184.
  • Set the new screen size:
    xrandr --fb 2184x1280
  • Find out the display name of your right monitor:
    $ xrandr | grep ^[^\(]*right HDMI3connected 1024x1280+1024+0 right (normal left inverted right x axis y axis) 376mm x 301mm
  • Virtually move the right monitor further to the right to create the gap. Add your gap size to the third number displayed by the above command (highlighted in bold). In my example, this is 1024+136=1160:
    xrandr --output HDMI3 --pos 1160x0

Now, make Compiz handle the whole area as one single screen

  • Start CompizConfig Settings Manager (installable with sudo apt-get install compizconfig-settings-manager)
  • Go to "General Options" plugin (e.g. type this in search box)
  • Select tab "Display Settings"
  • Uncheck "Detect Outputs"
  • If this doesn't already do the trick, right click on each line listed under "Outputs", select "Edit" and delete their content.

When maximizing a window, it will now stretch both monitors. Fullscreen will also stretch both monitors.

Clearly, this isn't ideal, as most of the time it is desirable that maximized windows fill a single monitor. This means, the "Detect Outputs" Compiz option will have to be checked and unchecked depending on what behavior is currently desired.

A note to user with non-English locale: If you can't find the CompizConfig plugin and setting because you don't know how their names were translated, start CompizConfig like so:

LANG=C ccsm
Related Question