1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 #include <gdk/gdkwindow.h>
23 #include "gdkdevice-wayland.h"
24 #include "gdkprivate-wayland.h"
25 #include "gdkwayland.h"
27 static gboolean gdk_device_core_get_history (GdkDevice *device,
31 GdkTimeCoord ***events,
33 static void gdk_device_core_get_state (GdkDevice *device,
36 GdkModifierType *mask);
37 static void gdk_device_core_set_window_cursor (GdkDevice *device,
40 static void gdk_device_core_warp (GdkDevice *device,
44 static gboolean gdk_device_core_query_state (GdkDevice *device,
46 GdkWindow **root_window,
47 GdkWindow **child_window,
52 GdkModifierType *mask);
53 static GdkGrabStatus gdk_device_core_grab (GdkDevice *device,
55 gboolean owner_events,
56 GdkEventMask event_mask,
57 GdkWindow *confine_to,
60 static void gdk_device_core_ungrab (GdkDevice *device,
62 static GdkWindow * gdk_device_core_window_at_position (GdkDevice *device,
65 GdkModifierType *mask,
66 gboolean get_toplevel);
67 static void gdk_device_core_select_window_events (GdkDevice *device,
69 GdkEventMask event_mask);
72 G_DEFINE_TYPE (GdkDeviceCore, gdk_device_core, GDK_TYPE_DEVICE)
75 gdk_device_core_class_init (GdkDeviceCoreClass *klass)
77 GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
79 device_class->get_history = gdk_device_core_get_history;
80 device_class->get_state = gdk_device_core_get_state;
81 device_class->set_window_cursor = gdk_device_core_set_window_cursor;
82 device_class->warp = gdk_device_core_warp;
83 device_class->query_state = gdk_device_core_query_state;
84 device_class->grab = gdk_device_core_grab;
85 device_class->ungrab = gdk_device_core_ungrab;
86 device_class->window_at_position = gdk_device_core_window_at_position;
87 device_class->select_window_events = gdk_device_core_select_window_events;
91 gdk_device_core_init (GdkDeviceCore *device_core)
95 device = GDK_DEVICE (device_core);
97 _gdk_device_add_axis (device, GDK_NONE, GDK_AXIS_X, 0, 0, 1);
98 _gdk_device_add_axis (device, GDK_NONE, GDK_AXIS_Y, 0, 0, 1);
102 gdk_device_core_get_history (GdkDevice *device,
106 GdkTimeCoord ***events,
113 gdk_device_core_get_state (GdkDevice *device,
116 GdkModifierType *mask)
120 gdk_window_get_pointer (window, &x_int, &y_int, mask);
130 gdk_device_core_set_window_cursor (GdkDevice *device,
134 GdkWaylandDevice *wd = GDK_DEVICE_CORE(device)->device;
135 struct wl_buffer *buffer;
140 buffer = _gdk_wayland_cursor_get_buffer(cursor, &x, &y);
141 wl_input_device_attach(wd->device, wd->time, buffer, x, y);
145 wl_input_device_attach(wd->device, wd->time, NULL, 0, 0);
150 gdk_device_core_warp (GdkDevice *device,
158 gdk_device_core_query_state (GdkDevice *device,
160 GdkWindow **root_window,
161 GdkWindow **child_window,
166 GdkModifierType *mask)
168 GdkWaylandDevice *wd;
169 GdkScreen *default_screen;
171 wd = GDK_DEVICE_CORE(device)->device;
172 default_screen = gdk_display_get_default_screen (wd->display);
175 *root_window = gdk_screen_get_root_window (default_screen);
177 *child_window = wd->pointer_focus;
183 *win_x = wd->surface_x;
185 *win_y = wd->surface_y;
187 *mask = wd->modifiers;
193 gdk_device_core_grab (GdkDevice *device,
195 gboolean owner_events,
196 GdkEventMask event_mask,
197 GdkWindow *confine_to,
201 return GDK_GRAB_SUCCESS;
205 gdk_device_core_ungrab (GdkDevice *device,
211 gdk_device_core_window_at_position (GdkDevice *device,
214 GdkModifierType *mask,
215 gboolean get_toplevel)
217 GdkWaylandDevice *wd;
219 wd = GDK_DEVICE_CORE(device)->device;
221 return wd->pointer_focus;
225 gdk_device_core_select_window_events (GdkDevice *device,
227 GdkEventMask event_mask)