nuttyartist / notes

Fast and beautiful note-taking app written in C++. Write down your thoughts.
https://notes-foss.com
Mozilla Public License 2.0
3.81k stars 338 forks source link

Resizing on tiling window managers is broken #454

Open zjeffer opened 1 year ago

zjeffer commented 1 year ago

https://user-images.githubusercontent.com/4633209/213937857-2236bb1c-742e-463a-8e1c-1e8cf6e97042.mp4

This is on bspwm, a tiling window manager running in X11. Resizing with bspwm's keyboard shortcuts works fine: I press super+left click on the window to move, super+right click near a corner to resize.

1) Moving the window using the window bar works fine. 2) Resizing the window by dragging the top border continuously moves the window diagonally to the left until I release the mouse button. Only the top border seems to be interactive.

bjorn commented 1 year ago

For sure related to our custom resizing implementation, which can be found in the code by looking for m_canStretchWindow. While it would be nice to fix it, this code should likely also get disabled when a native frame is used.

nuttyartist commented 1 year ago

For sure related to our custom resizing implementation, which can be found in the code by looking for m_canStretchWindow. While it would be nice to fix it, this code should likely also get disabled when a native frame is used.

👍

zjeffer commented 1 year ago

Just out of interest, why do we have a custom resizing implementation? What does it do better than the normal Qt resizing?

guihkx commented 1 year ago

I could be wrong, but I believe once we go "frameless mode", we have to (or had to) deal with window decorations and window controls ourselves...

nuttyartist commented 1 year ago

I could be wrong, but I believe once we go "frameless mode", we have to (or had to) deal with window decorations and window controls ourselves...

Exactly. It's a big pain to do so, it's never as smooth as native. On macOS it's a native experience because we're using custom native Objective-C code from this repo https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window. We should also try to integrate its Windows equivalent (in the same repo), but I remember the last programmer reported problems to do so. We should try again tho.

nuttyartist commented 1 year ago

Seems like there are many other cool open source projects:

This one is pretty cool https://github.com/zhiyiYo/PyQt-Frameless-Window based on: https://github.com/wangwenx190/framelesshelper https://github.com/winsoft666/Qt-FramelessWindow https://github.com/antonypro/QGoodWindow

bjorn commented 1 year ago

Of course, similar to our change to use startSystemMove (#445), for proper resizing behavior we need to call startSystemResize.

nuttyartist commented 1 year ago

Of course, similar to our change to use startSystemMove (#445), for proper resizing behavior we need to call startSystemResize.

Oh, cool.

nuttyartist commented 1 year ago

Is this fixed after https://github.com/nuttyartist/notes/pull/492? @guihkx

guihkx commented 1 year ago

I'm not really sure. Perhaps @zjeffer can retest this...

zjeffer commented 1 year ago

It's not completely fixed but is has been improved. Resizing using the window borders is now impossible unless I enable non-native frame, and double click the border.

So only point 3 needs to be fixed. Preferably, double clicking the border shouldn't really do anything.

zjeffer commented 1 year ago

Current situation when building the dev branch, starting from a clean settings file:

https://user-images.githubusercontent.com/4633209/221948417-65ac04fc-cdfc-4b74-b03b-37b4171a72a3.mp4

Since recently, the 'double clicked mode' seems to have shadows inside of the window borders (these borders are automatically added by my window manager). I would expect to see those shadows outside of the border.

bjorn commented 1 year ago

I would expect to see those shadows outside of the border.

Hmm, yes, but then the window manager has to draw the shadow rather than Notes, I guess.

guihkx commented 1 year ago

Oof. When you double click the title bar, the window is actually supposed to be maximized (to mimic what most window managers do), but I'm guessing bspwm doesn't allow that on purpose?

The margins and shadows around the window were restored in #492, so users could resize it properly. We could get rid of the margins again, but in my opinion the resizing mechanism has to be improved as well...

Overall, we should probably recommend using native window decorations for people using tiling window managers.

nuttyartist commented 1 year ago

Current situation when building the dev branch, starting from a clean settings file:

Since recently, the 'double clicked mode' seems to have shadows inside of the window borders (these borders are automatically added by my window manager). I would expect to see those shadows outside of the border.

Oh no, how come with native window rendering you can't resize the window? Is this only a problem with your specific window manager? At least that should work...

zjeffer commented 1 year ago

Oh no, how come with native window rendering you can't resize the window?

That's a tiling window manager thing; not a problem :)

zjeffer commented 1 year ago

Oof. When you double click the title bar, the window is actually supposed to be maximized (to mimic what most window managers do), but I'm guessing bspwm doesn't allow that on purpose?

Maximizing on bspwm works by putting the window in the monocle mode, which requires a specific keybind, not something you can do with the mouse.

Usually, bspwm hides the titlebar anyway, so the user never gets to double click the titlebar. For apps that implement custom window decorations (like Visual Studio Code), this is how it looks:

https://user-images.githubusercontent.com/4633209/222233737-5bbe398a-7336-436f-b6a4-6529d56ca86f.mp4

So the maximizing function does get called, and the middle button changes. But nothing happens to the window itself. I would prefer something like this to happen in Notes, too.

Maybe we could find a way to fix the margins and shadows, and improve resizing, but without the impact on tiling wms.

Overall, we should probably recommend using native window decorations for people using tiling window managers.

Definitely

zjeffer commented 1 year ago

I'm also getting strange behaviour in my Ubuntu VM (latest master Qt6 AppImage):

https://user-images.githubusercontent.com/4633209/226169308-cae43aa7-ed40-45ef-b11a-7ee382d47eda.mp4

Maybe this happens because I'm on a VM running inside a tiling WM, can any of you check whether this same thing happens on your machines?

zjeffer commented 1 year ago

I just found the above only happens when:

1) Starting the application with native decorations enabled 2) Disabling native decorations inside the application 3) The bug will occur

When starting the application with native decorations already disabled, this bug doesn't occur. I'll create a separate issue. The bug in this issue still happens on bspwm, regardless of when I disable native decorations.

nuttyartist commented 1 year ago

Weird. Day by day I'm getting more used to the fact that we should ship native window decorations by default on Linux as well. Edit: It just doesn't look sexy ):