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 "gdksurface.h" |
23 | #include "gdkcursor.h" |
24 | #include "gdkmonitor.h" |
25 | #include "gdkdebug.h" |
26 | #include "gdksurfaceprivate.h" |
27 | #include "gdkkeysprivate.h" |
28 | #include "gdkdeviceprivate.h" |
29 | |
30 | #ifdef GDK_RENDERING_VULKAN |
31 | #include <vulkan/vulkan.h> |
32 | #endif |
33 | |
34 | G_BEGIN_DECLS |
35 | |
36 | #define GDK_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass)) |
37 | #define GDK_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY)) |
38 | #define GDK_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass)) |
39 | |
40 | |
41 | typedef struct _GdkDisplayClass GdkDisplayClass; |
42 | |
43 | /* Tracks information about the device grab on this display */ |
44 | typedef struct |
45 | { |
46 | GdkSurface *surface; |
47 | gulong serial_start; |
48 | gulong serial_end; /* exclusive, i.e. not active on serial_end */ |
49 | guint event_mask; |
50 | guint32 time; |
51 | |
52 | guint activated : 1; |
53 | guint implicit_ungrab : 1; |
54 | guint owner_events : 1; |
55 | guint implicit : 1; |
56 | } GdkDeviceGrabInfo; |
57 | |
58 | /* Tracks information about which surface and position the pointer last was in. |
59 | * This is useful when we need to synthesize events later. |
60 | * Note that we track toplevel_under_pointer using enter/leave events, |
61 | * so in the case of a grab, either with owner_events==FALSE or with the |
62 | * pointer in no clients surface the x/y coordinates may actually be outside |
63 | * the surface. |
64 | */ |
65 | typedef struct |
66 | { |
67 | GdkSurface *surface_under_pointer; /* surface that last got a normal enter event */ |
68 | double toplevel_x, toplevel_y; |
69 | guint32 state; |
70 | guint32 button; |
71 | GdkDevice *last_physical_device; |
72 | } GdkPointerSurfaceInfo; |
73 | |
74 | struct _GdkDisplay |
75 | { |
76 | GObject parent_instance; |
77 | |
78 | GQueue queued_events; |
79 | |
80 | guint event_pause_count; /* How many times events are blocked */ |
81 | |
82 | guint closed : 1; /* Whether this display has been closed */ |
83 | |
84 | GHashTable *device_grabs; |
85 | |
86 | GdkClipboard *clipboard; |
87 | GdkClipboard *primary_clipboard; |
88 | |
89 | GHashTable *pointers_info; /* GdkPointerSurfaceInfo for each device */ |
90 | guint32 last_event_time; /* Last reported event time from server */ |
91 | |
92 | guint double_click_time; /* Maximum time between clicks in msecs */ |
93 | guint double_click_distance; /* Maximum distance between clicks in pixels */ |
94 | |
95 | GList *seats; |
96 | |
97 | #ifdef GDK_RENDERING_VULKAN |
98 | VkInstance vk_instance; |
99 | VkDebugReportCallbackEXT vk_debug_callback; |
100 | VkPhysicalDevice vk_physical_device; |
101 | VkDevice vk_device; |
102 | VkQueue vk_queue; |
103 | uint32_t vk_queue_family_index; |
104 | |
105 | guint vulkan_refcount; |
106 | #endif /* GDK_RENDERING_VULKAN */ |
107 | |
108 | /* egl info */ |
109 | guint have_egl_buffer_age : 1; |
110 | guint have_egl_no_config_context : 1; |
111 | guint have_egl_pixel_format_float : 1; |
112 | guint have_egl_win32_libangle : 1; |
113 | }; |
114 | |
115 | struct _GdkDisplayClass |
116 | { |
117 | GObjectClass parent_class; |
118 | |
119 | GType cairo_context_type; /* type for GdkCairoContext, must be set */ |
120 | GType vk_context_type; /* type for GdkVulkanContext, must be set if vk_extension_name != NULL */ |
121 | const char *vk_extension_name; /* Name of required windowing vulkan extension or %NULL (default) if Vulkan isn't supported */ |
122 | |
123 | const char * (*get_name) (GdkDisplay *display); |
124 | void (*beep) (GdkDisplay *display); |
125 | void (*sync) (GdkDisplay *display); |
126 | void (*flush) (GdkDisplay *display); |
127 | gboolean (*has_pending) (GdkDisplay *display); |
128 | void (*queue_events) (GdkDisplay *display); |
129 | void (*make_default) (GdkDisplay *display); |
130 | |
131 | GdkAppLaunchContext * (*get_app_launch_context) (GdkDisplay *display); |
132 | |
133 | gulong (*get_next_serial) (GdkDisplay *display); |
134 | |
135 | void (*notify_startup_complete) (GdkDisplay *display, |
136 | const char *startup_id); |
137 | const char * (*get_startup_notification_id) (GdkDisplay *display); |
138 | |
139 | GdkSurface * (*create_surface) (GdkDisplay *display, |
140 | GdkSurfaceType surface_type, |
141 | GdkSurface *parent, |
142 | int x, |
143 | int y, |
144 | int width, |
145 | int height); |
146 | |
147 | GdkKeymap * (*get_keymap) (GdkDisplay *display); |
148 | |
149 | GdkGLContext * (* init_gl) (GdkDisplay *display, |
150 | GError **error); |
151 | /* Returns the distance from a perfect score EGL config. |
152 | * GDK chooses the one with the *LOWEST* score */ |
153 | guint (* rate_egl_config) (GdkDisplay *display, |
154 | gpointer egl_display, |
155 | gpointer egl_config); |
156 | |
157 | GdkSeat * (*get_default_seat) (GdkDisplay *display); |
158 | |
159 | GListModel * (*get_monitors) (GdkDisplay *self); |
160 | GdkMonitor * (*get_monitor_at_surface) (GdkDisplay *display, |
161 | GdkSurface *surface); |
162 | gboolean (*get_setting) (GdkDisplay *display, |
163 | const char *name, |
164 | GValue *value); |
165 | void (*set_cursor_theme) (GdkDisplay *display, |
166 | const char *name, |
167 | int size); |
168 | |
169 | /* Signals */ |
170 | void (*opened) (GdkDisplay *display); |
171 | void (*closed) (GdkDisplay *display, |
172 | gboolean is_error); |
173 | }; |
174 | |
175 | |
176 | typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display, |
177 | GdkDevice *device, |
178 | GdkPointerSurfaceInfo *device_info, |
179 | gpointer user_data); |
180 | |
181 | void _gdk_display_update_last_event (GdkDisplay *display, |
182 | GdkEvent *event); |
183 | void _gdk_display_device_grab_update (GdkDisplay *display, |
184 | GdkDevice *device, |
185 | gulong current_serial); |
186 | GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display, |
187 | GdkDevice *device); |
188 | GdkDeviceGrabInfo * _gdk_display_add_device_grab (GdkDisplay *display, |
189 | GdkDevice *device, |
190 | GdkSurface *surface, |
191 | gboolean owner_events, |
192 | GdkEventMask event_mask, |
193 | gulong serial_start, |
194 | guint32 time, |
195 | gboolean implicit); |
196 | GdkDeviceGrabInfo * _gdk_display_has_device_grab (GdkDisplay *display, |
197 | GdkDevice *device, |
198 | gulong serial); |
199 | gboolean _gdk_display_end_device_grab (GdkDisplay *display, |
200 | GdkDevice *device, |
201 | gulong serial, |
202 | GdkSurface *if_child, |
203 | gboolean implicit); |
204 | GdkPointerSurfaceInfo * _gdk_display_get_pointer_info (GdkDisplay *display, |
205 | GdkDevice *device); |
206 | void _gdk_display_pointer_info_foreach (GdkDisplay *display, |
207 | GdkDisplayPointerInfoForeach func, |
208 | gpointer user_data); |
209 | gulong _gdk_display_get_next_serial (GdkDisplay *display); |
210 | void _gdk_display_pause_events (GdkDisplay *display); |
211 | void _gdk_display_unpause_events (GdkDisplay *display); |
212 | GdkSurface * gdk_display_create_surface (GdkDisplay *display, |
213 | GdkSurfaceType surface_type, |
214 | GdkSurface *parent, |
215 | int x, |
216 | int y, |
217 | int width, |
218 | int height); |
219 | |
220 | GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display); |
221 | |
222 | gboolean gdk_display_init_egl (GdkDisplay *display, |
223 | int /*EGLenum*/ platform, |
224 | gpointer native_display, |
225 | gboolean allow_any, |
226 | GError **error); |
227 | gpointer gdk_display_get_egl_display (GdkDisplay *display); |
228 | gpointer gdk_display_get_egl_config (GdkDisplay *display); |
229 | gpointer gdk_display_get_egl_config_high_depth |
230 | (GdkDisplay *display); |
231 | |
232 | void gdk_display_set_rgba (GdkDisplay *display, |
233 | gboolean rgba); |
234 | void gdk_display_set_composited (GdkDisplay *display, |
235 | gboolean composited); |
236 | void gdk_display_set_input_shapes (GdkDisplay *display, |
237 | gboolean input_shapes); |
238 | |
239 | void gdk_display_add_seat (GdkDisplay *display, |
240 | GdkSeat *seat); |
241 | void gdk_display_remove_seat (GdkDisplay *display, |
242 | GdkSeat *seat); |
243 | void gdk_display_emit_opened (GdkDisplay *display); |
244 | |
245 | void gdk_display_setting_changed (GdkDisplay *display, |
246 | const char *name); |
247 | |
248 | GdkEvent * gdk_display_get_event (GdkDisplay *display); |
249 | |
250 | GdkKeymap * gdk_display_get_keymap (GdkDisplay *display); |
251 | |
252 | void _gdk_display_set_surface_under_pointer (GdkDisplay *display, |
253 | GdkDevice *device, |
254 | GdkSurface *surface); |
255 | |
256 | void _gdk_windowing_got_event (GdkDisplay *display, |
257 | GList *event_link, |
258 | GdkEvent *event, |
259 | gulong serial); |
260 | |
261 | G_END_DECLS |
262 | |
263 | #endif /* __GDK_DISPLAY_PRIVATE_H__ */ |
264 | |