1/* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2010 Red Hat, Inc.
3 *
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.
8 *
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.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GDK_DISPLAY_PRIVATE_H__
19#define __GDK_DISPLAY_PRIVATE_H__
20
21#include "gdkdisplay.h"
22#include "gdkwindow.h"
23#include "gdkcursor.h"
24#include "gdkmonitor.h"
25#include "gdkinternals.h"
26
27G_BEGIN_DECLS
28
29#define GDK_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass))
30#define GDK_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY))
31#define GDK_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass))
32
33
34typedef struct _GdkDisplayClass GdkDisplayClass;
35
36/* Tracks information about the device grab on this display */
37typedef struct
38{
39 GdkWindow *window;
40 GdkWindow *native_window;
41 gulong serial_start;
42 gulong serial_end; /* exclusive, i.e. not active on serial_end */
43 guint event_mask;
44 guint32 time;
45 GdkGrabOwnership ownership;
46
47 guint activated : 1;
48 guint implicit_ungrab : 1;
49 guint owner_events : 1;
50 guint implicit : 1;
51} GdkDeviceGrabInfo;
52
53/* Tracks information about a touch implicit grab on this display */
54typedef struct
55{
56 GdkDevice *device;
57 GdkEventSequence *sequence;
58
59 GdkWindow *window;
60 GdkWindow *native_window;
61 gulong serial;
62 guint event_mask;
63 guint32 time;
64} GdkTouchGrabInfo;
65
66/* Tracks information about which window and position the pointer last was in.
67 * This is useful when we need to synthesize events later.
68 * Note that we track toplevel_under_pointer using enter/leave events,
69 * so in the case of a grab, either with owner_events==FALSE or with the
70 * pointer in no clients window the x/y coordinates may actually be outside
71 * the window.
72 */
73typedef struct
74{
75 GdkWindow *toplevel_under_pointer; /* toplevel window containing the pointer, */
76 /* tracked via native events */
77 GdkWindow *window_under_pointer; /* window that last got a normal enter event */
78 gdouble toplevel_x, toplevel_y;
79 guint32 state;
80 guint32 button;
81 GdkDevice *last_slave;
82 guint need_touch_press_enter : 1;
83} GdkPointerWindowInfo;
84
85typedef struct
86{
87 guint32 button_click_time[2]; /* last 2 button click times */
88 GdkWindow *button_window[2]; /* last 2 windows to receive button presses */
89 gint button_number[2]; /* last 2 buttons to be pressed */
90 gint button_x[2]; /* last 2 button click positions */
91 gint button_y[2];
92 GdkDevice *last_slave;
93} GdkMultipleClickInfo;
94
95struct _GdkDisplay
96{
97 GObject parent_instance;
98
99 GList *queued_events;
100 GList *queued_tail;
101
102 /* Information for determining if the latest button click
103 * is part of a double-click or triple-click
104 */
105 GHashTable *multiple_click_info;
106
107 guint event_pause_count; /* How many times events are blocked */
108
109 guint closed : 1; /* Whether this display has been closed */
110
111 GArray *touch_implicit_grabs;
112 GHashTable *device_grabs;
113 GHashTable *motion_hint_info;
114 GdkDeviceManager *device_manager;
115 GList *input_devices; /* Deprecated, only used to keep gdk_display_list_devices working */
116
117 GHashTable *pointers_info; /* GdkPointerWindowInfo for each device */
118 guint32 last_event_time; /* Last reported event time from server */
119
120 guint double_click_time; /* Maximum time between clicks in msecs */
121 guint double_click_distance; /* Maximum distance between clicks in pixels */
122
123 guint has_gl_extension_texture_non_power_of_two : 1;
124 guint has_gl_extension_texture_rectangle : 1;
125
126 guint debug_updates : 1;
127 guint debug_updates_set : 1;
128
129 GdkRenderingMode rendering_mode;
130
131 GList *seats;
132};
133
134struct _GdkDisplayClass
135{
136 GObjectClass parent_class;
137
138 GType window_type; /* type for native windows for this display, set in class_init */
139
140 const gchar * (*get_name) (GdkDisplay *display);
141 GdkScreen * (*get_default_screen) (GdkDisplay *display);
142 void (*beep) (GdkDisplay *display);
143 void (*sync) (GdkDisplay *display);
144 void (*flush) (GdkDisplay *display);
145 gboolean (*has_pending) (GdkDisplay *display);
146 void (*queue_events) (GdkDisplay *display);
147 void (*make_default) (GdkDisplay *display);
148 GdkWindow * (*get_default_group) (GdkDisplay *display);
149 gboolean (*supports_selection_notification) (GdkDisplay *display);
150 gboolean (*request_selection_notification) (GdkDisplay *display,
151 GdkAtom selection);
152 gboolean (*supports_shapes) (GdkDisplay *display);
153 gboolean (*supports_input_shapes) (GdkDisplay *display);
154 gboolean (*supports_composite) (GdkDisplay *display);
155 gboolean (*supports_cursor_alpha) (GdkDisplay *display);
156 gboolean (*supports_cursor_color) (GdkDisplay *display);
157
158 gboolean (*supports_clipboard_persistence) (GdkDisplay *display);
159 void (*store_clipboard) (GdkDisplay *display,
160 GdkWindow *clipboard_window,
161 guint32 time_,
162 const GdkAtom *targets,
163 gint n_targets);
164
165 void (*get_default_cursor_size) (GdkDisplay *display,
166 guint *width,
167 guint *height);
168 void (*get_maximal_cursor_size) (GdkDisplay *display,
169 guint *width,
170 guint *height);
171 GdkCursor * (*get_cursor_for_type) (GdkDisplay *display,
172 GdkCursorType type);
173 GdkCursor * (*get_cursor_for_name) (GdkDisplay *display,
174 const gchar *name);
175 GdkCursor * (*get_cursor_for_surface) (GdkDisplay *display,
176 cairo_surface_t *surface,
177 gdouble x,
178 gdouble y);
179
180 GdkAppLaunchContext * (*get_app_launch_context) (GdkDisplay *display);
181
182 void (*before_process_all_updates) (GdkDisplay *display);
183 void (*after_process_all_updates) (GdkDisplay *display);
184
185 gulong (*get_next_serial) (GdkDisplay *display);
186
187 void (*notify_startup_complete) (GdkDisplay *display,
188 const gchar *startup_id);
189 void (*event_data_copy) (GdkDisplay *display,
190 const GdkEvent *event,
191 GdkEvent *new_event);
192 void (*event_data_free) (GdkDisplay *display,
193 GdkEvent *event);
194 void (*create_window_impl) (GdkDisplay *display,
195 GdkWindow *window,
196 GdkWindow *real_parent,
197 GdkScreen *screen,
198 GdkEventMask event_mask,
199 GdkWindowAttr *attributes,
200 gint attributes_mask);
201
202 GdkKeymap * (*get_keymap) (GdkDisplay *display);
203 void (*push_error_trap) (GdkDisplay *display);
204 gint (*pop_error_trap) (GdkDisplay *display,
205 gboolean ignore);
206
207 GdkWindow * (*get_selection_owner) (GdkDisplay *display,
208 GdkAtom selection);
209 gboolean (*set_selection_owner) (GdkDisplay *display,
210 GdkWindow *owner,
211 GdkAtom selection,
212 guint32 time,
213 gboolean send_event);
214 void (*send_selection_notify) (GdkDisplay *dispay,
215 GdkWindow *requestor,
216 GdkAtom selection,
217 GdkAtom target,
218 GdkAtom property,
219 guint32 time);
220 gint (*get_selection_property) (GdkDisplay *display,
221 GdkWindow *requestor,
222 guchar **data,
223 GdkAtom *type,
224 gint *format);
225 void (*convert_selection) (GdkDisplay *display,
226 GdkWindow *requestor,
227 GdkAtom selection,
228 GdkAtom target,
229 guint32 time);
230
231 gint (*text_property_to_utf8_list) (GdkDisplay *display,
232 GdkAtom encoding,
233 gint format,
234 const guchar *text,
235 gint length,
236 gchar ***list);
237 gchar * (*utf8_to_string_target) (GdkDisplay *display,
238 const gchar *text);
239
240 gboolean (*make_gl_context_current) (GdkDisplay *display,
241 GdkGLContext *context);
242
243 GdkSeat * (*get_default_seat) (GdkDisplay *display);
244
245 int (*get_n_monitors) (GdkDisplay *display);
246 GdkMonitor * (*get_monitor) (GdkDisplay *display,
247 int index);
248 GdkMonitor * (*get_primary_monitor) (GdkDisplay *display);
249 GdkMonitor * (*get_monitor_at_window) (GdkDisplay *display,
250 GdkWindow *window);
251
252 /* Signals */
253 void (*opened) (GdkDisplay *display);
254 void (*closed) (GdkDisplay *display,
255 gboolean is_error);
256};
257
258
259typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display,
260 GdkDevice *device,
261 GdkPointerWindowInfo *device_info,
262 gpointer user_data);
263
264void _gdk_display_update_last_event (GdkDisplay *display,
265 const GdkEvent *event);
266void _gdk_display_device_grab_update (GdkDisplay *display,
267 GdkDevice *device,
268 GdkDevice *source_device,
269 gulong current_serial);
270GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display,
271 GdkDevice *device);
272GdkDeviceGrabInfo * _gdk_display_add_device_grab (GdkDisplay *display,
273 GdkDevice *device,
274 GdkWindow *window,
275 GdkWindow *native_window,
276 GdkGrabOwnership grab_ownership,
277 gboolean owner_events,
278 GdkEventMask event_mask,
279 gulong serial_start,
280 guint32 time,
281 gboolean implicit);
282GdkDeviceGrabInfo * _gdk_display_has_device_grab (GdkDisplay *display,
283 GdkDevice *device,
284 gulong serial);
285gboolean _gdk_display_end_device_grab (GdkDisplay *display,
286 GdkDevice *device,
287 gulong serial,
288 GdkWindow *if_child,
289 gboolean implicit);
290gboolean _gdk_display_check_grab_ownership (GdkDisplay *display,
291 GdkDevice *device,
292 gulong serial);
293void _gdk_display_add_touch_grab (GdkDisplay *display,
294 GdkDevice *device,
295 GdkEventSequence *sequence,
296 GdkWindow *window,
297 GdkWindow *native_window,
298 GdkEventMask event_mask,
299 unsigned long serial_start,
300 guint32 time);
301GdkTouchGrabInfo * _gdk_display_has_touch_grab (GdkDisplay *display,
302 GdkDevice *device,
303 GdkEventSequence *sequence,
304 gulong serial);
305gboolean _gdk_display_end_touch_grab (GdkDisplay *display,
306 GdkDevice *device,
307 GdkEventSequence *sequence);
308void _gdk_display_enable_motion_hints (GdkDisplay *display,
309 GdkDevice *device);
310GdkPointerWindowInfo * _gdk_display_get_pointer_info (GdkDisplay *display,
311 GdkDevice *device);
312void _gdk_display_pointer_info_foreach (GdkDisplay *display,
313 GdkDisplayPointerInfoForeach func,
314 gpointer user_data);
315gulong _gdk_display_get_next_serial (GdkDisplay *display);
316void _gdk_display_pause_events (GdkDisplay *display);
317void _gdk_display_unpause_events (GdkDisplay *display);
318void _gdk_display_event_data_copy (GdkDisplay *display,
319 const GdkEvent *event,
320 GdkEvent *new_event);
321void _gdk_display_event_data_free (GdkDisplay *display,
322 GdkEvent *event);
323void _gdk_display_create_window_impl (GdkDisplay *display,
324 GdkWindow *window,
325 GdkWindow *real_parent,
326 GdkScreen *screen,
327 GdkEventMask event_mask,
328 GdkWindowAttr *attributes,
329 gint attributes_mask);
330GdkWindow * _gdk_display_create_window (GdkDisplay *display);
331
332gboolean gdk_display_make_gl_context_current (GdkDisplay *display,
333 GdkGLContext *context);
334
335void gdk_display_add_seat (GdkDisplay *display,
336 GdkSeat *seat);
337void gdk_display_remove_seat (GdkDisplay *display,
338 GdkSeat *seat);
339void gdk_display_monitor_added (GdkDisplay *display,
340 GdkMonitor *monitor);
341void gdk_display_monitor_removed (GdkDisplay *display,
342 GdkMonitor *monitor);
343
344G_END_DECLS
345
346#endif /* __GDK_DISPLAY_PRIVATE_H__ */
347