Changeset 52509 in vbox
- Timestamp:
- Aug 28, 2014 11:31:23 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95745
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.h
r50491 r52509 47 47 { 48 48 public: 49 49 50 static UICocoaApplication* instance(); 50 51 void hide(); … … 55 56 56 57 /** Register passed @a pWidget to native notification @a strNativeNotificationName, using @a pCallback as handler. */ 57 void registerToN ativeNotification(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback);58 void registerToNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback); 58 59 /** Unregister passed @a pWidget from native notification @a strNativeNotificationName. */ 59 void unregisterFromN ativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);60 void unregisterFromNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget); 60 61 /** Redirects native notification @a pstrNativeNotificationName for window @a pWindow to registered listener. */ 61 void nativeNotificationProxy (NativeNSStringRef pstrNativeNotificationName, NativeNSWindowRef pWindow);62 void nativeNotificationProxyForWidget(NativeNSStringRef pstrNativeNotificationName, NativeNSWindowRef pWindow); 62 63 63 64 private: 65 64 66 UICocoaApplication(); 65 67 static UICocoaApplication *m_pInstance; … … 68 70 69 71 /** Map of notification callbacks registered for corresponding QWidget(s). */ 70 QMap<QWidget*, QMap<QString, PfnNativeNotificationCallbackForQWidget> > m_ callbacks;72 QMap<QWidget*, QMap<QString, PfnNativeNotificationCallbackForQWidget> > m_widgetCallbacks; 71 73 }; 72 74 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.mm
r51248 r52509 69 69 - (void)unsetCallback:(uint32_t)fMask :(PFNVBOXCACALLBACK)pfnCallback :(void *)pvUser; 70 70 71 - (void)registerToNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow; 72 - (void)unregisterFromNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow; 73 - (void)notificationCallback :(NSNotification*)notification; 71 - (void)registerToNotificationOfWindow :(NSString*)pstrNotificationName :(NSWindow*)pWindow; 72 - (void)unregisterFromNotificationOfWindow :(NSString*)pstrNotificationName :(NSWindow*)pWindow; 73 74 - (void)notificationCallbackOfWindow :(NSNotification*)notification; 74 75 @end /* @interface UICocoaApplicationPrivate */ 75 76 … … 166 167 167 168 /** Register @a pWindow to cocoa notification @a pstrNotificationName. */ 168 - (void) registerToNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow169 - (void) registerToNotificationOfWindow :(NSString*)pstrNotificationName :(NSWindow*)pWindow 169 170 { 170 171 /* Register notification observer: */ 171 172 [[NSNotificationCenter defaultCenter] addObserver:self 172 selector:@selector(notificationCallback :)173 selector:@selector(notificationCallbackOfWindow:) 173 174 name:pstrNotificationName 174 175 object:pWindow]; … … 176 177 177 178 /** Unregister @a pWindow from cocoa notification @a pstrNotificationName. */ 178 - (void) unregisterFromNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow179 - (void) unregisterFromNotificationOfWindow :(NSString*)pstrNotificationName :(NSWindow*)pWindow 179 180 { 180 181 /* Uninstall notification observer: */ … … 185 186 186 187 /** Redirects cocoa @a notification to UICocoaApplication instance. */ 187 - (void) notificationCallback :(NSNotification*)notification188 - (void) notificationCallbackOfWindow :(NSNotification*)notification 188 189 { 189 190 /* Get current notification name: */ 190 191 NSString *pstrName = [notification name]; 191 192 192 /* Define known notification names: */ 193 NSString *spstrWillEnterFullscreenNotification = @"NSWindowWillEnterFullScreenNotification"; 194 NSString *spstrDidEnterFullscreenNotification = @"NSWindowDidEnterFullScreenNotification"; 195 NSString *spstrWillExitFullscreenNotification = @"NSWindowWillExitFullScreenNotification"; 196 NSString *spstrDidExitFullscreenNotification = @"NSWindowDidExitFullScreenNotification"; 197 NSString *spstrDidFailToEnterFullScreenNotification = @"NSWindowDidFailToEnterFullScreenNotification"; 198 199 /* Redirect known notifications to UICocoaApplication instance: */ 200 if ( [pstrName isEqualToString :spstrWillEnterFullscreenNotification] 201 || [pstrName isEqualToString :spstrDidEnterFullscreenNotification] 202 || [pstrName isEqualToString :spstrWillExitFullscreenNotification] 203 || [pstrName isEqualToString :spstrDidExitFullscreenNotification] 204 || [pstrName isEqualToString :spstrDidFailToEnterFullScreenNotification]) 205 UICocoaApplication::instance()->nativeNotificationProxy(pstrName, [notification object]); 193 /* Redirect known notifications to widgets: */ 194 UICocoaApplication::instance()->nativeNotificationProxyForWidget(pstrName, [notification object]); 206 195 } 207 196 @end /* @implementation UICocoaApplicationPrivate */ … … 251 240 } 252 241 253 void UICocoaApplication::registerToNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback) 242 void UICocoaApplication::registerToNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget, 243 PfnNativeNotificationCallbackForQWidget pCallback) 254 244 { 255 245 /* Make sure it is not registered yet: */ 256 AssertReturnVoid(!m_ callbacks.contains(pWidget) || !m_callbacks[pWidget].contains(strNativeNotificationName));246 AssertReturnVoid(!m_widgetCallbacks.contains(pWidget) || !m_widgetCallbacks[pWidget].contains(strNativeNotificationName)); 257 247 258 248 /* Remember callback: */ 259 m_ callbacks[pWidget][strNativeNotificationName] = pCallback;249 m_widgetCallbacks[pWidget][strNativeNotificationName] = pCallback; 260 250 261 251 /* Register observer: */ 262 252 NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData()); 263 253 NativeNSWindowRef pWindow = darwinToNativeWindow(pWidget); 264 [m_pNative registerToNotification :pstrNativeNotificationName :pWindow];265 } 266 267 void UICocoaApplication::unregisterFromN ativeNotification(const QString &strNativeNotificationName, QWidget *pWidget)254 [m_pNative registerToNotificationOfWindow :pstrNativeNotificationName :pWindow]; 255 } 256 257 void UICocoaApplication::unregisterFromNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget) 268 258 { 269 259 /* Make sure it is registered yet: */ 270 AssertReturnVoid(m_ callbacks.contains(pWidget) && m_callbacks[pWidget].contains(strNativeNotificationName));260 AssertReturnVoid(m_widgetCallbacks.contains(pWidget) && m_widgetCallbacks[pWidget].contains(strNativeNotificationName)); 271 261 272 262 /* Forget callback: */ 273 m_ callbacks[pWidget].remove(strNativeNotificationName);274 if (m_ callbacks[pWidget].isEmpty())275 m_ callbacks.remove(pWidget);263 m_widgetCallbacks[pWidget].remove(strNativeNotificationName); 264 if (m_widgetCallbacks[pWidget].isEmpty()) 265 m_widgetCallbacks.remove(pWidget); 276 266 277 267 /* Unregister observer: */ 278 268 NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData()); 279 269 NativeNSWindowRef pWindow = darwinToNativeWindow(pWidget); 280 [m_pNative unregisterFromNotification :pstrNativeNotificationName :pWindow];281 } 282 283 void UICocoaApplication::nativeNotificationProxy (NativeNSStringRef pstrNotificationName, NativeNSWindowRef pWindow)270 [m_pNative unregisterFromNotificationOfWindow :pstrNativeNotificationName :pWindow]; 271 } 272 273 void UICocoaApplication::nativeNotificationProxyForWidget(NativeNSStringRef pstrNotificationName, NativeNSWindowRef pWindow) 284 274 { 285 275 /* Get notification name: */ … … 287 277 288 278 /* Check if existing widget(s) have corresponding notification handler: */ 289 const QList<QWidget*> &keys1 = m_callbacks.keys(); 290 for (int i = 0; i < keys1.size(); ++i) 291 { 292 QWidget *pWidget = keys1[i]; 279 foreach (QWidget *pWidget, m_widgetCallbacks.keys()) 280 { 293 281 if (darwinToNativeWindow(pWidget) == pWindow) 294 282 { 295 const QMap<QString, PfnNativeNotificationCallbackForQWidget> &callbacks = m_ callbacks[pWidget];283 const QMap<QString, PfnNativeNotificationCallbackForQWidget> &callbacks = m_widgetCallbacks[pWidget]; 296 284 if (callbacks.contains(strNotificationName)) 297 285 callbacks[strNotificationName](strNotificationName, pWidget); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r52382 r52509 203 203 darwinEnableTransienceSupport(this); 204 204 /* Register to native fullscreen notifications: */ 205 UICocoaApplication::instance()->registerToN ativeNotification("NSWindowWillEnterFullScreenNotification", this,206 UIMachineWindow::handleNativeNotification);207 UICocoaApplication::instance()->registerToN ativeNotification("NSWindowDidEnterFullScreenNotification", this,208 UIMachineWindow::handleNativeNotification);209 UICocoaApplication::instance()->registerToN ativeNotification("NSWindowWillExitFullScreenNotification", this,210 UIMachineWindow::handleNativeNotification);211 UICocoaApplication::instance()->registerToN ativeNotification("NSWindowDidExitFullScreenNotification", this,212 UIMachineWindow::handleNativeNotification);213 UICocoaApplication::instance()->registerToN ativeNotification("NSWindowDidFailToEnterFullScreenNotification", this,214 UIMachineWindow::handleNativeNotification);205 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowWillEnterFullScreenNotification", this, 206 UIMachineWindow::handleNativeNotification); 207 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidEnterFullScreenNotification", this, 208 UIMachineWindow::handleNativeNotification); 209 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowWillExitFullScreenNotification", this, 210 UIMachineWindow::handleNativeNotification); 211 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidExitFullScreenNotification", this, 212 UIMachineWindow::handleNativeNotification); 213 UICocoaApplication::instance()->registerToNotificationOfWindow("NSWindowDidFailToEnterFullScreenNotification", this, 214 UIMachineWindow::handleNativeNotification); 215 215 } 216 216 #endif /* Q_WS_MAC */ … … 259 259 { 260 260 /* Unregister from native fullscreen notifications: */ 261 UICocoaApplication::instance()->unregisterFromN ativeNotification("NSWindowWillEnterFullScreenNotification", this);262 UICocoaApplication::instance()->unregisterFromN ativeNotification("NSWindowDidEnterFullScreenNotification", this);263 UICocoaApplication::instance()->unregisterFromN ativeNotification("NSWindowWillExitFullScreenNotification", this);264 UICocoaApplication::instance()->unregisterFromN ativeNotification("NSWindowDidExitFullScreenNotification", this);265 UICocoaApplication::instance()->unregisterFromN ativeNotification("NSWindowDidFailToEnterFullScreenNotification", this);261 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowWillEnterFullScreenNotification", this); 262 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidEnterFullScreenNotification", this); 263 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowWillExitFullScreenNotification", this); 264 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidExitFullScreenNotification", this); 265 UICocoaApplication::instance()->unregisterFromNotificationOfWindow("NSWindowDidFailToEnterFullScreenNotification", this); 266 266 } 267 267 #endif /* Q_WS_MAC */
Note:
See TracChangeset
for help on using the changeset viewer.