]> Pileus Git - ~andy/gtk/blob - gdk/gdkwindow.h
[ Patch from Sebastian Wilhelmi, 52790 ]
[~andy/gtk] / gdk / gdkwindow.h
1 #ifndef __GDK_WINDOW_H__
2 #define __GDK_WINDOW_H__
3
4 #include <gdk/gdkdrawable.h>
5 #include <gdk/gdktypes.h>
6 #include <gdk/gdkwindow.h>
7 #include <gdk/gdkevents.h>
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif /* __cplusplus */
12
13 typedef struct _GdkGeometry           GdkGeometry;
14 typedef struct _GdkWindowAttr         GdkWindowAttr;
15 typedef struct _GdkPointerHooks       GdkPointerHooks;
16
17 /* Classes of windows.
18  *   InputOutput: Almost every window should be of this type. Such windows
19  *                receive events and are also displayed on screen.
20  *   InputOnly: Used only in special circumstances when events need to be
21  *              stolen from another window or windows. Input only windows
22  *              have no visible output, so they are handy for placing over
23  *              top of a group of windows in order to grab the events (or
24  *              filter the events) from those windows.
25  */
26 typedef enum
27 {
28   GDK_INPUT_OUTPUT,
29   GDK_INPUT_ONLY
30 } GdkWindowClass;
31
32 /* Types of windows.
33  *   Root: There is only 1 root window and it is initialized
34  *         at startup. Creating a window of type GDK_WINDOW_ROOT
35  *         is an error.
36  *   Toplevel: Windows which interact with the window manager.
37  *   Child: Windows which are children of some other type of window.
38  *          (Any other type of window). Most windows are child windows.
39  *   Dialog: A special kind of toplevel window which interacts with
40  *           the window manager slightly differently than a regular
41  *           toplevel window. Dialog windows should be used for any
42  *           transient window.
43  *   Foreign: A window that actually belongs to another application
44  */
45 typedef enum
46 {
47   GDK_WINDOW_ROOT,
48   GDK_WINDOW_TOPLEVEL,
49   GDK_WINDOW_CHILD,
50   GDK_WINDOW_DIALOG,
51   GDK_WINDOW_TEMP,
52   GDK_WINDOW_FOREIGN
53 } GdkWindowType;
54
55 /* Window attribute mask values.
56  *   GDK_WA_TITLE: The "title" field is valid.
57  *   GDK_WA_X: The "x" field is valid.
58  *   GDK_WA_Y: The "y" field is valid.
59  *   GDK_WA_CURSOR: The "cursor" field is valid.
60  *   GDK_WA_COLORMAP: The "colormap" field is valid.
61  *   GDK_WA_VISUAL: The "visual" field is valid.
62  */
63 typedef enum
64 {
65   GDK_WA_TITLE    = 1 << 1,
66   GDK_WA_X        = 1 << 2,
67   GDK_WA_Y        = 1 << 3,
68   GDK_WA_CURSOR   = 1 << 4,
69   GDK_WA_COLORMAP = 1 << 5,
70   GDK_WA_VISUAL   = 1 << 6,
71   GDK_WA_WMCLASS  = 1 << 7,
72   GDK_WA_NOREDIR  = 1 << 8
73 } GdkWindowAttributesType;
74
75 /* Size restriction enumeration.
76  */
77 typedef enum
78 {
79   GDK_HINT_POS         = 1 << 0,
80   GDK_HINT_MIN_SIZE    = 1 << 1,
81   GDK_HINT_MAX_SIZE    = 1 << 2,
82   GDK_HINT_BASE_SIZE   = 1 << 3,
83   GDK_HINT_ASPECT      = 1 << 4,
84   GDK_HINT_RESIZE_INC  = 1 << 5,
85   GDK_HINT_WIN_GRAVITY = 1 << 6,
86   GDK_HINT_USER_POS    = 1 << 7,
87   GDK_HINT_USER_SIZE   = 1 << 8
88 } GdkWindowHints;
89
90
91 /* Window type hints.
92  * These are hints for the window manager that indicate
93  * what type of function the window has. The window manager
94  * can use this when determining decoration and behaviour
95  * of the window. The hint must be set before mapping the
96  * window.
97  *
98  *   Normal: Normal toplevel window
99  *   Dialog: Dialog window
100  *   Menu: Window used to implement a menu.
101  *   Toolbar: Window used to implement toolbars.
102  */
103 typedef enum
104 {
105   GDK_WINDOW_TYPE_HINT_NORMAL,
106   GDK_WINDOW_TYPE_HINT_DIALOG,
107   GDK_WINDOW_TYPE_HINT_MENU,
108   GDK_WINDOW_TYPE_HINT_TOOLBAR
109 } GdkWindowTypeHint;
110
111
112 /* The next two enumeration values current match the
113  * Motif constants. If this is changed, the implementation
114  * of gdk_window_set_decorations/gdk_window_set_functions
115  * will need to change as well.
116  */
117 typedef enum
118 {
119   GDK_DECOR_ALL         = 1 << 0,
120   GDK_DECOR_BORDER      = 1 << 1,
121   GDK_DECOR_RESIZEH     = 1 << 2,
122   GDK_DECOR_TITLE       = 1 << 3,
123   GDK_DECOR_MENU        = 1 << 4,
124   GDK_DECOR_MINIMIZE    = 1 << 5,
125   GDK_DECOR_MAXIMIZE    = 1 << 6
126 } GdkWMDecoration;
127
128 typedef enum
129 {
130   GDK_FUNC_ALL          = 1 << 0,
131   GDK_FUNC_RESIZE       = 1 << 1,
132   GDK_FUNC_MOVE         = 1 << 2,
133   GDK_FUNC_MINIMIZE     = 1 << 3,
134   GDK_FUNC_MAXIMIZE     = 1 << 4,
135   GDK_FUNC_CLOSE        = 1 << 5
136 } GdkWMFunction;
137
138 /* Currently, these are the same values numerically as in the
139  * X protocol. If you change that, gdkwindow-x11.c/gdk_window_set_geometry_hints()
140  * will need fixing.
141  */
142 typedef enum
143 {
144   GDK_GRAVITY_NORTH_WEST = 1,
145   GDK_GRAVITY_NORTH,
146   GDK_GRAVITY_NORTH_EAST,
147   GDK_GRAVITY_WEST,
148   GDK_GRAVITY_CENTER,
149   GDK_GRAVITY_EAST,
150   GDK_GRAVITY_SOUTH_WEST,
151   GDK_GRAVITY_SOUTH,
152   GDK_GRAVITY_SOUTH_EAST,
153   GDK_GRAVITY_STATIC
154 } GdkGravity;
155
156
157 typedef enum
158 {
159   GDK_WINDOW_EDGE_NORTH_WEST,
160   GDK_WINDOW_EDGE_NORTH,
161   GDK_WINDOW_EDGE_NORTH_EAST,
162   GDK_WINDOW_EDGE_WEST,
163   GDK_WINDOW_EDGE_EAST,
164   GDK_WINDOW_EDGE_SOUTH_WEST,
165   GDK_WINDOW_EDGE_SOUTH,
166   GDK_WINDOW_EDGE_SOUTH_EAST  
167 } GdkWindowEdge;
168
169 struct _GdkWindowAttr
170 {
171   gchar *title;
172   gint event_mask;
173   gint x, y;
174   gint width;
175   gint height;
176   GdkWindowClass wclass;
177   GdkVisual *visual;
178   GdkColormap *colormap;
179   GdkWindowType window_type;
180   GdkCursor *cursor;
181   gchar *wmclass_name;
182   gchar *wmclass_class;
183   gboolean override_redirect;
184 };
185
186 struct _GdkGeometry
187 {
188   gint min_width;
189   gint min_height;
190   gint max_width;
191   gint max_height;
192   gint base_width;
193   gint base_height;
194   gint width_inc;
195   gint height_inc;
196   gdouble min_aspect;
197   gdouble max_aspect;
198   GdkGravity win_gravity;
199 };
200
201 struct _GdkPointerHooks 
202 {
203   GdkWindow* (*get_pointer)       (GdkWindow       *window,
204                                    gint            *x,
205                                    gint            *y,
206                                    GdkModifierType *mask);
207   GdkWindow* (*window_at_pointer) (gint            *win_x,
208                                    gint            *win_y);
209 };
210
211 typedef struct _GdkWindowObject GdkWindowObject;
212 typedef struct _GdkWindowObjectClass GdkWindowObjectClass;
213
214 #define GDK_TYPE_WINDOW              (gdk_window_object_get_type ())
215 #define GDK_WINDOW(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW, GdkWindow))
216 #define GDK_WINDOW_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW, GdkWindowObjectClass))
217 #define GDK_IS_WINDOW(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW))
218 #define GDK_IS_WINDOW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW))
219 #define GDK_WINDOW_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW, GdkWindowObjectClass))
220 #define GDK_WINDOW_OBJECT(object)    ((GdkWindowObject *) GDK_WINDOW (object))
221
222 struct _GdkWindowObject
223 {
224   GdkDrawable parent_instance;
225
226   GdkDrawable *impl; /* window-system-specific delegate object */  
227   
228   GdkWindowObject *parent;
229
230   gpointer user_data;
231
232   gint x;
233   gint y;
234   
235   gint extension_events;
236
237   GList *filters;
238   GList *children;
239
240   GdkColor bg_color;
241   GdkPixmap *bg_pixmap;
242   
243   GSList *paint_stack;
244   
245   GdkRegion *update_area;
246   guint update_freeze_count;
247   
248   guint8 window_type;
249   guint8 depth;
250   guint8 resize_count;
251
252   GdkWindowState state;
253   
254   guint guffaw_gravity : 1;
255   guint input_only : 1;
256   guint modal_hint : 1;
257   
258   guint destroyed : 2;
259 };
260
261 struct _GdkWindowObjectClass
262 {
263   GdkDrawableClass parent_class;
264 };
265
266 /* Windows
267  */
268 GType         gdk_window_object_get_type       (void) G_GNUC_CONST;
269 GdkWindow*    gdk_window_new                   (GdkWindow     *parent,
270                                                 GdkWindowAttr *attributes,
271                                                 gint           attributes_mask);
272 void          gdk_window_destroy               (GdkWindow     *window);
273 GdkWindowType gdk_window_get_window_type       (GdkWindow     *window);
274 GdkWindow*    gdk_window_at_pointer            (gint          *win_x,
275                                                 gint          *win_y);
276 void          gdk_window_show                  (GdkWindow     *window);
277 void          gdk_window_hide                  (GdkWindow     *window);
278 void          gdk_window_withdraw              (GdkWindow     *window);
279 void          gdk_window_show_unraised         (GdkWindow     *window);
280 void          gdk_window_move                  (GdkWindow     *window,
281                                                 gint           x,
282                                                 gint           y);
283 void          gdk_window_resize                (GdkWindow     *window,
284                                                 gint           width,
285                                                 gint           height);
286 void          gdk_window_move_resize           (GdkWindow     *window,
287                                                 gint           x,
288                                                 gint           y,
289                                                 gint           width,
290                                                 gint           height);
291 void          gdk_window_reparent              (GdkWindow     *window,
292                                                 GdkWindow     *new_parent,
293                                                 gint           x,
294                                                 gint           y);
295 void          gdk_window_clear                 (GdkWindow     *window);
296 void          gdk_window_clear_area            (GdkWindow     *window,
297                                                 gint           x,
298                                                 gint           y,
299                                                 gint           width,
300                                                 gint           height);
301 void          gdk_window_clear_area_e          (GdkWindow     *window,
302                                                 gint           x,
303                                                 gint           y,
304                                                 gint           width,
305                                                 gint           height);
306 void          gdk_window_raise                 (GdkWindow     *window);
307 void          gdk_window_lower                 (GdkWindow     *window);
308 void          gdk_window_focus                 (GdkWindow     *window,
309                                                 guint32        timestamp);
310 void          gdk_window_set_user_data         (GdkWindow     *window,
311                                                 gpointer       user_data);
312 void          gdk_window_set_override_redirect (GdkWindow     *window,
313                                                 gboolean       override_redirect);
314 void          gdk_window_add_filter            (GdkWindow     *window,
315                                                 GdkFilterFunc  function,
316                                                 gpointer       data);
317 void          gdk_window_remove_filter         (GdkWindow     *window,
318                                                 GdkFilterFunc  function,
319                                                 gpointer       data);
320 void          gdk_window_scroll                (GdkWindow *window,
321                                                 gint       dx,
322                                                 gint       dy);
323
324 /* 
325  * This allows for making shaped (partially transparent) windows
326  * - cool feature, needed for Drag and Drag for example.
327  *  The shape_mask can be the mask
328  *  from gdk_pixmap_create_from_xpm.   Stefan Wille
329  */
330 void gdk_window_shape_combine_mask  (GdkWindow      *window,
331                                      GdkBitmap      *shape_mask,
332                                      gint            offset_x,
333                                      gint            offset_y);
334 void gdk_window_shape_combine_region (GdkWindow     *window,
335                                       GdkRegion     *shape_region,
336                                       gint           offset_x,
337                                       gint           offset_y);
338
339 /*
340  * This routine allows you to quickly take the shapes of all the child windows
341  * of a window and use their shapes as the shape mask for this window - useful
342  * for container windows that dont want to look like a big box
343  * 
344  * - Raster
345  */
346 void gdk_window_set_child_shapes (GdkWindow *window);
347
348 /*
349  * This routine allows you to merge (ie ADD) child shapes to your
350  * own window's shape keeping its current shape and ADDING the child
351  * shapes to it.
352  * 
353  * - Raster
354  */
355 void gdk_window_merge_child_shapes (GdkWindow *window);
356
357 /*
358  * Check if a window has been shown, and whether all its
359  * parents up to a toplevel have been shown, respectively.
360  * Note that a window that is_viewable below is not necessarily
361  * viewable in the X sense.
362  */
363 gboolean gdk_window_is_visible     (GdkWindow *window);
364 gboolean gdk_window_is_viewable    (GdkWindow *window);
365
366 GdkWindowState gdk_window_get_state (GdkWindow *window);
367
368 /* Set static bit gravity on the parent, and static
369  * window gravity on all children.
370  */
371 gboolean gdk_window_set_static_gravities (GdkWindow *window,
372                                           gboolean   use_static);   
373
374 /* GdkWindow */
375
376 void          gdk_window_set_hints       (GdkWindow       *window,
377                                           gint             x,
378                                           gint             y,
379                                           gint             min_width,
380                                           gint             min_height,
381                                           gint             max_width,
382                                           gint             max_height,
383                                           gint             flags);
384 void          gdk_window_set_type_hint   (GdkWindow       *window,
385                                           GdkWindowTypeHint hint);
386 void          gdk_window_set_modal_hint  (GdkWindow       *window,
387                                           gboolean         modal);
388 void          gdk_window_set_geometry_hints (GdkWindow        *window,
389                                              GdkGeometry      *geometry,
390                                              GdkWindowHints    flags);
391 void          gdk_set_sm_client_id         (const gchar *sm_client_id);
392
393 void          gdk_window_begin_paint_rect   (GdkWindow    *window,
394                                              GdkRectangle *rectangle);
395 void          gdk_window_begin_paint_region (GdkWindow    *window,
396                                              GdkRegion    *region);
397 void          gdk_window_end_paint          (GdkWindow    *window);
398
399 void          gdk_window_set_title         (GdkWindow     *window,
400                                             const gchar   *title);
401 void          gdk_window_set_role          (GdkWindow       *window,
402                                             const gchar     *role);
403 void          gdk_window_set_transient_for (GdkWindow       *window, 
404                                             GdkWindow       *leader);
405 void          gdk_window_set_background  (GdkWindow       *window,
406                                           GdkColor        *color);
407 void          gdk_window_set_back_pixmap (GdkWindow       *window,
408                                           GdkPixmap       *pixmap,
409                                           gboolean         parent_relative);
410 void          gdk_window_set_cursor      (GdkWindow       *window,
411                                           GdkCursor       *cursor);
412 void          gdk_window_get_user_data   (GdkWindow       *window,
413                                           gpointer        *data);
414 void          gdk_window_get_geometry    (GdkWindow       *window,
415                                           gint            *x,
416                                           gint            *y,
417                                           gint            *width,
418                                           gint            *height,
419                                           gint            *depth);
420 void          gdk_window_get_position    (GdkWindow       *window,
421                                           gint            *x,
422                                           gint            *y);
423 gint          gdk_window_get_origin      (GdkWindow       *window,
424                                           gint            *x,
425                                           gint            *y);
426 gboolean      gdk_window_get_deskrelative_origin (GdkWindow       *window,
427                                           gint            *x,
428                                           gint            *y);
429 void          gdk_window_get_root_origin (GdkWindow       *window,
430                                           gint            *x,
431                                           gint            *y);
432 void          gdk_window_get_frame_extents (GdkWindow     *window,
433                                             GdkRectangle  *rect);
434 GdkWindow*    gdk_window_get_pointer     (GdkWindow       *window,
435                                           gint            *x,
436                                           gint            *y,
437                                           GdkModifierType *mask);
438 GdkWindow *   gdk_window_get_parent      (GdkWindow       *window);
439 GdkWindow *   gdk_window_get_toplevel    (GdkWindow       *window);
440
441 GList *       gdk_window_get_children    (GdkWindow       *window);
442 GList *       gdk_window_peek_children   (GdkWindow       *window);
443 GdkEventMask  gdk_window_get_events      (GdkWindow       *window);
444 void          gdk_window_set_events      (GdkWindow       *window,
445                                           GdkEventMask     event_mask);
446
447 gboolean      gdk_window_set_icon_list   (GdkWindow       *window,
448                                           GList           *pixbufs);
449 void          gdk_window_set_icon        (GdkWindow       *window, 
450                                           GdkWindow       *icon_window,
451                                           GdkPixmap       *pixmap,
452                                           GdkBitmap       *mask);
453 void          gdk_window_set_icon_name   (GdkWindow       *window, 
454                                           const gchar     *name);
455 void          gdk_window_set_group       (GdkWindow       *window, 
456                                           GdkWindow       *leader);
457 void          gdk_window_set_decorations (GdkWindow       *window,
458                                           GdkWMDecoration  decorations);
459 gboolean      gdk_window_get_decorations (GdkWindow       *window,
460                                           GdkWMDecoration *decorations);
461 void          gdk_window_set_functions   (GdkWindow       *window,
462                                           GdkWMFunction    functions);
463 GList *       gdk_window_get_toplevels   (void);
464
465 void          gdk_window_iconify         (GdkWindow       *window);
466 void          gdk_window_deiconify       (GdkWindow       *window);
467 void          gdk_window_stick           (GdkWindow       *window);
468 void          gdk_window_unstick         (GdkWindow       *window);
469 void          gdk_window_maximize        (GdkWindow       *window);
470 void          gdk_window_unmaximize      (GdkWindow       *window);
471
472 void          gdk_window_register_dnd    (GdkWindow       *window);
473
474 void gdk_window_begin_resize_drag (GdkWindow     *window,
475                                    GdkWindowEdge  edge,
476                                    gint           button,
477                                    gint           root_x,
478                                    gint           root_y,
479                                    guint32        timestamp);
480 void gdk_window_begin_move_drag   (GdkWindow     *window,
481                                    gint           button,
482                                    gint           root_x,
483                                    gint           root_y,
484                                    guint32        timestamp);
485
486 /* Interface for dirty-region queueing */
487 void       gdk_window_invalidate_rect     (GdkWindow    *window,
488                                            GdkRectangle *rect,
489                                            gboolean      invalidate_children);
490 void       gdk_window_invalidate_region   (GdkWindow    *window,
491                                            GdkRegion    *region,
492                                            gboolean      invalidate_children);
493 GdkRegion *gdk_window_get_update_area     (GdkWindow    *window);
494
495 void       gdk_window_freeze_updates      (GdkWindow    *window);
496 void       gdk_window_thaw_updates        (GdkWindow    *window);
497
498 void       gdk_window_process_all_updates (void);
499 void       gdk_window_process_updates     (GdkWindow    *window,
500                                            gboolean      update_children);
501
502 /* Enable/disable flicker, so you can tell if your code is inefficient. */
503 void       gdk_window_set_debug_updates   (gboolean      setting);
504
505 void       gdk_window_constrain_size      (GdkGeometry  *geometry,
506                                            guint         flags,
507                                            gint          width,
508                                            gint          height,
509                                            gint         *new_width,
510                                            gint         *new_height);
511
512 void gdk_window_get_internal_paint_info (GdkWindow    *window,
513                                          GdkDrawable **real_drawable,
514                                          gint         *x_offset,
515                                          gint         *y_offset);
516
517 GdkPointerHooks *gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks);   
518
519
520 #ifndef GDK_DISABLE_DEPRECATED
521 #define gdk_window_get_size            gdk_drawable_get_size
522 #define gdk_window_get_type            gdk_window_get_window_type
523 #define gdk_window_get_colormap        gdk_drawable_get_colormap
524 #define gdk_window_set_colormap        gdk_drawable_set_colormap
525 #define gdk_window_get_visual          gdk_drawable_get_visual
526 #define gdk_window_ref                 gdk_drawable_ref
527 #define gdk_window_unref               gdk_drawable_unref
528
529 #define gdk_window_copy_area(drawable,gc,x,y,source_drawable,source_x,source_y,width,height) \
530    gdk_draw_pixmap(drawable,gc,source_drawable,source_x,source_y,x,y,width,height)
531 #endif /* GDK_DISABLE_DEPRECATED */
532
533 #ifdef __cplusplus
534 }
535 #endif /* __cplusplus */
536
537 #endif /* __GDK_WINDOW_H__ */