summaryrefslogtreecommitdiff
path: root/gdk/directfb/gdkprivate-directfb.h
blob: db04f9275fb9ec9b0e029b3d29f9a33a2e511f99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
/* GDK - The GIMP Drawing Kit
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/*
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
 * file for a list of people on the GTK+ Team.
 */

/*
 * GTK+ DirectFB backend
 * Copyright (C) 2001-2002  convergence integrated media GmbH
 * Copyright (C) 2002-2004  convergence GmbH
 * Written by Denis Oliver Kropp <dok@convergence.de> and
 *            Sven Neumann <sven@convergence.de>
 */

#ifndef __GDK_PRIVATE_DIRECTFB_H__
#define __GDK_PRIVATE_DIRECTFB_H__

//#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
#include "gdkinternals.h"
#include "gdkcursor.h"
#include "gdkdisplay-directfb.h"
#include <cairo.h>

#include <string.h>

#include <directfb_util.h>


#define GDK_TYPE_DRAWABLE_IMPL_DIRECTFB       (gdk_drawable_impl_directfb_get_type ())
#define GDK_DRAWABLE_IMPL_DIRECTFB(object)    (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE_IMPL_DIRECTFB, GdkDrawableImplDirectFB))
#define GDK_IS_DRAWABLE_IMPL_DIRECTFB(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE_IMPL_DIRECTFB))

#define GDK_TYPE_WINDOW_IMPL_DIRECTFB         (gdk_window_impl_directfb_get_type ())
#define GDK_WINDOW_IMPL_DIRECTFB(object)      (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_DIRECTFB, GdkWindowImplDirectFB))
#define GDK_IS_WINDOW_IMPL_DIRECTFB(object)   (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_DIRECTFB))

#define GDK_TYPE_PIXMAP_IMPL_DIRECTFB         (gdk_pixmap_impl_directfb_get_type ())
#define GDK_PIXMAP_IMPL_DIRECTFB(object)      (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXMAP_IMPL_DIRECTFB, GdkPixmapImplDirectFB))
#define GDK_IS_PIXMAP_IMPL_DIRECTFB(object)   (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXMAP_IMPL_DIRECTFB))


typedef struct _GdkDrawableImplDirectFB GdkDrawableImplDirectFB;
typedef struct _GdkWindowImplDirectFB   GdkWindowImplDirectFB;
typedef struct _GdkPixmapImplDirectFB   GdkPixmapImplDirectFB;


struct _GdkDrawableImplDirectFB
{
  GdkDrawable             parent_object;

  GdkDrawable            *wrapper;

  gboolean                buffered;

  cairo_region_t               paint_region;
  gint                    paint_depth;
  gint                    width;
  gint                    height;
  gint                    abs_x;
  gint                    abs_y;

  cairo_region_t               clip_region;

  GdkColormap            *colormap;

  IDirectFBSurface       *surface;
  DFBSurfacePixelFormat   format;
  cairo_surface_t *  cairo_surface;

};

typedef struct
{
  GdkDrawableClass  parent_class;
} GdkDrawableImplDirectFBClass;

GType      gdk_drawable_impl_directfb_get_type (void);

GdkEvent *  gdk_directfb_event_make     (GdkWindow               *window,
                                         GdkEventType             type);


/*
 * Pixmap
 */

struct _GdkPixmapImplDirectFB
{
  GdkDrawableImplDirectFB parent_instance;
};

typedef struct
{
  GdkDrawableImplDirectFBClass parent_class;
} GdkPixmapImplDirectFBClass;

GType gdk_pixmap_impl_directfb_get_type (void);



/*
 * Window
 */

typedef struct
{
  gulong   length;
  GdkAtom  type;
  gint     format;
  guchar   data[1];
} GdkWindowProperty;


struct _GdkWindowImplDirectFB
{
  GdkDrawableImplDirectFB drawable;
  GdkWindow             *gdkWindow;

  IDirectFBWindow        *window;

  DFBWindowID             dfb_id;

  GdkCursor              *cursor;
  GHashTable             *properties;

  guint8                  opacity;

  GdkWindowTypeHint       type_hint;

  DFBUpdates              flips;
  DFBRegion               flip_regions[4];
};

typedef struct
{
  GdkDrawableImplDirectFBClass parent_class;
} GdkWindowImplDirectFBClass;

GType gdk_window_impl_directfb_get_type        (void);

void  gdk_directfb_window_send_crossing_events (GdkWindow       *src,
                                                GdkWindow       *dest,
                                                GdkCrossingMode  mode);

void  _gdk_directfb_calc_abs                   (GdkWindow       *window);

GdkWindow * gdk_directfb_window_find_toplevel  (GdkWindow       *window);


void        gdk_directfb_window_id_table_insert (DFBWindowID  dfb_id,
                                                 GdkWindow   *window);
void        gdk_directfb_window_id_table_remove (DFBWindowID  dfb_id);
GdkWindow * gdk_directfb_window_id_table_lookup (DFBWindowID  dfb_id);

void        _gdk_directfb_window_get_offsets    (GdkWindow       *window,
                                                 gint            *x_offset,
                                                 gint            *y_offset);
void        _gdk_directfb_window_scroll         (GdkWindow       *window,
                                                 gint             dx,
                                                 gint             dy);
void        _gdk_directfb_window_move_region    (GdkWindow       *window,
                                                 const cairo_region_t *region,
                                                 gint             dx,
                                                 gint             dy);


typedef struct
{
  GdkCursor         cursor;

  gint              hot_x;
  gint              hot_y;
  IDirectFBSurface *shape;
} GdkCursorDirectFB;

typedef struct
{
  GdkVisual              visual;
  DFBSurfacePixelFormat  format;
} GdkVisualDirectFB;

typedef struct
{
  IDirectFBSurface *surface;
} GdkImageDirectFB;


#define GDK_TYPE_GC_DIRECTFB       (_gdk_gc_directfb_get_type ())
#define GDK_GC_DIRECTFB(object)    (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_DIRECTFB, GdkGCDirectFB))
#define GDK_IS_GC_DIRECTFB(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_DIRECTFB))

typedef struct
{
  GdkGC             parent_instance;

  cairo_region_t         clip_region;

  GdkGCValuesMask   values_mask;
  GdkGCValues       values;
} GdkGCDirectFB;

typedef struct
{
  GdkGCClass        parent_class;
} GdkGCDirectFBClass;

GType     _gdk_gc_directfb_get_type (void);

GdkGC *   _gdk_directfb_gc_new      (GdkDrawable     *drawable,
                                     GdkGCValues     *values,
                                     GdkGCValuesMask  values_mask);

GdkImage* _gdk_directfb_copy_to_image (GdkDrawable  *drawable,
                                       GdkImage     *image,
                                       gint          src_x,
                                       gint          src_y,
                                       gint          dest_x,
                                       gint          dest_y,
                                       gint          width,
                                       gint          height);

void       gdk_directfb_event_windows_add    (GdkWindow *window);
void       gdk_directfb_event_windows_remove (GdkWindow *window);

GdkGrabStatus gdk_directfb_keyboard_grab  (GdkDisplay          *display,
                                           GdkWindow           *window,
                                           gint                 owner_events,
                                           guint32              time);

void          gdk_directfb_keyboard_ungrab(GdkDisplay          *display,
                                           guint32              time);

GdkGrabStatus gdk_directfb_pointer_grab   (GdkWindow           *window,
                                           gint                 owner_events,
                                           GdkEventMask         event_mask,
                                           GdkWindow           *confine_to,
                                           GdkCursor           *cursor,
                                           guint32              time,
                                           gboolean             implicit_grab);
void          gdk_directfb_pointer_ungrab (guint32              time,
                                           gboolean             implicit_grab);

guint32       gdk_directfb_get_time       (void);

GdkWindow * gdk_directfb_pointer_event_window  (GdkWindow    *window,
                                                GdkEventType  type);
GdkWindow * gdk_directfb_keyboard_event_window (GdkWindow    *window,
                                                GdkEventType  type);
GdkWindow * gdk_directfb_other_event_window    (GdkWindow    *window,
                                                GdkEventType  type);
void       _gdk_selection_window_destroyed    (GdkWindow       *window);

void       _gdk_directfb_move_resize_child (GdkWindow *window,
                                            gint       x,
                                            gint       y,
                                            gint       width,
                                            gint       height);

GdkWindow * gdk_directfb_child_at          (GdkWindow *window,
                                            gint      *x,
                                            gint      *y);

GdkWindow * gdk_directfb_window_find_focus (void);

void        gdk_directfb_change_focus      (GdkWindow *new_focus_window);

void        gdk_directfb_mouse_get_info    (gint            *x,
                                            gint            *y,
                                            GdkModifierType *mask);

/**********************/
/*  Global variables  */
/**********************/

extern GdkDisplayDFB *_gdk_display;

/* Pointer grab info */
extern GdkWindow           * _gdk_directfb_pointer_grab_window;
extern gboolean              _gdk_directfb_pointer_grab_owner_events;
extern GdkWindow           * _gdk_directfb_pointer_grab_confine;
extern GdkEventMask          _gdk_directfb_pointer_grab_events;
extern GdkCursor           * _gdk_directfb_pointer_grab_cursor;

/* Keyboard grab info */
extern GdkWindow           * _gdk_directfb_keyboard_grab_window;
extern GdkEventMask          _gdk_directfb_keyboard_grab_events;
extern gboolean              _gdk_directfb_keyboard_grab_owner_events;

extern GdkScreen  *  _gdk_screen;

extern GdkAtom               _gdk_selection_property;


IDirectFBPalette * gdk_directfb_colormap_get_palette (GdkColormap *colormap);


/* these are Linux-FB specific functions used for window decorations */

typedef gboolean (* GdkWindowChildChanged) (GdkWindow *window,
                                            gint       x,
                                            gint       y,
                                            gint       width,
                                            gint       height,
                                            gpointer   user_data);
typedef void     (* GdkWindowChildGetPos)  (GdkWindow *window,
                                            gint      *x,
                                            gint      *y,
                                            gpointer   user_data);

void gdk_fb_window_set_child_handler (GdkWindow              *window,
                                      GdkWindowChildChanged  changed,
                                      GdkWindowChildGetPos   get_pos,
                                      gpointer               user_data);

void gdk_directfb_clip_region (GdkDrawable  *drawable,
                               GdkGC        *gc,
                               GdkRectangle *draw_rect,
                               cairo_region_t    *ret_clip);


/* Utilities for avoiding mallocs */

static inline void
temp_region_init_copy( cairo_region_t       *region, 
                       const cairo_region_t *source)
{
  if (region != source) /*  don't want to copy to itself */
    {  
      if (region->size < source->numRects)
        {
          if (region->rects && region->rects != &region->extents)
            g_free( region->rects );

          region->rects = g_new (cairo_region_tBox, source->numRects);
          region->size  = source->numRects;
        }

      region->numRects = source->numRects;
      region->extents  = source->extents;

      memcpy( region->rects, source->rects, source->numRects * sizeof (cairo_region_tBox) );
    }
}

static inline void
temp_region_init_rectangle( cairo_region_t          *region,
                            const GdkRectangle *rect )
{
     region->numRects = 1;
     region->rects = &region->extents;
     region->extents.x1 = rect->x;
     region->extents.y1 = rect->y;
     region->extents.x2 = rect->x + rect->width;
     region->extents.y2 = rect->y + rect->height;
     region->size = 1;
}

static inline void
temp_region_init_rectangle_vals( cairo_region_t *region,
                                 int        x,
                                 int        y,
                                 int        w,
                                 int        h )
{
     region->numRects = 1;
     region->rects = &region->extents;
     region->extents.x1 = x;
     region->extents.y1 = y;
     region->extents.x2 = x + w;
     region->extents.y2 = y + h;
     region->size = 1;
}

static inline void
temp_region_reset( cairo_region_t *region )
{
     if (region->size > 32 && region->rects && region->rects != &region->extents) {
          g_free( region->rects );

          region->size  = 1;
          region->rects = &region->extents;
     }

     region->numRects = 0;
}

static inline void
temp_region_deinit( cairo_region_t *region )
{
     if (region->rects && region->rects != &region->extents) {
          g_free( region->rects );
          region->rects = NULL;
     }

     region->numRects = 0;
}


#define GDKDFB_RECTANGLE_VALS_FROM_BOX(s)   (s)->x1, (s)->y1, (s)->x2-(s)->x1, (s)->y2-(s)->y1


#endif /* __GDK_PRIVATE_DIRECTFB_H__ */