BLumia / pineapple-pictures

A homebrew lightweight image viewer.
https://sourceforge.net/projects/pineapple-pictures/
MIT License
397 stars 50 forks source link

Resolve resize issue under Qt 6 environment. #81

Closed yyc12345 closed 1 year ago

yyc12345 commented 1 year ago

Qt 6 assume that Qt::WindowMinMaxButtonsHint depend on Qt::WindowSystemMenuHint. And hard-code this in its source code. Source code reference: https://github.com/qt/qtbase/blob/6.4.2/src/plugins/platforms/windows/qwindowswindow.cpp#L833

However, if Qt::WindowSystemMenuHint added, an extra window style called WS_SYSMENU will be added for this frameless window. Due to Windows implementation, if WS_SYSMENU existed, any resize operations of this window will fail, even QWidget::nativeEvent() was still running.

I have tried QWidget::setWindowFlag(Qt::WindowSystemMenuHint, false); but it doesn't work. Obviously, we can remove Qt::WindowMinMaxButtonsHint to solve this issue. But we can not click icon on taskbar to minimize this window if removing it. This breaks the experience of this app, then I gave this up.

So this is the final solution. I use native Win32 API to forced remove this annoying flag.

BLumia commented 1 year ago

Another solution is... simply remove Qt::WindowMinMaxButtonsHint from window flags list, but then Winkey+Up / Winkey+Down will likely no longer works, and user will also no longer be able to minimize the window by clicking the taskbar icon.

I updated the master branch code with this as a workaround change before the real fix comes out.

yyc12345 commented 1 year ago

that's all what i have done. hope you can check it out, especially code format and memory issue. the references of this implementation already has been written in code file.