Skip to content

Commit

Permalink
On Linux, disable mouse event when creating windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Yu Wei committed Jan 16, 2023
1 parent c6dc25e commit 9f4d6c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changes/linux-mouse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-runtime-wry": patch
---

On Linux, disable mouse event when creating windows with `with_config`.

13 changes: 9 additions & 4 deletions core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,7 @@ impl WindowBuilder for WindowBuilderWrapper {
.always_on_top(config.always_on_top)
.content_protected(config.content_protected)
.skip_taskbar(config.skip_taskbar)
.theme(config.theme)
.disable_mouse_event(config.disable_mouse_event);
.theme(config.theme);

#[cfg(target_os = "macos")]
{
Expand Down Expand Up @@ -751,6 +750,12 @@ impl WindowBuilder for WindowBuilderWrapper {
");
}

#[cfg(target_os = "linux")]
{
// Mouse event is disabled on Linux since sudden event bursts could block event loop.
window = window.mouse_event(false);
}

if let (Some(min_width), Some(min_height)) = (config.min_width, config.min_height) {
window = window.min_inner_size(min_width, min_height);
}
Expand Down Expand Up @@ -953,8 +958,8 @@ impl WindowBuilder for WindowBuilderWrapper {
}

#[cfg(target_os = "linux")]
fn disable_mouse_event(mut self, disable: bool) -> Self {
self.inner = self.inner.disable_mouse_event(disable);
fn mouse_event(mut self, enable: bool) -> Self {
self.inner = self.inner.with_cursor_moved_event(enable);
self
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/tauri-runtime/src/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub trait WindowBuilder: WindowBuilderBase {
/// Disables mouse events on Linux.
#[cfg(target_os = "linux")]
#[must_use]
fn disable_mouse_event(self, disable: bool) -> Self;
fn mouse_event(self, enable: bool) -> Self;
}

/// IPC handler.
Expand Down
3 changes: 0 additions & 3 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,6 @@ impl Default for WindowConfig {
content_protected: false,
skip_taskbar: false,
theme: None,
disable_mouse_event: false,
title_bar_style: Default::default(),
hidden_title: false,
accept_first_mouse: false,
Expand Down Expand Up @@ -3133,7 +3132,6 @@ mod build {
let content_protected = self.content_protected;
let skip_taskbar = self.skip_taskbar;
let theme = opt_lit(self.theme.as_ref());
let disable_mouse_event = self.disable_mouse_event;
let title_bar_style = &self.title_bar_style;
let hidden_title = self.hidden_title;
let accept_first_mouse = self.accept_first_mouse;
Expand Down Expand Up @@ -3168,7 +3166,6 @@ mod build {
content_protected,
skip_taskbar,
theme,
disable_mouse_event,
title_bar_style,
hidden_title,
accept_first_mouse,
Expand Down

0 comments on commit 9f4d6c0

Please sign in to comment.