Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: ui/wayland/wayland_input_device.h

Issue 7457023: Adding a Wayland basic toolkit (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: More comments and Chrome style formatting Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 WAYLAND_INPUT_DEVICE_H_
6 #define WAYLAND_INPUT_DEVICE_H_
7
8 #include <stdint.h>
9
10 #include "base/basictypes.h"
11 #include "wayland_geometry_utils.h"
12 #include "wayland_widget.h"
13
14 struct xkb_desc;
15 struct wl_array;
16 struct wl_buffer;
17 struct wl_display;
18 struct wl_input_device;
19 struct wl_input_device_listener;
20 struct wl_surface;
21
22 class WaylandWindow;
23
24 /*
25 This class represents an input device that was registered with Wayland.
26 The purpose of this class is to parse and wrap events into generic
27 WaylandEvent types and dispatch the event to the appropriate WaylandWindow.
28
29 How Wayland events work:
30 ------------------------
31
32 When the On*Focus events are triggered, the input device receives a reference
33 to the surface that just received/lost focus. Each surface is associated with
34 a unique WaylandWindow. When processing the focus events we keep track of the
35 currently focused window such that when we receive different events (mouse
36 button press or key press) we only send the event to the window in focus.
37 */
38 class WaylandInputDevice {
39
40 public:
41 WaylandInputDevice(wl_display* display, uint32_t id);
42 ~WaylandInputDevice();
43
44 // Used to change the surface of the input device (normally pointer image).
45 void Attach(wl_buffer* buffer, int32_t x, int32_t y);
46 private:
47 wl_input_device* input_device_;
48
49 /* These keep track of the window that's currently under focus. NULL if no
50 window is under focus.
51 */
52 WaylandWindow* pointer_focus_;
53 WaylandWindow* keyboard_focus_;
54
55 /* Keeps track of the currently active keyboard modifiers. We keep this
56 since we want to advertise keyboard modifiers with mouse events.
57 */
58 uint32_t keyboard_modifiers_;
59
60 /* Keeps track of the last position for the motion event. We want to
61 publish this with events such as button notify which doesn't have a
62 position associated by default.
63 */
64 Point global_position_;
65 Point surface_position_;
66
67 /* Keep track of the time of last event. Useful when we get buffer Attach
68 calls and the calls wouldn't have a way of getting an event time.
69 */
70 uint32_t last_event_time_;
71
72 /* keymap used to transform keyboard events. */
73 xkb_desc* xkb_;
74
75 /* List of callback functions for input device events. */
76 static const wl_input_device_listener input_device_listener_;
77
78 /* Input device callback functions. These will create 'WaylandEvent's and
79 send them to the currently focused window.
80 Args:
81 - data: Pointer to the WaylandInputDevice object associated with the
82 'input_device'
83 - input_device:
84 The input device that sent the event
85 - time: The time of the event.
86 */
87 static void OnMotionNotify(void* data, wl_input_device* input_device,
88 uint32_t time, int32_t x, int32_t y,
89 int32_t sx, int32_t sy);
90 static void OnButtonNotify(void* data, wl_input_device* input_device,
91 uint32_t time, uint32_t button, uint32_t state);
92 static void OnKeyNotify(void* data, wl_input_device* input_device,
93 uint32_t time, uint32_t key, uint32_t state);
94 /* On*Focus events also have a Wayland surface associated with them. If the
95 surface is NULL, then the event signifies a loss of focus. Otherwise we
96 use the surface to get the WaylandWindow that receives focus.
97 */
98 static void OnPointerFocus(void* data, wl_input_device* input_device,
99 uint32_t time, wl_surface *surface,
100 int32_t x, int32_t y, int32_t sx, int32_t sy);
101 static void OnKeyboardFocus(void* data, wl_input_device* input_device,
102 uint32_t time, wl_surface *surface,
103 wl_array* keys);
104
105 DISALLOW_COPY_AND_ASSIGN(WaylandInputDevice);
106 };
107
108 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698