Skip to content

Implement Microsoft Windows snapping behavior for easier snapping to corners #144

Closed

Description

@orena1

I really like the tool, lately I got a to work on a windows pc, and I actually think that the way the snap is working on windows is better. It is hard to explain exactly the shortcuts, but it feel very natural.

https://www.zdnet.com/article/windows-10-tip-more-window-snapping-shortcuts-and-secrets/

Do you think it will be possible to implement a windows mode?

There is also a linux implementation -
https://extensions.gnome.org/extension/1723/wintile-windows-10-window-tiling-for-gnome/

Activity

  1. rxhanson commented on May 5, 2020

    @rxhanson
    Owner

    I don't understand what you're asking for. Are you asking to have a preset that of shortcuts so that you don't have to manually configure them?

  2. orena1 commented on May 5, 2020

    @orena1
    Author

    Its not exactly that, the whole way snap is handled in windows is different, see this video for example:
    https://www.youtube.com/watch?v=9RkfHNUhYiQ&t=182s

    In windows you just click w+left or w+right w+up, w+downs and it moved the window relative to the location the window is, no need to remember any shortcuts.

    As I said it is hard to explain, but if you ever next to a windows machine, try the snap shortcuts and you will see, its very intuitive.

  3. rxhanson commented on May 5, 2020

    @rxhanson
    Owner

    Ok, that video made it easier to understand what you're looking for. This makes sense to me, and I think it would be worthwhile to have.

    However, I don't currently have the time to add it in myself. If anyone wants to work on it, I would definitely consider a pull request for it.

    Windows is a little bit different in that the shortcuts are not configurable by the user (last I used Windows), so there's some edge case scenarios where this could behave weirdly for a user that doesn't have the default configuration in Rectangle. An implementation of this would most likely have to take into account the actual keycombo that results in each action, so that you can change for example what happens when a user presses the down keycombo if the window has been previously snapped to a side half. Knowing what keycombo was executed is not something that's tracked currently - just the resulting actions are kept track of. There's a decent amount to consider with this, so I don't see it as a trivial change.

  4. changed the title [-]Implement microsoft windows shortcuts[/-] [+]Implement Microsoft Windows snapping behavior for easier snapping to screen corners[/+] on May 5, 2020
  5. changed the title [-]Implement Microsoft Windows snapping behavior for easier snapping to screen corners[/-] [+]Implement Microsoft Windows snapping behavior for easier snapping to corners[/+] on May 5, 2020
  6. orena1 commented on May 5, 2020

    @orena1
    Author

    Thank you for taking the time to understand my request. I understand now that it is not easy to implement, but at least the request is out-there .

  7. VariantXYZ commented on Jun 17, 2020

    @VariantXYZ

    As a suggestion, maybe something like the following could work as an interim watered down implementation?

    • Map 'Modifier + Direction' to the already existing 'Move Left', 'Move Right' modifiers (having these not affect window height/auto-center)
    • Mod + Up:
      • If window height is not 'maximum': Maximize height
      • If window height is 'maximum': Maximize width
    • Mod + Down:
      • If window height is not 'maximum': Minimize window
      • If window height is 'maximum': Set window height to 'bottom corner height'

    It isn't the exact behavior Windows does (for example, if you have a floating window, Win+Left would map to left half, and Win+Right would bring restore the window to its original position), but it would mean that you could easily move and snap windows to corners, resize to half, maximize, or minimize within 3 key presses, which covers a lot of the Windows-style snapping functionality.

    It would also mean that current window height is the only 'state' that needs to be checked, no need to save the user state elsewhere.

  8. rxhanson commented on Jun 17, 2020

    @rxhanson
    Owner

    My initial thought on doing this is that it would be implemented best as a separate mode where most of the customizable shortcuts are not used, and instead the user selects a modifier key combination that all of the arrow keys use with the behavior of Windows hardcoded in. Unfortunately, this would kind of push it out of the scope of what I'd like to have in Rectangle in terms of complexity (mainly from a user's perspective, but somewhat from a developer perspective), but if there's more straightforward ways to add in some of the behavior then I'm open to PRs for it.

  9. VariantXYZ commented on Jun 17, 2020

    @VariantXYZ

    Ah, my earlier suggestion was made to minimize overall changes to the current scheme. Most of the intuitive nature of the way Windows snapping works stems from how it behaves based on the current window's position, so just adding that adaptive behavior based on the height seemed like a reasonable approach.

    If it's an acceptable compromise, I can try giving it a shot and creating a PR, though I'll admit I have no experience with Swift.

  10. VariantXYZ commented on Jun 18, 2020

    @VariantXYZ

    (Actually, it occurs to me my logic earlier was wrong anyway, it wouldn't be possible to go to the top quarters reasonably)

  11. rxhanson commented on Jun 18, 2020

    @rxhanson
    Owner

    To hopefully clarify my last comment: in my opinion even the interim solution presented already walks far enough down the path of the alternate "Windows mode" that we'd have to tackle most of the additional complexity from both user and developer perspective that we'd have to tackle if we just implemented the entire suite of Windows behavior. I'm not trying to deter you from giving it a go, but there's some considerations that we'd probably want to think through if this gets put in place:

    • How does a user configure it?
    • Just a checkbox and we use preset modifier keys (ctrl+alt) + arrows? Allowing the user to configure the mod keys would require either a bunch of checkboxes (not great) or a modified version of MASShortcut (right now Rectangle uses out-of-the-box MASShortcut - I've modified it for this use in my other apps but think it's best for the simplicity of Rectangle to not have a modified version of MASShortcut).
    • What if this conflicts with shortcuts already configured? Do we just disable those shortcuts or automatically remove the configs for them?

    Some more watered down behavior that might not require thinking through some of these items would be to change what happens on subsequent executions of each shortcut based on what was last executed. For example, a repeated execution of maximize height can maximize the width.

  12. VariantXYZ commented on Jun 19, 2020

    @VariantXYZ

    Some more watered down behavior that might not require thinking through some of these items would be to change what happens on subsequent executions of each shortcut based on what was last executed. For example, a repeated execution of maximize height can maximize the width.

    Something like a state machine? I've been messing around on my Windows machine, and I've come to realize that rather than care about subsequent actions, it only really cares about the current 'state' of the window, memorizing only the 'restored' state of the window.

    For example:
    2020-06-18-19-10-00

    Every time it was minimized was Win + Down, restoration was Alt+Tab, and you can see that whenever it got restored to its not-maximized not-snap state, it'd always return to that spot on the left of the screen.

    From an implementation standpoint, a lot of the existing behavior could still work with it. Rectangle already remembers the positions of windows, so maybe it'd be good enough to just have a single additional checkbox like 'Windows-style state transitions' with the option to set a modifier key?

  13. rxhanson commented on Jun 20, 2020

    @rxhanson
    Owner

    I think you're right - it is possible to get most of the desired Windows behavior with just a single checkbox provided we leverage corresponding window calculations (like right, left and maximize height) as part of the Windows behavior state machine.

    Currently, each window calculation that handles repeated executions has its own state machine to determine which action to perform next. Current window position is not taken into account, but it is not that difficult to add it in. These individual state machines are probably the most logical place to add in Windows behavior, but the downside of that is the added complexity to each calculation based on that. Definitely not desirable. Perhaps it would be more elegant to have the Windows behavior state machine in its entirety contained in its own class.

    Mod+down doesn't have any corresponding action in Rectangle, so there is the issue of how that gets added in.

  14. added
    enhancement
    on Jun 27, 2020
  15. bushnerd commented on Jul 27, 2020

    @bushnerd

    Great, i think it's a very useful function, highly anticipated waiting this enhancement.

  16. rxhanson commented on Nov 15, 2020

    @rxhanson
    Owner

    I added my first cut of this feature to my paid app, Hookshot. Apologies, but I have no plans to port it to Rectangle. A lot of the necessary pieces for this functionality already existed in Hookshot, and they're not really pieces that I want to have in Rectangle as they add a decent amount of complexity to the code.

    Closing this one out, but feel free to send feedback my way if you give Hookshot a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions