summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2026-09-04 22:57:01 +0800
committerErik Kundiman <erik@megapahit.org>2026-09-04 22:57:01 +0800
commit87d8ac40c6fe53ed75e48f9d50e0f0cde2627e40 (patch)
treeeb8f1576a32e8fefcce1d8124e57f0cb471a47a0
parentf7beb28baafa6600c1e8c9b6a08deb3705ba2e78 (diff)
parente47869b667ae34b524f303f7ab2b1c1c5d661278 (diff)
Merge tag 'Second_Life_Release#5ddd940-26.4' into 26.4
-rw-r--r--indra/llwindow/llopenglview-objc.mm46
-rw-r--r--indra/llwindow/llwindowcallbacks.cpp4
-rw-r--r--indra/llwindow/llwindowcallbacks.h1
-rw-r--r--indra/llwindow/llwindowmacosx-objc.h2
-rw-r--r--indra/llwindow/llwindowmacosx.cpp17
-rw-r--r--indra/llwindow/llwindowmacosx.h5
-rw-r--r--indra/newview/llviewerwindow.cpp21
-rw-r--r--indra/newview/llviewerwindow.h1
8 files changed, 89 insertions, 8 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 3030169d58..547c921736 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -164,6 +164,18 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void)viewDidMoveToWindow
{
+ // viewDidMoveToWindow is called both when the view is attached to a window
+ // and when it is detached (window == nil).
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(performDeferredResolutionUpdate)
+ object:nil];
+
+ if (![self window])
+ {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ return;
+ }
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowResized:) name:NSWindowDidResizeNotification
object:[self window]];
@@ -184,11 +196,37 @@ attributedStringInfo getSegments(NSAttributedString *str)
object:[self window]];
- NSRect wnd_rect = [[self window] frame];
- NSRect dev_rect = [self convertRectToBacking:wnd_rect];
- if (!NSEqualSizes(wnd_rect.size,dev_rect.size))
+ if (windowCallbacksReady())
+ {
+ NSRect wnd_rect = [[self window] frame];
+ NSRect dev_rect = [self convertRectToBacking:wnd_rect];
+ if (!NSEqualSizes(wnd_rect.size,dev_rect.size))
+ {
+ // If window size actually changes, update size immediately
+ callResize(dev_rect.size.width, dev_rect.size.height);
+ }
+ else
+ {
+ // Defer size update to let the window settle on its final display
+ // before checkSettings() reads the live backing size.
+ callRequestResolutionUpdate();
+ }
+ }
+ else
+ {
+ // Defer so that mCallbacks is the real callbacks object,
+ // not the null_callbacks used during LLWindowMacOSX construction.
+ // afterDelay will fire on the next loop iteration.
+ NSLog(@"viewDidMoveToWindow triggered, but callbacks not ready, postponing resolution update", nil);
+ [self performSelector:@selector(performDeferredResolutionUpdate) withObject:nil afterDelay:0];
+ }
+}
+
+- (void)performDeferredResolutionUpdate
+{
+ if ([self window])
{
- callResize(dev_rect.size.width, dev_rect.size.height);
+ callRequestResolutionUpdate();
}
}
diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp
index f997aebb9d..b16d0ffce8 100644
--- a/indra/llwindow/llwindowcallbacks.cpp
+++ b/indra/llwindow/llwindowcallbacks.cpp
@@ -156,6 +156,10 @@ void LLWindowCallbacks::handleResize(LLWindow *window, const S32 width, const S3
{
}
+void LLWindowCallbacks::handleRequestResolutionUpdate(LLWindow* window)
+{
+}
+
void LLWindowCallbacks::handleFocus(LLWindow *window)
{
LL_WARNS("COCOA") << "Called handleFocus proto" << LL_ENDL;
diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h
index cd54ccd7c9..1fcf2974b5 100644
--- a/indra/llwindow/llwindowcallbacks.h
+++ b/indra/llwindow/llwindowcallbacks.h
@@ -63,6 +63,7 @@ public:
virtual void handleScrollWheel(LLWindow *window, S32 clicks);
virtual void handleScrollHWheel(LLWindow *window, S32 clicks);
virtual void handleResize(LLWindow *window, S32 width, S32 height);
+ virtual void handleRequestResolutionUpdate(LLWindow* window);
virtual void handleFocus(LLWindow *window);
virtual void handleFocusLost(LLWindow *window);
virtual void handleMenuSelect(LLWindow *window, S32 menu_item);
diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h
index ec9afb1844..a9698bc0e1 100644
--- a/indra/llwindow/llwindowmacosx-objc.h
+++ b/indra/llwindow/llwindowmacosx-objc.h
@@ -140,6 +140,7 @@ void callLeftMouseDown(float *pos, unsigned int mask);
void callLeftMouseUp(float *pos, unsigned int mask);
void callDoubleClick(float *pos, unsigned int mask);
void callResize(unsigned int width, unsigned int height);
+void callRequestResolutionUpdate();
void callMouseMoved(float *pos, unsigned int mask);
void callMouseDragged(float *pos, unsigned int mask);
void callScrollMoved(float deltaX, float deltaY);
@@ -157,6 +158,7 @@ void callFocusLost();
void callModifier(unsigned int mask);
void callQuitHandler();
void commitCurrentPreedit(GLViewRef glView);
+bool windowCallbacksReady();
#include <string>
void callHandleDragEntered(std::string url);
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index ce2f3cf9e2..c0cc6596a2 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -166,6 +166,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
// Route them to a dummy callback structure until the end of constructor.
LLWindowCallbacks null_callbacks;
mCallbacks = &null_callbacks;
+ mIsConstructing = true;
// Voodoo for calling cocoa from carbon (see llwindowmacosx-objc.mm).
setupCocoa();
@@ -239,9 +240,8 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
setUseMultGL(sUseMultGL);
mCallbacks = callbacks;
+ mIsConstructing = false;
stop_glerror();
-
-
}
// These functions are used as wrappers for our internal event handling callbacks.
@@ -415,6 +415,14 @@ void callResize(unsigned int width, unsigned int height)
}
}
+void callRequestResolutionUpdate()
+{
+ if (gWindowImplementation && gWindowImplementation->getCallbacks())
+ {
+ gWindowImplementation->getCallbacks()->handleRequestResolutionUpdate(gWindowImplementation);
+ }
+}
+
void callMouseMoved(float *pos, MASK mask)
{
if (!gWindowImplementation)
@@ -708,6 +716,11 @@ void getPreeditLocation(float *location, unsigned int length)
}
}
+bool windowCallbacksReady()
+{
+ return gWindowImplementation && !gWindowImplementation->isConstructing();
+}
+
void LLWindowMacOSX::updateMouseDeltas(float* deltas)
{
if (mCursorDecoupled)
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index 9534eadf8e..cc6490bb62 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -147,6 +147,10 @@ public:
// enable or disable multithreaded GL
static void setUseMultGL(bool use_mult_gl);
+ // During construction null_callbacks are used,
+ // this is a way to determine when callbacks are ready.
+ bool isConstructing() const { return mIsConstructing; }
+
protected:
LLWindowMacOSX(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags,
@@ -223,6 +227,7 @@ protected:
bool mMinimized;
U32 mFSAASamples;
bool mForceRebuild;
+ bool mIsConstructing = true;
S32 mDragOverrideCursor;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index be8fcefb53..0ae7d3fa0c 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1581,6 +1581,12 @@ void LLViewerWindow::handleResize(LLWindow *window, S32 width, S32 height)
LL_DEBUGS("Window") << "handleResize, new width: " << width << " height: " << height << LL_ENDL;
}
+void LLViewerWindow::handleRequestResolutionUpdate(LLWindow* window)
+{
+ requestResolutionUpdate();
+ LL_DEBUGS("Window") << "handleRequestResolutionUpdate: mResDirty set" << LL_ENDL;
+}
+
// The top-level window has gained focus (e.g. via ALT-TAB)
void LLViewerWindow::handleFocus(LLWindow *window)
{
@@ -2043,7 +2049,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
}
else
{
- LL_DEBUGS("Window") << "Display init diagnostics:"
+ LL_DEBUGS("Window") << "Display init:"
<< " screen_size=" << scr.mX << "x" << scr.mY
<< " system_ui_size=" << mWindow->getSystemUISize()
<< " pixel_aspect_ratio=" << mWindow->getPixelAspectRatio()
@@ -6106,7 +6112,18 @@ void LLViewerWindow::checkSettings()
mWindowRectRaw.set(0, size.mY, size.mX, 0);
mWindowRectScaled.set(0, ll_round((F32)size.mY / mDisplayScale.mV[VY]), ll_round((F32)size.mX / mDisplayScale.mV[VX]), 0);
- reshape(getWindowWidthRaw(), getWindowHeightRaw());
+ LLCoordScreen window_size;
+ if (mWindow->getSize(&window_size))
+ {
+ reshape(window_size.mX, window_size.mY);
+ }
+ else
+ {
+ S32 width = getWindowWidthRaw();
+ S32 height = getWindowHeightRaw();
+ LL_WARNS() << "Failed to get window size, using raw window size " << width << "x" << height << " instead" << LL_ENDL;
+ reshape(width, height);
+ }
mResDirty = false;
}
}
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 06d49df56d..e09e8fee14 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -221,6 +221,7 @@ public:
void handleMouseDragged(LLWindow *window, LLCoordGL pos, MASK mask);
/*virtual*/ void handleMouseLeave(LLWindow *window);
/*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y);
+ /*virtual*/ void handleRequestResolutionUpdate(LLWindow* window);
/*virtual*/ void handleFocus(LLWindow *window);
/*virtual*/ void handleFocusLost(LLWindow *window);
/*virtual*/ bool handleActivate(LLWindow *window, bool activated);