Skip to content

Conversation

@cmihail
Copy link

@cmihail cmihail commented Nov 25, 2025

Description:

Describe your PR, what does it fix/add?

This PR adds support for position-based monitor selection in workspace rules using the
monitor:position:XxY syntax.

Relates to #12305

Monitor IDs are assigned based on connection order, making them unreliable for multi-monitor
setups. Position-based selection enables deterministic workspace assignment regardless of hotplug
order.

Example usage for a triple-monitor setup:
workspace = 1, monitor:position:0x0, persistent:true
workspace = 2, monitor:position:1920x0, persistent:true
workspace = 3, monitor:position:3840x0, persistent:true

This is more reliable than using monitor IDs because:

  • Monitor IDs depend on attachment order
  • Position-based selection works consistently with monitor configurations like:
    monitor=eDP-1,preferred,0x0,1 # left monitor
    monitor=HDMI-A-1,preferred,1920x0,1 # middle monitor
    monitor=DP-1,preferred,auto-right,1 # right monitor

Implementation:

  • Added position matching in CMonitor::matchesStaticSelector()
  • Added CCompositor::getMonitorFromPosition() helper function
  • Updated CConfigManager::getBoundMonitorForWS() to handle position-based selection
  • Fallback to monitor ID 0 when position doesn't match any monitor

Is there anything you want to mention? (unchecked code, possible bugs, found problems,

breaking compatibility, etc.)

  • Fully backward compatible - existing monitor:desc: and monitor:name syntax unchanged
  • Integration tests added in hyprtester/src/tests/main/persistent.cpp
  • Fallback behavior ensures graceful handling when position doesn't exist

Is it ready for merging, or does it need work?

Ready for merging. I tested this behavior on my Fedora 43 build manually and works as I expected

@cmihail cmihail marked this pull request as draft November 26, 2025 06:14
@cmihail
Copy link
Author

cmihail commented Nov 26, 2025

Actually I found an edge case not yet supported by this configuration, i.e. if I want to assign workspaces to the most right monitor.

I will see if I can add an extra setting like r-1920x0 or 1920xb-1080 which will choose layouts starting from right/bottom instead of left/top

@cmihail cmihail force-pushed the workspace-position-monitor-selection branch 5 times, most recently from cee6211 to 5919d75 Compare November 27, 2025 08:22
Add support for monitor:position:XxY syntax in workspace rules to enable
deterministic monitor assignment based on monitor position coordinates.

Monitor IDs are assigned based on connection order, making them unreliable
for multi-monitor setups. Position-based selection allows consistent
workspace placement regardless of hotplug order.

Usage:
  workspace = 1, monitor:position:0x0, persistent:true
  workspace = 2, monitor:position:1920x0, persistent:true

Fallback to monitor ID 0 when position doesn't match any monitor.
@cmihail cmihail force-pushed the workspace-position-monitor-selection branch from 5919d75 to 2a0472c Compare November 27, 2025 08:52
@cmihail cmihail marked this pull request as ready for review November 27, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant