VirtualBox

Changeset 52509 in vbox


Ignore:
Timestamp:
Aug 28, 2014 11:31:23 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95745
Message:

FE/Qt: Mac OS X: Runtime UI: UICocoaApplication API update.

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  
    4747{
    4848public:
     49
    4950    static UICocoaApplication* instance();
    5051    void hide();
     
    5556
    5657    /** Register passed @a pWidget to native notification @a strNativeNotificationName, using @a pCallback as handler. */
    57     void registerToNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback);
     58    void registerToNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback);
    5859    /** Unregister passed @a pWidget from native notification @a strNativeNotificationName. */
    59     void unregisterFromNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);
     60    void unregisterFromNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget);
    6061    /** 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);
    6263
    6364private:
     65
    6466    UICocoaApplication();
    6567    static UICocoaApplication *m_pInstance;
     
    6870
    6971    /** 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;
    7173};
    7274
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.mm

    r51248 r52509  
    6969- (void)unsetCallback:(uint32_t)fMask :(PFNVBOXCACALLBACK)pfnCallback :(void *)pvUser;
    7070
    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;
    7475@end /* @interface UICocoaApplicationPrivate */
    7576
     
    166167
    167168/** Register @a pWindow to cocoa notification @a pstrNotificationName. */
    168 - (void) registerToNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow
     169- (void) registerToNotificationOfWindow :(NSString*)pstrNotificationName :(NSWindow*)pWindow
    169170{
    170171    /* Register notification observer: */
    171172    [[NSNotificationCenter defaultCenter] addObserver:self
    172                                              selector:@selector(notificationCallback:)
     173                                             selector:@selector(notificationCallbackOfWindow:)
    173174                                                 name:pstrNotificationName
    174175                                               object:pWindow];
     
    176177
    177178/** Unregister @a pWindow from cocoa notification @a pstrNotificationName. */
    178 - (void) unregisterFromNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow
     179- (void) unregisterFromNotificationOfWindow :(NSString*)pstrNotificationName :(NSWindow*)pWindow
    179180{
    180181    /* Uninstall notification observer: */
     
    185186
    186187/** Redirects cocoa @a notification to UICocoaApplication instance. */
    187 - (void) notificationCallback :(NSNotification*)notification
     188- (void) notificationCallbackOfWindow :(NSNotification*)notification
    188189{
    189190    /* Get current notification name: */
    190191    NSString *pstrName = [notification name];
    191192
    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]);
    206195}
    207196@end /* @implementation UICocoaApplicationPrivate */
     
    251240}
    252241
    253 void UICocoaApplication::registerToNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback)
     242void UICocoaApplication::registerToNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget,
     243                                                        PfnNativeNotificationCallbackForQWidget pCallback)
    254244{
    255245    /* 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));
    257247
    258248    /* Remember callback: */
    259     m_callbacks[pWidget][strNativeNotificationName] = pCallback;
     249    m_widgetCallbacks[pWidget][strNativeNotificationName] = pCallback;
    260250
    261251    /* Register observer: */
    262252    NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData());
    263253    NativeNSWindowRef pWindow = darwinToNativeWindow(pWidget);
    264     [m_pNative registerToNotification :pstrNativeNotificationName :pWindow];
    265 }
    266 
    267 void UICocoaApplication::unregisterFromNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget)
     254    [m_pNative registerToNotificationOfWindow :pstrNativeNotificationName :pWindow];
     255}
     256
     257void UICocoaApplication::unregisterFromNotificationOfWindow(const QString &strNativeNotificationName, QWidget *pWidget)
    268258{
    269259    /* 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));
    271261
    272262    /* 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);
    276266
    277267    /* Unregister observer: */
    278268    NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData());
    279269    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
     273void UICocoaApplication::nativeNotificationProxyForWidget(NativeNSStringRef pstrNotificationName, NativeNSWindowRef pWindow)
    284274{
    285275    /* Get notification name: */
     
    287277
    288278    /* 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    {
    293281        if (darwinToNativeWindow(pWidget) == pWindow)
    294282        {
    295             const QMap<QString, PfnNativeNotificationCallbackForQWidget> &callbacks = m_callbacks[pWidget];
     283            const QMap<QString, PfnNativeNotificationCallbackForQWidget> &callbacks = m_widgetCallbacks[pWidget];
    296284            if (callbacks.contains(strNotificationName))
    297285                callbacks[strNotificationName](strNotificationName, pWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r52382 r52509  
    203203            darwinEnableTransienceSupport(this);
    204204        /* Register to native fullscreen notifications: */
    205         UICocoaApplication::instance()->registerToNativeNotification("NSWindowWillEnterFullScreenNotification", this,
    206                                                                      UIMachineWindow::handleNativeNotification);
    207         UICocoaApplication::instance()->registerToNativeNotification("NSWindowDidEnterFullScreenNotification", this,
    208                                                                      UIMachineWindow::handleNativeNotification);
    209         UICocoaApplication::instance()->registerToNativeNotification("NSWindowWillExitFullScreenNotification", this,
    210                                                                      UIMachineWindow::handleNativeNotification);
    211         UICocoaApplication::instance()->registerToNativeNotification("NSWindowDidExitFullScreenNotification", this,
    212                                                                      UIMachineWindow::handleNativeNotification);
    213         UICocoaApplication::instance()->registerToNativeNotification("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);
    215215    }
    216216#endif /* Q_WS_MAC */
     
    259259    {
    260260        /* Unregister from native fullscreen notifications: */
    261         UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowWillEnterFullScreenNotification", this);
    262         UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowDidEnterFullScreenNotification", this);
    263         UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowWillExitFullScreenNotification", this);
    264         UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowDidExitFullScreenNotification", this);
    265         UICocoaApplication::instance()->unregisterFromNativeNotification("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);
    266266    }
    267267#endif /* Q_WS_MAC */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette