Rename QMacScopedObserver to the more fittingly QMacNotificationObserver
Change-Id: I1d8280fe88871572a3a27e612de49717b3b9ef77 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
c3571d2922
commit
a67b25067e
@ -295,13 +295,13 @@ QT_MAC_WEAK_IMPORT(_os_activity_current);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#if defined( __OBJC__)
|
||||
class QMacScopedObserver
|
||||
class QMacNotificationObserver
|
||||
{
|
||||
public:
|
||||
QMacScopedObserver() {}
|
||||
QMacNotificationObserver() {}
|
||||
|
||||
template<typename Functor>
|
||||
QMacScopedObserver(id object, NSNotificationName name, Functor callback) {
|
||||
QMacNotificationObserver(id object, NSNotificationName name, Functor callback) {
|
||||
observer = [[NSNotificationCenter defaultCenter] addObserverForName:name
|
||||
object:object queue:nil usingBlock:^(NSNotification *) {
|
||||
callback();
|
||||
@ -309,13 +309,13 @@ public:
|
||||
];
|
||||
}
|
||||
|
||||
QMacScopedObserver(const QMacScopedObserver& other) = delete;
|
||||
QMacScopedObserver(QMacScopedObserver&& other) : observer(other.observer) {
|
||||
QMacNotificationObserver(const QMacNotificationObserver& other) = delete;
|
||||
QMacNotificationObserver(QMacNotificationObserver&& other) : observer(other.observer) {
|
||||
other.observer = nil;
|
||||
}
|
||||
|
||||
QMacScopedObserver &operator=(const QMacScopedObserver& other) = delete;
|
||||
QMacScopedObserver &operator=(QMacScopedObserver&& other) {
|
||||
QMacNotificationObserver &operator=(const QMacNotificationObserver& other) = delete;
|
||||
QMacNotificationObserver &operator=(QMacNotificationObserver&& other) {
|
||||
if (this != &other) {
|
||||
remove();
|
||||
observer = other.observer;
|
||||
@ -329,7 +329,7 @@ public:
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:observer];
|
||||
observer = nil;
|
||||
}
|
||||
~QMacScopedObserver() { remove(); }
|
||||
~QMacNotificationObserver() { remove(); }
|
||||
|
||||
private:
|
||||
id observer = nil;
|
||||
|
@ -80,7 +80,7 @@ private:
|
||||
NSOpenGLContext *m_shareContext = nil;
|
||||
QSurfaceFormat m_format;
|
||||
bool m_didCheckForSoftwareContext = false;
|
||||
QVarLengthArray<QMacScopedObserver, 3> m_updateObservers;
|
||||
QVarLengthArray<QMacNotificationObserver, 3> m_updateObservers;
|
||||
QAtomicInt m_needsUpdate = false;
|
||||
};
|
||||
|
||||
|
@ -404,13 +404,13 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
|
||||
m_updateObservers.clear();
|
||||
|
||||
if (view.layer) {
|
||||
m_updateObservers.append(QMacScopedObserver(view, NSViewFrameDidChangeNotification, updateCallback));
|
||||
m_updateObservers.append(QMacScopedObserver(view.window, NSWindowDidChangeScreenNotification, updateCallback));
|
||||
m_updateObservers.append(QMacNotificationObserver(view, NSViewFrameDidChangeNotification, updateCallback));
|
||||
m_updateObservers.append(QMacNotificationObserver(view.window, NSWindowDidChangeScreenNotification, updateCallback));
|
||||
} else {
|
||||
m_updateObservers.append(QMacScopedObserver(view, NSViewGlobalFrameDidChangeNotification, updateCallback));
|
||||
m_updateObservers.append(QMacNotificationObserver(view, NSViewGlobalFrameDidChangeNotification, updateCallback));
|
||||
}
|
||||
|
||||
m_updateObservers.append(QMacScopedObserver([NSApplication sharedApplication],
|
||||
m_updateObservers.append(QMacNotificationObserver([NSApplication sharedApplication],
|
||||
NSApplicationDidChangeScreenParametersNotification, updateCallback));
|
||||
|
||||
// If any of the observers fire at this point it's fine. We check the
|
||||
|
@ -144,7 +144,7 @@ private:
|
||||
#endif
|
||||
QScopedPointer<QPlatformTheme> mPlatformTheme;
|
||||
QList<QCocoaScreen *> mScreens;
|
||||
QMacScopedObserver m_screensObserver;
|
||||
QMacNotificationObserver m_screensObserver;
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
QCocoaClipboard *mCocoaClipboard;
|
||||
#endif
|
||||
|
@ -207,7 +207,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList)
|
||||
// which will resolve to an actual value and result in screen invalidation.
|
||||
cocoaApplication.presentationOptions = NSApplicationPresentationDefault;
|
||||
|
||||
m_screensObserver = QMacScopedObserver([NSApplication sharedApplication],
|
||||
m_screensObserver = QMacNotificationObserver([NSApplication sharedApplication],
|
||||
NSApplicationDidChangeScreenParametersNotification, [&]() { updateScreens(); });
|
||||
updateScreens();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user