OLD | NEW |
(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 "wayland_geometry_utils.h" |
| 9 #include "wayland_widget.h" |
| 10 |
| 11 #include <wayland-client.h> |
| 12 |
| 13 struct xkb_desc; |
| 14 struct wl_buffer; |
| 15 |
| 16 class WaylandWindow; |
| 17 |
| 18 /* |
| 19 This class represents an input device that was registered with Wayland. |
| 20 The purpose of this class is to parse and wrap events into generic |
| 21 WaylandEvent types and dispatch the event to the appropriate WaylandWindow. |
| 22 |
| 23 How Wayland events work: |
| 24 ------------------------ |
| 25 |
| 26 When the On*Focus events are triggered, the input device receives a reference |
| 27 to the surface that just received/lost focus. Each surface is associated with |
| 28 a unique WaylandWindow. When processing the focus events we keep track of the |
| 29 currently focused window such that when we receive different events (mouse |
| 30 button press or key press) we only send the event to the window in focus. |
| 31 */ |
| 32 class WaylandInputDevice { |
| 33 |
| 34 public: |
| 35 WaylandInputDevice(struct wl_display* display, uint32_t id); |
| 36 ~WaylandInputDevice(); |
| 37 |
| 38 // Used to change the surface of the input device (normally pointer image). |
| 39 void Attach(struct wl_buffer* buffer, int32_t x, int32_t y); |
| 40 private: |
| 41 struct wl_input_device* input_device_; |
| 42 |
| 43 WaylandWindow* pointer_focus_; |
| 44 WaylandWindow* keyboard_focus_; |
| 45 |
| 46 uint32_t keyboard_modifiers_; |
| 47 |
| 48 Point global_position_; |
| 49 Point surface_position_; |
| 50 |
| 51 uint32_t last_event_time_; |
| 52 |
| 53 struct xkb_desc* xkb_; |
| 54 |
| 55 static const struct wl_input_device_listener input_device_listener_; |
| 56 |
| 57 static void OnMotionNotify(void* data, struct wl_input_device* input_device, |
| 58 uint32_t time, int32_t x, int32_t y, int32_t sx, int32_t sy); |
| 59 static void OnButtonNotify(void* data, struct wl_input_device* input_device, |
| 60 uint32_t time, uint32_t button, uint32_t state); |
| 61 static void OnKeyNotify(void* data, struct wl_input_device* input_device, |
| 62 uint32_t time, uint32_t key, uint32_t state); |
| 63 static void OnPointerFocus(void* data, struct wl_input_device* input_device, |
| 64 uint32_t time, struct wl_surface *surface, int32_t x, int32_t y, |
| 65 int32_t sx, int32_t sy); |
| 66 static void OnKeyboardFocus(void* data, |
| 67 struct wl_input_device* input_device, |
| 68 uint32_t time, struct wl_surface *surface, struct wl_array* keys); |
| 69 }; |
| 70 |
| 71 #endif |
OLD | NEW |