1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_POINTER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_POINTER_H_
#include "base/macros.h"
#include "ui/events/types/event_type.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
namespace gfx {
class PointF;
class Vector2d;
} // namespace gfx
namespace ui {
class WaylandConnection;
class WaylandWindow;
// Wraps the wl_pointer object and injects event data through
// |WaylandPointer::Delegate| interface.
class WaylandPointer {
public:
class Delegate;
WaylandPointer(wl_pointer* pointer,
WaylandConnection* connection,
Delegate* delegate);
virtual ~WaylandPointer();
wl_pointer* wl_object() const { return obj_.get(); }
private:
// wl_pointer_listener
static void Enter(void* data,
wl_pointer* obj,
uint32_t serial,
wl_surface* surface,
wl_fixed_t surface_x,
wl_fixed_t surface_y);
static void Leave(void* data,
wl_pointer* obj,
uint32_t serial,
wl_surface* surface);
static void Motion(void* data,
wl_pointer* obj,
uint32_t time,
wl_fixed_t surface_x,
wl_fixed_t surface_y);
static void Button(void* data,
wl_pointer* obj,
uint32_t serial,
uint32_t time,
uint32_t button,
uint32_t state);
static void Axis(void* data,
wl_pointer* obj,
uint32_t time,
uint32_t axis,
wl_fixed_t value);
wl::Object<wl_pointer> obj_;
WaylandConnection* const connection_;
Delegate* const delegate_;
DISALLOW_COPY_AND_ASSIGN(WaylandPointer);
};
class WaylandPointer::Delegate {
public:
virtual void OnPointerCreated(WaylandPointer* pointer) = 0;
virtual void OnPointerDestroyed(WaylandPointer* pointer) = 0;
virtual void OnPointerFocusChanged(WaylandWindow* window,
const gfx::PointF& location) = 0;
virtual void OnPointerButtonEvent(EventType evtype,
int changed_button,
WaylandWindow* window = nullptr) = 0;
virtual void OnPointerMotionEvent(const gfx::PointF& location) = 0;
virtual void OnPointerAxisEvent(const gfx::Vector2d& offset) = 0;
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_POINTER_H_
|