diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp index 59e858af..21cb706d 100644 --- a/src/core/UBDisplayManager.cpp +++ b/src/core/UBDisplayManager.cpp @@ -158,7 +158,7 @@ void UBDisplayManager::setDisplayWidget(QWidget* pDisplayWidget) mDisplayWidget = pDisplayWidget; mDisplayWidget->setGeometry(mDesktop->screenGeometry(mDisplayScreenIndex)); if (UBSettings::settings()->appUseMultiscreen->get().toBool()) - mDisplayWidget->showFullScreen(); + UBPlatformUtils::showFullScreen(mDisplayWidget); } } @@ -209,14 +209,14 @@ void UBDisplayManager::positionScreens() { mControlWidget->hide(); mControlWidget->setGeometry(mDesktop->screenGeometry(mControlScreenIndex)); - mControlWidget->showFullScreen(); + UBPlatformUtils::showFullScreen(mControlWidget); } if (mDisplayWidget && mDisplayScreenIndex > -1) { mDisplayWidget->hide(); mDisplayWidget->setGeometry(mDesktop->screenGeometry(mDisplayScreenIndex)); - mDisplayWidget->showFullScreen(); + UBPlatformUtils::showFullScreen(mDisplayWidget); } else if(mDisplayWidget) { @@ -234,7 +234,7 @@ void UBDisplayManager::positionScreens() { QWidget* previous = mPreviousDisplayWidgets.at(psi); previous->setGeometry(mDesktop->screenGeometry(mPreviousScreenIndexes.at(psi))); - previous->showFullScreen(); + UBPlatformUtils::showFullScreen(previous); } } @@ -280,7 +280,7 @@ void UBDisplayManager::blackout() foreach(UBBlackoutWidget *blackoutWidget, mBlackoutWidgets) { - blackoutWidget->showFullScreen(); + UBPlatformUtils::showFullScreen(blackoutWidget); } } diff --git a/src/desktop/UBCustomCaptureWindow.cpp b/src/desktop/UBCustomCaptureWindow.cpp index 47eafdbe..36e8969b 100644 --- a/src/desktop/UBCustomCaptureWindow.cpp +++ b/src/desktop/UBCustomCaptureWindow.cpp @@ -30,6 +30,7 @@ #include "UBCustomCaptureWindow.h" +#include "frameworks/UBPlatformUtils.h" #include "gui/UBRubberBand.h" #include "core/memcheck.h" @@ -74,7 +75,7 @@ int UBCustomCaptureWindow::execute(const QPixmap &pScreenPixmap) int currentScreen = desktop->screenNumber(QCursor::pos()); setGeometry(desktop->screenGeometry(currentScreen)); - showFullScreen(); + UBPlatformUtils::showFullScreen(this); setWindowOpacity(1.0); return exec(); diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 330093fe..879b39e4 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -332,7 +332,7 @@ void UBDesktopAnnotationController::showWindow() UBDrawingController::drawingController()->setStylusTool(mDesktopStylusTool); #ifndef Q_OS_LINUX - mTransparentDrawingView->showFullScreen(); + UBPlatformUtils::showFullScreen(mTransparentDrawingView); #else // this is necessary to avoid unity to hide the panels mTransparentDrawingView->show(); diff --git a/src/frameworks/UBPlatformUtils.h b/src/frameworks/UBPlatformUtils.h index e0b3f4ff..0b28c7dd 100644 --- a/src/frameworks/UBPlatformUtils.h +++ b/src/frameworks/UBPlatformUtils.h @@ -204,6 +204,7 @@ public: static QString urlFromClipboard(); static QStringList availableTranslations(); static void setFrontProcess(); + static void showFullScreen(QWidget * pWidget); #ifdef Q_OS_OSX static void SetMacLocaleByIdentifier(const QString& id); diff --git a/src/frameworks/UBPlatformUtils_linux.cpp b/src/frameworks/UBPlatformUtils_linux.cpp index 20a68d27..d4b4f690 100644 --- a/src/frameworks/UBPlatformUtils_linux.cpp +++ b/src/frameworks/UBPlatformUtils_linux.cpp @@ -429,7 +429,14 @@ QString UBPlatformUtils::urlFromClipboard() return qsRet; } - void UBPlatformUtils::setFrontProcess() { + // not used in Linux +} + + +void UBPlatformUtils::showFullScreen(QWidget *pWidget) +{ + pWidget->showFullScreen(); } + diff --git a/src/frameworks/UBPlatformUtils_mac.mm b/src/frameworks/UBPlatformUtils_mac.mm index 531e6fd0..17b87548 100644 --- a/src/frameworks/UBPlatformUtils_mac.mm +++ b/src/frameworks/UBPlatformUtils_mac.mm @@ -65,7 +65,7 @@ void UBPlatformUtils::init() //originalSetSystemUIMode = APEPatchCreate((const void *)SetSystemUIMode, (const void *)emptySetSystemUIMode); - setDesktopMode(false); + //setDesktopMode(false); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -93,20 +93,24 @@ void UBPlatformUtils::init() void UBPlatformUtils::setDesktopMode(bool desktop) -{ /* -#ifndef OS_NEWER_THAN_OR_EQUAL_TO_1010 - //OSStatus (*functor)(SystemUIMode, SystemUIOptions) = (OSStatus (*)(SystemUIMode, SystemUIOptions))originalSetSystemUIMode; +{ - if (desktop) - { - functor(kUIModeNormal, 0); + //qDebug() << "setDesktopMode called. desktop = " << desktop; + + @try { + // temporarily disabled due to bug: when switching to desktop mode (and calling this), + // openboard switches right back to the board mode. clicking again on desktop mode works. + /*if (desktop) { + [NSApp setPresentationOptions:NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock]; + } + else*/ + [NSApp setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; } - else - { - functor(kUIModeAllHidden, 0); + + @catch(NSException * exception) { + qDebug() << "Error setting presentation options"; } -#endif -*/ + } @@ -574,6 +578,23 @@ void UBPlatformUtils::setFrontProcess() // activate the application, forcing focus on it [app activateWithOptions: NSApplicationActivateIgnoringOtherApps]; - // other option:NSApplicationActivateAllWindows. This won't steal focus from another app, e.g + // other option: NSApplicationActivateAllWindows. This won't steal focus from another app, e.g // if the user is doing something else while waiting for OpenBoard to load } + + +/** + * @brief Full-screen a QWidget. Specific behaviour is platform-dependent. + * @param pWidget the QWidget to maximize + */ +void UBPlatformUtils::showFullScreen(QWidget *pWidget) +{ + pWidget->showMaximized(); + + /* On OS X, we want to hide the Dock and menu bar (aka "kiosk mode"). Qt's default behaviour + * when full-screening a QWidget is to set the dock and menu bar to auto-hide. + * Since it is impossible to later set different presentation options (i.e Hide dock & menu bar) + * to NSApplication, we have to avoid calling QWidget::showFullScreen on OSX. + */ +} + diff --git a/src/frameworks/UBPlatformUtils_win.cpp b/src/frameworks/UBPlatformUtils_win.cpp index ed698a39..1c1f453f 100644 --- a/src/frameworks/UBPlatformUtils_win.cpp +++ b/src/frameworks/UBPlatformUtils_win.cpp @@ -427,4 +427,11 @@ QString UBPlatformUtils::urlFromClipboard() void UBPlatformUtils::setFrontProcess() { + // not used in Windows +} + + +void UBPlatformUtils::showFullScreen(QWidget *pWidget) +{ + pWidget->showFullScreen(); }