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

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

Powered by Google App Engine
This is Rietveld 408576698