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

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 argument layout 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/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 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
47 private:
48 // Input device callback functions. These will create 'WaylandEvent's and
49 // send them to the currently focused window.
50 // Args:
51 // - data: Pointer to the WaylandInputDevice object associated with the
52 // 'input_device'
53 // - input_device:
54 // The input device that sent the event
55 // - time: The time of the event.
56 static void OnMotionNotify(void* data, wl_input_device* input_device,
57 uint32_t time, int32_t x, int32_t y,
58 int32_t sx, int32_t sy);
59 static void OnButtonNotify(void* data, wl_input_device* input_device,
60 uint32_t time, uint32_t button, uint32_t state);
61 static void OnKeyNotify(void* data, wl_input_device* input_device,
62 uint32_t time, uint32_t key, uint32_t state);
63 // On*Focus events also have a Wayland surface associated with them. If the
64 // surface is NULL, then the event signifies a loss of focus. Otherwise we
65 // use the surface to get the WaylandWindow that receives focus.
66 static void OnPointerFocus(void* data, wl_input_device* input_device,
67 uint32_t time, wl_surface *surface,
68 int32_t x, int32_t y, int32_t sx, int32_t sy);
69 static void OnKeyboardFocus(void* data, wl_input_device* input_device,
70 uint32_t time, wl_surface *surface,
71 wl_array* keys);
72
73 wl_input_device* input_device_;
74
75 // These keep track of the window that's currently under focus. NULL if no
76 // window is under focus.
77 WaylandWindow* pointer_focus_;
78 WaylandWindow* keyboard_focus_;
79
80 // Keeps track of the currently active keyboard modifiers. We keep this
81 // since we want to advertise keyboard modifiers with mouse events.
82 uint32_t keyboard_modifiers_;
83
84 // Keeps track of the last position for the motion event. We want to
85 // publish this with events such as button notify which doesn't have a
86 // position associated by default.
87 gfx::Point global_position_;
88 gfx::Point surface_position_;
89
90 // Keep track of the time of last event. Useful when we get buffer Attach
91 // calls and the calls wouldn't have a way of getting an event time.
92 uint32_t last_event_time_;
93
94 // keymap used to transform keyboard events.
95 xkb_desc* xkb_;
96
97 DISALLOW_COPY_AND_ASSIGN(WaylandInputDevice);
98 };
99
100 } // namespace ui
101
102 #endif // UI_WAYLAND_WAYLAND_INPUT_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698