macOS: Handle NSViewGlobalFrameDidChangeNotification via QCocoaWindow
The notification is only posted for NSViews with attached surfaces, meaning NSOpenGLContext, so there's no need to guard the subscription within [QNSView setQCocoaGLContext:]. Change-Id: I8179e58c84925a756315b711d15fa9c356adaecf Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>bb10
parent
c1c99c3bfe
commit
ab1744b18d
|
|
@ -198,6 +198,7 @@ public:
|
|||
Q_NOTIFICATION_HANDLER(NSWindowDidMoveNotification) void windowDidMove();
|
||||
Q_NOTIFICATION_HANDLER(NSWindowDidResizeNotification) void windowDidResize();
|
||||
Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification) void viewDidChangeFrame();
|
||||
Q_NOTIFICATION_HANDLER(NSViewGlobalFrameDidChangeNotification) void viewDidChangeGlobalFrame();
|
||||
Q_NOTIFICATION_HANDLER(NSWindowDidEndLiveResizeNotification) void windowDidEndLiveResize();
|
||||
Q_NOTIFICATION_HANDLER(NSWindowDidBecomeKeyNotification) void windowDidBecomeKey();
|
||||
Q_NOTIFICATION_HANDLER(NSWindowDidResignKeyNotification) void windowDidResignKey();
|
||||
|
|
|
|||
|
|
@ -1270,6 +1270,18 @@ void QCocoaWindow::viewDidChangeFrame()
|
|||
[qnsview_cast(m_view) updateGeometry];
|
||||
}
|
||||
|
||||
/*!
|
||||
Callback for NSViewGlobalFrameDidChangeNotification.
|
||||
|
||||
Posted whenever an NSView object that has attached surfaces (that is,
|
||||
NSOpenGLContext objects) moves to a different screen, or other cases
|
||||
where the NSOpenGLContext object needs to be updated.
|
||||
*/
|
||||
void QCocoaWindow::viewDidChangeGlobalFrame()
|
||||
{
|
||||
updateExposedGeometry();
|
||||
}
|
||||
|
||||
void QCocoaWindow::windowDidEndLiveResize()
|
||||
{
|
||||
if (m_synchedWindowState == Qt::WindowMaximized && ![m_nsWindow isZoomed]) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
|
|||
QStringList *currentCustomDragTypes;
|
||||
bool m_sendUpAsRightButton;
|
||||
Qt::KeyboardModifiers currentWheelModifiers;
|
||||
bool m_subscribesForGlobalFrameNotifications;
|
||||
#ifndef QT_NO_OPENGL
|
||||
QCocoaGLContext *m_glContext;
|
||||
bool m_shouldSetGLContextinDrawRect;
|
||||
|
|
|
|||
|
|
@ -149,7 +149,6 @@ static bool _q_dontOverrideCtrlLMB = false;
|
|||
m_acceptedMouseDowns = Qt::NoButton;
|
||||
m_frameStrutButtons = Qt::NoButton;
|
||||
m_sendKeyEvent = false;
|
||||
m_subscribesForGlobalFrameNotifications = false;
|
||||
#ifndef QT_NO_OPENGL
|
||||
m_glContext = 0;
|
||||
m_shouldSetGLContextinDrawRect = false;
|
||||
|
|
@ -181,7 +180,6 @@ static bool _q_dontOverrideCtrlLMB = false;
|
|||
CGImageRelease(m_maskImage);
|
||||
[m_trackingArea release];
|
||||
m_maskImage = 0;
|
||||
m_subscribesForGlobalFrameNotifications = false;
|
||||
[m_inputSource release];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[m_mouseMoveHelper release];
|
||||
|
|
@ -235,27 +233,9 @@ static bool _q_dontOverrideCtrlLMB = false;
|
|||
//was unable to set view
|
||||
m_shouldSetGLContextinDrawRect = true;
|
||||
}
|
||||
|
||||
if (!m_subscribesForGlobalFrameNotifications) {
|
||||
// NSOpenGLContext expects us to repaint (or update) the view when
|
||||
// it changes position on screen. Since this happens unnoticed for
|
||||
// the view when the parent view moves, we need to register a special
|
||||
// notification that lets us handle this case:
|
||||
m_subscribesForGlobalFrameNotifications = true;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(globalFrameChanged:)
|
||||
name:NSViewGlobalFrameDidChangeNotification
|
||||
object:self];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void) globalFrameChanged:(NSNotification*)notification
|
||||
{
|
||||
Q_UNUSED(notification);
|
||||
m_platformWindow->updateExposedGeometry();
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToSuperview
|
||||
{
|
||||
if (!(m_platformWindow->m_viewIsToBeEmbedded))
|
||||
|
|
|
|||
Loading…
Reference in New Issue