mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-14 00:14:18 +00:00
Various changes to improve the behaviour of kiosk mode for DocumentWindows on win32.
This commit is contained in:
parent
f34d1cdb3c
commit
042d9f22fc
7 changed files with 38 additions and 27 deletions
|
|
@ -173,6 +173,22 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE (MouseListenerList)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
struct FocusRestorer
|
||||
{
|
||||
FocusRestorer() : lastFocus (Component::getCurrentlyFocusedComponent()) {}
|
||||
|
||||
~FocusRestorer()
|
||||
{
|
||||
if (lastFocus != nullptr && ! lastFocus->isCurrentlyBlockedByAnotherModalComponent())
|
||||
lastFocus->grabKeyboardFocus();
|
||||
}
|
||||
|
||||
WeakReference<Component> lastFocus;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (FocusRestorer)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
struct ScalingHelpers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ int ModalComponentManager::runEventLoopForCurrentComponent()
|
|||
|
||||
if (Component* currentlyModal = getModalComponent (0))
|
||||
{
|
||||
WeakReference<Component> prevFocused (Component::getCurrentlyFocusedComponent());
|
||||
FocusRestorer focusRestorer;
|
||||
|
||||
bool finished = false;
|
||||
attachCallback (currentlyModal, new ReturnValueRetriever (returnValue, finished));
|
||||
|
|
@ -276,9 +276,6 @@ int ModalComponentManager::runEventLoopForCurrentComponent()
|
|||
}
|
||||
}
|
||||
JUCE_CATCH_EXCEPTION
|
||||
|
||||
if (prevFocused != nullptr && ! prevFocused->isCurrentlyBlockedByAnotherModalComponent())
|
||||
prevFocused->grabKeyboardFocus();
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ bool FileChooser::browseForDirectory()
|
|||
|
||||
bool FileChooser::showDialog (const int flags, FilePreviewComponent* const previewComp)
|
||||
{
|
||||
WeakReference<Component> previouslyFocused (Component::getCurrentlyFocusedComponent());
|
||||
FocusRestorer focusRestorer;
|
||||
|
||||
results.clear();
|
||||
|
||||
|
|
@ -127,9 +127,6 @@ bool FileChooser::showDialog (const int flags, FilePreviewComponent* const previ
|
|||
}
|
||||
}
|
||||
|
||||
if (previouslyFocused != nullptr)
|
||||
previouslyFocused->grabKeyboardFocus();
|
||||
|
||||
return results.size() > 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3169,6 +3169,9 @@ String SystemClipboard::getTextFromClipboard()
|
|||
//==============================================================================
|
||||
void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool /*allowMenusAndBars*/)
|
||||
{
|
||||
if (TopLevelWindow* tlw = dynamic_cast<TopLevelWindow*> (kioskModeComponent))
|
||||
tlw->setUsingNativeTitleBar (! enableOrDisable);
|
||||
|
||||
if (enableOrDisable)
|
||||
kioskModeComponent->setBounds (getDisplays().getMainDisplay().totalArea);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,17 +249,17 @@ void DocumentWindow::resized()
|
|||
|
||||
BorderSize<int> DocumentWindow::getBorderThickness()
|
||||
{
|
||||
return BorderSize<int> ((isFullScreen() || isUsingNativeTitleBar())
|
||||
? 0 : (resizableBorder != nullptr ? 4 : 1));
|
||||
return ResizableWindow::getBorderThickness();
|
||||
}
|
||||
|
||||
BorderSize<int> DocumentWindow::getContentComponentBorder()
|
||||
{
|
||||
BorderSize<int> border (getBorderThickness());
|
||||
|
||||
border.setTop (border.getTop()
|
||||
+ (isUsingNativeTitleBar() ? 0 : titleBarHeight)
|
||||
+ (menuBar != nullptr ? menuBarHeight : 0));
|
||||
if (! isKioskMode())
|
||||
border.setTop (border.getTop()
|
||||
+ (isUsingNativeTitleBar() ? 0 : titleBarHeight)
|
||||
+ (menuBar != nullptr ? menuBarHeight : 0));
|
||||
|
||||
return border;
|
||||
}
|
||||
|
|
@ -273,6 +273,9 @@ Rectangle<int> DocumentWindow::getTitleBarArea()
|
|||
{
|
||||
const BorderSize<int> border (getBorderThickness());
|
||||
|
||||
if (isKioskMode())
|
||||
return Rectangle<int>();
|
||||
|
||||
return Rectangle<int> (border.getLeft(), border.getTop(),
|
||||
getWidth() - border.getLeftAndRight(), getTitleBarHeight());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,10 @@ void ResizableWindow::setContentComponentSize (int width, int height)
|
|||
|
||||
BorderSize<int> ResizableWindow::getBorderThickness()
|
||||
{
|
||||
return BorderSize<int> (isUsingNativeTitleBar() ? 0 : ((resizableBorder != nullptr && ! isFullScreen()) ? 5 : 3));
|
||||
if (isUsingNativeTitleBar() || isKioskMode())
|
||||
return BorderSize<int>();
|
||||
|
||||
return BorderSize<int> ((resizableBorder != nullptr && ! isFullScreen()) ? 4 : 1);
|
||||
}
|
||||
|
||||
BorderSize<int> ResizableWindow::getContentComponentBorder()
|
||||
|
|
@ -189,15 +192,11 @@ void ResizableWindow::visibilityChanged()
|
|||
|
||||
void ResizableWindow::resized()
|
||||
{
|
||||
const bool resizerHidden = isFullScreen() || isKioskMode() || isUsingNativeTitleBar();
|
||||
|
||||
if (resizableBorder != nullptr)
|
||||
{
|
||||
#if JUCE_WINDOWS || JUCE_LINUX
|
||||
// hide the resizable border if the OS already provides one..
|
||||
resizableBorder->setVisible (! (isFullScreen() || isUsingNativeTitleBar()));
|
||||
#else
|
||||
resizableBorder->setVisible (! isFullScreen());
|
||||
#endif
|
||||
|
||||
resizableBorder->setVisible (! resizerHidden);
|
||||
resizableBorder->setBorderThickness (getBorderThickness());
|
||||
resizableBorder->setSize (getWidth(), getHeight());
|
||||
resizableBorder->toBack();
|
||||
|
|
@ -205,12 +204,7 @@ void ResizableWindow::resized()
|
|||
|
||||
if (resizableCorner != nullptr)
|
||||
{
|
||||
#if JUCE_MAC
|
||||
// hide the resizable border if the OS already provides one..
|
||||
resizableCorner->setVisible (! (isFullScreen() || isUsingNativeTitleBar()));
|
||||
#else
|
||||
resizableCorner->setVisible (! isFullScreen());
|
||||
#endif
|
||||
resizableCorner->setVisible (! resizerHidden);
|
||||
|
||||
const int resizerSize = 18;
|
||||
resizableCorner->setBounds (getWidth() - resizerSize,
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ void TopLevelWindow::setUsingNativeTitleBar (const bool shouldUseNativeTitleBar)
|
|||
{
|
||||
if (useNativeTitleBar != shouldUseNativeTitleBar)
|
||||
{
|
||||
FocusRestorer focusRestorer;
|
||||
useNativeTitleBar = shouldUseNativeTitleBar;
|
||||
recreateDesktopWindow();
|
||||
sendLookAndFeelChange();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue