summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r--indra/newview/llviewerwindow.cpp172
1 files changed, 130 insertions, 42 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index d32e3f4cbd..ef24bcf598 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -261,9 +261,6 @@ static const F32 MIN_DISPLAY_SCALE = 0.75f;
static const char KEY_MOUSELOOK = 'M';
-static LLCachedControl<std::string> sSnapshotBaseName(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseName", "Snapshot"));
-static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", ""));
-
LLTrace::SampleStatHandle<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity");
@@ -784,8 +781,16 @@ public:
addText(xpos, ypos, "Projection Matrix");
ypos += y_inc;
+#if LL_DARWIN
+// 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
+#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;
MATRIX_ROW_N32_TO_STR(gGLModelView, 4,camera_lines[1]); addText(xpos, ypos, std::string(camera_lines[1])); ypos += y_inc; mBackRectCamera2.mTop = ypos + 2;
MATRIX_ROW_N32_TO_STR(gGLModelView, 0,camera_lines[0]); addText(xpos, ypos, std::string(camera_lines[0])); ypos += y_inc;
@@ -1424,11 +1429,17 @@ void LLViewerWindow::handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask
mWindow->showCursorFromMouseMove();
- if (gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME
- && !gDisconnected)
+ if (!gDisconnected)
+ {
+ if (gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
{
gAgent.clearAFK();
}
+ else
+ {
+ gAwayTriggerTimer.reset();
+ }
+ }
}
void LLViewerWindow::handleMouseDragged(LLWindow *window, LLCoordGL pos, MASK mask)
@@ -1455,18 +1466,43 @@ void LLViewerWindow::handleMouseLeave(LLWindow *window)
LLToolTipMgr::instance().blockToolTips();
}
-bool LLViewerWindow::handleCloseRequest(LLWindow *window)
+bool LLViewerWindow::handleCloseRequest(LLWindow *window, bool from_user)
{
if (!LLApp::isExiting() && !LLApp::isStopped())
{
- // User has indicated they want to close, but we may need to ask
- // about modified documents.
- LLAppViewer::instance()->userQuit();
- // Don't quit immediately
+ if (from_user)
+ {
+ // User has indicated they want to close, but we may need to ask
+ // about modified documents.
+ LLAppViewer::instance()->userQuit();
+ // Don't quit immediately
+ }
+ else
+ {
+ // OS is asking us to quit, assume we have time and start cleanup
+ LLAppViewer::instance()->requestQuit();
+ }
}
return false;
}
+bool LLViewerWindow::handleSessionExit(LLWindow* window)
+{
+ if (!LLApp::isExiting() && !LLApp::isStopped())
+ {
+ // Viewer received WM_ENDSESSION and app will be killed soon if it doesn't respond
+ LLAppViewer* app = LLAppViewer::instance();
+ app->sendSimpleLogoutRequest();
+ app->earlyExitNoNotify();
+
+ // Not viewer's fault, remove marker files so
+ // that statistics won't consider this to be a crash
+ app->removeMarkerFiles();
+ return false;
+ }
+ return true;
+}
+
void LLViewerWindow::handleQuit(LLWindow *window)
{
if (gNonInteractive)
@@ -1547,6 +1583,10 @@ bool LLViewerWindow::handleTranslatedKeyDown(KEY key, MASK mask, bool repeated)
{
gAgent.clearAFK();
}
+ else
+ {
+ gAwayTriggerTimer.reset();
+ }
// *NOTE: We want to interpret KEY_RETURN later when it arrives as
// a Unicode char, not as a keydown. Otherwise when client frame
@@ -1882,7 +1922,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
p.ignore_pixel_depth,
0,
max_core_count,
- max_gl_version); //don't use window level anti-aliasing
+ max_gl_version); //don't use window level anti-aliasing, windows only
if (NULL == mWindow)
{
@@ -1967,7 +2007,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
LL_DEBUGS("Window") << "Loading feature tables." << LL_ENDL;
// Initialize OpenGL Renderer
- LLVertexBuffer::initClass(mWindow);
+ LLVertexBuffer::initClass(mWindow, gSavedSettings.getU32("MPVertexBufferMode"));
LL_INFOS("RenderInit") << "LLVertexBuffer initialization done." << LL_ENDL ;
if (!gGL.init(true))
{
@@ -2026,6 +2066,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
std::string LLViewerWindow::getLastSnapshotDir()
{
+ static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", ""));
return sSnapshotDir;
}
@@ -2283,24 +2324,23 @@ void LLViewerWindow::initWorldUI()
gToolBarView->setVisible(true);
}
- if (!gNonInteractive)
+ // Don't preload cef instances on low end hardware
+ const F32Gigabytes MIN_PHYSICAL_MEMORY(8);
+ F32Gigabytes physical_mem = LLMemory::getMaxMemKB();
+ if (physical_mem <= 0)
{
- LLMediaCtrl* destinations = LLFloaterReg::getInstance("destinations")->getChild<LLMediaCtrl>("destination_guide_contents");
- if (destinations)
- {
- destinations->setErrorPageURL(gSavedSettings.getString("GenericErrorPageURL"));
- std::string url = gSavedSettings.getString("DestinationGuideURL");
- url = LLWeb::expandURLSubstitutions(url, LLSD());
- destinations->navigateTo(url, HTTP_CONTENT_TEXT_HTML);
- }
- LLMediaCtrl* avatar_picker = LLFloaterReg::getInstance("avatar")->findChild<LLMediaCtrl>("avatar_picker_contents");
- if (avatar_picker)
- {
- avatar_picker->setErrorPageURL(gSavedSettings.getString("GenericErrorPageURL"));
- std::string url = gSavedSettings.getString("AvatarPickerURL");
- url = LLWeb::expandURLSubstitutions(url, LLSD());
- avatar_picker->navigateTo(url, HTTP_CONTENT_TEXT_HTML);
- }
+ LLMemory::updateMemoryInfo();
+ physical_mem = LLMemory::getMaxMemKB();
+ }
+
+ if (!gNonInteractive && physical_mem > MIN_PHYSICAL_MEMORY)
+ {
+ LL_INFOS() << "Preloading cef instances" << LL_ENDL;
+
+ LLFloaterReg::getInstance("destinations");
+ LLFloaterReg::getInstance("avatar_welcome_pack");
+ LLFloaterReg::getInstance("search");
+ LLFloaterReg::getInstance("marketplace");
}
}
@@ -3017,7 +3057,8 @@ bool LLViewerWindow::handleKey(KEY key, MASK mask)
{
if ((focusedFloaterName == "nearby_chat") || (focusedFloaterName == "im_container") || (focusedFloaterName == "impanel"))
{
- if (gSavedSettings.getBOOL("ArrowKeysAlwaysMove"))
+ LLCachedControl<bool> key_move(gSavedSettings, "ArrowKeysAlwaysMove");
+ if (key_move())
{
// let Control-Up and Control-Down through for chat line history,
if (!(key == KEY_UP && mask == MASK_CONTROL)
@@ -3031,10 +3072,9 @@ bool LLViewerWindow::handleKey(KEY key, MASK mask)
case KEY_RIGHT:
case KEY_UP:
case KEY_DOWN:
- case KEY_PAGE_UP:
- case KEY_PAGE_DOWN:
- case KEY_HOME:
- case KEY_END:
+ case KEY_PAGE_UP: //jump
+ case KEY_PAGE_DOWN: // down
+ case KEY_HOME: // toggle fly
// when chatbar is empty or ArrowKeysAlwaysMove set,
// pass arrow keys on to avatar...
return false;
@@ -3289,7 +3329,31 @@ void LLViewerWindow::clearPopups()
void LLViewerWindow::moveCursorToCenter()
{
- if (! gSavedSettings.getBOOL("DisableMouseWarp"))
+ bool mouse_warp = false;
+ LLCachedControl<S32> mouse_warp_mode(gSavedSettings, "MouseWarpMode", 1);
+
+ switch (mouse_warp_mode())
+ {
+ case 0:
+ // For Windows:
+ // Mouse usually uses 'delta' position since it isn't aware of own location, keep it centered.
+ // Touch screen reports absolute or virtual absolute position and warping a physical
+ // touch is pointless, so don't move it.
+ //
+ // MacOS
+ // If 'decoupled', CGAssociateMouseAndMouseCursorPosition can make mouse stay in
+ // one place and not move, do not move it (needs testing).
+ mouse_warp = mWindow->isWrapMouse();
+ break;
+ case 1:
+ mouse_warp = true;
+ break;
+ default:
+ mouse_warp = false;
+ break;
+ }
+
+ if (mouse_warp)
{
S32 x = getWorldViewWidthScaled() / 2;
S32 y = getWorldViewHeightScaled() / 2;
@@ -3848,7 +3912,7 @@ void LLViewerWindow::updateLayout()
void LLViewerWindow::updateMouseDelta()
{
-#if LL_WINDOWS
+#if LL_WINDOWS && !LL_SDL
LLCoordCommon delta;
mWindow->getCursorDelta(&delta);
S32 dx = delta.mX;
@@ -4724,6 +4788,7 @@ void LLViewerWindow::saveImageNumbered(LLImageFormatted *image, bool force_picke
// Get a base file location if needed.
if (force_picker || !isSnapshotLocSet())
{
+ static LLCachedControl<std::string> sSnapshotBaseName(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseName", "Snapshot"));
std::string proposed_name(sSnapshotBaseName);
// getSaveFile will append an appropriate extension to the proposed name, based on the ESaveFilter constant passed in.
@@ -4778,11 +4843,22 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
// Check if there is enough free space to save snapshot
#ifdef LL_WINDOWS
- boost::filesystem::path b_path(utf8str_to_utf16str(lastSnapshotDir));
+ boost::filesystem::path b_path(ll_convert<std::wstring>(lastSnapshotDir));
#else
boost::filesystem::path b_path(lastSnapshotDir);
#endif
- if (!boost::filesystem::is_directory(b_path))
+ boost::system::error_code ec;
+ if (!boost::filesystem::is_directory(b_path, ec) || ec.failed())
+ {
+ LLSD args;
+ args["PATH"] = lastSnapshotDir;
+ LLNotificationsUtil::add("SnapshotToLocalDirNotExist", args);
+ resetSnapshotLoc();
+ failure_cb();
+ return;
+ }
+ boost::filesystem::space_info b_space = boost::filesystem::space(b_path, ec);
+ if (ec.failed())
{
LLSD args;
args["PATH"] = lastSnapshotDir;
@@ -4791,7 +4867,6 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
failure_cb();
return;
}
- boost::filesystem::space_info b_space = boost::filesystem::space(b_path);
if (b_space.free < image->getDataSize())
{
LLSD args;
@@ -4808,8 +4883,13 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
LLNotificationsUtil::add("SnapshotToComputerFailed", args);
failure_cb();
+
+ // Shouldn't there be a return here?
}
+ static LLCachedControl<std::string> sSnapshotBaseName(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseName", "Snapshot"));
+ static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", ""));
+
// Look for an unused file name
auto is_snapshot_name_loc_set = isSnapshotLocSet();
std::string filepath;
@@ -4817,13 +4897,21 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
auto err = 0;
auto extension("." + image->getExtension());
auto now = LLDate::now();
+ static LLCachedControl<bool> snapshot_timestamp(gSavedSettings, "SnapshotTimestamp", true);
do
{
filepath = sSnapshotDir;
filepath += gDirUtilp->getDirDelimiter();
filepath += sSnapshotBaseName;
+ if (snapshot_timestamp)
+ {
filepath += now.toLocalDateString("_%Y-%m-%d_%H%M%S");
filepath += llformat("%.2d", i);
+ }
+ else if (is_snapshot_name_loc_set)
+ {
+ filepath += llformat("_%.3d", i);
+ }
filepath += extension;
llstat stat_info;
@@ -4917,8 +5005,8 @@ void LLViewerWindow::playSnapshotAnimAndSound()
bool LLViewerWindow::isSnapshotLocSet() const
{
- std::string snapshot_dir = sSnapshotDir;
- return !snapshot_dir.empty();
+ static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", ""));
+ return !sSnapshotDir().empty();
}
void LLViewerWindow::resetSnapshotLoc() const
@@ -5165,7 +5253,7 @@ bool LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
glReadPixels(
subimage_x_offset, out_y + subimage_y_offset,
read_width, 1,
- GL_DEPTH_COMPONENT, GL_FLOAT,
+ GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
depth_line_buffer->getData()// current output pixel is beginning of buffer...
);