Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Persistent workspaces are not always kept on the correct (specified) monitor

Open vaxerski opened this issue 7 months ago • 3 comments

Discussion Link

https://github.com/hyprwm/Hyprland/discussions/9879

Description

More information in the discussion, but in some specific cases, workspaces marked persistent do not stay on their assigned monitor (provided they have one.

Provided by OP:

I looked a bit around the source code and If I understand things correctly:

  1. Workspace rules are processed in CConfigManager::handleWorkspaceRules
  2. They get the id from getWorkspaceIDNameFromString
  3. Because they are named (e.g. name:L1) the id comes from CCompositor::getNextAvailableNamedWorkspace
  4. Since no workspace was created yet, they all get the same (-1337) id
  5. Then CCompositor::ensurePersistentWorkspacesPresent (through CConfigManager::ensurePersistentWorkspacesPresent) creates all the workspaces
  6. Since their ids are not set to WORKSPACE_INVALID, they (-1337) are used to fetch the workspace and move it to the correct monitor, but this results in all moves working on the same workspace.

Explicitly setting the wsRule.workspaceId to WORKSPACE_INVALID in CConfigManager::handleWorkspaceRules solves the problem, but > I have no clue how to fix this correctly.

vaxerski avatar Apr 06 '25 21:04 vaxerski

@vaxerski u forgot to replace the old issues that were in the milestones including this 1

ghost avatar Apr 06 '25 21:04 ghost

Image

ghost avatar Apr 06 '25 21:04 ghost

doesn't really matter. I realize.

vaxerski avatar Apr 06 '25 22:04 vaxerski

@LokiNaBoki is this still an issue on -git?

vaxerski avatar Aug 02 '25 11:08 vaxerski

It is still present on f1f1161c179374f7f703f7a17b1680205904cc90

LokiNaBoki avatar Aug 03 '25 11:08 LokiNaBoki

I just checked v0.51.0 and it looks like all workspaces are on the correct monitors, but when both persistent:true and default:true are specified, some workspaces are duplicated.

Using this config:

$MONITOR_L = HDMI-A-1
$MONITOR_R = DP-3

monitor = $MONITOR_L, 1280x1024@75, 0x0,    1
monitor = $MONITOR_R, 1920x1080@60, 1280x0, 1

workspace = name:L1, monitor:$MONITOR_L,persistent:true,default:true
workspace = name:L2, monitor:$MONITOR_L,persistent:true,default:true

workspace = name:R1, monitor:$MONITOR_R,persistent:true,default:true
workspace = name:R2, monitor:$MONITOR_R,persistent:true,default:true

bind = SUPER, 1, workspace,name:L1
bind = SUPER, 2, workspace,name:L2

bind = SUPER SHIFT, 1, workspace,name:R1
bind = SUPER SHIFT, 2, workspace,name:R2

bind = SUPER, M, exit
bind = SUPER, T, exec,kitty

Starting Hyprland and going through every workspace opening a terminal on each results in this hyprctl workspaces output:

workspace ID -1341 (R1) on monitor DP-3:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55c28dca5320
	lastwindowtitle: ~/.config/hypr
	ispersistent: 0

workspace ID -1342 (L1) on monitor HDMI-A-1:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55c28dc1cf80
	lastwindowtitle: ~/.config/hypr
	ispersistent: 0

workspace ID -1337 (L1) on monitor HDMI-A-1:
	monitorID: 1
	windows: 0
	hasfullscreen: 0
	lastwindow: 0x0
	lastwindowtitle: 
	ispersistent: 1

workspace ID -1338 (L2) on monitor HDMI-A-1:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55c28dc672f0
	lastwindowtitle: ~/.config/hypr
	ispersistent: 1

workspace ID -1339 (R1) on monitor DP-3:
	monitorID: 0
	windows: 0
	hasfullscreen: 0
	lastwindow: 0x0
	lastwindowtitle: 
	ispersistent: 1

workspace ID -1340 (R2) on monitor DP-3:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55c28dcc2700
	lastwindowtitle: hyprctl workspaces > /tmp/workspaces
	ispersistent: 1

Both R1 and L1 are duplicated. That being said I think this is a different issue, should I open a new discussion?

LokiNaBoki avatar Sep 13 '25 08:09 LokiNaBoki

Probably? Does it happen with ID-based workspaces too?

vaxerski avatar Sep 15 '25 11:09 vaxerski

With IDs instead of names there is no duplication

$MONITOR_L = HDMI-A-1
$MONITOR_R = DP-3

monitor = $MONITOR_L, 1280x1024@75, 0x0,    1
monitor = $MONITOR_R, 1920x1080@60, 1280x0, 1

workspace = 1, monitor:$MONITOR_L,persistent:true,default:true
workspace = 2, monitor:$MONITOR_L,persistent:true,default:true

workspace = 11, monitor:$MONITOR_R,persistent:true,default:true
workspace = 12, monitor:$MONITOR_R,persistent:true,default:true

bind = SUPER, 1, workspace,1
bind = SUPER, 2, workspace,2

bind = SUPER SHIFT, 1, workspace,11
bind = SUPER SHIFT, 2, workspace,12

bind = SUPER, M, exit
bind = SUPER, T, exec,kitty
workspace ID 11 (11) on monitor DP-3:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55970d65aa70
	lastwindowtitle: ~/.config/hypr
	ispersistent: 1

workspace ID 1 (1) on monitor HDMI-A-1:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55970d5d2c70
	lastwindowtitle: ~/.config/hypr
	ispersistent: 1

workspace ID 2 (2) on monitor HDMI-A-1:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55970d61ddb0
	lastwindowtitle: ~/.config/hypr
	ispersistent: 1

workspace ID 12 (12) on monitor DP-3:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x55970d677cd0
	lastwindowtitle: hyprctl workspaces > /tmp/workspaces
	ispersistent: 1

LokiNaBoki avatar Sep 15 '25 16:09 LokiNaBoki

I have opened a new discussion about the duplicated workspaces: #12084. The problem from this issue is resolved, so I think it can be closed.

LokiNaBoki avatar Oct 19 '25 11:10 LokiNaBoki