summaryrefslogtreecommitdiff
path: root/chromium/components/exo/keyboard.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-07 13:12:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:02:59 +0000
commit33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (patch)
treef6af110909c79b2759136554f1143d8b0572af0a /chromium/components/exo/keyboard.cc
parent7d2c5d177e9813077a621df8d18c0deda73099b3 (diff)
downloadqtwebengine-chromium-33fc33aa94d4add0878ec30dc818e34e1dd3cc2a.tar.gz
BASELINE: Update Chromium to 104.0.5112.120
Change-Id: I5d2726c2ab018d75d055739b6ba64317904f05bb Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438935 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/exo/keyboard.cc')
-rw-r--r--chromium/components/exo/keyboard.cc51
1 files changed, 26 insertions, 25 deletions
diff --git a/chromium/components/exo/keyboard.cc b/chromium/components/exo/keyboard.cc
index 94220ddeca7..524379420f2 100644
--- a/chromium/components/exo/keyboard.cc
+++ b/chromium/components/exo/keyboard.cc
@@ -4,6 +4,7 @@
#include "components/exo/keyboard.h"
+#include "ash/accelerators/accelerator_table.h"
#include "ash/constants/app_types.h"
#include "ash/constants/ash_features.h"
#include "ash/keyboard/ui/keyboard_ui_controller.h"
@@ -13,6 +14,8 @@
#include "ash/shell.h"
#include "base/bind.h"
#include "base/containers/contains.h"
+#include "base/containers/span.h"
+#include "base/no_destructor.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "components/exo/input_trace.h"
@@ -126,14 +129,10 @@ bool CanConsumeAshAccelerators(Surface* surface) {
for (; window; window = window->parent()) {
const auto app_type =
static_cast<ash::AppType>(window->GetProperty(aura::client::kAppType));
- // TODO(fukino): Always returning false for Lacros window is a short-term
- // solution. In reality, Lacros can consume ash accelerator's key
- // combination when it is a deprecated ash accelerator or the window is
- // running PWA. We need to let the wayland client dynamically decrlare
- // whether it want to consume ash accelerators' key combinations.
- // crbug.com/1174025.
+ // TOOD(hidehiko): get rid of this if check, after introducing capability,
+ // followed by ARC/Crostini migration.
if (app_type == ash::AppType::LACROS)
- return false;
+ return surface->is_keyboard_shortcuts_inhibited();
}
return true;
}
@@ -146,25 +145,27 @@ bool ProcessAshAcceleratorIfPossible(Surface* surface, ui::KeyEvent* event) {
if (CanConsumeAshAccelerators(surface))
return false;
- // TODO(crbug.com/1301977): Remove this workaround on fixing acceleartor
- // handling for lacros.
- const ui::Accelerator kAppHandlingAccelerators[] = {
- // Ctrl-N (new window), Shift-Ctrl-N (new incognite window), Ctrl-T (new
- // tab), and Shit-Ctrl-T (restore tab) need to be sent to the active
- // client even when the active window is lacros-chrome, since the
- // ash-chrome does not handle these new-window requests properly at this
- // moment.
- {ui::VKEY_N, ui::EF_CONTROL_DOWN},
- {ui::VKEY_N, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN},
- {ui::VKEY_T, ui::EF_CONTROL_DOWN},
- {ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN},
- // Also forward Ctrl-/ and Shift-Ctrl-/ so Lacros processes the help app
- // opening while it can be intercepted.
- {ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN},
- {ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN},
- };
+ // If accelerators can be processed by browser, send it to the app.
+ static const base::NoDestructor<std::vector<ui::Accelerator>>
+ kAppHandlingAccelerators([] {
+ std::vector<ui::Accelerator> result;
+ for (size_t i = 0; i < ash::kAcceleratorDataLength; ++i) {
+ const auto& ash_entry = ash::kAcceleratorData[i];
+ if (base::Contains(base::span<const ash::AcceleratorAction>(
+ ash::kActionsInterceptableByBrowser,
+ ash::kActionsInterceptableByBrowserLength),
+ ash_entry.action) ||
+ base::Contains(base::span<const ash::AcceleratorAction>(
+ ash::kActionsDuplicatedWithBrowser,
+ ash::kActionsDuplicatedWithBrowserLength),
+ ash_entry.action)) {
+ result.emplace_back(ash_entry.keycode, ash_entry.modifiers);
+ }
+ }
+ return result;
+ }());
ui::Accelerator accelerator(*event);
- if (base::Contains(kAppHandlingAccelerators, accelerator))
+ if (base::Contains(*kAppHandlingAccelerators, accelerator))
return false;
return ash::AcceleratorController::Get()->Process(accelerator);