| @@ -111,8 +111,7 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (const bool returnIfNoPend | |||
| } | |||
| else if (m.message == WM_QUIT) | |||
| { | |||
| JUCEApplicationBase* const app = JUCEApplicationBase::getInstance(); | |||
| if (app != nullptr) | |||
| if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance()) | |||
| app->systemRequestedQuit(); | |||
| } | |||
| else if (isEventBlockedByModalComps == nullptr || ! isEventBlockedByModalComps (m)) | |||
| @@ -25,8 +25,10 @@ | |||
| Desktop::Desktop() | |||
| : mouseClickCounter (0), mouseWheelCounter (0), | |||
| kioskModeComponent (nullptr), | |||
| allowedOrientations (allOrientations) | |||
| allowedOrientations (allOrientations), | |||
| masterScaleFactor (1.0f) | |||
| { | |||
| displays = new Displays (*this); | |||
| addMouseInputSource(); | |||
| } | |||
| @@ -352,7 +354,7 @@ void Desktop::sendMouseMove() | |||
| //============================================================================== | |||
| Desktop::Displays::Displays() { init(); } | |||
| Desktop::Displays::Displays (Desktop& desktop) { init (desktop); } | |||
| Desktop::Displays::~Displays() {} | |||
| const Desktop::Displays::Display& Desktop::Displays::getMainDisplay() const noexcept | |||
| @@ -421,9 +423,9 @@ bool operator!= (const Desktop::Displays::Display& d1, const Desktop::Displays:: | |||
| return ! (d1 == d2); | |||
| } | |||
| void Desktop::Displays::init() | |||
| void Desktop::Displays::init (Desktop& desktop) | |||
| { | |||
| findDisplays(); | |||
| findDisplays (desktop.masterScaleFactor); | |||
| jassert (displays.size() > 0); | |||
| } | |||
| @@ -432,7 +434,7 @@ void Desktop::Displays::refresh() | |||
| Array<Display> oldDisplays; | |||
| oldDisplays.swapWithArray (displays); | |||
| init(); | |||
| init (Desktop::getInstance()); | |||
| if (oldDisplays != displays) | |||
| { | |||
| @@ -367,14 +367,15 @@ public: | |||
| private: | |||
| friend class Desktop; | |||
| Displays(); | |||
| friend class ScopedPointer<Displays>; | |||
| Displays (Desktop&); | |||
| ~Displays(); | |||
| void init(); | |||
| void findDisplays(); | |||
| void init (Desktop&); | |||
| void findDisplays (float masterScale); | |||
| }; | |||
| const Displays& getDisplays() const noexcept { return displays; } | |||
| const Displays& getDisplays() const noexcept { return *displays; } | |||
| //============================================================================== | |||
| /** True if the OS supports semitransparent windows */ | |||
| @@ -403,7 +404,7 @@ private: | |||
| void addPeer (ComponentPeer*); | |||
| void removePeer (ComponentPeer*); | |||
| Displays displays; | |||
| ScopedPointer<Displays> displays; | |||
| Point<int> lastFakeMouseMove; | |||
| void sendMouseMove(); | |||
| @@ -421,11 +422,10 @@ private: | |||
| Rectangle<int> kioskComponentOriginalBounds; | |||
| int allowedOrientations; | |||
| float masterScaleFactor; | |||
| ComponentAnimator animator; | |||
| AffineTransform masterTransform; | |||
| void timerCallback() override; | |||
| void resetTimer(); | |||
| ListenerList <MouseListener>& getMouseListeners(); | |||
| @@ -686,12 +686,13 @@ bool juce_areThereAnyAlwaysOnTopWindows() | |||
| } | |||
| //============================================================================== | |||
| void Desktop::Displays::findDisplays() | |||
| void Desktop::Displays::findDisplays (float masterScale) | |||
| { | |||
| Display d; | |||
| d.userArea = d.totalArea = Rectangle<int> (android.screenWidth, android.screenHeight); | |||
| d.userArea = d.totalArea = Rectangle<int> (android.screenWidth, | |||
| android.screenHeight) / masterScale; | |||
| d.isMain = true; | |||
| d.scale = 1.0; | |||
| d.scale = masterScale; | |||
| displays.add (d); | |||
| } | |||
| @@ -302,21 +302,20 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const | |||
| return Orientations::convertToJuce ([[UIApplication sharedApplication] statusBarOrientation]); | |||
| } | |||
| void Desktop::Displays::findDisplays() | |||
| void Desktop::Displays::findDisplays (float masterScale) | |||
| { | |||
| JUCE_AUTORELEASEPOOL | |||
| { | |||
| UIScreen* s = [UIScreen mainScreen]; | |||
| Display d; | |||
| d.userArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s applicationFrame])); | |||
| d.totalArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s bounds])); | |||
| d.userArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s applicationFrame])) / masterScale; | |||
| d.totalArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s bounds])) / masterScale; | |||
| d.isMain = true; | |||
| d.scale = masterScale; | |||
| if ([s respondsToSelector: @selector (scale)]) | |||
| d.scale = s.scale; | |||
| else | |||
| d.scale = 1.0; | |||
| d.scale *= s.scale; | |||
| d.dpi = 160 * d.scale; | |||
| @@ -2975,7 +2975,7 @@ static double getDisplayDPI (int index) | |||
| return (dpiX + dpiY) / 2.0; | |||
| } | |||
| void Desktop::Displays::findDisplays() | |||
| void Desktop::Displays::findDisplays (float masterScale) | |||
| { | |||
| if (display == 0) | |||
| return; | |||
| @@ -3025,9 +3025,9 @@ void Desktop::Displays::findDisplays() | |||
| d.userArea = d.totalArea = Rectangle<int> (screens[j].x_org, | |||
| screens[j].y_org, | |||
| screens[j].width, | |||
| screens[j].height); | |||
| screens[j].height) * masterScale; | |||
| d.isMain = (index == 0); | |||
| d.scale = 1.0; | |||
| d.scale = masterScale; | |||
| d.dpi = getDisplayDPI (index); | |||
| displays.add (d); | |||
| @@ -3059,9 +3059,9 @@ void Desktop::Displays::findDisplays() | |||
| Display d; | |||
| d.userArea = d.totalArea = Rectangle<int> (position[0], position[1], | |||
| position[2], position[3]); | |||
| position[2], position[3]) / masterScale; | |||
| d.isMain = (displays.size() == 0); | |||
| d.scale = 1.0; | |||
| d.scale = masterScale; | |||
| d.dpi = getDisplayDPI (i); | |||
| displays.add (d); | |||
| @@ -3073,9 +3073,9 @@ void Desktop::Displays::findDisplays() | |||
| { | |||
| Display d; | |||
| d.userArea = d.totalArea = Rectangle<int> (DisplayWidth (display, DefaultScreen (display)), | |||
| DisplayHeight (display, DefaultScreen (display))); | |||
| DisplayHeight (display, DefaultScreen (display))) * masterScale; | |||
| d.isMain = true; | |||
| d.scale = 1.0; | |||
| d.scale = masterScale; | |||
| d.dpi = getDisplayDPI (0); | |||
| displays.add (d); | |||
| @@ -348,7 +348,7 @@ static Rectangle<int> convertDisplayRect (NSRect r, CGFloat mainScreenBottom) | |||
| return convertToRectInt (r); | |||
| } | |||
| void Desktop::Displays::findDisplays() | |||
| void Desktop::Displays::findDisplays (const float masterScale) | |||
| { | |||
| JUCE_AUTORELEASEPOOL | |||
| { | |||
| @@ -362,16 +362,15 @@ void Desktop::Displays::findDisplays() | |||
| NSScreen* s = (NSScreen*) [screens objectAtIndex: i]; | |||
| Display d; | |||
| d.userArea = convertDisplayRect ([s visibleFrame], mainScreenBottom); | |||
| d.totalArea = convertDisplayRect ([s frame], mainScreenBottom); | |||
| d.userArea = convertDisplayRect ([s visibleFrame], mainScreenBottom) / masterScale; | |||
| d.totalArea = convertDisplayRect ([s frame], mainScreenBottom) / masterScale; | |||
| d.isMain = (i == 0); | |||
| d.scale = masterScale; | |||
| #if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) | |||
| if ([s respondsToSelector: @selector (backingScaleFactor)]) | |||
| d.scale = s.backingScaleFactor; | |||
| else | |||
| d.scale *= s.backingScaleFactor; | |||
| #endif | |||
| d.scale = 1.0; | |||
| NSSize dpi = [[[s deviceDescription] objectForKey: NSDeviceResolution] sizeValue]; | |||
| d.dpi = (dpi.width + dpi.height) / 2.0; | |||
| @@ -1338,6 +1338,7 @@ private: | |||
| registerTouchWindow (hwnd, 0); | |||
| setDPIAwareness(); | |||
| setMessageFilter(); | |||
| updateBorderSize(); | |||
| // Calling this function here is (for some reason) necessary to make Windows | |||
| @@ -1408,6 +1409,19 @@ private: | |||
| } | |||
| } | |||
| void setMessageFilter() | |||
| { | |||
| typedef BOOL (WINAPI* ChangeWindowMessageFilterExFunc) (HWND, UINT, DWORD, PVOID); | |||
| if (ChangeWindowMessageFilterExFunc changeMessageFilter | |||
| = (ChangeWindowMessageFilterExFunc) getUser32Function ("ChangeWindowMessageFilterEx")) | |||
| { | |||
| changeMessageFilter (hwnd, WM_DROPFILES, 1 /*MSGFLT_ALLOW*/, nullptr); | |||
| changeMessageFilter (hwnd, WM_COPYDATA, 1 /*MSGFLT_ALLOW*/, nullptr); | |||
| changeMessageFilter (hwnd, 0x49, 1 /*MSGFLT_ALLOW*/, nullptr); | |||
| } | |||
| } | |||
| //============================================================================== | |||
| void handlePaintMessage() | |||
| { | |||
| @@ -3163,7 +3177,7 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR, HDC, LPRECT r, LPARAM userInfo) | |||
| return TRUE; | |||
| } | |||
| void Desktop::Displays::findDisplays() | |||
| void Desktop::Displays::findDisplays (float masterScale) | |||
| { | |||
| setDPIAwareness(); | |||
| @@ -3190,9 +3204,9 @@ void Desktop::Displays::findDisplays() | |||
| for (int i = 0; i < monitors.size(); ++i) | |||
| { | |||
| Display d; | |||
| d.userArea = d.totalArea = monitors.getReference(i); | |||
| d.userArea = d.totalArea = monitors.getReference(i) / masterScale; | |||
| d.isMain = (i == 0); | |||
| d.scale = 1.0; | |||
| d.scale = masterScale; | |||
| d.dpi = dpi; | |||
| if (i == 0) | |||