VirtualBox

Changeset 64446 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 27, 2016 3:39:05 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8636: Desktop-widget watchdog: Implement listening for geometry and available geometry changes on the basis of Qt5 API, moving Qt4 API into corresponding ifdef.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp

    r64442 r64446  
    299299}
    300300
     301void UIDesktopWidgetWatchdog::sltHandleHostScreenResized(int iHostScreenIndex)
     302{
     303//    printf("UIDesktopWidgetWatchdog::sltHandleHostScreenResized(%d)\n", iHostScreenIndex);
     304
     305# ifdef VBOX_WS_X11
     306    /* Update host-screen available-geometry: */
     307    updateHostScreenAvailableGeometry(iHostScreenIndex);
     308# endif /* VBOX_WS_X11 */
     309
     310    /* Notify listeners: */
     311    emit sigHostScreenResized(iHostScreenIndex);
     312}
     313
     314void UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized(int iHostScreenIndex)
     315{
     316//    printf("UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized(%d)\n", iHostScreenIndex);
     317
     318# ifdef VBOX_WS_X11
     319    /* Update host-screen available-geometry: */
     320    updateHostScreenAvailableGeometry(iHostScreenIndex);
     321# endif /* VBOX_WS_X11 */
     322
     323    /* Notify listeners: */
     324    emit sigHostScreenWorkAreaResized(iHostScreenIndex);
     325}
     326
    301327#else /* QT_VERSION >= 0x050000 */
    302328
    303 void UIDesktopWidgetWatchdog::sltHostScreenAdded(QScreen * /* pHostScreen */)
     329void UIDesktopWidgetWatchdog::sltHostScreenAdded(QScreen *pHostScreen)
    304330{
    305331//    printf("UIDesktopWidgetWatchdog::sltHostScreenAdded(%d)\n", screenCount());
     332
     333    /* Listen for screen signals: */
     334    connect(pHostScreen, SIGNAL(geometryChanged(const QRect &)),
     335            this, SLOT(sltHandleHostScreenResized(const QRect &)));
     336    connect(pHostScreen, SIGNAL(availableGeometryChanged(const QRect &)),
     337            this, SLOT(sltHandleHostScreenWorkAreaResized(const QRect &)));
    306338
    307339# ifdef VBOX_WS_X11
     
    314346}
    315347
    316 void UIDesktopWidgetWatchdog::sltHostScreenRemoved(QScreen * /* pHostScreen */)
     348void UIDesktopWidgetWatchdog::sltHostScreenRemoved(QScreen *pHostScreen)
    317349{
    318350//    printf("UIDesktopWidgetWatchdog::sltHostScreenRemoved(%d)\n", screenCount());
     351
     352    /* Forget about screen signals: */
     353    disconnect(pHostScreen, SIGNAL(geometryChanged(const QRect &)),
     354               this, SLOT(sltHandleHostScreenResized(const QRect &)));
     355    disconnect(pHostScreen, SIGNAL(availableGeometryChanged(const QRect &)),
     356               this, SLOT(sltHandleHostScreenWorkAreaResized(const QRect &)));
    319357
    320358# ifdef VBOX_WS_X11
     
    327365}
    328366
    329 #endif /* QT_VERSION >= 0x050000 */
    330 
    331 void UIDesktopWidgetWatchdog::sltHandleHostScreenResized(int iHostScreenIndex)
    332 {
     367void UIDesktopWidgetWatchdog::sltHandleHostScreenResized(const QRect &geometry)
     368{
     369    /* Get the screen: */
     370    QScreen *pScreen = sender() ? qobject_cast<QScreen*>(sender()) : 0;
     371    AssertPtrReturnVoid(pScreen);
     372
     373    /* Determine screen index: */
     374    const int iHostScreenIndex = qApp->screens().indexOf(pScreen);
     375    AssertReturnVoid(iHostScreenIndex != -1);
    333376//    printf("UIDesktopWidgetWatchdog::sltHandleHostScreenResized(%d)\n", iHostScreenIndex);
    334377
    335 #ifdef VBOX_WS_X11
     378# ifdef VBOX_WS_X11
    336379    /* Update host-screen available-geometry: */
    337380    updateHostScreenAvailableGeometry(iHostScreenIndex);
    338 #endif /* VBOX_WS_X11 */
     381# endif /* VBOX_WS_X11 */
    339382
    340383    /* Notify listeners: */
     
    342385}
    343386
    344 void UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized(int iHostScreenIndex)
    345 {
     387void UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized(const QRect &availableGeometry)
     388{
     389    /* Get the screen: */
     390    QScreen *pScreen = sender() ? qobject_cast<QScreen*>(sender()) : 0;
     391    AssertPtrReturnVoid(pScreen);
     392
     393    /* Determine screen index: */
     394    const int iHostScreenIndex = qApp->screens().indexOf(pScreen);
     395    AssertReturnVoid(iHostScreenIndex != -1);
    346396//    printf("UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized(%d)\n", iHostScreenIndex);
    347397
    348 #ifdef VBOX_WS_X11
     398# ifdef VBOX_WS_X11
    349399    /* Update host-screen available-geometry: */
    350400    updateHostScreenAvailableGeometry(iHostScreenIndex);
    351 #endif /* VBOX_WS_X11 */
     401# endif /* VBOX_WS_X11 */
    352402
    353403    /* Notify listeners: */
    354404    emit sigHostScreenWorkAreaResized(iHostScreenIndex);
    355405}
     406
     407#endif /* QT_VERSION >= 0x050000 */
    356408
    357409#ifdef VBOX_WS_X11
     
    381433#if QT_VERSION < 0x050000
    382434    connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(sltHandleHostScreenCountChanged(int)));
     435    connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltHandleHostScreenResized(int)));
     436    connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(sltHandleHostScreenWorkAreaResized(int)));
    383437#else /* QT_VERSION >= 0x050000 */
    384438    connect(qApp, SIGNAL(screenAdded(QScreen *)), this, SLOT(sltHostScreenAdded(QScreen *)));
    385439    connect(qApp, SIGNAL(screenRemoved(QScreen *)), this, SLOT(sltHostScreenRemoved(QScreen *)));
     440    foreach (QScreen *pHostScreen, qApp->screens())
     441    {
     442        connect(pHostScreen, SIGNAL(geometryChanged(const QRect &)),
     443                this, SLOT(sltHandleHostScreenResized(const QRect &)));
     444        connect(pHostScreen, SIGNAL(availableGeometryChanged(const QRect &)),
     445                this, SLOT(sltHandleHostScreenWorkAreaResized(const QRect &)));
     446    }
    386447#endif /* QT_VERSION >= 0x050000 */
    387     connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltHandleHostScreenResized(int)));
    388     connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(sltHandleHostScreenWorkAreaResized(int)));
    389448
    390449#ifdef VBOX_WS_X11
     
    399458#if QT_VERSION < 0x050000
    400459    disconnect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(sltHandleHostScreenCountChanged(int)));
     460    disconnect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltHandleHostScreenResized(int)));
     461    disconnect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(sltHandleHostScreenWorkAreaResized(int)));
    401462#else /* QT_VERSION >= 0x050000 */
    402463    disconnect(qApp, SIGNAL(screenAdded(QScreen *)), this, SLOT(sltHostScreenAdded(QScreen *)));
    403464    disconnect(qApp, SIGNAL(screenRemoved(QScreen *)), this, SLOT(sltHostScreenRemoved(QScreen *)));
     465    foreach (QScreen *pHostScreen, qApp->screens())
     466    {
     467        disconnect(pHostScreen, SIGNAL(geometryChanged(const QRect &)),
     468                   this, SLOT(sltHandleHostScreenResized(const QRect &)));
     469        disconnect(pHostScreen, SIGNAL(availableGeometryChanged(const QRect &)),
     470                   this, SLOT(sltHandleHostScreenWorkAreaResized(const QRect &)));
     471    }
    404472#endif /* QT_VERSION >= 0x050000 */
    405     disconnect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltHandleHostScreenResized(int)));
    406     disconnect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(sltHandleHostScreenWorkAreaResized(int)));
    407473
    408474#ifdef VBOX_WS_X11
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.h

    r64440 r64446  
    111111    /** Handles host-screen count change to @a cHostScreenCount. */
    112112    void sltHandleHostScreenCountChanged(int cHostScreenCount);
     113    /** Handles resize for the host-screen with @a iHostScreenIndex. */
     114    void sltHandleHostScreenResized(int iHostScreenIndex);
     115    /** Handles work-area resize for the host-screen with @a iHostScreenIndex. */
     116    void sltHandleHostScreenWorkAreaResized(int iHostScreenIndex);
    113117#else /* QT_VERSION >= 0x050000 */
    114118    /** Handles @a pHostScreen adding. */
     
    116120    /** Handles @a pHostScreen removing. */
    117121    void sltHostScreenRemoved(QScreen *pHostScreen);
     122    /** Handles host-screen resize to passed @a geometry. */
     123    void sltHandleHostScreenResized(const QRect &geometry);
     124    /** Handles host-screen work-area resize to passed @a availableGeometry. */
     125    void sltHandleHostScreenWorkAreaResized(const QRect &availableGeometry);
    118126#endif /* QT_VERSION >= 0x050000 */
    119 
    120     /** Handles resize for the host-screen with @a iHostScreenIndex. */
    121     void sltHandleHostScreenResized(int iHostScreenIndex);
    122     /** Handles work-area resize for the host-screen with @a iHostScreenIndex. */
    123     void sltHandleHostScreenWorkAreaResized(int iHostScreenIndex);
    124127
    125128#ifdef VBOX_WS_X11
Note: See TracChangeset for help on using the changeset viewer.

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