Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Support 'promote' focused window to master pane

Open Philipp-M opened this issue 2 years ago • 5 comments

In XMonad contrib there's a features called Promote which I often use(d).

Citing the description:

Moves the focused window to the master pane. All other windows retain their order. If focus is in the master, swap it with the next window in the stack. Focus stays in the master.

I think this feature could fit well in Hyprland

Philipp-M avatar Sep 16 '22 19:09 Philipp-M

uhh swapwithmaster?

vaxerski avatar Nov 19 '22 17:11 vaxerski

Sorry I haven't tested this sooner.

swapwithmaster is pretty much the behaviour of https://hackage.haskell.org/package/xmonad-0.17.1/docs/XMonad-StackSet.html#v:swapMaster

So very close, I think the only difference is, that the focus stays in the master. Is there a way to combine it with e.g. focusmaster (without selecting the child, if the 'promoted' window is the new master)?

Also all those features in xmonad did work as well in the dwindle layout in xmonad, is it possible to have the behaviour there as well?

Philipp-M avatar Jan 22 '23 14:01 Philipp-M

bind=SUPER,X,layoutmsg,swapwithmaster
bind=SUPER,X,layoutmsg,focusmaster

?

vaxerski avatar Jan 23 '23 18:01 vaxerski

As said before: when the window was not in the master and was "promoted" the selected window will not be the new master.

With the feature mentioned the selected window is always the master after promoting. Maybe we can extend "focusmaster" with a parameter, being a noop when the selected window is already the master?

Is it possible to have these features as well with the dwindle layout, or does the logic of the dynamic features differ too much?

Philipp-M avatar Jan 30 '23 12:01 Philipp-M

there are no masters in dwindle?

Maybe we can extend "focusmaster" with a parameter, being a noop when the selected window is already the master?

maybe, patches welcome

vaxerski avatar Jan 30 '23 15:01 vaxerski

In my opionion, there is a difference between 'promote' and 'swapwithmaster':

'swapwithmaster' swaps the focused window with the old master window. The other windows do not retain their order. The important notion here is order in the stack as opposed to position in the layout. To illustrate (* shows focus), notice how the windows 'B' and 'D' stay in the same position:

+-----------+-----------+            +-----------+-----------+
|           |     B     |            |           |     B     |
|           +-----------+            |           +-----------+
|     A     |     C*    |    --->    |     C*    |     A     |
|           +-----------+            |           +-----------+
|           |     D     |            |           |     D     |
+-----------+-----------+            +-----------+-----------+

So 'A' and 'C' get swapped in the stack:

A B C D
^---^

'promote' moves the focused window to the master area (top of the stack). All windows get pushed down in the stack, including the old master. But they do retain their order:

+-----------+-----------+            +-----------+-----------+
|           |     B     |            |           |     A     |
|           +-----------+            |           +-----------+
|     A     |     C*    |    --->    |     C*    |     B     |
|           +-----------+            |           +-----------+
|           |     D     |            |           |     D     |
+-----------+-----------+            +-----------+-----------+

Here, 'C' is just pushed to the top of the stack:

  A B C D
^-----┘

After that, you can use the 'promote' function to quickly switch between your to most recently used windows ('A' and 'C'). The focus stays on the master area all the time:

+-----------+-----------+            +-----------+-----------+
|           |     A     |            |           |     C     |
|           +-----------+            |           +-----------+
|     C*    |     B     |    <-->    |     A*    |     B     |
|           +-----------+            |           +-----------+
|           |     D     |            |           |     D     |
+-----------+-----------+            +-----------+-----------+

I hope the illustrations make the difference clear. I would like to have an additional 'promote' dispatcher, i find it very useful in dwm :)

svemoe avatar Mar 06 '23 21:03 svemoe

Oh yeah you're right, haven't thought about it that much, but indeed something felt different in xmonad vs hyprland. But it should be simple to implement, have a look at: https://github.com/hyprwm/Hyprland/blob/a85a6fa6c8ff9e51ba774cec112b408bce601451/src/layout/MasterLayout.cpp#L863 and
https://github.com/hyprwm/Hyprland/blob/a85a6fa6c8ff9e51ba774cec112b408bce601451/src/layout/MasterLayout.cpp#L946

Philipp-M avatar Mar 07 '23 20:03 Philipp-M

I switched back to dwl (dwm for wayland). Hyprland is cool and the animations are sweet, but I'm just too used to the way dwm does things :)

svemoe avatar Mar 08 '23 18:03 svemoe