From 920ba35397623a0743fe25e90094e4e86dd64822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 5 Jul 2017 14:12:42 +0200 Subject: macOS: Use same naming for QPA event forwarding functions Expose events and others will follow. Change-Id: I8e11a133381a678517b54ad1872fe302515d4104 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.h | 8 ++++-- src/plugins/platforms/cocoa/qcocoawindow.mm | 40 ++++++++++++++--------------- 2 files changed, 26 insertions(+), 22 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 533ad3444b..57e00e6bfe 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -149,8 +149,6 @@ public: bool windowShouldClose(); bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const; - void reportCurrentWindowState(bool unconditionally = false); - NSInteger windowLevel(Qt::WindowFlags flags); NSUInteger windowStyleMask(Qt::WindowFlags flags); void setWindowZoomButton(Qt::WindowFlags flags); @@ -226,7 +224,13 @@ public: // for QNSView bool alwaysShowToolWindow() const; void removeMonitor(); + enum HandleFlags { + NoHandleFlags = 0, + HandleUnconditionally = 1 + }; + void handleGeometryChange(); + void handleWindowStateChanged(HandleFlags flags = NoHandleFlags); NSView *m_view; QCocoaNSWindow *m_nsWindow; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 3d8d4d35be..b2b522e824 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -840,7 +840,7 @@ void QCocoaWindow::windowDidMove() handleGeometryChange(); // Moving a window might bring it out of maximized state - reportCurrentWindowState(); + handleWindowStateChanged(); } void QCocoaWindow::windowDidResize() @@ -851,7 +851,7 @@ void QCocoaWindow::windowDidResize() handleGeometryChange(); if (!m_view.inLiveResize) - reportCurrentWindowState(); + handleWindowStateChanged(); } void QCocoaWindow::viewDidChangeFrame() @@ -873,7 +873,7 @@ void QCocoaWindow::viewDidChangeGlobalFrame() void QCocoaWindow::windowDidEndLiveResize() { - reportCurrentWindowState(); + handleWindowStateChanged(); } void QCocoaWindow::windowDidBecomeKey() @@ -910,12 +910,12 @@ void QCocoaWindow::windowDidResignKey() void QCocoaWindow::windowDidMiniaturize() { - reportCurrentWindowState(); + handleWindowStateChanged(); } void QCocoaWindow::windowDidDeminiaturize() { - reportCurrentWindowState(); + handleWindowStateChanged(); } void QCocoaWindow::windowWillEnterFullScreen() @@ -934,7 +934,7 @@ void QCocoaWindow::windowDidEnterFullScreen() // Reset to original styleMask setWindowFlags(m_windowFlags); - reportCurrentWindowState(); + handleWindowStateChanged(); } void QCocoaWindow::windowWillExitFullScreen() @@ -955,7 +955,7 @@ void QCocoaWindow::windowDidExitFullScreen() Qt::WindowState requestedState = window()->windowState(); // Deliver update of QWindow state - reportCurrentWindowState(); + handleWindowStateChanged(); if (requestedState != windowState() && requestedState != Qt::WindowFullScreen) { // We were only going out of full screen as an intermediate step before @@ -1071,6 +1071,17 @@ void QCocoaWindow::handleGeometryChange() [qnsview_cast(m_view) clearBackingStore]; } +void QCocoaWindow::handleWindowStateChanged(HandleFlags flags) +{ + Qt::WindowState currentState = windowState(); + if (!(flags & HandleUnconditionally) && currentState == m_lastReportedWindowState) + return; + + QWindowSystemInterface::handleWindowStateChanged( + window(), currentState, m_lastReportedWindowState); + m_lastReportedWindowState = currentState; +} + // -------------------------------------------------------------------------- bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const @@ -1344,7 +1355,7 @@ void QCocoaWindow::applyWindowState(Qt::WindowStates requestedState) // If content view width or height is 0 then the window animations will crash so // do nothing. We report the current state back to reflect the failed operation. qWarning("invalid window content view size, check your window geometry"); - reportCurrentWindowState(true); + handleWindowStateChanged(HandleUnconditionally); return; } @@ -1353,7 +1364,7 @@ void QCocoaWindow::applyWindowState(Qt::WindowStates requestedState) if (nsWindow.styleMask & NSUtilityWindowMask && newState & (Qt::WindowMinimized | Qt::WindowFullScreen)) { qWarning() << window()->type() << "windows can not be made" << newState; - reportCurrentWindowState(true); + handleWindowStateChanged(HandleUnconditionally); return; } @@ -1453,17 +1464,6 @@ Qt::WindowState QCocoaWindow::windowState() const return Qt::WindowNoState; } -void QCocoaWindow::reportCurrentWindowState(bool unconditionally) -{ - Qt::WindowState currentState = windowState(); - if (!unconditionally && currentState == m_lastReportedWindowState) - return; - - QWindowSystemInterface::handleWindowStateChanged( - window(), currentState, m_lastReportedWindowState); - m_lastReportedWindowState = currentState; -} - bool QCocoaWindow::setWindowModified(bool modified) { if (!isContentView()) -- cgit v1.2.3