diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-11-13 00:11:53 +0200 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-10-13 16:27:36 +0300 |
| commit | 38257221d090a8c2669d34a23891e7b66153df6f (patch) | |
| tree | 113a169c33f240536f1e03d9e92ffece19fdd87c | |
| parent | 46b4ea4d6d256fb644369d8701cc80944be44800 (diff) | |
viewer#3018 Expose mouse wrap in UI
And attempt some basic automation
| -rw-r--r-- | indra/llwindow/llwindow.h | 1 | ||||
| -rw-r--r-- | indra/llwindow/llwindowheadless.h | 1 | ||||
| -rw-r--r-- | indra/llwindow/llwindowmacosx.h | 1 | ||||
| -rw-r--r-- | indra/llwindow/llwindowsdl.h | 1 | ||||
| -rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 3 | ||||
| -rw-r--r-- | indra/llwindow/llwindowwin32.h | 2 | ||||
| -rw-r--r-- | indra/newview/app_settings/settings.xml | 8 | ||||
| -rw-r--r-- | indra/newview/llfloaterpreference.cpp | 11 | ||||
| -rw-r--r-- | indra/newview/llviewerwindow.cpp | 26 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/panel_preferences_move.xml | 36 |
10 files changed, 84 insertions, 6 deletions
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index d0fa16b26a..7a5404e615 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -95,6 +95,7 @@ public: #if LL_WINDOWS virtual bool getCursorDelta(LLCoordCommon* delta) = 0; #endif + virtual bool isWrapMouse() const = 0; virtual void showCursor() = 0; virtual void hideCursor() = 0; virtual bool isCursorHidden() = 0; diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index 5696b69a59..dc7b833013 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -63,6 +63,7 @@ public: #if LL_WINDOWS /*virtual*/ bool getCursorDelta(LLCoordCommon* delta) override { return false; } #endif + /*virtual*/ bool isWrapMouse() const override { return true; } /*virtual*/ void showCursor() override {} /*virtual*/ void hideCursor() override {} /*virtual*/ void showCursorFromMouseMove() override {} diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 110c5756d0..d703a84d02 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -63,6 +63,7 @@ public: bool switchContext(bool fullscreen, const LLCoordScreen &size, bool enable_vsync, const LLCoordScreen * const posp = NULL) override; bool setCursorPosition(LLCoordWindow position) override; bool getCursorPosition(LLCoordWindow *position) override; + bool isWrapMouse() const override { return !mCursorDecoupled; }; void showCursor() override; void hideCursor() override; void showCursorFromMouseMove() override; diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 196ad2986d..521d52df30 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -68,6 +68,7 @@ public: /*virtual*/ bool switchContext(bool fullscreen, const LLCoordScreen &size, bool disable_vsync, const LLCoordScreen * const posp = NULL); /*virtual*/ bool setCursorPosition(LLCoordWindow position); /*virtual*/ bool getCursorPosition(LLCoordWindow *position); + /*virtual*/ bool isWrapMouse() const override { return true; } /*virtual*/ void showCursor(); /*virtual*/ void hideCursor(); /*virtual*/ void showCursorFromMouseMove(); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 23d5866710..824d0f5ec6 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -450,6 +450,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, F32 max_gl_version) : LLWindow(callbacks, fullscreen, flags), + mAbsoluteCursorPosition(false), mMaxGLVersion(max_gl_version), mMaxCores(max_cores) { @@ -3156,6 +3157,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ prev_absolute_x = absolute_x; prev_absolute_y = absolute_y; + window_imp->mAbsoluteCursorPosition = true; } else { @@ -3172,6 +3174,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mRawMouseDelta.mX += (S32)round((F32)raw->data.mouse.lLastX * (F32)speed / DEFAULT_SPEED); window_imp->mRawMouseDelta.mY -= (S32)round((F32)raw->data.mouse.lLastY * (F32)speed / DEFAULT_SPEED); } + window_imp->mAbsoluteCursorPosition = false; } } } diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 7196706f87..0fc93ad0b1 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -70,6 +70,7 @@ public: /*virtual*/ bool setCursorPosition(LLCoordWindow position); /*virtual*/ bool getCursorPosition(LLCoordWindow *position); /*virtual*/ bool getCursorDelta(LLCoordCommon* delta); + /*virtual*/ bool isWrapMouse() const override { return !mAbsoluteCursorPosition; }; /*virtual*/ void showCursor(); /*virtual*/ void hideCursor(); /*virtual*/ void showCursorFromMouseMove(); @@ -195,6 +196,7 @@ protected: HCURSOR mCursor[ UI_CURSOR_COUNT ]; // Array of all mouse cursors LLCoordWindow mCursorPosition; // mouse cursor position, should only be mutated on main thread + bool mAbsoluteCursorPosition; // true if last position was received in absolute coordinates. LLMutex mRawMouseMutex; RAWINPUTDEVICE mRawMouse; LLCoordWindow mLastCursorPosition; // mouse cursor position from previous frame diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ac79223738..d6a1fbd124 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2469,16 +2469,16 @@ <key>Value</key> <integer>0</integer> </map> - <key>DisableMouseWarp</key> + <key>MouseWarpMode</key> <map> <key>Comment</key> - <string>Disable warping of the mouse to the center of the screen during alt-zoom and mouse look. Useful with certain input devices, mouse sharing programs like Synergy, or running under Parallels.</string> + <string>Controls warping of the mouse to the center of the screen during alt-zoom and mouse look. Useful with certain input devices, mouse sharing programs like Synergy, or running under Parallels. 0 - automatic, 1 - on, 2 - off</string> <key>Persist</key> <integer>1</integer> <key>Type</key> - <string>Boolean</string> + <string>S32</string> <key>Value</key> - <integer>0</integer> + <integer>1</integer> </map> <key>DisableExternalBrowser</key> <map> diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 5a39d41478..99161d8d93 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -774,6 +774,17 @@ void LLFloaterPreference::onOpen(const LLSD& key) // Load (double-)click to walk/teleport settings. updateClickActionViews(); +#if LL_LINUX + // Lixux doesn't support automatic mode + LLComboBox* combo = getChild<LLComboBox>("double_click_action_combo"); + S32 mode = gSavedSettings.getS32("MouseWarpMode"); + if (mode == 0) + { + combo->setValue("1"); + } + combo->setEnabledByValue("0", false); +#endif + // Enabled/disabled popups, might have been changed by user actions // while preferences floater was closed. buildPopupLists(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 3849c286c5..670a3b2939 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3340,7 +3340,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; diff --git a/indra/newview/skins/default/xui/en/panel_preferences_move.xml b/indra/newview/skins/default/xui/en/panel_preferences_move.xml index 4aafceb112..3a5a8cbfec 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_move.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_move.xml @@ -202,9 +202,43 @@ height="10" layout="topleft" left="86" - name="single_click_action_lbl" + name="mouse_warp_lbl" width="150" top_pad="20"> + Mouse Warp: + </text> + <combo_box + control_name="MouseWarpMode" + height="23" + layout="topleft" + left_pad="10" + top_delta="-6" + name="mouse_warp_combo" + tooltip="Controls warping of the mouse to the center of the screen during alt-zoom and mouse look." + width="200"> + <combo_box.item + label="Automatic" + name="0" + value="0"/> + <combo_box.item + label="On" + name="1" + value="1"/> + <combo_box.item + label="Off" + name="2" + value="2"/> + </combo_box> + <text + follows="left|top" + type="string" + length="1" + height="10" + layout="topleft" + left="86" + name="single_click_action_lbl" + width="150" + top_pad="12"> Single click on land: </text> <combo_box |
