Maximizing a window vertically

Is there any way to maximize a window vertically? This is something I need while programming, and basically all window managers in GNU/Linux have a way to do this.

Trying to do that in Haiku using the mouse requires nearly impossibly precise mouse movement, otherwise horizontal size is affected (which is what I want to avoid). Holding Alt, Shift, or Ctrl while resizing with the mouse doesn’t seem to restrict resizing vertically. I’m not sure such a functionality is available in Haiku, preferably with a keyboard shortcut.

You can use the super (windows) key for that.

https://www.haiku-os.org/docs/userguide/en/gui.html#

Hey could help, you can do a lot of things with this little tool, readapting a script of mine you can use something similar, it finds the current active window and resize it to the desktop height

#! /bin/bash

  while read app_name
  do
    while read win_count
    do
      for ((win_ID=0;win_ID<${win_count};win_ID++))
      do
      [ "timeout 0.1 hey -o "${app_name}" get Active of Window ${win_ID}" == "true" ] && hey -o "${app_name}" set Frame of Window "${win_ID}" TO BRect[\
$(( hey Tracker get Frame of Window 0 ; hey "${app_name}" get Frame of Window "${win_ID}" ) | awk '/result/{sub(/^.*\(/,"");sub(/\)/,"");gsub(" ","");printf "%s,",$0}' | awk '{print $5,30,$7,$4-5}' FS="," OFS=",")]
      done
    done <<< hey -o ${app_name} count of Window
  done <<< roster | grep -v 'server' | awk '/\(/{print $2}' FS='[()]' | sort -u

I dunno how to find how tall is the window tab, so I set 30, surely it depends by the system font size

Edit: launch this by setting a system shortcut

Super key doesn’t seem to work, but Ctrl+Alt with right mouse button does. However I still have to move the mouse carefully to correctly maximize a window vertically. Definitely better than just resizing though.

@zuMi First time I hear about hey. Your script is exactly what I was looking for, but unfortnately it doesn’t seem to work:

line 12: syntax error near unexpected token `-o'
line 12: "    done <<< hey -o ${app_name} count of Window"

hey
hey v1.2.8, written by Attila Mezei (attila.mezei@mail.datanet.hu)
usage: hey [-s][-o] <app|signature|teamid> [let do] <specifier_1> <of
<specifier_n>>* [to ] [with name= [and name=]*]
where : DO|GET|SET|COUNT|CREATE|DELETE|GETSUITES|QUIT|SAVE|LOAD|‘what’
: [the] <property_name> [ | name | “name” | ‘“name”’ ]
: int | -int | ‘[‘int’]’ | ‘[’-int’]’ | ‘[‘startint to end’]’
: “string” | | | bool(value) | int8(value)
| int16(value) | int32(value) | float(value) | double(value)
| BPoint(x,y) | BRect(l,t,r,b) | rgb_color(r,g,b,a) | file(path)
options: -s: silent
-o: output result to stdout for easy parsing

probably some quotes went lost copypasting it

https://0x0.st/Htam.sh.zip

2 Likes

Sorry I misremembered, super is on linux : )
Anyhow, just hold ctrl alt and move to the lower part of the window untill only the lower end is highlighted and neither side is. You can then resize without having to worry about mouse movement left to right.

1 Like

@nephele It works, what I meant in my previous post is you still have to stop resizing at the screen borders, since it doesn’t snap on edges. Still, it does the job pretty nicely.

@zuMi Yes, it was a copy/paste issue (which I suspected it was but couldn’t find where). The script works now. I guess there is a way to unmaximize the window (return it to its previous dimensions), pretty much like full zoom (Ctrl+Alt+Z toggles between full size and initial window dimensions). I will have to study hey and see how it works.

Thank you both for your help!

Ah. indeed.
Perhaps that can be enhancement in the future : )

I don’t know how other systems implement maximizing only vertically or horizontally without mouse-dragging and snapping. But thinking of it, clicking the maximize button with a modifier key feels natural since modifier keys are supposed to modify the behavior of a function. So if clicking the maximize button maximizes the window both horizontal and vertical, clicking it with one modifier key could maximize it only horizontal and another modifier key only vertical.

I’m only at the beginning of learning the Haiku API so I can’t tell anything about how this could be implemented. However, I can tell from experience that, in GLFW, maximizing a window only vertically or horizontally is a fairly easy task (in fact it’s just a special case of fully maximizing). While the API is very different, the concept is trivially simple, and not particularly a GLFW thing: (1) save the current dimensions, (2) change the vertical dimension to the maximum (which is easily known). Then do the same in reverse order if the corresponding toggle key is pressed again.
Granted, GLFW is relying on the underlying OS and X11/Wayland to operate, but again, the concept seems pretty standard no matter the API. As you said, if Ctrl+Alt+Z can maximize both dimensions, then an additional modifier key could maximize it only vertically or horizontally.

The Be API does provide methods for individual windows to override the zoom behavior but at the moment this is done on a per application/window basis and there is no system wide shortcut for vertical zooming. Several of the apps included with Haiku have custom Zoom() implementations, like Tracker for example. The BeBook has documentation for Zoom() and SetZoomLimits()

Will be possible to use Ctrl+Alt+cursor keys to resize sides with just the keyboard, without conflicting with something else?

Example:
Ctrl+Alt+Up resizes the top part of the window to the upper limit of the screen (keeping Ctrl+Alt pushed and pushing UP again returns to the previous position).
Same with the other sides.

Maybe adding Shift for a bit of control:

Shift+Ctrl+Alt+Up lets you resize the upper part of the window in, say, 32 pixel jumps.
As long as you keep Shift+Ctrl+Alt pushed, the focus remains in this window border, so you can control it up and down as you wish.
Releasing Shift+Ctrl+Alt and pushing it again lets you select and resize another border the same way.

And why not not go all the way and also move the window pushing Opt instead of Alt?:

Ctrl+Opt+Left moves the window to the left border of the screen, Shift+Ctrl+Opt+Left lets you move the window to the left in steps.
In this case, as you are moving just the “center” of the window, as long as you keep Shift+Ctrl+Opt pushed, you could move the window in any direction.

Practically sure it will conflict with a thousand things :boom: :sweat_smile:

1 Like

Or “shortcuts” just needs to be updated/extended with some new actions, I’ve never used mouse moving with cursor keys, I would prefer to move windows to an adjacent workspaces with that combo, another user would prefer to resize the window using shortcuts, someone would prefer to change the position against screen edges or corners instead

2 Likes

Or something more like in Windows : some shortcut in the window puts it in keyboard-resizing-mode, then the arrow keys work for resizing it, until ESC is pressed.

Perhaps you should open a ticket if you think adding a feature like this would be useful to the user.

I don’t like maximizing. I prefer that, by default, windows grow keeping their proportions to avoid distortion of the content. I like Sudoku’s cases square, for example. So, if there was a mod key to hold while resizing, or something in the app that would say ‘keep proportions’ to ensure that, I would appreciate.