hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.82k stars 907 forks source link

resizewindow on both sides #4248

Open vincentaxhe opened 11 months ago

vincentaxhe commented 11 months ago

Description

when a window in the middle ,resizewindow cannot specify sides, in bspwm when I want to expand a window, use bspc node -z {left -30 0,bottom 0 30,top 0 -30,right 30 0} when shrink a window use bspc node -z {right -30 0,top 0 30,bottom 0 -30,left 30 0},hyprland simplify it ,but I think bspwm have a more flawless strategy because firstly user determined is expand or shrink a window, but resizewindow in hyprland cannot always got what users want, there should be a sub definition to deal with resizewindow.

dranull commented 11 months ago

You can move and resize the window at the same time, which gives you the effect of expanding it to the opposite direction. Here's an example:

$isFloat = hyprctl activewindow | grep -q 'floating: 1'
$mpx = 20

binde = $mainMod SHIFT, H, exec, $isFloat && hyprctl --batch "dispatch resizeactive $mpx 0; dispatch moveactive -$mpx 0" || hyprctl dispatch resizeactive -$mpx 0
binde = $mainMod SHIFT, L, resizeactive, $mpx 0
binde = $mainMod SHIFT, J, resizeactive, 0 $mpx
binde = $mainMod SHIFT, K, exec, $isFloat && hyprctl --batch "dispatch resizeactive 0 $mpx; dispatch moveactive 0 -$mpx" || hyprctl dispatch resizeactive 0 -$mpx

binde = $mainMod CTRL SHIFT, L, exec, $isFloat && hyprctl --batch "dispatch resizeactive -$mpx 0; dispatch moveactive $mpx 0" || hyprctl dispatch resizeactive $mpx 0
binde = $mainMod CTRL SHIFT, H, resizeactive, -$mpx 0
binde = $mainMod CTRL SHIFT, K, resizeactive, 0 -$mpx
binde = $mainMod CTRL SHIFT, J, exec, $isFloat && hyprctl --batch "dispatch resizeactive 0 -$mpx; dispatch moveactive 0 $mpx" || hyprctl dispatch resizeactive 0 $mpx

If you want to resize both sides at the same time, then you have to move the window twice as far. Or maybe I didn't understand your issue...

vincentaxhe commented 11 months ago

I mean when the middle window is active ,resizeactive can only move the left side left or right ,not the right side,It's not about floating,though movewindow on a floating window pushes it to the the edge seems not exactly what I think about "movewindow". resizeactive only works on window boundary in the same node ,not aware of higher level node. ![Uploading 2023-12-27T01:05:45,910897430+08:00.png…]()

dranull commented 11 months ago

Ah, tiled windows... You can resize it in one direction because it's in a split. However, you can resize it in both directions if you use the mouse shortcut, so the functionality is already there, just cannot be accessed via commands (or at least I don't know how).

For gradually moving floating windows you can use moveactive instead of movewindow:

binde = $mainMod CTRL, H, moveactive, -$mpx 0
binde = $mainMod CTRL, L, moveactive, $mpx 0
binde = $mainMod CTRL, J, moveactive, 0 $mpx
binde = $mainMod CTRL, K, moveactive, 0 -$mpx

And you didn't wait for your screenshot to upload...

vincentaxhe commented 11 months ago

mouse drag can move the border ,though when there are three columns ,two of them will interact ,it will not auto balanced among three, but its enough. if only the sensitive area near border could add more px will be more convient, I usually try more than once to activiate the drag mode. How to config it without recomplie the source code, I assume no trick in it. a script about move one side border failed trigger adjacent window also in an incorrelate node to move shared boundary will solve the problem ,but I dont know if window border side can be specified and how to filter the adjacent window.

vincentaxhe commented 11 months ago

about move floating window thing, how to bind the same key, when the window is active and floating,do moveactive ,when it is tiled do movewindow,that will a bit simple.Now I have movefocus movewindow swapwindow preselect bind to J I K L with different modifiers.

vincentaxhe commented 11 months ago

I figure it out hyprmove.sh as below:

state=$(hyprctl activewindow -j |jq -r ".floating")
if [[ $1 == l ]];then
    if [[ $state == true ]];then
    hyprctl dispatch moveactive -30 0
    elif [[ $state == false ]];then
    hyprctl dispatch movewindow l
    fi
elif [[ $1 == r ]];then
    if [[ $state == true ]];then
    hyprctl dispatch moveactive 30 0
    elif [[ $state == false ]];then
    hyprctl dispatch movewindow r
    fi
elif [[ $1 == u ]];then
    if [[ $state == true ]];then
    hyprctl dispatch moveactive 0 -30
    elif [[ $state == false ]];then
    hyprctl dispatch movewindow u
    fi
elif [[ $1 == d ]];then
    if [[ $state == true ]];then
    hyprctl dispatch moveactive 0 30
    elif [[ $state == false ]];then
    hyprctl dispatch movewindow d
    fi
fi

hyprland.conf add as below

binde = ALT SHIFT, KP_Left, exec, hyprmove.sh l
binde = ALT SHIFT, KP_Right, exec, hyprmove.sh r
binde = ALT SHIFT, KP_Up, exec, hyprmove.sh u
binde = ALT SHIFT, KP_Down, exec, hyprmove.sh d
vincentaxhe commented 11 months ago

better to replace [[ ]] with [] ,and run with dash, because every move need to query hyprctl first.