Commit fb7ff04d authored by Ahmad Samir's avatar Ahmad Samir Committed by Kurt Hindenburg
Browse files

Fix initial window size again; also always set Qt::WA_NativeWindow

The Qt::WA_NativeWindow attribute is need so that windowHandle() doesn't
return 0, since windowHandle() is used in two places now in the code, just
always set it.

When rememberWindowSize() is false, override the Window-Maximized config
key, which maximizes the window initially.

To test:
- unset "remember window size"
- close the window and make sure the config has been saved to konsolerc
- open konsole, keep the window unmaximized, close, open -> size is restored
- open konsole, maximize the window, close, open, the window is maximized
  even when rememberWindowSize() is false
parent 897435e5
......@@ -11,6 +11,7 @@
#include <QMenu>
#include <QMenuBar>
#include <QMouseEvent>
#include <QWindow>
// KDE
#include <KAcceleratorManager>
......@@ -67,6 +68,11 @@ MainWindow::MainWindow()
, _newTabMenuAction(nullptr)
, _pluggedController(nullptr)
{
// Set the WA_NativeWindow attribute to force the creation of the QWindow.
// Without this QWidget::windowHandle() returns 0.
// See https://phabricator.kde.org/D23108
setAttribute(Qt::WA_NativeWindow);
updateUseTransparency();
// create actions for menus
......@@ -842,10 +848,6 @@ void MainWindow::setBlur(bool blur)
#if KWINDOWSYSTEM_VERSION < QT_VERSION_CHECK(5, 82, 0)
KWindowEffects::enableBlurBehind(winId(), blur);
#else
// Set the WA_NativeWindow attribute to force the creation of the QWindow.
// Without this QWidget::windowHandle() returns 0.
// See https://phabricator.kde.org/D23108
setAttribute(Qt::WA_NativeWindow);
if (QWindow *window = windowHandle()) {
KWindowEffects::enableBlurBehind(window, blur);
} else {
......@@ -897,6 +899,13 @@ void MainWindow::showEvent(QShowEvent *event)
// (ViewManager, TabbedViewContainer, TerminalDisplay ... etc)
// have been created and TabbedViewContainer::sizeHint() returns
// a usuable size.
// Remove the WindowMaximized state to override the Window-Maximized
// config key
if (QWindow *window = windowHandle()) {
window->setWindowStates(window->windowStates() & ~Qt::WindowMaximized);
}
resize(sizeHint());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment