cortile icon indicating copy to clipboard operation
cortile copied to clipboard

Multiple monitor support (identical monitors)

Open svandragt opened this issue 8 months ago • 6 comments

It appears cortile only works on my secondary monitor when I enable it. I can drag windows to the primary monitor but when I drop the window it gets sent back to the secondary one.

The monitors are of the same type and have the same name, on MacOS this can cause confusion with Hammerspoon, perhaps something similar is happening here, if cortile has multi-monitor support?

I'm running cortile on elementary OS 7 (Based on Ubuntu 22.04 in case you're not familiar), let me know if anyone needs more information.

svandragt avatar Jun 12 '25 19:06 svandragt

The monitors are of the same type and have the same name...

The monitors should have some distinct id that cortile recognized. I can also confirm that two monitors of the same brand and model just works fine.

Please stop the service and run cortile -v on the terminal. Then provide the first 4 INFO logs here. The two lines after the Connected to X server ... output should contain the recognized monitors.

leukipp avatar Jun 24 '25 07:06 leukipp

Thanks for the response.

INFO[2025-06-24T10:35:28+01:00] Starting [cortile v2.5.2-96a0edd, built on 2024-11-02T18:34:52Z (linux-amd64)]
INFO[2025-06-24T10:35:28+01:00] Connected to X server on sander-x670 [debian, Mutter(Gala)]
INFO[2025-06-24T10:35:28+01:00] Screens [{86 DisplayPort-2 true {0 0 1920 1080}} {87 HDMI-A-0 false {1920 0 1920 1080}}]
INFO[2025-06-24T10:35:28+01:00] Desktops [{86 DisplayPort-2 true {1920 0 0 1080}} {87 HDMI-A-0 false {1920 0 1920 1080}}]

After I start cortile all windows get bunched up to the HDMI one. The dock is showing on the primary monitor, DP.

svandragt avatar Jun 24 '25 09:06 svandragt

I see, somehow your DP screen (physically located on the left?) reports zero width or swaps the x {86 DisplayPort-2 true {x=1920 y=0 w=0 h=1080}} after calculating the desktop dimensions. Therefore no windows are stacked there.

Make sure you don't have any invalid margins configured on the monitors: https://github.com/leukipp/cortile/blob/96a0eddbaf37706a7ed64ffdf93cfc675e144730/config.toml#L92

It could also be caused by your dock, where is it located (top, left, etc.)? Also try to temporary move the dock to the HDMI screen or disabling it. What happens if you reconfigure your screens such that HDMI is on the left and DP on the right?

Are you able to follow the development instructions using Option 2 to make a local build? Try commenting this line https://github.com/leukipp/cortile/blob/96a0eddbaf37706a7ed64ffdf93cfc675e144730/store/root.go#L310 and report back if something changed.

leukipp avatar Jun 24 '25 10:06 leukipp

Thanks @leukipp. Good news:

Clarifications

  • The DP screen is physically located on the left yes.
  • My $HOME/.config/cortile/config.toml matches exactly the default, checked through a diff. So the margins are default
  • My dock (the default elementaryOS7 dock (plank 0.11.89), is located on the left middle of the DP screen. I had intellihide on, but it works the same with it off. (with plank, intellihide hides only when there's an overlapping window).

Screenshot of the problem in action:

Created with flameshot full:

Image

Test results

  • With the dock to the right side of the right (HDMI) monitor), running cortile, all windows still bunch up on the HDMI screen. Same with the dock killed. I guess we can rule out the dock.
  • With the HDMI monitor the primary monitor on the left, and the secondary DP monitor on the right (changed via display settings), after running cortile, all windows are bunched up on the secondary DP monitor on the right.
  • I restarted and there is no change.
  • I installed the local development versions Option 2, and no change after building.
  • FIXED: I commented out the statement starting at line 310, and renamed the variables geom and strut to _ to make it compile and this fixed the issue. I've enclosed my patch below! This works even with my original setup.

Asides

  • with the dock on the side inbetween the two screens, I'm seeing a weird issue , it restricts where windows can go on the left monitor to half of the screen. (with cortile not running, just mentioning this in case it turns out to be related), probably one of the reasons why plank was dropped from ElementaryOS 8.)

My Patch

diff --git a/store/root.go b/store/root.go
index 9f0362c..c1e869e 100644
--- a/store/root.go
+++ b/store/root.go
@@ -277,7 +277,7 @@ func DisplaysGet(X *xgbutil.XUtil) XDisplays {
 
 	// Get geometry of root window
 	root := CreateXWindow(X.RootWin())
-	geom, err := root.Instance.Geometry()
+	_, err := root.Instance.Geometry()
 	if err != nil {
 		log.Fatal("Error retrieving root geometry: ", err)
 	}
@@ -301,17 +301,17 @@ func DisplaysGet(X *xgbutil.XUtil) XDisplays {
 
 	// Get margins of desktop panels
 	for _, w := range Windows.Stacked {
-		strut, err := ewmh.WmStrutPartialGet(X, w.Id)
+		_, err := ewmh.WmStrutPartialGet(X, w.Id)
 		if err != nil {
 			continue
 		}
 
 		// Apply struts to rectangles in place
-		xrect.ApplyStrut(rects, uint(geom.Width()), uint(geom.Height()),
-			strut.Left, strut.Right, strut.Top, strut.Bottom,
-			strut.LeftStartY, strut.LeftEndY, strut.RightStartY, strut.RightEndY,
-			strut.TopStartX, strut.TopEndX, strut.BottomStartX, strut.BottomEndX,
-		)
+		// xrect.ApplyStrut(rects, uint(geom.Width()), uint(geom.Height()),
+		// 	strut.Left, strut.Right, strut.Top, strut.Bottom,
+		// 	strut.LeftStartY, strut.LeftEndY, strut.RightStartY, strut.RightEndY,
+		// 	strut.TopStartX, strut.TopEndX, strut.BottomStartX, strut.BottomEndX,
+		// )
 	}
 
 	// Update desktop geometry

INFO logs of the patched version:

INFO[2025-06-24T11:55:28+01:00] Starting [cortile v0.0.0-local, built on 2025-06-24T11:46:33+01:00 (unknown)]
INFO[2025-06-24T11:55:28+01:00] Connected to X server on sander-x670 [debian, Mutter(Gala)]
INFO[2025-06-24T11:55:28+01:00] Screens [{86 DisplayPort-2 true {0 0 1920 1080}} {87 HDMI-A-0 false {1920 0 1920 1080}}]
INFO[2025-06-24T11:55:28+01:00] Desktops [{86 DisplayPort-2 true {0 0 1920 1080}} {87 HDMI-A-0 false {1920 0 1920 1080}}]

svandragt avatar Jun 24 '25 10:06 svandragt

Thank you for coding and maintaining cortile! I would love to use this as a daily driver, but currently not possible.

Tested it (non-patched version) on two setups with two identical monitors on each of them, but cortile does not behave as expected. First, I cannot get more then three tiles per monitor, independent of whatever setting is provided in cortile.toml. When a fourth window is opened, it completely overlaps with one existing tile, so the window can only be accessed using the dock. It is even not visible how many windows are actually open, because they then all overlapping 100%. If single window sizes are adjusted after tiling, weird large gaps appear between windows. On one monitor, cortile remains in fullscreen layout, any additional windows are 100% overlapping. No layout change is possible, because the mouse has to go to the other monitor for the tray. Could not make keyboard working for this monitor either, but maybe this is due to a conflict in xfce-settings.

Not sure, if the 100% overlapping windows are intended when the number of windows have reached max, but how about moving windows to an additional workspace instead of 100% overlapping?

Iam running xfce on xubuntu 22.04. Would be better to show this in a screencast, but I am currently not at this computer...

Should I try to open a separate issue?

MikePotes avatar Aug 01 '25 09:08 MikePotes

If the patch doesn't work for you, it's a different issue.

svandragt avatar Aug 01 '25 10:08 svandragt