agzam / spacehammer

Hammerspoon config inspired by Spacemacs
MIT License
567 stars 70 forks source link

`center-window-frame` doesn't work nicely on ultra-wide screen #119

Closed agzam closed 3 years ago

agzam commented 3 years ago

Since switching to an ultra-wide monitor, I have noticed several things, but one irritatingly annoying issue stands out.

It looks like hs.window:centerOnScreen doesn't properly calculate the window size. It gets way too wide. I suspect the same problem would occur on a portrait-oriented screen, perhaps on the opposite axis (I have not tested this theory).

It's annoying me, mostly because windows/center-window-frame is used with edit-in-emacs feature, and I use that feature all the time.

For good measure, it would probably be nice if edit-in-emacs frame [instead of appearing in the center] would pop-up next to the app window [from where the edit session was initiated]. Perhaps, once we figure out the general tiling-window-manager feature [which I think would be nice to have in Spacehammer], it would just create a split, and Emacs frame appears precisely next to the app window.

But still, windows/center-window-frame probably needs to be fixed. The window should have the proper (and visually appealing) aspect ratio, regardless of the screen size.

Also, it would be nice to add interactive functions like: stretch-vertically, stretch-horizontally and make them available in Window modal.

jaidetree commented 3 years ago

2021-09-12 16 41 56

Just tried it myself. I see what you mean, the algorithm makes it nearly the full width of the screen depending on your grid dimensions.

To fix it I'm tempted to make a config option, and an advisable function:

In your config.fnl

{
  :center-window-ratio "40:30"
}

Where it would center the window to 40% of the width of the screen and 30% of the height of the screen and users can of course adjust to taste.

The advisable function comes into play so that users can customize how they want to apply the config option so they can use a different config format, and apply the resize however they want in case the default is insufficient.

How does that sound to you?

I'm definitely on board with window tiling as the next big feature I'd like to work on. I've got a concept in mind https://www.notion.so/eccentric-j/Spacehammer-Tiling-Manager-9c9e3326e23a4c2595ae739538348ad1 and will add those as requirements to it.

agzam commented 3 years ago

Where it would center the window to 40% of the width of the screen and 30% of the height of the screen and users can of course adjust to taste.

That sounds like a very reasonable approach to the problem, but I'd like to be careful and not screw up the default window size for many people, I think this should work.

agzam commented 3 years ago

I'm definitely on board with window tiling as the next big feature I'd like to work on.

Maybe we can utilize existing solutions like https://github.com/szymonkaliski/hhtwm? Or borrow some good ideas.

Tiling window manager is going to be quite a big milestone. It probably even would render many [most?] Window Modal features useless.

jaidetree commented 3 years ago

I'm definitely on board with window tiling as the next big feature I'd like to work on.

Maybe we can utilize existing solutions like https://github.com/szymonkaliski/hhtwm? Or borrow some good ideas.

Tiling window manager is going to be quite a big milestone. It probably even would render many [most?] Window Modal features useless.

That's going to be very helpful. Thanks!

jaidetree commented 3 years ago

Where it would center the window to 40% of the width of the screen and 30% of the height of the screen and users can of course adjust to taste.

That sounds like a very reasonable approach to the problem, but I'd like to be careful and not screw up the default window size for many people, I think this should work.

It can default to a ratio that's a near equivalent to the current behavior. It's definitely off when using a 27" monitor so I'd imagine even more bad on an ultra widescreen, and looks ok-ish on smaller monitors.

jaidetree commented 3 years ago

Got a fix up at #120 but depends on PR #118

jaidetree commented 3 years ago

118 was merged so good to test and review whenever

jaidetree commented 3 years ago

Moved fix to #121 to make it easier to check out these branches

jaidetree commented 3 years ago

Reopened the issue. Please confirm this solves the problem for you then I can close it 🙂

agzam commented 3 years ago

Wow, that was quick. This works very nicely. Thank you!