calandoa/movescreen

Skips first monitor

Closed this issue · 2 comments

I have 5 monitors. The first monitor in xrandr's output is being skipped. (It is the 4th monitor left to right, but judging on who the windows move, it is skipping the first one in the lsit).
xrandr output:
Screen 0: minimum 8 x 8, current 10160 x 1440, maximum 16384 x 16384
DP-0 connected 1440x900+7280+540 (normal left inverted right x axis y axis) 408mm x 255mm
1440x900 59.89*+
1280x1024 75.02 60.02
1280x960 60.00
1152x720 60.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 connected 1440x900+8720+540 (normal left inverted right x axis y axis) 408mm x 255mm
1440x900 59.89*+
1280x1024 75.02 60.02
1280x960 60.00
1152x720 60.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 connected 3440x1440+3840+0 (normal left inverted right x axis y axis) 800mm x 335mm
3440x1440 59.97*+ 29.99
2560x1440 59.95
2560x1080 59.98
2048x1152 60.00
1920x1200 59.88
1920x1080 60.00 59.94 50.00
1680x1050 59.95
1600x1200 60.00
1280x1024 75.02 60.02
1280x800 59.81
1280x720 59.94 50.00
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
DP-6 disconnected (normal left inverted right x axis y axis)
DP-7 disconnected (normal left inverted right x axis y axis)
DVI-I-4-4 disconnected (normal left inverted right x axis y axis)
DVI-I-3-3 disconnected (normal left inverted right x axis y axis)
DVI-I-1-1 connected 1920x1080+0+360 (normal left inverted right x axis y axis) 598mm x 336mm
1920x1080 60.00*+ 50.00 59.94
1680x1050 59.88
1280x1024 75.02 60.02
1440x900 59.90
1280x960 60.00
1280x720 60.00 50.00 59.94
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
720x576 50.00
720x480 60.00 59.94
640x480 75.00 72.81 66.67 60.00 59.94
720x400 70.08
DVI-I-2-2 connected 1920x1080+1920+360 (normal left inverted right x axis y axis) 0mm x 0mm
1280x1024 60.02 +
1920x1200 59.88
1920x1080 60.00*
1600x1200 60.00
1680x1050 59.95
1440x900 59.89
1366x768 59.88
1280x720 60.00
1024x768 60.00
800x600 72.19 75.00 60.32
720x480 59.71
640x480 59.94
1920x1080 (0x294) 148.500MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz
1920x1080 (0x296) 148.500MHz +HSync +VSync
h: width 1920 start 2448 end 2492 total 2640 skew 0 clock 56.25KHz
v: height 1080 start 1084 end 1089 total 1125 clock 50.00Hz
1280x1024 (0x27f) 135.000MHz +HSync +VSync
h: width 1280 start 1296 end 1440 total 1688 skew 0 clock 79.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 75.02Hz
1280x1024 (0x280) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1280x960 (0x281) 108.000MHz +HSync +VSync
h: width 1280 start 1376 end 1488 total 1800 skew 0 clock 60.00KHz
v: height 960 start 961 end 964 total 1000 clock 60.00Hz
1280x720 (0x29b) 74.250MHz +HSync +VSync
h: width 1280 start 1720 end 1760 total 1980 skew 0 clock 37.50KHz
v: height 720 start 725 end 730 total 750 clock 50.00Hz
1024x768 (0x283) 78.750MHz +HSync +VSync
h: width 1024 start 1040 end 1136 total 1312 skew 0 clock 60.02KHz
v: height 768 start 769 end 772 total 800 clock 75.03Hz
1024x768 (0x284) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x285) 49.500MHz +HSync +VSync
h: width 800 start 816 end 896 total 1056 skew 0 clock 46.88KHz
v: height 600 start 601 end 604 total 625 clock 75.00Hz
800x600 (0x286) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
720x576 (0x29d) 27.000MHz -HSync -VSync
h: width 720 start 732 end 796 total 864 skew 0 clock 31.25KHz
v: height 576 start 581 end 586 total 625 clock 50.00Hz
720x480 (0x29e) 27.000MHz -HSync -VSync
h: width 720 start 736 end 798 total 858 skew 0 clock 31.47KHz
v: height 480 start 489 end 495 total 525 clock 59.94Hz
640x480 (0x287) 31.500MHz -HSync -VSync
h: width 640 start 656 end 720 total 840 skew 0 clock 37.50KHz
v: height 480 start 481 end 484 total 500 clock 75.00Hz
640x480 (0x288) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz
1280x1024 (0x280) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1920x1200 (0x293) 193.250MHz -HSync +VSync
h: width 1920 start 2056 end 2256 total 2592 skew 0 clock 74.56KHz
v: height 1200 start 1203 end 1209 total 1245 clock 59.88Hz
1600x1200 (0x298) 162.000MHz +HSync +VSync
h: width 1600 start 1664 end 1856 total 2160 skew 0 clock 75.00KHz
v: height 1200 start 1201 end 1204 total 1250 clock 60.00Hz
1680x1050 (0x297) 146.250MHz -HSync +VSync
h: width 1680 start 1784 end 1960 total 2240 skew 0 clock 65.29KHz
v: height 1050 start 1053 end 1059 total 1089 clock 59.95Hz
1440x900 (0x27e) 106.500MHz -HSync +VSync
h: width 1440 start 1520 end 1672 total 1904 skew 0 clock 55.93KHz
v: height 900 start 903 end 909 total 934 clock 59.89Hz
1280x720 (0x2c7) 74.250MHz +HSync +VSync
h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 45.00KHz
v: height 720 start 725 end 730 total 750 clock 60.00Hz
1024x768 (0x284) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x2cb) 50.000MHz +HSync +VSync
h: width 800 start 856 end 976 total 1040 skew 0 clock 48.08KHz
v: height 600 start 637 end 643 total 666 clock 72.19Hz
800x600 (0x285) 49.500MHz +HSync +VSync
h: width 800 start 816 end 896 total 1056 skew 0 clock 46.88KHz
v: height 600 start 601 end 604 total 625 clock 75.00Hz
800x600 (0x286) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
640x480 (0x288) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz

I found the problem. The code sorts the monitors by duplicating each screen left and right, then checks for the intersection with each other screen. In your case, the middle monitor is so big that it can "engulf" both monitors on the right ; the 5th is then overriding the 4th in the left/right lists.

I will need to find a new algorithm which works better... however I am still glad to see that it almost works in such extreme configuration as yours !

A dirty hack to solve your problem: around line 73, change this stuff:

	# Using the max of interection area would be better
	if isect_area([sa[0], sa[1], sa[2] + sa[0], sa[3]], sb):
		r["right"][ia] = ib
		r["left"][ib] = ia

by adding the and (...) at the end of the if:

	if isect_area([sa[0], sa[1], sa[2] + sa[0], sa[3]], sb) and (len(scr) != 5 or (ia, ib) != (2,1)):

This should only work with your current configuration.

Ok, use latest commit, it should work better now.

If you can, check also prev/next arguments modified to follow apparent order and cycle from one end to another.