fix: release mouse buttons on focus loss on Wayland (#48752)

This commit is contained in:
Mitchell Cohen
2025-11-03 08:37:42 -05:00
committed by GitHub
parent 20fc76cb43
commit 4d6db515bd
2 changed files with 35 additions and 0 deletions

View File

@@ -143,3 +143,4 @@ expose_referrerscriptinfo_hostdefinedoptionsindex.patch
chore_disable_protocol_handler_dcheck.patch
fix_check_for_file_existence_before_setting_mtime.patch
revert_cleanup_remove_feature_windelayspellcheckserviceinit.patch
fix_release_mouse_buttons_on_focus_loss_on_wayland.patch

View File

@@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mitchell COhen <mitch.cohen@me.com>
Date: Sun, 2 Nov 2025 15:30:56 -0500
Subject: fix: release mouse buttons on focus loss on Wayland
Fixes an issue where the mouse flags would get stuck if you right-click
the CSD titlebar in Wayland.
Bug: 455147429
Change-Id: I9f5a9f395b3c1d85094a40a92d40691a897dbd05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7091872
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Kramer Ge <fangzhoug@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1538048}
diff --git a/ui/ozone/platform/wayland/host/wayland_event_source.cc b/ui/ozone/platform/wayland/host/wayland_event_source.cc
index 4cc15e842b633e93f1d6654225765769eb75fffd..4e421ccbd36d4efebd43c9def5b575b7d8d5e336 100644
--- a/ui/ozone/platform/wayland/host/wayland_event_source.cc
+++ b/ui/ozone/platform/wayland/host/wayland_event_source.cc
@@ -336,6 +336,13 @@ void WaylandEventSource::OnPointerFocusChanged(
// Save new pointer location.
pointer_location_ = location;
window_manager_->SetPointerFocusedWindow(window);
+ } else {
+ // The compositor may swallow the release event for any buttons that are
+ // pressed when the window loses focus, e.g. when right-clicking the
+ // titlebar to open the system menu on GNOME.
+ if (!connection_->IsDragInProgress()) {
+ ReleasePressedPointerButtons(window, ui::EventTimeForNow());
+ }
}
auto closure = focused ? base::NullCallback()