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

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: Removed the WaylandDisplay singleton 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 UI_WAYLAND_WAYLAND_INPUT_DEVICE_H_
6 #define UI_WAYLAND_WAYLAND_INPUT_DEVICE_H_
7
8 #include <stdint.h>
9
10 #include "base/basictypes.h"
11 #include "ui/wayland/wayland_geometry_utils.h"
12 #include "ui/wayland/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 // This class represents an input device that was registered with Wayland.
25 // The purpose of this class is to parse and wrap events into generic
26 // WaylandEvent types and dispatch the event to the appropriate WaylandWindow.
27 //
28 // How Wayland events work:
29 // ------------------------
30 //
31 // When the On*Focus events are triggered, the input device receives a
32 // reference to the surface that just received/lost focus. Each surface is
33 // associated with a unique WaylandWindow. When processing the focus events we
34 // keep track of the currently focused window such that when we receive
35 // different events (mouse button press or key press) we only send the event to
36 // the window in focus.
37 class WaylandInputDevice {
38
39 public:
40 WaylandInputDevice(wl_display* display, uint32_t id);
41 ~WaylandInputDevice();
42
43 // Used to change the surface of the input device (normally pointer image).
44 void Attach(wl_buffer* buffer, int32_t x, int32_t y);
45 private:
46 wl_input_device* input_device_;
47
48 // These keep track of the window that's currently under focus. NULL if no
49 // window is under focus.
50 WaylandWindow* pointer_focus_;
51 WaylandWindow* keyboard_focus_;
Evan Martin 2011/07/22 21:08:54 Does this mean that pointer and keyboard focus can
52
53 // Keeps track of the currently active keyboard modifiers. We keep this
54 // since we want to advertise keyboard modifiers with mouse events.
55 uint32_t keyboard_modifiers_;
56
57 // Keeps track of the last position for the motion event. We want to
58 // publish this with events such as button notify which doesn't have a
59 // position associated by default.
60 Point global_position_;
61 Point surface_position_;
62
63 // Keep track of the time of last event. Useful when we get buffer Attach
64 // calls and the calls wouldn't have a way of getting an event time.
65 uint32_t last_event_time_;
66
67 // keymap used to transform keyboard events.
68 xkb_desc* xkb_;
69
70 // List of callback functions for input device events.
71 static const wl_input_device_listener input_device_listener_;
72
73 // Input device callback functions. These will create 'WaylandEvent's and
74 // send them to the currently focused window.
75 // Args:
76 // - data: Pointer to the WaylandInputDevice object associated with the
77 // 'input_device'
78 // - input_device:
79 // The input device that sent the event
80 // - time: The time of the event.
81 static void OnMotionNotify(void* data, wl_input_device* input_device,
82 uint32_t time, int32_t x, int32_t y,
83 int32_t sx, int32_t sy);
84 static void OnButtonNotify(void* data, wl_input_device* input_device,
85 uint32_t time, uint32_t button, uint32_t state);
86 static void OnKeyNotify(void* data, wl_input_device* input_device,
87 uint32_t time, uint32_t key, uint32_t state);
88 // On*Focus events also have a Wayland surface associated with them. If the
89 // surface is NULL, then the event signifies a loss of focus. Otherwise we
90 // use the surface to get the WaylandWindow that receives focus.
91 static void OnPointerFocus(void* data, wl_input_device* input_device,
92 uint32_t time, wl_surface *surface,
93 int32_t x, int32_t y, int32_t sx, int32_t sy);
94 static void OnKeyboardFocus(void* data, wl_input_device* input_device,
95 uint32_t time, wl_surface *surface,
96 wl_array* keys);
97
98 DISALLOW_COPY_AND_ASSIGN(WaylandInputDevice);
99 };
100
101 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698