Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for retrieving first empty workspace #1085

Merged
merged 1 commit into from
Nov 23, 2022

Conversation

julianschuler
Copy link
Contributor

Describe your PR, what does it fix/add?

This pull request adds a new option to reference workspaces with: "empty".
It references the first empty workspace, i.e. the workspace with the smallest (positive) workspace ID without any windows.

The new option allows to e.g. focus an empty workspace or move a window to an empty workspace by using something like this:

bind = $MOD, $KEY1, workspace, empty
bind = $MOD, $KEY2, movetoworkspace, empty

These examples are equivalent to the ws_empty and ws_empty_move actions in spectrwm.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

I will add a pull request for updating the wiki entry soon after.

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

It is ready for merging.

@vaxerski
Copy link
Member

There is a function to retrieve the highest workspace ID in CCompositor iirc. Why not use that?

Also, make a wiki entry prior to merge. I'll merge both at once

@julianschuler
Copy link
Contributor Author

I assume you mean CCompositor::workspaceIDOutOfBounds() and to use the workspace ID which is out of bounds as new empty workspace?

I decided against this approach due to three reasons:

  1. There may be workspaces without any windows but still within m_vWorkspaces. Empty workspaces seem to be only removed in CCompositor::sanityCheckWorkspaces(). I am not sure whether this is called often enough to ensure that only non-empty or active empty workspaces are present when getWorkspaceIDFromString() is called.
  2. If an empty workspace is currently focused, the focus would be switched to a new empty workspace, since the current empty workspace is considered to be in bounds.
  3. If we have e.g. two non-empty workspaces with IDs 1 and 3, this approach would result in ID 4 while ID 2 would be the first empty workspace. In general, empty workspaces within the range given by the lowest to highest IDs of non-empty workspaces will never be considered and the IDs potentially becoming larger and larger.

Please correct me, if any of my assumptions are wrong or there is another reason to prefer CCompositor::workspaceIDOutOfBounds(). Thank your for all your work and time for Hyprland!

@vaxerski
Copy link
Member

I see your points. Makes sense, sure. Thanks!

@vaxerski vaxerski merged commit 79a9bc9 into hyprwm:main Nov 23, 2022
@julianschuler julianschuler deleted the empty-workspace branch November 24, 2022 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants