2 * Copyright (C) 2011-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
24 #include <wayland-client.h>
26 #include "windowing/DllWaylandClient.h"
27 #include "windowing/WaylandProtocol.h"
30 namespace xw = xbmc::wayland;
32 const struct wl_pointer_listener xw::Pointer::m_listener =
34 Pointer::HandleEnterCallback,
35 Pointer::HandleLeaveCallback,
36 Pointer::HandleMotionCallback,
37 Pointer::HandleButtonCallback,
38 Pointer::HandleAxisCallback
41 xw::Pointer::Pointer(IDllWaylandClient &clientLibrary,
42 struct wl_pointer *pointer,
43 IPointerReceiver &receiver) :
44 m_clientLibrary(clientLibrary),
48 protocol::AddListenerOnWaylandObject(m_clientLibrary,
54 xw::Pointer::~Pointer()
56 protocol::DestroyWaylandObject(m_clientLibrary,
60 void xw::Pointer::SetCursor(uint32_t serial,
61 struct wl_surface *surface,
65 protocol::CallMethodOnWaylandObject(m_clientLibrary,
67 WL_POINTER_SET_CURSOR,
74 void xw::Pointer::HandleEnterCallback(void *data,
75 struct wl_pointer *pointer,
77 struct wl_surface *surface,
81 static_cast<Pointer *>(data)->HandleEnter(serial,
87 void xw::Pointer::HandleLeaveCallback(void *data,
88 struct wl_pointer *pointer,
90 struct wl_surface *surface)
92 static_cast<Pointer *>(data)->HandleLeave(serial, surface);
95 void xw::Pointer::HandleMotionCallback(void *data,
96 struct wl_pointer *pointer,
101 static_cast<Pointer *>(data)->HandleMotion(time,
106 void xw::Pointer::HandleButtonCallback(void *data,
107 struct wl_pointer * pointer,
113 static_cast<Pointer *>(data)->HandleButton(serial,
119 void xw::Pointer::HandleAxisCallback(void *data,
120 struct wl_pointer *pointer,
125 static_cast<Pointer *>(data)->HandleAxis(time,
130 void xw::Pointer::HandleEnter(uint32_t serial,
131 struct wl_surface *surface,
132 wl_fixed_t surfaceXFixed,
133 wl_fixed_t surfaceYFixed)
135 m_receiver.Enter(surface,
136 wl_fixed_to_double(surfaceXFixed),
137 wl_fixed_to_double(surfaceYFixed));
140 void xw::Pointer::HandleLeave(uint32_t serial,
141 struct wl_surface *surface)
145 void xw::Pointer::HandleMotion(uint32_t time,
146 wl_fixed_t surfaceXFixed,
147 wl_fixed_t surfaceYFixed)
149 m_receiver.Motion(time,
150 wl_fixed_to_double(surfaceXFixed),
151 wl_fixed_to_double(surfaceYFixed));
154 void xw::Pointer::HandleButton(uint32_t serial,
159 m_receiver.Button(serial,
162 static_cast<enum wl_pointer_button_state>(state));
165 void xw::Pointer::HandleAxis(uint32_t time,
169 m_receiver.Axis(time,
171 wl_fixed_to_double(value));