blob: ff97652bac6b1d71b7dc7a64334e08c81afac30a [file] [log] [blame]
reveman5cacf70c2015-12-09 22:50:021// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_EXO_KEYBOARD_DELEGATE_H_
6#define COMPONENTS_EXO_KEYBOARD_DELEGATE_H_
7
Shawn Gallea1310d8a2018-11-14 23:07:218#include "base/containers/flat_map.h"
David Revemand93d69362017-11-27 19:52:059#include "base/containers/flat_set.h"
Hidehiko Abe3375cfe52020-09-29 08:48:2610#include "base/strings/string_piece.h"
reveman5cacf70c2015-12-09 22:50:0211#include "base/time/time.h"
12
13namespace ui {
14enum class DomCode;
15}
16
17namespace exo {
Hidehiko Abe3375cfe52020-09-29 08:48:2618struct KeyboardModifiers;
reveman5cacf70c2015-12-09 22:50:0219class Surface;
20
21// Handles events on keyboards in context-specific ways.
22class KeyboardDelegate {
23 public:
Hidehiko Abe0fbe4abc2020-09-18 02:15:1324 virtual ~KeyboardDelegate() = default;
25
reveman5cacf70c2015-12-09 22:50:0226 // This should return true if |surface| is a valid target for this keyboard.
27 // E.g. the surface is owned by the same client as the keyboard.
28 virtual bool CanAcceptKeyboardEventsForSurface(Surface* surface) const = 0;
29
30 // Called when keyboard focus enters a new valid target surface.
31 virtual void OnKeyboardEnter(
32 Surface* surface,
David Reveman94a6f1a2018-06-25 17:04:5533 const base::flat_map<ui::DomCode, ui::DomCode>& pressed_keys) = 0;
reveman5cacf70c2015-12-09 22:50:0234
35 // Called when keyboard focus leaves a valid target surface.
36 virtual void OnKeyboardLeave(Surface* surface) = 0;
37
yhanada5d5b8cb52016-12-10 04:16:0238 // Called when keyboard key state changed. |pressed| is true when |key|
yhanada6b8fafc52017-07-27 11:40:3439 // was pressed and false if it was released. Should return the serial
40 // number that will be used by the client to acknowledge the change in
41 // key state.
42 virtual uint32_t OnKeyboardKey(base::TimeTicks time_stamp,
43 ui::DomCode key,
44 bool pressed) = 0;
reveman5cacf70c2015-12-09 22:50:0245
46 // Called when keyboard modifier state changed.
Hidehiko Abe3375cfe52020-09-29 08:48:2647 virtual void OnKeyboardModifiers(const KeyboardModifiers& modifiers) = 0;
reveman5cacf70c2015-12-09 22:50:0248
Chloe Pelling8a2fb0a2020-05-05 23:12:0249 // Called when key repeat settings are changed.
50 virtual void OnKeyRepeatSettingsChanged(bool enabled,
51 base::TimeDelta delay,
52 base::TimeDelta interval) = 0;
Hidehiko Abec07fd66e2020-09-19 12:43:1453
54 // Called when keyboard layout is updated.
Hidehiko Abe3375cfe52020-09-29 08:48:2655 virtual void OnKeyboardLayoutUpdated(base::StringPiece keymap) = 0;
reveman5cacf70c2015-12-09 22:50:0256};
57
58} // namespace exo
59
60#endif // COMPONENTS_EXO_KEYBOARD_DELEGATE_H_