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

Basic keyboard quarter tiling #408

Open
wants to merge 17 commits into
base: master
from

Conversation

@peteruithoven
Copy link
Member

commented Nov 10, 2018

Basic quarter tiling support.
Ctrl + Super + 1: Tile top left
Ctrl + Super + 2: Tile top right
Ctrl + Super + 3: Tile bottom left
Ctrl + Super + 4: Tile bottom right

Partially Implements: #105 (only the keyboard support).

To my surprise, contrary to when using wmctrl, there was no issue with different shadows margins.

It doesn't transition (yet).

@cassidyjames

This comment has been minimized.

Copy link
Member

commented Nov 10, 2018

I think we'd want these to be bound to arrow keys by default if possible, so:

Ctrl+Super+Up+Left, Ctrl+Super+Up+Right, etc.

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Nov 10, 2018

Good point.
I'm having a bit of an issue with the keybindings though.
With the keybindings:

<Super><Ctrl><Up>Left
<Super><Ctrl><Up>Right
<Super><Ctrl><Bottom>Left
<Super><Ctrl><Bottom>Right

only the bottom left + right work. It also blocks regular left and right tile.

With the keybindings:

<Super><Ctrl><Left>Up
<Super><Ctrl><Right>Up
<Super><Ctrl><Left>Bottom
<Super><Ctrl><Right>Bottom
  • both Super+Ctrl+left and Super+Ctrl+left +Up and Super+Ctrl+left +Down triggers tiles top left.
  • both Super+Ctrl+right and Super+Ctrl+right +Up and Super+Ctrl+right +Down triggers tile right.

Anyway, quite a mess. I could use some tips on how to get this working.

@jchannon

This comment has been minimized.

Copy link

commented Nov 10, 2018

I’d prefer these but not sure it fixes your issue.

Move to the upper left — ⌃⌘←
Move to the lower left — ⌃⇧⌘←
Move to the upper right — ⌃⌘→
Move to the lower right — ⌃⇧⌘→

⌘ = super
⌃ = ctrl ?
⇧ = shift ?

Command-Control-Shift-

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Nov 11, 2018

@jchannon I might be confused by your usage of ⌃ (which means ctrl right?), but isn't ⌃⌘←( Ctrl+Super+) the same as the current tile left keyboard shortcut?

@jchannon

This comment has been minimized.

Copy link

commented Nov 11, 2018

Quite possibly, those are the shortcuts I use on OSX for quarter tiling :)

@ianmjones

This comment has been minimized.

Copy link

commented Nov 12, 2018

This is awesome, but I worry that changing the key combinations to use two cursor keys at the same time would be problematic given that using one of those keys is already ingrained and as @peteruithoven has found requires some special handling of the keybindings.

I would propose something a little more visual and hopefully simpler to implement.

Ctrl+Super+u: Top Left
Ctrl+Super+i: Top Right
Ctrl+Super+j: Bottom Left
Ctrl+Super+k: Bottom Right

This could later be suplemented with 3rd tiling...

Ctrl+Super+d: Left 3rd
Ctrl+Super+f: Middle 3rd
Ctrl+Super+g: Right 3rd

Ctrl+Super+e: Left 2 3rds
Ctrl+Super+t: Right 3rds

I might be influenced by muscle memory, but I do honestly think it's less problematic.

magnet for macos keybindings

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Nov 12, 2018

One issue with using letters is that it's logical orientation breaks down on non Querty keyboards. I couldn't find statistics on keyboard layout popularity.

@ianmjones

This comment has been minimized.

Copy link

commented Nov 12, 2018

Hmm, yeah, that did occur to me.

I wonder if there is some sort of hardware code mapping that could be used more reliably than letters for saving to settings?

@jchannon

This comment has been minimized.

Copy link

commented Jan 30, 2019

Any update to this, most distros have quarter tiling so it would be good to get it into elementary

@ricotz ricotz force-pushed the quarter-tiler branch from 8c9bbed to 5540331 Feb 7, 2019
if (!("tile-topleft" in settings.list_keys ())) {
warning ("Quarter tiling key bindings not found");
return;
}

This comment has been minimized.

Copy link
@peteruithoven

peteruithoven Feb 7, 2019

Author Member

@ricotz Thanks for the cleanup! But why remove this check? Without this, if a user where to try gala with this version and then downgrade he wouldn't be able to login anymore.
See: https://elementaryos.stackexchange.com/a/17582/3892

This comment has been minimized.

Copy link
@ricotz

ricotz Feb 7, 2019

Contributor

gsettings schemas and keys are part of the API. We can't deal with not properly installed systems of all kinds.

This comment has been minimized.

Copy link
@peteruithoven

peteruithoven Feb 8, 2019

Author Member

After I've experiencing suddenly not being able to login that seems scary / fragile, but yeah it probably doesn't make sense to make an exception for this property.

@thomasfaller

This comment has been minimized.

Copy link

commented Feb 10, 2019

Would be a terrific addition!

@peteruithoven peteruithoven changed the title Basic quarter tiling Basic keyboard quarter tiling Feb 11, 2019
@Julioevm

This comment has been minimized.

Copy link

commented Feb 22, 2019

I hope this get added soon, its really useful productivity wise!

@ricotz ricotz force-pushed the quarter-tiler branch from cfd8af0 to e1ebfe3 Feb 27, 2019
donadigo added 2 commits May 24, 2019
Copy link
Contributor

left a comment

Is it intentional that you cannot tile a window that's already fully maximized? I would expect that to work.

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Jul 3, 2019

@donadigo nop it definitely wasn't. I just rarely use maximized / fullscreen windows. I added those allow resize / move checks because that seemed safe. But I changed it, it now also works for maximized and fullscreen windows.

Copy link
Contributor

left a comment

Looks good to me.

@btkostner

This comment has been minimized.

Copy link
Member

commented Jul 3, 2019

Is it possible to tell if a window is already half tiled? If so, maybe have it so you half tile first, then do up or down to go into quarter tiling?

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Jul 3, 2019

@btkostner yes I can tell if it's tiled.
What would that sequence of actions accomplish?

@btkostner

This comment has been minimized.

Copy link
Member

commented Jul 3, 2019

@peteruithoven So super+ctrl+left would left half tile it, then super+ctrl+top would quarter tile it to the upper left. Just a thought 🤔

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Jul 3, 2019

@btkostner Ah! Interesting idea! I've implemented the idea. Please let me know what you think.

@jchannon

This comment has been minimized.

Copy link

commented Jul 4, 2019

@btkostner

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

@jchannon The way I've seen it implemented is where you could (but don't have to) let go of left or right. But this way, you get instant feedback.

@btkostner

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

@peteruithoven Just tried it and it feels pretty cool 🎊. Two things might need to be changed, but I think @cassidyjames might have some insight to this. First being up + left should be the same thing as left + up if possible (not sure the technical constraints)... Second, I found myself wanting to move the whole window when it was already tiled. For instance, if I had a window in the upper left part of the screen and I did right, it would then be tiled in the upper right of the screen. This might be my tiling window manager brain, but might be something to try out...

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Jul 6, 2019

First being up + left should be the same thing as left + up if possible (not sure the technical constraints)...

I think I've explained the technical limitation earlier. Properly implementing that keyboard shortcut simply is not supported. With the left/light > top/down I can use the tiling position as a workaround.

I thought I could maybe also register to Super+Ctrl+left/right and maybe do some kind of timeout where if Super+Ctrl+up/down and Super+Ctrl+left/right are pressed within a certain time I could trigger a quarter tile, but listening for left/right breaks the existing tile to side behaivior. I assume only one listener is allowed.

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Jul 6, 2019

Second, I found myself wanting to move the whole window when it was already tiled. For instance, if I had a window in the upper left part of the screen and I did right, it would then be tiled in the upper right of the screen. This might be my tiling window manager brain, but might be something to try out...

Let's first get quarter tiling to work...

Copy link
Member

left a comment

I think it's better than no quarter-tiling at all, but it does feel a bit arbitrary in how it handles keystrokes right now.

y += height;
break;
case "tile-top":
if (!was_maximized_vertically) {

This comment has been minimized.

Copy link
@jlnr

jlnr Jul 6, 2019

Member

This if logic means a window in the bottom-left corner cannot be moved to the top-left corner by pressing ctrl+meta+up. I think this is a bit of a missed opportunity.

This comment has been minimized.

Copy link
@jlnr

jlnr Jul 6, 2019

Member

Conversely, maximized windows do react to ctrl+meta+down, and move to the bottom left corner. Maybe it would be more consistent if they occupied the bottom half of the screen? (And vice versa for up)

This comment has been minimized.

Copy link
@peteruithoven

peteruithoven Jul 9, 2019

Author Member

But doing that opens up a lot of edge cases, for example for determining on which side the window is. Since I'm limiting myself to already tiled windows it's left when x is 0, it's on the right when it's not.

This comment has been minimized.

Copy link
@jlnr

jlnr Jul 9, 2019

Member

maximized_vertically is true for tiled windows and maximized windows, which is why maximized windows can be shrunk into the bottom left corner using ctrl+shift+down right now.

I feel either the up/down shortcuts should be ignored in maximized windows, or they should do something that does not randomly favor the left over the right side (e.g. by using the full bottom half of the screen in this special case).

This comment has been minimized.

Copy link
@jlnr

jlnr Jul 9, 2019

Member

The code can still be simple that way:

If the cases for "tile-top" and "tile-bottom" left the x and width of the window alone, and only adjust y and height, then ctrl+shift+up could be used to move from "left half" to "top left corner", etc.

No need for edge cases :) We know that for maximized_vertically windows, the x and width are already fine as they are.

This comment has been minimized.

Copy link
@peteruithoven

peteruithoven Jul 10, 2019

Author Member

Good points, except for the fact that when I "unmaximize" a window it's position and size will be restored to a pre-tiled state. If I don't unmaximize I can't change the position and size.

I feel either the up/down shortcuts should be ignored in maximized windows, or they should do something that does not randomly favor the left over the right side (e.g. by using the full bottom half of the screen in this special case).

Good point! I'm now tiling to the full bottom or top of the screen when the window was maximized.

plugins/quartertiler/Main.vala Outdated Show resolved Hide resolved
@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Jul 10, 2019

So a little summarizing update, beside tiling using Super+Ctrl+1/2/3/4 I've implemented @btkostner's suggestion. You can now quarter tile using a two step process:

  1. Tile window to left or right using Super+Ctrl+Left/Right
  2. Quarter tile window to top or bottom of that side using Super+Ctrl+Up/Down

Tiling to top or bottom half is also supported:

  1. Maximize window using Super+Up
  2. Tile to top or bottom half using: Super+Ctrl+Up/Down

And thanks @jlnr for the code review.

@jlnr

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

Can't wait to try the updated branch 💪

Another thought: Does a majority of people use keyboards with numpads? (Definitely not me, I'm a complete TKL fanatic 😬) Would 1, 3, 6, 9 be more intuitive shortcuts for corner tiling in that case? You could also use 4 and 6 for half-screen tiling, etc...

@btkostner

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

@jlnr @cassidyjames That's a pretty cool idea. I would wonder how many people use a 10 key with elementary. I personally do, and this solution sounds like the best for me, but I'm not sure that would work for everyone...

@peteruithoven

This comment has been minimized.

Copy link
Member Author

commented Jul 10, 2019

I've personally never had those, on any of the laptops I've owned. But sounds like someone could just remap the Super+Ctrl+1/2/3/4 and Super+Ctrl+Left shortcuts?
You might miss something for the 2 and 8 though, something to directly tile something to the top or bottom half of the screen.

It's a pity it's not possible to bind multiple keyboard shortcuts to the same action, as far as I know.

plugins/quartertiler/Main.vala Outdated Show resolved Hide resolved
@renevall

This comment has been minimized.

Copy link

commented Aug 21, 2019

I hope this makes it. I'm actually using a UHD 3440x1440 and three panels side by side would be awesome too. But yes, hope all the work on this ticket makes it

cassidyjames and others added 2 commits Aug 29, 2019
@kgrubb kgrubb requested a review from jlnr Sep 18, 2019
@jlnr jlnr dismissed their stale review Oct 2, 2019

Thanks for resolving this.

@jlnr

This comment has been minimized.

Copy link
Member

commented Oct 2, 2019

@btkostner About the numpad idea: Turns out Ubuntu MATE 19.10 just changed it's tiling shortcuts away from a numpad-based system (see "New Key-bindings"). I don't know what data they've based it on, but it seems numpads are not an overwhelming majority then.

Copy link
Member

left a comment

The code is fine and does the job, but due to the technical limitations mentioned above, using the arrow keys feels a bit like a hack: cmd+ctrl+left+up only works if you press "left" before "up", etc.

Also, if you press cmd+ctrl+left, cmd+ctrl+down, cmd+ctrl+right, cmd+ctrl+down, you can see a ghost window floating in the wrong direction. I am not sure if this can be fixed easily.

I think it's up to @elementary/ux to decide whether this is polished enough. In any case, the number-based shortcuts feel solid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.