]> Pileus Git - ~andy/gtk/blob - gdk/directfb/gdkprivate-directfb.h
gdk/directfb: convert gdkgc-directfb to using G_DEFINE_TYPE
[~andy/gtk] / gdk / directfb / gdkprivate-directfb.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.
23  */
24
25 /*
26  * GTK+ DirectFB backend
27  * Copyright (C) 2001-2002  convergence integrated media GmbH
28  * Copyright (C) 2002-2004  convergence GmbH
29  * Written by Denis Oliver Kropp <dok@convergence.de> and
30  *            Sven Neumann <sven@convergence.de>
31  */
32
33 #ifndef __GDK_PRIVATE_DIRECTFB_H__
34 #define __GDK_PRIVATE_DIRECTFB_H__
35
36 //#include <gdk/gdk.h>
37 #include <gdk/gdkprivate.h>
38 #include "gdkinternals.h"
39 #include "gdkcursor.h"
40 #include "gdkdisplay-directfb.h"
41 #include "gdkregion-generic.h"
42 #include <cairo.h>
43
44 #include <string.h>
45
46 #include <directfb_util.h>
47
48
49 #define GDK_TYPE_DRAWABLE_IMPL_DIRECTFB       (gdk_drawable_impl_directfb_get_type ())
50 #define GDK_DRAWABLE_IMPL_DIRECTFB(object)    (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE_IMPL_DIRECTFB, GdkDrawableImplDirectFB))
51 #define GDK_IS_DRAWABLE_IMPL_DIRECTFB(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE_IMPL_DIRECTFB))
52
53 #define GDK_TYPE_WINDOW_IMPL_DIRECTFB         (gdk_window_impl_directfb_get_type ())
54 #define GDK_WINDOW_IMPL_DIRECTFB(object)      (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_DIRECTFB, GdkWindowImplDirectFB))
55 #define GDK_IS_WINDOW_IMPL_DIRECTFB(object)   (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_DIRECTFB))
56
57 #define GDK_TYPE_PIXMAP_IMPL_DIRECTFB         (gdk_pixmap_impl_directfb_get_type ())
58 #define GDK_PIXMAP_IMPL_DIRECTFB(object)      (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXMAP_IMPL_DIRECTFB, GdkPixmapImplDirectFB))
59 #define GDK_IS_PIXMAP_IMPL_DIRECTFB(object)   (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXMAP_IMPL_DIRECTFB))
60
61
62 typedef struct _GdkDrawableImplDirectFB GdkDrawableImplDirectFB;
63 typedef struct _GdkWindowImplDirectFB   GdkWindowImplDirectFB;
64 typedef struct _GdkPixmapImplDirectFB   GdkPixmapImplDirectFB;
65
66
67 struct _GdkDrawableImplDirectFB
68 {
69   GdkDrawable             parent_object;
70
71   GdkDrawable            *wrapper;
72
73   gboolean                buffered;
74
75   GdkRegion               paint_region;
76   gint                    paint_depth;
77   gint                    width;
78   gint                    height;
79   gint                    abs_x;
80   gint                    abs_y;
81
82   GdkRegion               clip_region;
83
84   GdkColormap            *colormap;
85
86   IDirectFBSurface       *surface;
87   DFBSurfacePixelFormat   format;
88   cairo_surface_t *  cairo_surface;
89
90 };
91
92 typedef struct
93 {
94   GdkDrawableClass  parent_class;
95 } GdkDrawableImplDirectFBClass;
96
97 GType      gdk_drawable_impl_directfb_get_type (void);
98
99 GdkEvent *  gdk_directfb_event_make     (GdkWindow               *window,
100                                          GdkEventType             type);
101
102
103 /*
104  * Pixmap
105  */
106
107 struct _GdkPixmapImplDirectFB
108 {
109   GdkDrawableImplDirectFB parent_instance;
110 };
111
112 typedef struct
113 {
114   GdkDrawableImplDirectFBClass parent_class;
115 } GdkPixmapImplDirectFBClass;
116
117 GType gdk_pixmap_impl_directfb_get_type (void);
118
119
120
121 /*
122  * Window
123  */
124
125 typedef struct
126 {
127   gulong   length;
128   GdkAtom  type;
129   gint     format;
130   guchar   data[1];
131 } GdkWindowProperty;
132
133
134 struct _GdkWindowImplDirectFB
135 {
136   GdkDrawableImplDirectFB drawable;
137   GdkWindow             *gdkWindow;
138
139   IDirectFBWindow        *window;
140
141   DFBWindowID             dfb_id;
142
143   GdkCursor              *cursor;
144   GHashTable             *properties;
145
146   guint8                  opacity;
147
148   GdkWindowTypeHint       type_hint;
149
150   DFBUpdates              flips;
151   DFBRegion               flip_regions[4];
152 };
153
154 typedef struct
155 {
156   GdkDrawableImplDirectFBClass parent_class;
157 } GdkWindowImplDirectFBClass;
158
159 GType gdk_window_impl_directfb_get_type        (void);
160
161 void  gdk_directfb_window_send_crossing_events (GdkWindow       *src,
162                                                 GdkWindow       *dest,
163                                                 GdkCrossingMode  mode);
164
165 void  _gdk_directfb_calc_abs                   (GdkWindow       *window);
166
167 GdkWindow * gdk_directfb_window_find_toplevel  (GdkWindow       *window);
168
169
170 void        gdk_directfb_window_id_table_insert (DFBWindowID  dfb_id,
171                                                  GdkWindow   *window);
172 void        gdk_directfb_window_id_table_remove (DFBWindowID  dfb_id);
173 GdkWindow * gdk_directfb_window_id_table_lookup (DFBWindowID  dfb_id);
174
175 void        _gdk_directfb_window_get_offsets    (GdkWindow       *window,
176                                                  gint            *x_offset,
177                                                  gint            *y_offset);
178 void        _gdk_directfb_window_scroll         (GdkWindow       *window,
179                                                  gint             dx,
180                                                  gint             dy);
181 void        _gdk_directfb_window_move_region    (GdkWindow       *window,
182                                                  const GdkRegion *region,
183                                                  gint             dx,
184                                                  gint             dy);
185
186
187 typedef struct
188 {
189   GdkCursor         cursor;
190
191   gint              hot_x;
192   gint              hot_y;
193   IDirectFBSurface *shape;
194 } GdkCursorDirectFB;
195
196 typedef struct
197 {
198   GdkVisual              visual;
199   DFBSurfacePixelFormat  format;
200 } GdkVisualDirectFB;
201
202 typedef struct
203 {
204   IDirectFBSurface *surface;
205 } GdkImageDirectFB;
206
207
208 #define GDK_TYPE_GC_DIRECTFB       (_gdk_gc_directfb_get_type ())
209 #define GDK_GC_DIRECTFB(object)    (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_DIRECTFB, GdkGCDirectFB))
210 #define GDK_IS_GC_DIRECTFB(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_DIRECTFB))
211
212 typedef struct
213 {
214   GdkGC             parent_instance;
215
216   GdkRegion         clip_region;
217
218   GdkGCValuesMask   values_mask;
219   GdkGCValues       values;
220 } GdkGCDirectFB;
221
222 typedef struct
223 {
224   GdkGCClass        parent_class;
225 } GdkGCDirectFBClass;
226
227 GType     _gdk_gc_directfb_get_type (void);
228
229 GdkGC *   _gdk_directfb_gc_new      (GdkDrawable     *drawable,
230                                      GdkGCValues     *values,
231                                      GdkGCValuesMask  values_mask);
232
233 GdkImage* _gdk_directfb_copy_to_image (GdkDrawable  *drawable,
234                                        GdkImage     *image,
235                                        gint          src_x,
236                                        gint          src_y,
237                                        gint          dest_x,
238                                        gint          dest_y,
239                                        gint          width,
240                                        gint          height);
241
242 void       gdk_directfb_event_windows_add    (GdkWindow *window);
243 void       gdk_directfb_event_windows_remove (GdkWindow *window);
244
245 GdkGrabStatus gdk_directfb_keyboard_grab  (GdkDisplay          *display,
246                                            GdkWindow           *window,
247                                            gint                 owner_events,
248                                            guint32              time);
249
250 void          gdk_directfb_keyboard_ungrab(GdkDisplay          *display,
251                                            guint32              time);
252
253 GdkGrabStatus gdk_directfb_pointer_grab   (GdkWindow           *window,
254                                            gint                 owner_events,
255                                            GdkEventMask         event_mask,
256                                            GdkWindow           *confine_to,
257                                            GdkCursor           *cursor,
258                                            guint32              time,
259                                            gboolean             implicit_grab);
260 void          gdk_directfb_pointer_ungrab (guint32              time,
261                                            gboolean             implicit_grab);
262
263 guint32       gdk_directfb_get_time       (void);
264
265 GdkWindow * gdk_directfb_pointer_event_window  (GdkWindow    *window,
266                                                 GdkEventType  type);
267 GdkWindow * gdk_directfb_keyboard_event_window (GdkWindow    *window,
268                                                 GdkEventType  type);
269 GdkWindow * gdk_directfb_other_event_window    (GdkWindow    *window,
270                                                 GdkEventType  type);
271 void       _gdk_selection_window_destroyed    (GdkWindow       *window);
272
273 void       _gdk_directfb_move_resize_child (GdkWindow *window,
274                                             gint       x,
275                                             gint       y,
276                                             gint       width,
277                                             gint       height);
278
279 GdkWindow * gdk_directfb_child_at          (GdkWindow *window,
280                                             gint      *x,
281                                             gint      *y);
282
283 GdkWindow * gdk_directfb_window_find_focus (void);
284
285 void        gdk_directfb_change_focus      (GdkWindow *new_focus_window);
286
287 void        gdk_directfb_mouse_get_info    (gint            *x,
288                                             gint            *y,
289                                             GdkModifierType *mask);
290
291 /**********************/
292 /*  Global variables  */
293 /**********************/
294
295 extern GdkDisplayDFB *_gdk_display;
296
297 /* Pointer grab info */
298 extern GdkWindow           * _gdk_directfb_pointer_grab_window;
299 extern gboolean              _gdk_directfb_pointer_grab_owner_events;
300 extern GdkWindow           * _gdk_directfb_pointer_grab_confine;
301 extern GdkEventMask          _gdk_directfb_pointer_grab_events;
302 extern GdkCursor           * _gdk_directfb_pointer_grab_cursor;
303
304 /* Keyboard grab info */
305 extern GdkWindow           * _gdk_directfb_keyboard_grab_window;
306 extern GdkEventMask          _gdk_directfb_keyboard_grab_events;
307 extern gboolean              _gdk_directfb_keyboard_grab_owner_events;
308
309 extern GdkScreen  *  _gdk_screen;
310
311 extern GdkAtom               _gdk_selection_property;
312
313
314 IDirectFBPalette * gdk_directfb_colormap_get_palette (GdkColormap *colormap);
315
316
317 /* these are Linux-FB specific functions used for window decorations */
318
319 typedef gboolean (* GdkWindowChildChanged) (GdkWindow *window,
320                                             gint       x,
321                                             gint       y,
322                                             gint       width,
323                                             gint       height,
324                                             gpointer   user_data);
325 typedef void     (* GdkWindowChildGetPos)  (GdkWindow *window,
326                                             gint      *x,
327                                             gint      *y,
328                                             gpointer   user_data);
329
330 void gdk_fb_window_set_child_handler (GdkWindow              *window,
331                                       GdkWindowChildChanged  changed,
332                                       GdkWindowChildGetPos   get_pos,
333                                       gpointer               user_data);
334
335 void gdk_directfb_clip_region (GdkDrawable  *drawable,
336                                GdkGC        *gc,
337                                GdkRectangle *draw_rect,
338                                GdkRegion    *ret_clip);
339
340
341 /* Utilities for avoiding mallocs */
342
343 static inline void
344 temp_region_init_copy( GdkRegion       *region, 
345                        const GdkRegion *source)
346 {
347   if (region != source) /*  don't want to copy to itself */
348     {  
349       if (region->size < source->numRects)
350         {
351           if (region->rects && region->rects != &region->extents)
352             g_free( region->rects );
353
354           region->rects = g_new (GdkRegionBox, source->numRects);
355           region->size  = source->numRects;
356         }
357
358       region->numRects = source->numRects;
359       region->extents  = source->extents;
360
361       memcpy( region->rects, source->rects, source->numRects * sizeof (GdkRegionBox) );
362     }
363 }
364
365 static inline void
366 temp_region_init_rectangle( GdkRegion          *region,
367                             const GdkRectangle *rect )
368 {
369      region->numRects = 1;
370      region->rects = &region->extents;
371      region->extents.x1 = rect->x;
372      region->extents.y1 = rect->y;
373      region->extents.x2 = rect->x + rect->width;
374      region->extents.y2 = rect->y + rect->height;
375      region->size = 1;
376 }
377
378 static inline void
379 temp_region_init_rectangle_vals( GdkRegion *region,
380                                  int        x,
381                                  int        y,
382                                  int        w,
383                                  int        h )
384 {
385      region->numRects = 1;
386      region->rects = &region->extents;
387      region->extents.x1 = x;
388      region->extents.y1 = y;
389      region->extents.x2 = x + w;
390      region->extents.y2 = y + h;
391      region->size = 1;
392 }
393
394 static inline void
395 temp_region_reset( GdkRegion *region )
396 {
397      if (region->size > 32 && region->rects && region->rects != &region->extents) {
398           g_free( region->rects );
399
400           region->size  = 1;
401           region->rects = &region->extents;
402      }
403
404      region->numRects = 0;
405 }
406
407 static inline void
408 temp_region_deinit( GdkRegion *region )
409 {
410      if (region->rects && region->rects != &region->extents) {
411           g_free( region->rects );
412           region->rects = NULL;
413      }
414
415      region->numRects = 0;
416 }
417
418
419 #define GDKDFB_RECTANGLE_VALS_FROM_BOX(s)   (s)->x1, (s)->y1, (s)->x2-(s)->x1, (s)->y2-(s)->y1
420
421
422 #endif /* __GDK_PRIVATE_DIRECTFB_H__ */