Skip to content

Commit 008de3c

Browse files
fix: Fix window focus management on ozone-nexus OS-18564
Added a patch to fix the issue with window focus management on ozone nexus backend.
1 parent fc72d24 commit 008de3c

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

patches/chromium/.patches

+1
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,4 @@ os-18216_fix_mouse_input_on_html_form_select_popups.patch
179179
os-18170_allow_mse_mediasource_to_be_disabled.patch
180180
os-15658_do_not_convert_tooltip_position_to_screen_coordinates_for.patch
181181
fix_nexus_fix_window_focus_management_for_vk_os-17597.patch
182+
fix_track_keyboard_focus_on_nexuswindowmanager_os-18564.patch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Caner Altinbasak <cal@brightsign.biz>
3+
Date: Thu, 30 Jan 2025 12:11:33 +0000
4+
Subject: fix: Track keyboard focus on NexusWindowManager OS-18564
5+
6+
On systems with a window manager, the focus management is
7+
done by the window manager.
8+
9+
NxClient is a window compositor, it is not a window manager,
10+
so we have to track the focused window and send the input
11+
events to that window.
12+
13+
diff --git a/ui/ozone/platform/nexus/nexus_window.cc b/ui/ozone/platform/nexus/nexus_window.cc
14+
index 1d117fb137dedc1270970b5b6ba8a46ed5831708..26e6a32324637b1672c80d105cbd94781b607a95 100644
15+
--- a/ui/ozone/platform/nexus/nexus_window.cc
16+
+++ b/ui/ozone/platform/nexus/nexus_window.cc
17+
@@ -301,6 +301,10 @@ bool NexusWindow::CanDispatchEvent(const PlatformEvent& event) {
18+
NexusWindow* window_on_mouse =
19+
window_manager_->GetWindowAt(located_event->location());
20+
return window_on_mouse == this;
21+
+ } else if (event->IsKeyEvent()) {
22+
+ NexusWindow* keyboard_grabber =
23+
+ window_manager_->GetWindow(window_manager_->keyboard_grabber());
24+
+ return keyboard_grabber == this;
25+
}
26+
return true;
27+
}
28+
diff --git a/ui/ozone/platform/nexus/nexus_window_manager.cc b/ui/ozone/platform/nexus/nexus_window_manager.cc
29+
index f227a9a35806c99f63f0f775202f697b3d38f730..c38fc13003b77b5f48e00038d52337fc1073513d 100644
30+
--- a/ui/ozone/platform/nexus/nexus_window_manager.cc
31+
+++ b/ui/ozone/platform/nexus/nexus_window_manager.cc
32+
@@ -72,6 +72,7 @@ void NexusWindowManager::GrabEvents(gfx::AcceleratedWidget widget) {
33+
if (event_grabber_ != gfx::kNullAcceleratedWidget)
34+
return;
35+
event_grabber_ = widget;
36+
+ keyboard_grabber_ = widget;
37+
}
38+
39+
void NexusWindowManager::UngrabEvents(gfx::AcceleratedWidget widget) {
40+
diff --git a/ui/ozone/platform/nexus/nexus_window_manager.h b/ui/ozone/platform/nexus/nexus_window_manager.h
41+
index f4f8777e3799d1cc7caf26e6a17978d4e7a0dffe..afa5f7b7e47f3a53c1f8c79eeecaa474dedc26d0 100644
42+
--- a/ui/ozone/platform/nexus/nexus_window_manager.h
43+
+++ b/ui/ozone/platform/nexus/nexus_window_manager.h
44+
@@ -49,6 +49,9 @@ class NexusWindowManager {
45+
// Called when a mouse physicall moved into the |window|.
46+
void MouseOnWindow(NexusWindow* window);
47+
48+
+ // Get Keyboard grabber.
49+
+ gfx::AcceleratedWidget keyboard_grabber() const { return keyboard_grabber_; }
50+
+
51+
// Gets the current widget recipient of mouse events.
52+
gfx::AcceleratedWidget event_grabber() const { return event_grabber_; }
53+
54+
@@ -58,6 +61,7 @@ class NexusWindowManager {
55+
56+
NexusWindow* window_mouse_currently_on_ = nullptr;
57+
gfx::AcceleratedWidget event_grabber_ = gfx::kNullAcceleratedWidget;
58+
+ gfx::AcceleratedWidget keyboard_grabber_ = gfx::kNullAcceleratedWidget;
59+
gfx::AcceleratedWidget next_accelerated_widget_ = 0;
60+
};
61+

0 commit comments

Comments
 (0)