From 5eae3d3493c31288753ce8415296e2efdb9d2b8e Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Tue, 10 Nov 2020 22:27:42 -0500 Subject: [PATCH] Fix up osx backing prop callback to use handleDPIChanged --- indra/llwindow/llopenglview-objc.mm | 9 ++++++--- indra/llwindow/llwindowcallbacks.cpp | 5 ----- indra/llwindow/llwindowcallbacks.h | 1 - indra/llwindow/llwindowmacosx-objc.h | 2 +- indra/llwindow/llwindowmacosx.cpp | 4 ++-- indra/newview/llviewerwindow.cpp | 7 ------- indra/newview/llviewerwindow.h | 1 - 7 files changed, 9 insertions(+), 20 deletions(-) diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index abddf8f7ceb..015a4ad9c14 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -143,7 +143,7 @@ attributedStringInfo getSegments(NSAttributedString *str) selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:[self window]]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(windowDidChangeScreen:) name:NSWindowDidChangeScreenNotification + selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:[self window]]; NSRect rect = [[self window] frame]; @@ -176,9 +176,12 @@ attributedStringInfo getSegments(NSAttributedString *str) mModifiers = [NSEvent modifierFlags]; } --(void)windowDidChangeScreen:(NSNotification *)notification; +-(void)windowDidChangeBackingProperties:(NSNotification *)notification; { - callWindowDidChangeScreen(); + NSSize size = [self frame].size; + NSSize scaled_size = [self convertSizeToBacking:size]; + float scale_factor = [self convertSizeToBacking:NSMakeSize(1, 1)].width; + callHandleDPIChanged(scaled_size.width, scaled_size.height, scale_factor); } - (void)dealloc diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index be61e1e16c6..54bb8ec46c9 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -194,11 +194,6 @@ BOOL LLWindowCallbacks::handleDPIChanged(LLWindow *window, F32 ui_scale_factor, return FALSE; } -BOOL LLWindowCallbacks::handleWindowDidChangeScreen(LLWindow *window) -{ - return FALSE; -} - void LLWindowCallbacks::handlePingWatchdog(LLWindow *window, const char * msg) { diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index 3b186481388..77644e1f234 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -69,7 +69,6 @@ class LLWindowCallbacks virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); virtual BOOL handleDPIChanged(LLWindow *window, F32 ui_scale_factor, S32 window_width, S32 window_height); - virtual BOOL handleWindowDidChangeScreen(LLWindow *window); enum DragNDropAction { DNDA_START_TRACKING = 0,// Start tracking an incoming drag diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index 8fd45408889..356e30c699e 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -144,7 +144,7 @@ void callWindowFocus(); void callWindowUnfocus(); void callWindowHide(); void callWindowUnhide(); -void callWindowDidChangeScreen(); +void callHandleDPIChanged(unsigned int width, unsigned int height, float scale_factor); void callDeltaUpdate(float *delta, unsigned int mask); void callOtherMouseDown(float *pos, unsigned int mask, int button); void callOtherMouseUp(float *pos, unsigned int mask, int button); diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 0d6884c3c6f..8876c421f99 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -406,11 +406,11 @@ void callWindowUnhide() } } -void callWindowDidChangeScreen() +void callHandleDPIChanged(unsigned int width, unsigned int height, float scale_factor) { if ( gWindowImplementation && gWindowImplementation->getCallbacks() ) { - gWindowImplementation->getCallbacks()->handleWindowDidChangeScreen(gWindowImplementation); + gWindowImplementation->getCallbacks()->handleDPIChanged(gWindowImplementation, scale_factor, width, height); } } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 1aa7871f296..0d1dcadb62a 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1695,13 +1695,6 @@ BOOL LLViewerWindow::handleDPIChanged(LLWindow *window, F32 ui_scale_factor, S32 } } -BOOL LLViewerWindow::handleWindowDidChangeScreen(LLWindow *window) -{ - LLCoordScreen window_rect; - mWindow->getSize(&window_rect); - reshape(window_rect.mX, window_rect.mY); - return TRUE; -} void LLViewerWindow::handlePingWatchdog(LLWindow *window, const char * msg) { diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index ab65b2a1618..66228f3b4fb 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -216,7 +216,6 @@ class LLViewerWindow final : public LLWindowCallbacks /*virtual*/ BOOL handleTimerEvent(LLWindow *window); /*virtual*/ BOOL handleDeviceChange(LLWindow *window); /*virtual*/ BOOL handleDPIChanged(LLWindow *window, F32 ui_scale_factor, S32 window_width, S32 window_height); - /*virtual*/ BOOL handleWindowDidChangeScreen(LLWindow *window); /*virtual*/ void handlePingWatchdog(LLWindow *window, const char * msg); /*virtual*/ void handlePauseWatchdog(LLWindow *window); -- GitLab