blob: 6e9bb0313f9dd9056f087af8c215812d9ac66f3a [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"
reveman5cacf70c2015-12-09 22:50:0210#include "base/time/time.h"
11
12namespace ui {
13enum class DomCode;
14}
15
16namespace exo {
reveman5cacf70c2015-12-09 22:50:0217class Surface;
18
19// Handles events on keyboards in context-specific ways.
20class KeyboardDelegate {
21 public:
Hidehiko Abe0fbe4abc2020-09-18 02:15:1322 virtual ~KeyboardDelegate() = default;
23
reveman5cacf70c2015-12-09 22:50:0224 // This should return true if |surface| is a valid target for this keyboard.
25 // E.g. the surface is owned by the same client as the keyboard.
26 virtual bool CanAcceptKeyboardEventsForSurface(Surface* surface) const = 0;
27
28 // Called when keyboard focus enters a new valid target surface.
29 virtual void OnKeyboardEnter(
30 Surface* surface,
David Reveman94a6f1a2018-06-25 17:04:5531 const base::flat_map<ui::DomCode, ui::DomCode>& pressed_keys) = 0;
reveman5cacf70c2015-12-09 22:50:0232
33 // Called when keyboard focus leaves a valid target surface.
34 virtual void OnKeyboardLeave(Surface* surface) = 0;
35
yhanada5d5b8cb52016-12-10 04:16:0236 // Called when keyboard key state changed. |pressed| is true when |key|
yhanada6b8fafc52017-07-27 11:40:3437 // was pressed and false if it was released. Should return the serial
38 // number that will be used by the client to acknowledge the change in
39 // key state.
40 virtual uint32_t OnKeyboardKey(base::TimeTicks time_stamp,
41 ui::DomCode key,
42 bool pressed) = 0;
reveman5cacf70c2015-12-09 22:50:0243
44 // Called when keyboard modifier state changed.
45 virtual void OnKeyboardModifiers(int modifier_flags) = 0;
46
Chloe Pelling8a2fb0a2020-05-05 23:12:0247 // Called when key repeat settings are changed.
48 virtual void OnKeyRepeatSettingsChanged(bool enabled,
49 base::TimeDelta delay,
50 base::TimeDelta interval) = 0;
reveman5cacf70c2015-12-09 22:50:0251};
52
53} // namespace exo
54
55#endif // COMPONENTS_EXO_KEYBOARD_DELEGATE_H_