icewm icon indicating copy to clipboard operation
icewm copied to clipboard

Minimal tiling

Open hideov opened this issue 5 years ago • 27 comments

Hi, I tried reading the man pages and I can't seem to find an option to map keys (say Super + directional keys) to minimally tile windows. I'm thinking of something like resizing and arranging the windows on the top half, bottom half, left half or right half of the current screen.

I am aware of the KeyWinArrangeXY commands, which get me almost there, it would just need some windows resizing before hand.

Any chance this already exists or could be implemented?

Cheers

hideov avatar Feb 26 '19 11:02 hideov

How would you define "minimally tile"? Doesn't exist yet. Could be implemented. Did you look into icewm's MiniIcons? You could also write a script using wmctrl and/or xdotool to do what you want?

gijsbers avatar Feb 26 '19 16:02 gijsbers

Thanks for the speedy answer! By "minimal" I meant that I am not looking for (what I perceived as) advanced tiling functionality like splitting the screen in a grid with multiple (> 2) "cells", but rather just to resize the window to either "full height x half width" or "half height x full width", and then arrange them at the left / right or top / bottom parts of the screen.

Thanks for the pointers, I'll look into MiniIcons and scripting and report if I get it done without requiring changes to IceWM.


After some playing with wmctrl and xdotool I came up with the attached script that does what I want (though not very elegantly): tile.sh

I had to hardcode the height in pixels of my toolbar.

I added it to my PATH, chmod +x'd it, and then configured my .icewm/keys file to include

key "Super+Right" tile.sh e key "Super+Left" tile.sh w key "Super+Up" tile.sh n key "Super+Down" tile.sh s

It'd be nice to have this functionality natively (it should be possible since wmctrl should be directly interfacing with IceWM as far as I understand), but my solution does it for me. Thanks again for the pointers!

hideov avatar Feb 27 '19 00:02 hideov

antiX has a set of WinGrid shell scripts that do exactly what you are asking for in /usr/local/bin

Keys entries:

Wingrid

key "Ctrl+1" wingrid-left.sh key "Ctrl+2" wingrid-right.sh key "Ctrl+3" wingrid-top.sh key "Ctrl+4" wingrid-bottom.sh key "Ctrl+5" wingrid-topleft.sh key "Ctrl+6" wingrid-topright.sh key "Ctrl+7" wingrid-bottomleft.sh key "Ctrl+8" wingrid-bottomright.sh key "Ctrl+9" wingrid-maximize.sh key "Ctrl+0" wingrid-close.sh

cheapy avatar Jun 15 '19 20:06 cheapy

I hacked together wingrid programs to grow, shrink or move/resize a quadrant sized window in the center of the screen in case anyone is interested in those as well.

wingrid-new4.zip

cheapy avatar Jul 23 '19 02:07 cheapy

It's surprising to see this issue as I expected the same functionality as OP. I have xfwm4 (xfce) setup to manually tile windows with "Super + w/a/s/d" (in case xfwm4's automatic tiling is insufficient). Alongside the unsolvable focus issue this is a deal-breaker, otherwise icewm would be perfect for my needs. Thank you regardless.

IceWM 1.6.2 (default)

reinstallgentoo avatar Oct 21 '19 12:10 reinstallgentoo

The WinGrid scripts allow you to move/resize in one motion the current window to one or two of 4 quadrants as the OP asked for, and I added recently a 5th centered window at the same quadrant sized, in addition to Shrink and Grow keys to quickly resize the active window. The normal IceWM functions like show desktop, roll up, roll down, maximize, minimize, restore, and full vertical all still work. Those changes are included in the recently release antiX19 base and full versions, both 32 and 64 bit.

Yes, It would be great if that functionality were included in IceWM, and if that was being done I would suggest to make that and WinArrange available from the keys file so the same functionality can be assigned to multiple keys for people with different keyboard types, ie some people don't have a numeric pad sometimes, or all the time.

cheapy avatar Oct 22 '19 19:10 cheapy

The new TitleBar menu "Tile" functions should provide the op's requested functionality quite nicely if clicking the requested option from the menu is acceptable instead of driving them from mapped key shortcuts.

cheapy avatar Dec 22 '21 23:12 cheapy

Oh, interesting! I will check it out! Is this a very recent release? Should I build from source to test it?

fvirdia avatar Dec 24 '21 16:12 fvirdia

I tested it by compiling from source originally, but it's now included in antiX21 if you have all updates applied. Not sure what other distros might already include it.

cheapy avatar Dec 24 '21 16:12 cheapy

What a GREAT enhancement! I've been using it all the time. For example to drag a bunch of individual things between programs I just tile each temporarily to half the screen, drag all the objects, and F10 back to Maximize when done.

cheapy avatar Jan 23 '22 03:01 cheapy

It would be nice to see quick-tile functionality in icewm. I've created a modified script from @hideov 's original tile.sh script with a few icewm bindings:

https://xannode.com/tile.sh.txt

Something internal to icewm would be more ideal, since things like titlebar height and border padding wouldn't need to be manually defined. Would love to see this implemented

prg318 avatar Jul 25 '22 21:07 prg318

Is this the same as Tile submenu, which tiles a single window? In that case only keybindings need to be provided?

gijsbers avatar Jul 26 '22 05:07 gijsbers

Is this the same as Tile submenu, which tiles a single window? In that case only keybindings need to be provided?

Yup! The tile submenu does exactly my modified tile.sh script does (but better), but it's not keyboard mappable at the moment

prg318 avatar Jul 26 '22 05:07 prg318

But then icewm-keys(5) shows how to add them using isesh? Near the end.

gijsbers avatar Jul 26 '22 05:07 gijsbers

But then icewm-keys(5) shows how to add them using isesh? Near the end.

Not sure how I missed that - that does exactly what I'm looking for. Thanks!

prg318 avatar Jul 26 '22 20:07 prg318

@gijsbers I can't wait to give that a try. Thanks!

cheapy avatar Jul 27 '22 00:07 cheapy

Perfect!

I got it compiled and configured and tested. All worked. I configured it in ~/.icewm/prefoverride.

What does “KeyWinSmartPlace” do?

I like when programs have obvious good features built in and not needing to code around missing functionality, but its a balancing act between that and bloat where you pay for so many features that nobody uses with big memory requirements and pokey performance. IceWM does a great job in that regard.

Thanks again :)

cheapy avatar Jul 27 '22 02:07 cheapy

KeyWinSmartPlace finds a new optimal position for a window where it least obscures other windows.

gijsbers avatar Jul 27 '22 04:07 gijsbers

My main issue with the configuration suggested in icewm-keys is that it often obscures the titlebar of the window or leaves space below the window. Is there a better way to handle this through icesh or would something need to be added to account for titlebar height and border padding?

Edit: it works decently as provided in the icewm-keys man page, but it would be nice if it used as much screen real estate as possible like how kwin or windows7+ would

prg318 avatar Jul 28 '22 02:07 prg318

I don't know how kwin or w7 behaves, so you have to describe it in detail. Also providing screenshots may help to clarify what you mean exactly.

gijsbers avatar Jul 28 '22 15:07 gijsbers

icewm-keys configuration example screenshots

Here's an example of how the configuration example provided in icemw-keys (shown below) looks on the latest version of icewm:

key "Super+KP_Home"  icesh -f sizeto 49% 49% top left
key "Super+KP_Up"    icesh -f sizeto 100% 49% top left
key "Super+KP_Prior" icesh -f sizeto 49% 49% top right
key "Super+KP_Right" icesh -f sizeto 49% 100% top right
key "Super+KP_Next"  icesh -f sizeto 49% 49% bottom right
key "Super+KP_Down"  icesh -f sizeto 100% 49% bottom left
key "Super+KP_End"   icesh -f sizeto 49% 49% bottom left
key "Super+KP_Left"  icesh -f sizeto 49% 100% top left
key "Super+KP_Begin" icesh -f sizeto 49% 49% center

Bottom:

tile-bottom

This example is mostly okay, but there is extra space between the window and the task bar and there is also extra space between the window and the right side of the screen. The titlebar remains visible however, which is a plus.

Left:

tile-left

In this example, the titlebar is moved above the desktop, so the window needs to be moved before any of the titlebar controls can be accessed. I would expect the titlebar to be visible and for the window to extend to the bottom of the screen where the taskbar begins.

Right:

tile-right

Same issue as left, except we also see some extra pixels to the right of the window in addition to the issues mentioned above.

Up:

tile-up

In this example, the window titlebar is outside of the bounds of the desktop area, so the window needs to be moved before the titlebar is accessible. In addition, there is extra space to the right of the window.

What quick tile does on other window managers

Here's an example of what the general placement for quick tiling windows would be using other WMs (I mentioned kwin and windows7+ earlier, but this is a common feature among many WMs).

I've manually positioned these windows to show where they should be after a quick tile command. They might not be pixel perfect, but should give a general idea of the requested behavior.

Bottom:

tile-proper-down

Left:

tile-proper-left_000

Right:

tile-proper-right

Up:

tile-proper-up

Hope this clears some things up. Let me know if there is any additional clarification that I can provide. Thanks again

edit: i didn't include nw/sw/ne/se examples, but they should follow the same guidelines. Let me know if additional information/screenshots of that would be helpful

prg318 avatar Jul 28 '22 15:07 prg318

Good! 3 ideas:

  1. There may be a race condition between the resize and the reposition. You can try to rewrite the icesh sizeto as: key "Super+KP_Left" icesh -f sizeto 49% 100% sync delay top left
  2. There may be an issue with the fact that this is a terminal and so it is resized with character size units. Does the problem remain identical if you use, say, xclock?
  3. There may be an inaccuracy with the sizeto in icesh. I can see if I can find it.

gijsbers avatar Jul 28 '22 19:07 gijsbers

FYI, I double checked my testing of your code commit above from 3 days ago, and all of the windows are sized and positioned as I would have expected.

cheapy avatar Jul 29 '22 02:07 cheapy

FYI, I double checked my testing of your code commit above from 3 days ago, and all of the windows are sized and positioned as I would have expected.

I'm running 2.9.8; was there a recent commit related to this? I'd be happy to try again with latest git. To clarify, my above post related to icewm 2.9.8

prg318 avatar Jul 29 '22 02:07 prg318

$ icewm -V IceWM 2.9.8.11, Copyright 1997-2012 Marko Macek, 2001 Mathias Hasselmann.

@gijsbers commit above was to add configurable tiling keys, making the icesh solution for tiling via keys entries methodology not necessary. The keys themselves were not assigned, but if they are, in either preferences or prefoverride, they do work, and I didn't find any problems with titles or borders.

The settings I added were as follows:

KeyWinSmartPlace="Ctrl+Alt+Shift+KP_Begin"   #  Smart place the active window.
KeyWinTileBottom="Ctrl+Shift+KP_Down"   #  Let the active window occupy the bottom half of the screen.
KeyWinTileBottomLeft="Ctrl+Shift+KP_End"   #  Let the active window occupy the bottom left quarter of the screen.
KeyWinTileBottomRight="Ctrl+Shift+KP_Next"   #  Let the active window occupy the bottom right quarter of the screen.
KeyWinTileCenter="Ctrl+Shift+KP_Begin"   #  Let the active window occupy the center quarter of the screen.
KeyWinTileLeft="Ctrl+Shift+KP_Left"   #  Let the active window occupy the left half of the screen.
KeyWinTileRight="Ctrl+Shift+KP_Right"   #  Let the active window occupy the right half of the screen.
KeyWinTileTop="Ctrl+Shift+KP_Up"   #  Let the active window occupy the top half of the screen.
KeyWinTileTopLeft="Ctrl+Shift+KP_Home"   #  Let the active window occupy the top left quarter of the screen.
KeyWinTileTopRight="Ctrl+Shift+KP_Prior"  #  Let the active window occupy the top right quarter of the screen.

cheapy avatar Jul 29 '22 02:07 cheapy

This commit improves the sizeto command. It automatically detects and prevents the problems with first resizing and then moving a window in the same icesh command.

The previous commit, as mentioned by cheapy, introduced these new keybindings in icewm:

       KeyWinTileLeft=""
           Let the active window occupy the left half of the screen.

       KeyWinTileRight=""
           Let the active window occupy the right half of the screen.

       KeyWinTileTop=""
           Let the active window occupy the top half of the screen.

       KeyWinTileBottom=""
           Let the active window occupy the bottom half of the screen.

       KeyWinTileTopLeft=""
           Let the active window occupy the top left quarter of the screen.

       KeyWinTileTopRight=""
           Let the active window occupy the top right quarter of the screen.

       KeyWinTileBottomLeft=""
           Let the active window occupy the bottom left quarter of the screen.

       KeyWinTileBottomRight=""
           Let the active window occupy the bottom right quarter of the
           screen.

       KeyWinTileCenter=""
           Let the active window occupy the center quarter of the screen.

gijsbers avatar Jul 29 '22 08:07 gijsbers

This seems to do exactly what I would expect and is much better than the previous icesh solution. Thanks for making this great improvement!

prg318 avatar Jul 29 '22 17:07 prg318