-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
customization: Adapt shortcut_input element to be generic
Bug: b/241965717 Change-Id: I414161881f8d3fb6365351555d7256616757af46 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4953072 Commit-Queue: David Padlipsky <dpad@google.com> Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org> Cr-Commit-Position: refs/heads/main@{#1215950}
- Loading branch information
1 parent
13fcd6d
commit 18c94fb
Showing
11 changed files
with
959 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2023 The Chromium Authors | ||
# Use of this source code is governed by a BSD - style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//build/config/chromeos/ui_mode.gni") | ||
|
||
assert(is_chromeos_ash, "Shortcut Input is for Chrome OS only.") | ||
|
||
copy("copy_mojo_files") { | ||
deps = [ | ||
"//ash/public/mojom:accelerator_actions_ts__generator", | ||
"//ash/public/mojom:accelerator_keys_ts__generator", | ||
"//ash/public/mojom:input_device_settings_ts__generator", | ||
"//ash/webui/common/mojom:shortcut_input_provider_ts__generator", | ||
"//ui/events/ash/mojom:mojom_ts__generator", | ||
] | ||
sources = [ | ||
"$root_gen_dir/ash/public/mojom/accelerator_actions.mojom-webui.ts", | ||
"$root_gen_dir/ash/public/mojom/accelerator_keys.mojom-webui.ts", | ||
"$root_gen_dir/ash/public/mojom/input_device_settings.mojom-webui.ts", | ||
"$root_gen_dir/ash/webui/common/mojom/shortcut_input_provider.mojom-webui.ts", | ||
"$root_gen_dir/ui/events/ash/mojom/extended_fkeys_modifier.mojom-webui.ts", | ||
"$root_gen_dir/ui/events/ash/mojom/modifier_key.mojom-webui.ts", | ||
"$root_gen_dir/ui/events/ash/mojom/simulate_right_click_modifier.mojom-webui.ts", | ||
"$root_gen_dir/ui/events/ash/mojom/six_pack_shortcut_modifier.mojom-webui.ts", | ||
] | ||
outputs = [ "$root_gen_dir/ash/webui/common/resources/preprocessed/shortcut_input_ui/{{source_file_part}}" ] | ||
} |
56 changes: 56 additions & 0 deletions
56
ash/webui/common/resources/shortcut_input_ui/fake_shortcut_input_provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import {FakeObservables} from '../fake_observables.js'; | ||
|
||
import {KeyEvent} from './input_device_settings.mojom-webui.js'; | ||
import {ShortcutInputObserverInterface, ShortcutInputProviderInterface} from './shortcut_input_provider.mojom-webui.js'; | ||
|
||
export class FakeShortcutInputProvider implements | ||
ShortcutInputProviderInterface { | ||
private observables: FakeObservables = new FakeObservables(); | ||
|
||
constructor() { | ||
this.registerObservables(); | ||
} | ||
|
||
sendKeyPressEvent(keyEvent: KeyEvent) { | ||
this.observables.setObservableData( | ||
'ShortcutInputObserver_OnShortcutInputEventPressed', [keyEvent]); | ||
this.observables.trigger( | ||
'ShortcutInputObserver_OnShortcutInputEventPressed'); | ||
} | ||
|
||
sendKeyReleaseEvent(keyEvent: KeyEvent) { | ||
this.observables.setObservableData( | ||
'ShortcutInputObserver_OnShortcutInputEventReleased', [keyEvent]); | ||
this.observables.trigger( | ||
'ShortcutInputObserver_OnShortcutInputEventReleased'); | ||
} | ||
|
||
startObservingShortcutInput(observer: ShortcutInputObserverInterface) { | ||
this.observables.observe( | ||
'ShortcutInputObserver_OnShortcutInputEventPressed', | ||
(keyEvent: KeyEvent) => { | ||
observer.onShortcutInputEventPressed(keyEvent); | ||
}); | ||
this.observables.observe( | ||
'ShortcutInputObserver_OnShortcutInputEventReleased', | ||
(keyEvent: KeyEvent) => { | ||
observer.onShortcutInputEventReleased(keyEvent); | ||
}); | ||
} | ||
|
||
stopObservingShortcutInput() { | ||
this.observables = new FakeObservables(); | ||
this.registerObservables(); | ||
} | ||
|
||
private registerObservables() { | ||
this.observables.register( | ||
'ShortcutInputObserver_OnShortcutInputEventPressed'); | ||
this.observables.register( | ||
'ShortcutInputObserver_OnShortcutInputEventReleased'); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
ash/webui/common/resources/shortcut_input_ui/shortcut_input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<style> | ||
.flex-row { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
} | ||
|
||
#confirmContainer { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
#container:focus { | ||
outline: none; | ||
} | ||
|
||
#keySeparator { | ||
align-items: center; | ||
display: flex; | ||
padding-inline-end: 8px; | ||
} | ||
</style> | ||
|
||
<div id="container" class="flex-row" tabindex="-1"> | ||
<template is="dom-if" if="[[shouldShowConfirmView(isCapturing)]]"> | ||
<div id="confirmContainer"> | ||
<template is="dom-repeat" items="[[modifiers]]"> | ||
<shortcut-input-key key="[[item]]" key-state="modifier-selected"> | ||
</shortcut-input-key> | ||
</template> | ||
<template is="dom-if" | ||
if="[[shouldShowSeparator(showSeparator, modifiers)]]"> | ||
<div id="keySeparator"> + </div> | ||
</template> | ||
<template is="dom-if" if="[[shouldShowSelectedKey(pendingKeyEvent.*)]]"> | ||
<shortcut-input-key id="confirmKey" | ||
key="[[getKey(pendingKeyEvent.*)]]" | ||
key-state="alpha-numeric-selected"> | ||
</shortcut-input-key> | ||
</template> | ||
</div> | ||
</template> | ||
<template is="dom-if" if="[[shouldShowEditView(isCapturing)]]"> | ||
<div id="editContainer" class="flex-row"> | ||
<shortcut-input-key id="ctrlKey" | ||
key="ctrl" | ||
key-state="[[getCtrlState(pendingKeyEvent.*)]]"> | ||
</shortcut-input-key> | ||
<shortcut-input-key id="altKey" | ||
key="alt" | ||
key-state="[[getAltState(pendingKeyEvent.*)]]"> | ||
</shortcut-input-key> | ||
<shortcut-input-key id="shiftKey" | ||
key="shift" | ||
key-state="[[getShiftState(pendingKeyEvent.*)]]"> | ||
</shortcut-input-key> | ||
<shortcut-input-key id="searchKey" | ||
key="meta" | ||
key-state="[[getSearchState(pendingKeyEvent.*)]]"> | ||
</shortcut-input-key> | ||
<div id="keySeparator"> + </div> | ||
<shortcut-input-key id="pendingKey" | ||
key="[[getKey(pendingKeyEvent.*)]]" | ||
key-state="[[getKeyState(pendingKeyEvent.*)]]"> | ||
</shortcut-input-key> | ||
</div> | ||
</template> | ||
</div> |
Oops, something went wrong.