Merge pull request #5645 from fufesou/feat/scroll_mode

feat, mouse wheel and touchpad scroll mode, default or reverse
This commit is contained in:
RustDesk 2023-09-10 21:02:36 +08:00 committed by GitHub
commit f6973f9a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 202 additions and 57 deletions

View File

@ -138,6 +138,11 @@ const kRemoteScrollStyleAuto = 'scrollauto';
/// [kRemoteScrollStyleBar] Scroll image with scroll bar. /// [kRemoteScrollStyleBar] Scroll image with scroll bar.
const kRemoteScrollStyleBar = 'scrollbar'; const kRemoteScrollStyleBar = 'scrollbar';
/// [kScrollModeDefault] Mouse or touchpad, the default scroll mode.
const kScrollModeDefault = 'default';
/// [kScrollModeReverse] Mouse or touchpad, the reverse scroll mode.
const kScrollModeReverse = 'reverse';
/// [kRemoteImageQualityBest] Best image quality. /// [kRemoteImageQualityBest] Best image quality.
const kRemoteImageQualityBest = 'best'; const kRemoteImageQualityBest = 'best';

View File

@ -1216,6 +1216,7 @@ class _DisplayState extends State<_Display> {
otherRow('Disable clipboard', 'disable_clipboard'), otherRow('Disable clipboard', 'disable_clipboard'),
otherRow('Lock after session end', 'lock_after_session_end'), otherRow('Lock after session end', 'lock_after_session_end'),
otherRow('Privacy mode', 'privacy_mode'), otherRow('Privacy mode', 'privacy_mode'),
otherRow('Reverse mouse wheel', 'reverse_mouse_wheel'),
]); ]);
} }
} }

View File

@ -546,9 +546,11 @@ class _PinMenu extends StatelessWidget {
assetName: state.pin ? "assets/pinned.svg" : "assets/unpinned.svg", assetName: state.pin ? "assets/pinned.svg" : "assets/unpinned.svg",
tooltip: state.pin ? 'Unpin Toolbar' : 'Pin Toolbar', tooltip: state.pin ? 'Unpin Toolbar' : 'Pin Toolbar',
onPressed: state.switchPin, onPressed: state.switchPin,
color: state.pin ? _ToolbarTheme.blueColor : _ToolbarTheme.inactiveColor, color:
hoverColor: state.pin ? _ToolbarTheme.blueColor : _ToolbarTheme.inactiveColor,
state.pin ? _ToolbarTheme.hoverBlueColor : _ToolbarTheme.hoverInactiveColor, hoverColor: state.pin
? _ToolbarTheme.hoverBlueColor
: _ToolbarTheme.hoverInactiveColor,
), ),
); );
} }
@ -564,11 +566,14 @@ class _MobileActionMenu extends StatelessWidget {
return Obx(() => _IconMenuButton( return Obx(() => _IconMenuButton(
assetName: 'assets/actions_mobile.svg', assetName: 'assets/actions_mobile.svg',
tooltip: 'Mobile Actions', tooltip: 'Mobile Actions',
onPressed: () => ffi.dialogManager.toggleMobileActionsOverlay(ffi: ffi), onPressed: () =>
ffi.dialogManager.toggleMobileActionsOverlay(ffi: ffi),
color: ffi.dialogManager.mobileActionsOverlayVisible.isTrue color: ffi.dialogManager.mobileActionsOverlayVisible.isTrue
? _ToolbarTheme.blueColor : _ToolbarTheme.inactiveColor, ? _ToolbarTheme.blueColor
: _ToolbarTheme.inactiveColor,
hoverColor: ffi.dialogManager.mobileActionsOverlayVisible.isTrue hoverColor: ffi.dialogManager.mobileActionsOverlayVisible.isTrue
? _ToolbarTheme.hoverBlueColor : _ToolbarTheme.hoverInactiveColor, ? _ToolbarTheme.hoverBlueColor
: _ToolbarTheme.hoverInactiveColor,
)); ));
} }
} }
@ -1304,23 +1309,25 @@ class _KeyboardMenu extends StatelessWidget {
color: _ToolbarTheme.blueColor, color: _ToolbarTheme.blueColor,
hoverColor: _ToolbarTheme.hoverBlueColor, hoverColor: _ToolbarTheme.hoverBlueColor,
menuChildren: [ menuChildren: [
mode(modeOnly), keyboardMode(modeOnly),
localKeyboardType(), localKeyboardType(),
Divider(), Divider(),
view_mode(), viewMode(),
Divider(),
reverseMouseWheel(),
]); ]);
} }
mode(String? modeOnly) { keyboardMode(String? modeOnly) {
return futureBuilder(future: () async { return futureBuilder(future: () async {
return await bind.sessionGetKeyboardMode(sessionId: ffi.sessionId) ?? return await bind.sessionGetKeyboardMode(sessionId: ffi.sessionId) ??
_kKeyLegacyMode; _kKeyLegacyMode;
}(), hasData: (data) { }(), hasData: (data) {
final groupValue = data as String; final groupValue = data as String;
List<KeyboardModeMenu> modes = [ List<InputModeMenu> modes = [
KeyboardModeMenu(key: _kKeyLegacyMode, menu: 'Legacy mode'), InputModeMenu(key: _kKeyLegacyMode, menu: 'Legacy mode'),
KeyboardModeMenu(key: _kKeyMapMode, menu: 'Map mode'), InputModeMenu(key: _kKeyMapMode, menu: 'Map mode'),
KeyboardModeMenu(key: _kKeyTranslateMode, menu: 'Translate mode'), InputModeMenu(key: _kKeyTranslateMode, menu: 'Translate mode'),
]; ];
List<RdoMenuButton> list = []; List<RdoMenuButton> list = [];
final enabled = !ffi.ffiModel.viewOnly; final enabled = !ffi.ffiModel.viewOnly;
@ -1330,7 +1337,7 @@ class _KeyboardMenu extends StatelessWidget {
sessionId: ffi.sessionId, value: value); sessionId: ffi.sessionId, value: value);
} }
for (KeyboardModeMenu mode in modes) { for (InputModeMenu mode in modes) {
if (modeOnly != null && mode.key != modeOnly) { if (modeOnly != null && mode.key != modeOnly) {
continue; continue;
} else if (!bind.sessionIsKeyboardModeSupported( } else if (!bind.sessionIsKeyboardModeSupported(
@ -1379,7 +1386,7 @@ class _KeyboardMenu extends StatelessWidget {
); );
} }
view_mode() { viewMode() {
final ffiModel = ffi.ffiModel; final ffiModel = ffi.ffiModel;
final enabled = version_cmp(pi.version, '1.2.0') >= 0 && ffiModel.keyboard; final enabled = version_cmp(pi.version, '1.2.0') >= 0 && ffiModel.keyboard;
return CkbMenuButton( return CkbMenuButton(
@ -1395,6 +1402,32 @@ class _KeyboardMenu extends StatelessWidget {
ffi: ffi, ffi: ffi,
child: Text(translate('View Mode'))); child: Text(translate('View Mode')));
} }
reverseMouseWheel() {
return futureBuilder(future: () async {
final v =
await bind.sessionGetReverseMouseWheel(sessionId: ffi.sessionId);
debugPrint('REMOVE ME ======================== $v');
if (v != null && v != '') {
return v;
}
return bind.mainGetUserDefaultOption(key: 'reverse_mouse_wheel');
}(), hasData: (data) {
debugPrint('REMOVE ME ======================== data $data');
final enabled = !ffi.ffiModel.viewOnly;
onChanged(bool? value) async {
if (value == null) return;
await bind.sessionSetReverseMouseWheel(
sessionId: ffi.sessionId, value: value ? 'Y' : 'N');
}
return CkbMenuButton(
value: data == 'Y',
onChanged: enabled ? onChanged : null,
child: Text(translate('Reverse mouse wheel')),
ffi: ffi);
});
}
} }
class _ChatMenu extends StatefulWidget { class _ChatMenu extends StatefulWidget {
@ -1606,12 +1639,12 @@ class _IconMenuButtonState extends State<_IconMenuButton> {
type: MaterialType.transparency, type: MaterialType.transparency,
child: Ink( child: Ink(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(_ToolbarTheme.iconRadius), borderRadius:
BorderRadius.circular(_ToolbarTheme.iconRadius),
color: hover ? widget.hoverColor : widget.color, color: hover ? widget.hoverColor : widget.color,
), ),
child: icon)), child: icon)),
) )),
),
).marginSymmetric( ).marginSymmetric(
horizontal: widget.hMargin ?? _ToolbarTheme.buttonHMargin, horizontal: widget.hMargin ?? _ToolbarTheme.buttonHMargin,
vertical: widget.vMargin ?? _ToolbarTheme.buttonVMargin); vertical: widget.vMargin ?? _ToolbarTheme.buttonVMargin);
@ -1685,8 +1718,7 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> {
BorderRadius.circular(_ToolbarTheme.iconRadius), BorderRadius.circular(_ToolbarTheme.iconRadius),
color: hover ? widget.hoverColor : widget.color, color: hover ? widget.hoverColor : widget.color,
), ),
child: icon)) child: icon))),
),
menuChildren: widget.menuChildren menuChildren: widget.menuChildren
.map((e) => _buildPointerTrackWidget(e, widget.ffi)) .map((e) => _buildPointerTrackWidget(e, widget.ffi))
.toList())); .toList()));
@ -1973,11 +2005,11 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
} }
} }
class KeyboardModeMenu { class InputModeMenu {
final String key; final String key;
final String menu; final String menu;
KeyboardModeMenu({required this.key, required this.menu}); InputModeMenu({required this.key, required this.menu});
} }
_menuDismissCallback(FFI ffi) => ffi.inputModel.refreshMousePos(); _menuDismissCallback(FFI ffi) => ffi.inputModel.refreshMousePos();

View File

@ -230,6 +230,7 @@ pub struct PeerConfig {
skip_serializing_if = "String::is_empty" skip_serializing_if = "String::is_empty"
)] )]
pub view_style: String, pub view_style: String,
// Image scroll style, scrollbar or scroll auto
#[serde( #[serde(
default = "PeerConfig::default_scroll_style", default = "PeerConfig::default_scroll_style",
deserialize_with = "PeerConfig::deserialize_scroll_style", deserialize_with = "PeerConfig::deserialize_scroll_style",
@ -276,6 +277,13 @@ pub struct PeerConfig {
pub keyboard_mode: String, pub keyboard_mode: String,
#[serde(flatten)] #[serde(flatten)]
pub view_only: ViewOnly, pub view_only: ViewOnly,
// Mouse wheel or touchpad scroll mode
#[serde(
default = "PeerConfig::default_reverse_mouse_wheel",
deserialize_with = "PeerConfig::deserialize_reverse_mouse_wheel",
skip_serializing_if = "String::is_empty"
)]
pub reverse_mouse_wheel: String,
#[serde( #[serde(
default, default,
@ -319,6 +327,7 @@ impl Default for PeerConfig {
show_quality_monitor: Default::default(), show_quality_monitor: Default::default(),
keyboard_mode: Default::default(), keyboard_mode: Default::default(),
view_only: Default::default(), view_only: Default::default(),
reverse_mouse_wheel: Self::default_reverse_mouse_wheel(),
custom_resolutions: Default::default(), custom_resolutions: Default::default(),
options: Self::default_options(), options: Self::default_options(),
ui_flutter: Default::default(), ui_flutter: Default::default(),
@ -1130,6 +1139,11 @@ impl PeerConfig {
deserialize_image_quality, deserialize_image_quality,
UserDefaultConfig::read().get("image_quality") UserDefaultConfig::read().get("image_quality")
); );
serde_field_string!(
default_reverse_mouse_wheel,
deserialize_reverse_mouse_wheel,
UserDefaultConfig::read().get("reverse_mouse_wheel")
);
fn default_custom_image_quality() -> Vec<i32> { fn default_custom_image_quality() -> Vec<i32> {
let f: f64 = UserDefaultConfig::read() let f: f64 = UserDefaultConfig::read()
@ -1483,7 +1497,11 @@ impl UserDefaultConfig {
} }
pub fn set(&mut self, key: String, value: String) { pub fn set(&mut self, key: String, value: String) {
if value.is_empty() {
self.options.remove(&key);
} else {
self.options.insert(key, value); self.options.insert(key, value);
}
self.store(); self.store();
} }

View File

@ -1195,6 +1195,17 @@ impl LoginConfigHandler {
self.save_config(config); self.save_config(config);
} }
/// Save reverse mouse wheel ("", "Y") to the current config.
///
/// # Arguments
///
/// * `value` - The reverse mouse wheel ("", "Y").
pub fn save_reverse_mouse_wheel(&mut self, value: String) {
let mut config = self.load_config();
config.reverse_mouse_wheel = value;
self.save_config(config);
}
/// Save scroll style to the current config. /// Save scroll style to the current config.
/// ///
/// # Arguments /// # Arguments

View File

@ -21,8 +21,6 @@ use hbb_common::{
}; };
use std::{ use std::{
collections::HashMap, collections::HashMap,
ffi::{CStr, CString},
os::raw::c_char,
str::FromStr, str::FromStr,
sync::{ sync::{
atomic::{AtomicI32, Ordering}, atomic::{AtomicI32, Ordering},
@ -302,6 +300,20 @@ pub fn session_set_keyboard_mode(session_id: SessionID, value: String) {
} }
} }
pub fn session_get_reverse_mouse_wheel(session_id: SessionID) -> Option<String> {
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
Some(session.get_reverse_mouse_wheel())
} else {
None
}
}
pub fn session_set_reverse_mouse_wheel(session_id: SessionID, value: String) {
if let Some(session) = SESSIONS.write().unwrap().get_mut(&session_id) {
session.save_reverse_mouse_wheel(value);
}
}
pub fn session_get_custom_image_quality(session_id: SessionID) -> Option<Vec<i32>> { pub fn session_get_custom_image_quality(session_id: SessionID) -> Option<Vec<i32>> {
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) { if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
Some(session.get_custom_image_quality()) Some(session.get_custom_image_quality())

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "HSV 色"), ("HSV Color", "HSV 色"),
("Installation Successful!", "安装成功!"), ("Installation Successful!", "安装成功!"),
("Installation failed!", "安装失败!"), ("Installation failed!", "安装失败!"),
("Reverse mouse wheel", "鼠标滚轮反向"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "HSV-Farbe"), ("HSV Color", "HSV-Farbe"),
("Installation Successful!", "Installation erfolgreich!"), ("Installation Successful!", "Installation erfolgreich!"),
("Installation failed!", "Installation fehlgeschlagen!"), ("Installation failed!", "Installation fehlgeschlagen!"),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -77,5 +77,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("pull_ab_failed_tip", "Failed to refresh address book"), ("pull_ab_failed_tip", "Failed to refresh address book"),
("push_ab_failed_tip", "Failed to sync address book to server"), ("push_ab_failed_tip", "Failed to sync address book to server"),
("synced_peer_readded_tip", "The devices that were present in the recent sessions will be synchronized back to the address book."), ("synced_peer_readded_tip", "The devices that were present in the recent sessions will be synchronized back to the address book."),
("View Mode", "View mode"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "Color HSV"), ("HSV Color", "Color HSV"),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "Couleur TSL"), ("HSV Color", "Couleur TSL"),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "Warna HSV"), ("HSV Color", "Warna HSV"),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "Colore HSV"), ("HSV Color", "Colore HSV"),
("Installation Successful!", "Installazione completata"), ("Installation Successful!", "Installazione completata"),
("Installation failed!", "Installazione fallita"), ("Installation failed!", "Installazione fallita"),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "HSV Kleur"), ("HSV Color", "HSV Kleur"),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "Цвет HSV"), ("HSV Color", "Цвет HSV"),
("Installation Successful!", "Установка выполнена успешно!"), ("Installation Successful!", "Установка выполнена успешно!"),
("Installation failed!", "Установка не выполнена!"), ("Installation failed!", "Установка не выполнена!"),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "HSV Rengi"), ("HSV Color", "HSV Rengi"),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", "HSV 色"), ("HSV Color", "HSV 色"),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -543,5 +543,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("HSV Color", ""), ("HSV Color", ""),
("Installation Successful!", ""), ("Installation Successful!", ""),
("Installation failed!", ""), ("Installation failed!", ""),
("Reverse mouse wheel", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -1,4 +1,4 @@
use crate::input::{MOUSE_BUTTON_LEFT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP}; use crate::input::{MOUSE_BUTTON_LEFT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP, MOUSE_TYPE_WHEEL};
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use std::{collections::HashMap, sync::atomic::AtomicBool}; use std::{collections::HashMap, sync::atomic::AtomicBool};
use std::{ use std::{
@ -175,6 +175,14 @@ impl<T: InvokeUiSession> Session<T> {
self.lc.write().unwrap().save_keyboard_mode(value); self.lc.write().unwrap().save_keyboard_mode(value);
} }
pub fn get_reverse_mouse_wheel(&self) -> String {
self.lc.read().unwrap().reverse_mouse_wheel.clone()
}
pub fn save_reverse_mouse_wheel(&mut self, value: String) {
self.lc.write().unwrap().save_reverse_mouse_wheel(value);
}
pub fn save_view_style(&mut self, value: String) { pub fn save_view_style(&mut self, value: String) {
self.lc.write().unwrap().save_view_style(value); self.lc.write().unwrap().save_view_style(value);
} }
@ -730,6 +738,7 @@ impl<T: InvokeUiSession> Session<T> {
}); });
} }
"pan_update" => { "pan_update" => {
let (x, y) = self.get_scroll_xy((x, y));
touch_evt.set_pan_update(TouchPanUpdate { touch_evt.set_pan_update(TouchPanUpdate {
x, x,
y, y,
@ -753,6 +762,21 @@ impl<T: InvokeUiSession> Session<T> {
send_pointer_device_event(evt, alt, ctrl, shift, command, self); send_pointer_device_event(evt, alt, ctrl, shift, command, self);
} }
#[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn is_scroll_reverse_mode(&self) -> bool {
self.lc.read().unwrap().reverse_mouse_wheel.eq("Y")
}
#[inline]
fn get_scroll_xy(&self, xy: (i32, i32)) -> (i32, i32) {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if self.is_scroll_reverse_mode() {
return (-xy.0, -xy.1);
}
xy
}
pub fn send_mouse( pub fn send_mouse(
&self, &self,
mask: i32, mask: i32,
@ -772,6 +796,12 @@ impl<T: InvokeUiSession> Session<T> {
} }
} }
let (x, y) = if mask == MOUSE_TYPE_WHEEL {
self.get_scroll_xy((x, y))
} else {
(x, y)
};
// #[cfg(not(any(target_os = "android", target_os = "ios")))] // #[cfg(not(any(target_os = "android", target_os = "ios")))]
let (alt, ctrl, shift, command) = let (alt, ctrl, shift, command) =
keyboard::client::get_modifiers_state(alt, ctrl, shift, command); keyboard::client::get_modifiers_state(alt, ctrl, shift, command);