forked from qt-creator/qt-creator
macOS: Fix window state after going out of fullscreen
If you went out of fullscreen with the shortcut or menu item, it would not restore a previous maximized state, but instead resized the window to the smaller non-maximized state. So, 1. open Qt Creator and resize to some non-maximized size 2. double-click window title to maximize 3. Window > Enter Full Screen 4. Window > Exit Full Screen now returns correctly to state 2, not 1. Change-Id: I076321070d011d73bfe888c0a4a5ade24c1057d6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include <QEvent>
|
||||
#include <QMenu>
|
||||
#include <QWidget>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
@@ -111,6 +112,7 @@ bool WindowSupport::eventFilter(QObject *obj, QEvent *event)
|
||||
m_minimizeAction->setEnabled(!minimized);
|
||||
m_zoomAction->setEnabled(!minimized);
|
||||
}
|
||||
m_previousWindowState = static_cast<QWindowStateChangeEvent *>(event)->oldState();
|
||||
updateFullScreenAction();
|
||||
} else if (event->type() == QEvent::WindowActivate) {
|
||||
m_windowList->setActiveWindow(m_window);
|
||||
@@ -126,7 +128,7 @@ bool WindowSupport::eventFilter(QObject *obj, QEvent *event)
|
||||
void WindowSupport::toggleFullScreen()
|
||||
{
|
||||
if (m_window->isFullScreen()) {
|
||||
m_window->setWindowState(m_window->windowState() & ~Qt::WindowFullScreen);
|
||||
m_window->setWindowState(m_previousWindowState & ~Qt::WindowFullScreen);
|
||||
} else {
|
||||
m_window->setWindowState(m_window->windowState() | Qt::WindowFullScreen);
|
||||
}
|
||||
|
@@ -80,6 +80,7 @@ private:
|
||||
QAction *m_zoomAction;
|
||||
QAction *m_closeAction;
|
||||
QAction *m_toggleFullScreenAction;
|
||||
Qt::WindowStates m_previousWindowState;
|
||||
bool m_shutdown = false;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user