1 | /* GDK - The GIMP Drawing Kit |
2 | * Copyright (C) 2019 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 | /* Uninstalled header defining types and functions internal to GDK */ |
19 | |
20 | #ifndef __GDK_SURFACE_PRIVATE_H__ |
21 | #define __GDK_SURFACE_PRIVATE_H__ |
22 | |
23 | #include <gdk-pixbuf/gdk-pixbuf.h> |
24 | #include "gdkenumtypes.h" |
25 | #include "gdksurface.h" |
26 | #include "gdktoplevel.h" |
27 | |
28 | G_BEGIN_DECLS |
29 | |
30 | typedef enum |
31 | { |
32 | GDK_SURFACE_TOPLEVEL, |
33 | GDK_SURFACE_TEMP, |
34 | |
35 | } GdkSurfaceType; |
36 | |
37 | struct _GdkSurface |
38 | { |
39 | GObject parent_instance; |
40 | |
41 | GdkDisplay *display; |
42 | |
43 | GdkSurface *transient_for; /* for toplevels */ |
44 | GdkSurface *parent; /* for popups */ |
45 | GList *children; /* popups */ |
46 | |
47 | guint set_is_mapped_source_id; |
48 | gboolean pending_is_mapped; |
49 | gboolean is_mapped; |
50 | |
51 | int x; |
52 | int y; |
53 | |
54 | GdkGLContext *gl_paint_context; |
55 | |
56 | cairo_region_t *update_area; |
57 | guint update_freeze_count; |
58 | GdkFrameClockPhase pending_phases; |
59 | /* This is the update_area that was in effect when the current expose |
60 | started. It may be smaller than the expose area if we'e painting |
61 | more than we have to, but it represents the "true" damage. */ |
62 | cairo_region_t *active_update_area; |
63 | |
64 | GdkToplevelState pending_set_flags; |
65 | GdkToplevelState pending_unset_flags; |
66 | GdkToplevelState state; |
67 | |
68 | guint8 resize_count; |
69 | |
70 | guint8 alpha; |
71 | guint8 fullscreen_mode; |
72 | |
73 | guint modal_hint : 1; |
74 | guint destroyed : 2; |
75 | guint in_update : 1; |
76 | guint frame_clock_events_paused : 1; |
77 | guint autohide : 1; |
78 | guint shortcuts_inhibited : 1; |
79 | guint request_motion : 1; |
80 | |
81 | guint request_motion_id; |
82 | |
83 | struct { |
84 | GdkGravity surface_anchor; |
85 | GdkGravity rect_anchor; |
86 | } ; |
87 | |
88 | guint update_and_descendants_freeze_count; |
89 | |
90 | int width, height; |
91 | |
92 | GdkCursor *cursor; |
93 | GHashTable *device_cursor; |
94 | |
95 | cairo_region_t *input_region; |
96 | |
97 | GList *devices_inside; |
98 | |
99 | GdkFrameClock *frame_clock; /* NULL to use from parent or default */ |
100 | |
101 | GSList *draw_contexts; |
102 | GdkDrawContext *paint_context; |
103 | |
104 | cairo_region_t *opaque_region; |
105 | |
106 | GdkSeat *current_shortcuts_inhibited_seat; |
107 | }; |
108 | |
109 | struct _GdkSurfaceClass |
110 | { |
111 | GObjectClass parent_class; |
112 | |
113 | cairo_surface_t * |
114 | (* ref_cairo_surface) (GdkSurface *surface); |
115 | void (* hide) (GdkSurface *surface); |
116 | void (* get_geometry) (GdkSurface *surface, |
117 | int *x, |
118 | int *y, |
119 | int *width, |
120 | int *height); |
121 | void (* get_root_coords) (GdkSurface *surface, |
122 | int x, |
123 | int y, |
124 | int *root_x, |
125 | int *root_y); |
126 | gboolean (* get_device_state) (GdkSurface *surface, |
127 | GdkDevice *device, |
128 | double *x, |
129 | double *y, |
130 | GdkModifierType *mask); |
131 | void (* set_input_region) (GdkSurface *surface, |
132 | cairo_region_t *shape_region); |
133 | |
134 | /* Called to do the windowing system specific part of gdk_surface_destroy(), |
135 | * |
136 | * surface: The window being destroyed |
137 | * foreign_destroy: If TRUE, the surface or a parent was destroyed by some |
138 | * external agency. The surface has already been destroyed and no |
139 | * windowing system calls should be made. (This may never happen |
140 | * for some windowing systems.) |
141 | */ |
142 | void (* destroy) (GdkSurface *surface, |
143 | gboolean foreign_destroy); |
144 | |
145 | |
146 | /* optional */ |
147 | gboolean (* beep) (GdkSurface *surface); |
148 | |
149 | void (* destroy_notify) (GdkSurface *surface); |
150 | GdkDrag * (* drag_begin) (GdkSurface *surface, |
151 | GdkDevice *device, |
152 | GdkContentProvider *content, |
153 | GdkDragAction actions, |
154 | double dx, |
155 | double dy); |
156 | |
157 | int (* get_scale_factor) (GdkSurface *surface); |
158 | |
159 | void (* set_opaque_region) (GdkSurface *surface, |
160 | cairo_region_t *region); |
161 | void (* request_layout) (GdkSurface *surface); |
162 | gboolean (* compute_size) (GdkSurface *surface); |
163 | }; |
164 | |
165 | #define GDK_SURFACE_DESTROYED(d) (((GdkSurface *)(d))->destroyed) |
166 | |
167 | #define GDK_SURFACE_IS_MAPPED(surface) ((surface)->pending_is_mapped) |
168 | |
169 | void gdk_surface_set_state (GdkSurface *surface, |
170 | GdkToplevelState new_state); |
171 | |
172 | void gdk_surface_set_is_mapped (GdkSurface *surface, |
173 | gboolean is_mapped); |
174 | |
175 | GdkMonitor * gdk_surface_get_layout_monitor (GdkSurface *surface, |
176 | GdkPopupLayout *layout, |
177 | void (*get_bounds) (GdkMonitor *monitor, |
178 | GdkRectangle *bounds)); |
179 | |
180 | void (GdkSurface *surface, |
181 | int width, |
182 | int height, |
183 | int shadow_left, |
184 | int shadow_right, |
185 | int shadow_top, |
186 | int shadow_bottom, |
187 | GdkMonitor *monitor, |
188 | GdkRectangle *bounds, |
189 | GdkPopupLayout *layout, |
190 | GdkRectangle *out_final_rect); |
191 | |
192 | static inline GdkGravity |
193 | gdk_gravity_flip_horizontally (GdkGravity anchor) |
194 | { |
195 | switch (anchor) |
196 | { |
197 | default: |
198 | case GDK_GRAVITY_STATIC: |
199 | case GDK_GRAVITY_NORTH_WEST: |
200 | return GDK_GRAVITY_NORTH_EAST; |
201 | case GDK_GRAVITY_NORTH: |
202 | return GDK_GRAVITY_NORTH; |
203 | case GDK_GRAVITY_NORTH_EAST: |
204 | return GDK_GRAVITY_NORTH_WEST; |
205 | case GDK_GRAVITY_WEST: |
206 | return GDK_GRAVITY_EAST; |
207 | case GDK_GRAVITY_CENTER: |
208 | return GDK_GRAVITY_CENTER; |
209 | case GDK_GRAVITY_EAST: |
210 | return GDK_GRAVITY_WEST; |
211 | case GDK_GRAVITY_SOUTH_WEST: |
212 | return GDK_GRAVITY_SOUTH_EAST; |
213 | case GDK_GRAVITY_SOUTH: |
214 | return GDK_GRAVITY_SOUTH; |
215 | case GDK_GRAVITY_SOUTH_EAST: |
216 | return GDK_GRAVITY_SOUTH_WEST; |
217 | } |
218 | |
219 | g_assert_not_reached (); |
220 | } |
221 | |
222 | static inline GdkGravity |
223 | gdk_gravity_flip_vertically (GdkGravity anchor) |
224 | { |
225 | switch (anchor) |
226 | { |
227 | default: |
228 | case GDK_GRAVITY_STATIC: |
229 | case GDK_GRAVITY_NORTH_WEST: |
230 | return GDK_GRAVITY_SOUTH_WEST; |
231 | case GDK_GRAVITY_NORTH: |
232 | return GDK_GRAVITY_SOUTH; |
233 | case GDK_GRAVITY_NORTH_EAST: |
234 | return GDK_GRAVITY_SOUTH_EAST; |
235 | case GDK_GRAVITY_WEST: |
236 | return GDK_GRAVITY_WEST; |
237 | case GDK_GRAVITY_CENTER: |
238 | return GDK_GRAVITY_CENTER; |
239 | case GDK_GRAVITY_EAST: |
240 | return GDK_GRAVITY_EAST; |
241 | case GDK_GRAVITY_SOUTH_WEST: |
242 | return GDK_GRAVITY_NORTH_WEST; |
243 | case GDK_GRAVITY_SOUTH: |
244 | return GDK_GRAVITY_NORTH; |
245 | case GDK_GRAVITY_SOUTH_EAST: |
246 | return GDK_GRAVITY_NORTH_EAST; |
247 | } |
248 | |
249 | g_assert_not_reached (); |
250 | } |
251 | |
252 | void _gdk_surface_destroy (GdkSurface *surface, |
253 | gboolean foreign_destroy); |
254 | void gdk_surface_invalidate_rect (GdkSurface *surface, |
255 | const GdkRectangle *rect); |
256 | void gdk_surface_invalidate_region (GdkSurface *surface, |
257 | const cairo_region_t *region); |
258 | void _gdk_surface_clear_update_area (GdkSurface *surface); |
259 | void _gdk_surface_update_size (GdkSurface *surface); |
260 | |
261 | GdkGLContext * gdk_surface_get_paint_gl_context (GdkSurface *surface, |
262 | GError **error); |
263 | |
264 | gboolean gdk_surface_handle_event (GdkEvent *event); |
265 | GdkSeat * gdk_surface_get_seat_from_event (GdkSurface *surface, |
266 | GdkEvent *event); |
267 | |
268 | void gdk_surface_enter_monitor (GdkSurface *surface, |
269 | GdkMonitor *monitor); |
270 | void gdk_surface_leave_monitor (GdkSurface *surface, |
271 | GdkMonitor *monitor); |
272 | |
273 | void gdk_surface_destroy_notify (GdkSurface *surface); |
274 | |
275 | void gdk_synthesize_surface_state (GdkSurface *surface, |
276 | GdkToplevelState unset_flags, |
277 | GdkToplevelState set_flags); |
278 | |
279 | void gdk_surface_get_root_coords (GdkSurface *surface, |
280 | int x, |
281 | int y, |
282 | int *root_x, |
283 | int *root_y); |
284 | void gdk_surface_get_origin (GdkSurface *surface, |
285 | int *x, |
286 | int *y); |
287 | |
288 | |
289 | void gdk_surface_get_geometry (GdkSurface *surface, |
290 | int *x, |
291 | int *y, |
292 | int *width, |
293 | int *height); |
294 | |
295 | void gdk_surface_set_egl_native_window (GdkSurface *self, |
296 | gpointer native_window); |
297 | void gdk_surface_ensure_egl_surface (GdkSurface *self, |
298 | gboolean hdr); |
299 | gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self); |
300 | |
301 | void gdk_surface_set_widget (GdkSurface *self, |
302 | gpointer widget); |
303 | gpointer gdk_surface_get_widget (GdkSurface *self); |
304 | |
305 | void gdk_surface_freeze_updates (GdkSurface *surface); |
306 | void gdk_surface_thaw_updates (GdkSurface *surface); |
307 | |
308 | |
309 | typedef enum |
310 | { |
311 | GDK_HINT_MIN_SIZE = 1 << 1, |
312 | GDK_HINT_MAX_SIZE = 1 << 2, |
313 | } GdkSurfaceHints; |
314 | |
315 | typedef struct _GdkGeometry GdkGeometry; |
316 | |
317 | struct _GdkGeometry |
318 | { |
319 | int min_width; |
320 | int min_height; |
321 | int max_width; |
322 | int max_height; |
323 | }; |
324 | |
325 | void gdk_surface_constrain_size (GdkGeometry *geometry, |
326 | GdkSurfaceHints flags, |
327 | int width, |
328 | int height, |
329 | int *new_width, |
330 | int *new_height); |
331 | |
332 | void gdk_surface_queue_state_change (GdkSurface *surface, |
333 | GdkToplevelState unset_flags, |
334 | GdkToplevelState set_flags); |
335 | |
336 | void gdk_surface_apply_state_change (GdkSurface *surface); |
337 | |
338 | void gdk_surface_emit_size_changed (GdkSurface *surface, |
339 | int width, |
340 | int height); |
341 | |
342 | void gdk_surface_request_compute_size (GdkSurface *surface); |
343 | |
344 | GDK_AVAILABLE_IN_ALL |
345 | void gdk_surface_request_motion (GdkSurface *surface); |
346 | |
347 | |
348 | G_END_DECLS |
349 | |
350 | #endif /* __GDK_SURFACE_PRIVATE_H__ */ |
351 | |