summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@lindenlab.com>2026-10-13 14:30:21 -0400
committerGitHub <noreply@github.com>2026-10-13 14:30:21 -0400
commit8ba5d1a8adc47c21b23d9482e72de9517f9a98fc (patch)
treef97d67c8ee574c6ebaac8d0d8ba120d041dca051 /indra/newview/llviewerwindow.cpp
parent18648fc51e2a0c750182d8aa3814ed5b6bf8445e (diff)
parentefc7d2d7bb542ac905cb7ebd82ee329523f95608 (diff)
Merge pull request #6193 from secondlife/release/26.4
Release/26.4
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r--indra/newview/llviewerwindow.cpp203
1 files changed, 146 insertions, 57 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index b06c129974..5e06010012 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -33,11 +33,10 @@
#include <iostream>
#include <fstream>
#include <algorithm>
-#include <boost/filesystem.hpp>
-#include <boost/regex.hpp>
#include "llagent.h"
#include "llagentcamera.h"
+#include "llcallbacklist.h"
#include "llcommandhandler.h"
#include "llcommunicationchannel.h"
#include "llfloaterreg.h"
@@ -188,7 +187,6 @@
#include "llviewerjoystick.h"
#include "llviewermenufile.h" // LLFilePickerReplyThread
#include "llviewernetwork.h"
-#include "llpostprocess.h"
#include "llfloaterimnearbychat.h"
#include "llagentui.h"
#include "llwearablelist.h"
@@ -782,14 +780,14 @@ public:
addText(xpos, ypos, "Projection Matrix");
ypos += y_inc;
-#if LL_DARWIN
+#if LL_CLANG
// For sprintf deprecation
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
// View last column is always <0,0,0,1>
MATRIX_ROW_F32_TO_STR(gGLModelView, 12,camera_lines[3]); addText(xpos, ypos, std::string(camera_lines[3])); ypos += y_inc;
-#if LL_DARWIN
+#if LL_CLANG
#pragma clang diagnostic pop
#endif
MATRIX_ROW_N32_TO_STR(gGLModelView, 8,camera_lines[2]); addText(xpos, ypos, std::string(camera_lines[2])); ypos += y_inc;
@@ -1467,12 +1465,50 @@ void LLViewerWindow::handleMouseLeave(LLWindow *window)
LLToolTipMgr::instance().blockToolTips();
}
+void LLViewerWindow::handlePreCloseRequest()
+{
+ // WINDOW THREAD! since we need this to act fast.
+ if (!LLApp::isExiting() && !LLApp::isStopped())
+ {
+ LLAppViewer::instance()->createCloseRequestMarker();
+ }
+}
+
+void LLViewerWindow::handleCloseRequestCanceled()
+{
+ // WINDOW THREAD! since we need this to act fast.
+ if (!LLApp::isExiting() && !LLApp::isStopped())
+ {
+ LLAppViewer::instance()->removeCloseRequestMarker();
+ }
+}
+
+void LLViewerWindow::handleSuspendRequest()
+{
+ LLAppViewer::instance()->sendViewerStatistics(false);
+ // Todo: this should send a disconnect request as viewer
+ // can't keep heartbeat up while suspended and will get
+ // disconnected within a minute.
+ // Add a disconnect here once 'prevent OS from sleeping'
+ // feature is ready.
+}
+
bool LLViewerWindow::handleCloseRequest(LLWindow *window, bool from_user)
{
if (!LLApp::isExiting() && !LLApp::isStopped())
{
if (from_user)
{
+ // Task naamger kills viewer after 1 second, 3 seconds
+ // is overkill, but decided to be on a safe side.
+ doAfterInterval([]()
+ {
+ // if user quits, marker will be cleaned by cleanup,
+ // if user cancels quit, marker will be cleaned here,
+ // but if task manager kills us, marker stays.
+ LLAppViewer::instance()->removeCloseRequestMarker();
+ }, 3.0f);
+
// User has indicated they want to close, but we may need to ask
// about modified documents.
LLAppViewer::instance()->userQuit();
@@ -1493,6 +1529,9 @@ bool LLViewerWindow::handleSessionExit(LLWindow* window)
{
// Viewer received WM_ENDSESSION and app will be killed soon if it doesn't respond
LLAppViewer* app = LLAppViewer::instance();
+ // Normally we'd include preferences, but serializing them can be expensive.
+ // There is also a chance this won't be processed if the logout request arrives first.
+ app->sendViewerStatistics(false /*no preferences*/);
app->sendSimpleLogoutRequest();
app->earlyExitNoNotify();
@@ -1521,6 +1560,13 @@ void LLViewerWindow::handleResize(LLWindow *window, S32 width, S32 height)
{
reshape(width, height);
mResDirty = true;
+ 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)
@@ -1820,6 +1866,10 @@ bool LLViewerWindow::handleWindowDidChangeScreen(LLWindow *window)
LLCoordScreen window_rect;
mWindow->getSize(&window_rect);
reshape(window_rect.mX, window_rect.mY);
+ // The window may still be transitioning between states,
+ // schedule an update at checkSettings()
+ mResDirty = true;
+ LL_DEBUGS("Window") << "Window did change screen, new size: " << window_rect.mX << "x" << window_rect.mY << LL_ENDL;
return true;
}
@@ -1903,7 +1953,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
LLNotifications::instance().setIgnoreAllNotifications(ignore);
if (ignore)
{
- LL_INFOS() << "NOTE: ALL NOTIFICATIONS THAT OCCUR WILL GET ADDED TO IGNORE LIST FOR LATER RUNS." << LL_ENDL;
+ LL_INFOS("Window") << "NOTE: ALL NOTIFICATIONS THAT OCCUR WILL GET ADDED TO IGNORE LIST FOR LATER RUNS." << LL_ENDL;
}
@@ -1941,13 +1991,8 @@ LLViewerWindow::LLViewerWindow(const Params& p)
ms_sleep(5000) ; //wait for 5 seconds.
LLSplashScreen::update(LLTrans::getString("ShuttingDown"));
-#if LL_LINUX
- LL_WARNS() << "Unable to create window, be sure screen is set at 32-bit color and your graphics driver is configured correctly. See README-linux.txt for further information."
- << LL_ENDL;
-#else
LL_WARNS("Window") << "Unable to create window, be sure screen is set at 32-bit color in Control Panels->Display->Settings"
<< LL_ENDL;
-#endif
LLAppViewer::instance()->fastQuit(1);
}
else if (!LLViewerShaderMgr::sInitialized)
@@ -1976,6 +2021,23 @@ LLViewerWindow::LLViewerWindow(const Params& p)
gSavedSettings.setF32("UIScaleFactor", 1.f);
}
gSavedSettings.setBOOL("ResetUIScaleOnFirstRun", false);
+ LL_DEBUGS("Window") << "ResetUIScaleOnFirstRun fired:"
+ << " system_ui_size=" << mWindow->getSystemUISize()
+ << " UIScaleFactor_after_reset=" << gSavedSettings.getF32("UIScaleFactor")
+ << " screen_size=" << scr.mX << "x" << scr.mY
+ << " pixel_aspect_ratio=" << mWindow->getPixelAspectRatio()
+ << " ResetUIScaleOnFirstRun=" << gSavedSettings.getBOOL("ResetUIScaleOnFirstRun")
+ << LL_ENDL;
+ }
+ else
+ {
+ LL_DEBUGS("Window") << "Display init:"
+ << " screen_size=" << scr.mX << "x" << scr.mY
+ << " system_ui_size=" << mWindow->getSystemUISize()
+ << " pixel_aspect_ratio=" << mWindow->getPixelAspectRatio()
+ << " saved_UIScaleFactor=" << gSavedSettings.getF32("UIScaleFactor")
+ << " ResetUIScaleOnFirstRun=" << gSavedSettings.getBOOL("ResetUIScaleOnFirstRun")
+ << LL_ENDL;
}
// Get the real window rect the window was created with (since there are various OS-dependent reasons why
@@ -1984,6 +2046,12 @@ LLViewerWindow::LLViewerWindow(const Params& p)
mDisplayScale.setVec(llmax(1.f / mWindow->getPixelAspectRatio(), 1.f), llmax(mWindow->getPixelAspectRatio(), 1.f));
mDisplayScale *= ui_scale_factor;
+ LL_DEBUGS("Window") << "Display scale computed:"
+ << " ui_scale_factor=" << ui_scale_factor
+ << " mDisplayScale=" << mDisplayScale
+ << " (clamped_to=[" << MIN_UI_SCALE << ", " << MAX_UI_SCALE << "])"
+ << LL_ENDL;
+
LLUI::setScaleFactor(mDisplayScale);
LLFontGL::sResolutionGeneration++;
@@ -2546,6 +2614,15 @@ void LLViewerWindow::reshape(S32 width, S32 height)
mWindowRectRaw.mRight = mWindowRectRaw.mLeft + width;
mWindowRectRaw.mTop = mWindowRectRaw.mBottom + height;
+ LL_DEBUGS("Window") << "reshape called:";
+ LLCoordWindow live_size;
+ mWindow->getSize(&live_size);
+ LL_CONT << " args=" << width << "x" << height
+ << " live_getSize=" << live_size.mX << "x" << live_size.mY
+ << " current_mDisplayScale=" << mDisplayScale
+ << " systemUISize=" << mWindow->getSystemUISize()
+ << LL_ENDL;
+
//glViewport(0, 0, width, height );
LLViewerCamera * camera = LLViewerCamera::getInstance(); // simpleton, might not exist
@@ -2879,12 +2956,13 @@ bool LLViewerWindow::handleKeyUp(KEY key, MASK mask)
{
if (keyboard_focus->handleKeyUp(key, mask, false))
{
- LL_DEBUGS() << "LLviewerWindow::handleKeyUp - in 'traverse up' - no loops seen... just called keyboard_focus->handleKeyUp an it returned true" << LL_ENDL;
+ LL_DEBUGS() << "LLviewerWindow::handleKeyUp - in 'traverse up' - no loops seen... just called keyboard_focus->handleKeyUp and it returned true" << LL_ENDL;
LLViewerEventRecorder::instance().logKeyEvent(key, mask);
return true;
}
- else {
- LL_DEBUGS() << "LLviewerWindow::handleKeyUp - in 'traverse up' - no loops seen... just called keyboard_focus->handleKeyUp an it returned false" << LL_ENDL;
+ else
+ {
+ LL_DEBUGS() << "LLviewerWindow::handleKeyUp - in 'traverse up' - no loops seen... just called keyboard_focus->handleKeyUp and it returned false" << LL_ENDL;
}
}
@@ -3069,7 +3147,7 @@ bool LLViewerWindow::handleKey(KEY key, MASK mask)
{
if ((focusedFloaterName == "nearby_chat") || (focusedFloaterName == "im_container") || (focusedFloaterName == "impanel"))
{
- LLCachedControl<bool> key_move(gSavedSettings, "ArrowKeysAlwaysMove");
+ static LLCachedControl<bool> key_move(gSavedSettings, "ArrowKeysAlwaysMove");
if (key_move())
{
// let Control-Up and Control-Down through for chat line history,
@@ -3100,17 +3178,19 @@ bool LLViewerWindow::handleKey(KEY key, MASK mask)
if (keyboard_focus->handleKey(key, mask, false))
{
- LL_DEBUGS() << "LLviewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey an it returned true" << LL_ENDL;
+ LL_DEBUGS("Window") << "LLViewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey and it returned true" << LL_ENDL;
LLViewerEventRecorder::instance().logKeyEvent(key,mask);
return true;
- } else {
- LL_DEBUGS() << "LLviewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey an it returned false" << LL_ENDL;
+ }
+ else
+ {
+ LL_DEBUGS("Window") << "LLViewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey and it returned false" << LL_ENDL;
}
}
if( LLToolMgr::getInstance()->getCurrentTool()->handleKey(key, mask) )
{
- LL_DEBUGS() << "LLviewerWindow::handleKey toolbar handling?" << LL_ENDL;
+ LL_DEBUGS("Window") << "LLViewerWindow::handleKey toolbar handling?" << LL_ENDL;
LLViewerEventRecorder::instance().logKeyEvent(key,mask);
return true;
}
@@ -3118,7 +3198,7 @@ bool LLViewerWindow::handleKey(KEY key, MASK mask)
// Try for a new-format gesture
if (LLGestureMgr::instance().triggerGesture(key, mask))
{
- LL_DEBUGS() << "LLviewerWindow::handleKey new gesture feature" << LL_ENDL;
+ LL_DEBUGS("Window") << "LLViewerWindow::handleKey new gesture feature" << LL_ENDL;
LLViewerEventRecorder::instance().logKeyEvent(key,mask);
return true;
}
@@ -3230,7 +3310,7 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
mouse_captor->handleScrollWheel(local_x, local_y, clicks);
if (LLView::sDebugMouseHandling)
{
- LL_INFOS() << "Scroll Wheel handled by captor " << mouse_captor->getName() << LL_ENDL;
+ LL_INFOS("Window") << "Scroll Wheel handled by captor " << mouse_captor->getName() << LL_ENDL;
}
return;
}
@@ -3254,7 +3334,7 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
}
else if (LLView::sDebugMouseHandling)
{
- LL_INFOS() << "Scroll Wheel not handled by view" << LL_ENDL;
+ LL_INFOS("Window") << "Scroll Wheel not handled by view" << LL_ENDL;
}
// Zoom the camera in and out behavior
@@ -3285,7 +3365,7 @@ void LLViewerWindow::handleScrollHWheel(S32 clicks)
mouse_captor->handleScrollHWheel(local_x, local_y, clicks);
if (LLView::sDebugMouseHandling)
{
- LL_INFOS() << "Scroll Horizontal Wheel handled by captor " << mouse_captor->getName() << LL_ENDL;
+ LL_INFOS("Window") << "Scroll Horizontal Wheel handled by captor " << mouse_captor->getName() << LL_ENDL;
}
return;
}
@@ -3309,7 +3389,7 @@ void LLViewerWindow::handleScrollHWheel(S32 clicks)
}
else if (LLView::sDebugMouseHandling)
{
- LL_INFOS() << "Scroll Horizontal Wheel not handled by view" << LL_ENDL;
+ LL_INFOS("Window") << "Scroll Horizontal Wheel not handled by view" << LL_ENDL;
}
return;
@@ -3513,7 +3593,7 @@ void LLViewerWindow::updateUI()
}
if (child_count_timer.hasExpired())
{
- LL_INFOS() << "gMenuHolder child count: " << gMenuHolder->getChildCount() << LL_ENDL;
+ LL_INFOS("Window") << "gMenuHolder child count: " << gMenuHolder->getChildCount() << LL_ENDL;
std::vector<std::string> local_child_vec;
LLView::child_list_t child_list = *gMenuHolder->getChildList();
for (auto child : child_list)
@@ -3528,7 +3608,7 @@ void LLViewerWindow::updateUI()
std::set_difference(child_vec.begin(), child_vec.end(), local_child_vec.begin(), local_child_vec.end(), std::inserter(out_vec, out_vec.begin()));
if (!out_vec.empty())
{
- LL_INFOS() << "gMenuHolder removal diff size: '"<<out_vec.size() <<"' begin_child_diff";
+ LL_INFOS("Window") << "gMenuHolder removal diff size: '"<<out_vec.size() <<"' begin_child_diff";
for (auto str : out_vec)
{
LL_CONT << " : " << str;
@@ -3540,7 +3620,7 @@ void LLViewerWindow::updateUI()
std::set_difference(local_child_vec.begin(), local_child_vec.end(), child_vec.begin(), child_vec.end(), std::inserter(out_vec, out_vec.begin()));
if (!out_vec.empty())
{
- LL_INFOS() << "gMenuHolder addition diff size: '" << out_vec.size() << "' begin_child_diff";
+ LL_INFOS("Window") << "gMenuHolder addition diff size: '" << out_vec.size() << "' begin_child_diff";
for (auto str : out_vec)
{
LL_CONT << " : " << str;
@@ -4335,11 +4415,11 @@ bool LLViewerWindow::clickPointOnSurfaceGlobal(const S32 x, const S32 y, LLViewe
if (!intersect)
{
point_global = clickPointInWorldGlobal(x, y, objectp);
- LL_INFOS() << "approx intersection at " << (objectp->getPositionGlobal() - point_global) << LL_ENDL;
+ LL_INFOS("Window") << "approx intersection at " << (objectp->getPositionGlobal() - point_global) << LL_ENDL;
}
else
{
- LL_INFOS() << "good intersection at " << (objectp->getPositionGlobal() - point_global) << LL_ENDL;
+ LL_INFOS("Window") << "good intersection at " << (objectp->getPositionGlobal() - point_global) << LL_ENDL;
}
return intersect;
@@ -4857,14 +4937,10 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
return;
}
-// Check if there is enough free space to save snapshot
-#ifdef LL_WINDOWS
- boost::filesystem::path b_path(ll_convert<std::wstring>(lastSnapshotDir));
-#else
- boost::filesystem::path b_path(lastSnapshotDir);
-#endif
- boost::system::error_code ec;
- if (!boost::filesystem::is_directory(b_path, ec) || ec.failed())
+ // Check if there is enough free space to save snapshot
+ std::filesystem::path b_path = fsyspath(lastSnapshotDir);
+ std::error_code ec;
+ if (!std::filesystem::is_directory(b_path, ec) || ec)
{
LLSD args;
args["PATH"] = lastSnapshotDir;
@@ -4873,8 +4949,8 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
failure_cb();
return;
}
- boost::filesystem::space_info b_space = boost::filesystem::space(b_path, ec);
- if (ec.failed())
+ std::filesystem::space_info b_space = std::filesystem::space(b_path, ec);
+ if (ec)
{
LLSD args;
args["PATH"] = lastSnapshotDir;
@@ -4929,7 +5005,7 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
while( -1 != err // Search until the file is not found (i.e., stat() gives an error).
&& is_snapshot_name_loc_set); // Or stop if we are rewriting.
- LL_INFOS() << "Saving snapshot to " << filepath << LL_ENDL;
+ LL_INFOS("Window") << "Saving snapshot to " << filepath << LL_ENDL;
if (image->save(filepath))
{
playSnapshotAnimAndSound();
@@ -4983,7 +5059,7 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
bool LLViewerWindow::saveSnapshot(const std::string& filepath, S32 image_width, S32 image_height, bool show_ui, bool show_hud, bool do_rebuild, bool show_balance, LLSnapshotModel::ESnapshotLayerType type, LLSnapshotModel::ESnapshotFormat format)
{
- LL_INFOS() << "Saving snapshot to: " << filepath << LL_ENDL;
+ LL_INFOS("Window") << "Saving snapshot to: " << filepath << LL_ENDL;
LLPointer<LLImageRaw> raw = new LLImageRaw;
bool success = rawSnapshot(raw, image_width, image_height, true, false, show_ui, show_hud, do_rebuild, show_balance);
@@ -5675,11 +5751,6 @@ void* LLViewerWindow::getPlatformWindow() const
return mWindow->getPlatformWindow();
}
-void* LLViewerWindow::getMediaWindow() const
-{
- return mWindow->getMediaWindow();
-}
-
void LLViewerWindow::focusClient() const
{
return mWindow->focusClient();
@@ -5868,7 +5939,7 @@ void LLViewerWindow::stopGL()
//especially be careful to put anything behind gTextureList.destroyGL(save_state);
if (!gGLManager.mIsDisabled)
{
- LL_INFOS() << "Shutting down GL..." << LL_ENDL;
+ LL_INFOS("Window") << "Shutting down GL..." << LL_ENDL;
// Pause texture decode threads (will get unpaused during main loop)
LLAppViewer::getTextureCache()->pause();
@@ -5901,11 +5972,6 @@ void LLViewerWindow::stopGL()
gBox.cleanupGL();
- if(gPostProcess)
- {
- gPostProcess->invalidate();
- }
-
gTextureList.destroyGL();
stop_glerror();
@@ -5937,7 +6003,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message)
//especially, be careful to put something before gTextureList.restoreGL();
if (gGLManager.mIsDisabled)
{
- LL_INFOS() << "Restoring GL..." << LL_ENDL;
+ LL_INFOS("Window") << "Restoring GL..." << LL_ENDL;
gGLManager.mIsDisabled = false;
initGLDefaults();
@@ -5971,7 +6037,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message)
setShowProgress(true);
setProgressString(progress_message);
}
- LL_INFOS() << "...Restoring GL done" << LL_ENDL;
+ LL_INFOS("Window") << "...Restoring GL done" << LL_ENDL;
if(!LLAppViewer::instance()->restoreErrorTrap())
{
LL_WARNS() << " Someone took over my signal/exception handler (post restoreGL)!" << LL_ENDL;
@@ -6010,10 +6076,21 @@ void LLViewerWindow::checkSettings()
mStatesDirty = false;
}
- // We want to update the resolution AFTER the states getting refreshed not before.
if (mResDirty)
{
- reshape(getWindowWidthRaw(), getWindowHeightRaw());
+ // Deferred resolution update after states have been refreshed.
+ LLCoordWindow 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;
}
}
@@ -6039,7 +6116,19 @@ void LLViewerWindow::calcDisplayScale()
if (display_scale != mDisplayScale)
{
- LL_INFOS() << "Setting display scale to " << display_scale << " for ui scale: " << ui_scale_factor << LL_ENDL;
+ LL_INFOS("Window") << "Setting display scale to " << display_scale << " for ui scale: " << ui_scale_factor << LL_ENDL;
+
+ LL_DEBUGS("Window") << "calcDisplayScale changing:";
+
+ LLCoordWindow win_size;
+ mWindow->getSize(&win_size);
+ LL_CONT << " old=" << mDisplayScale
+ << " new=" << display_scale
+ << " UIScaleFactor=" << gSavedSettings.getF32("UIScaleFactor")
+ << " systemUISize=" << mWindow->getSystemUISize()
+ << " windowSize=" << win_size.mX << "x" << win_size.mY
+ << " mWindowRectRaw=" << mWindowRectRaw.getWidth() << "x" << mWindowRectRaw.getHeight()
+ << LL_ENDL;
mDisplayScale = display_scale;
// Init default fonts