summaryrefslogtreecommitdiff
path: root/Source/DirectFB/wm/unique/internal.h
blob: 0dbf9b45cf35dcd89783031bbd1cd8c2c9137450 (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
/*
   (c) Copyright 2001-2009  The world wide DirectFB Open Source Community (directfb.org)
   (c) Copyright 2000-2004  Convergence (integrated media) GmbH

   All rights reserved.

   Written by Denis Oliver Kropp <dok@directfb.org>,
              Andreas Hundt <andi@fischlustig.de>,
              Sven Neumann <neo@directfb.org>,
              Ville Syrjälä <syrjala@sci.fi> and
              Claudio Ciccani <klan@users.sf.net>.

   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.
*/

#ifndef __UNIQUE__INTERNAL_H__
#define __UNIQUE__INTERNAL_H__

#include <directfb.h>

#include <direct/list.h>

#include <fusion/object.h>
#include <fusion/vector.h>

#include <core/coretypes.h>
#include <core/windows.h>

#include <unique/context.h>
#include <unique/decoration.h>
#include <unique/device.h>
#include <unique/input_events.h>
#include <unique/stret.h>
#include <unique/types.h>
#include <unique/window.h>


#define UNIQUE_WM_ABI_VERSION 12


extern const StretRegionClass unique_root_region_class;
extern const StretRegionClass unique_frame_region_class;
extern const StretRegionClass unique_window_region_class;
extern const StretRegionClass unique_foo_region_class;

extern const UniqueDeviceClass unique_pointer_device_class;
extern const UniqueDeviceClass unique_wheel_device_class;
extern const UniqueDeviceClass unique_keyboard_device_class;

typedef enum {
     URCI_ROOT,
     URCI_FRAME,
     URCI_WINDOW,
     URCI_FOO,

     _URCI_NUM
} UniqueRegionClassIndex;

typedef enum {
     UFI_N,
     UFI_NE,
     UFI_E,
     UFI_SE,
     UFI_S,
     UFI_SW,
     UFI_W,
     UFI_NW
} UniqueFooIndex;

typedef ReactionResult (*UniqueWMContextNotify)( WMData                          *data,
                                                 const UniqueContextNotification *notification,
                                                 void                            *ctx );

typedef ReactionResult (*UniqueWMWindowNotify) ( WMData                          *data,
                                                 const UniqueWindowNotification  *notification,
                                                 void                            *ctx );


struct __UniQuE_WMData {
     int                           module_abi;

     CoreDFB                      *core;
     FusionWorld                  *world;

     WMShared                     *shared;

     UniqueWMContextNotify         context_notify;
     UniqueWMWindowNotify          window_notify;
};

struct __UniQuE_WMShared {
     int                           magic;

     FusionObjectPool             *context_pool;
     FusionObjectPool             *decoration_pool;
     FusionObjectPool             *window_pool;

     StretRegionClassID            region_classes[_URCI_NUM];
     UniqueDeviceClassID           device_classes[_UDCI_NUM];

     int                           device_listener;    /* index of the registered global */

     DFBInsets                     insets;

     DFBRectangle                  foo_rects[8];

     CoreSurface                  *foo_surface;
};


typedef enum {
     UNRL_DESKTOP,       /* Icons, redirected fullscreen apps (force-desktop) */
     UNRL_USER,          /* User windows (all currently available stacking classes) */
     UNRL_SYSTEM,        /* Dock/Panel, Glass, Expos?, Clipboard, Virtual Keyboard, IMs */
     UNRL_CURSOR,        /* Cursor shape and attached objects, e.g. Drag'N'Drop */
     UNRL_SCREEN,        /* Display Locking, Screensaver */

     _UNRL_NUM
} UniqueRootLevel;

typedef enum {
     UNFL_BACKGROUND,    /* Background for blended content, effects, decorations */
     UNFL_CONTENT,       /* The actual DirectFB Window, i.e. its content */
     UNFL_FOREGROUND,    /* Decorations, effects, any other content overlay */

     _UNFL_NUM
} UniqueFrameLevel;

typedef struct {
     DirectLink                    link;

     DFBInputDeviceKeySymbol       symbol;
     DFBInputDeviceModifierMask    modifiers;

     UniqueWindow                 *owner;
} GrabbedKey;


struct __UniQuE_UniqueContext {
     FusionObject             object;

     int                      magic;

     CoreWindowStack         *stack;
     WMShared                *shared;

     CoreLayerRegion         *region;
     CoreSurface             *surface;

     DFBDisplayLayerID        layer_id;

     bool                     active;

     DFBColor                 color;

     int                      width;
     int                      height;

     StretRegion             *root;

     FusionVector             windows;


     UniqueInputSwitch       *input_switch;

     UniqueDevice            *devices[_UDCI_NUM];

     GlobalReaction           cursor_reaction;

     FusionSHMPoolShared     *shmpool;

     UniqueInputChannel      *foo_channel;

     CoreSurface             *cursor_bs;          /* backing store for region under cursor */
     bool                     cursor_bs_valid;
     DFBRegion                cursor_region;
     bool                     cursor_drawn;
};

struct __UniQuE_UniqueWindow {
     FusionObject             object;

     int                      magic;

     CoreWindow              *window;
     UniqueContext           *context;
     WMShared                *shared;

     CoreSurface             *surface;

     UniqueInputChannel      *channel;
     GlobalReaction           channel_reaction;

     DirectLink              *filters;

     DFBWindowCapabilities    caps;

     UniqueWindowFlags        flags;

     StretRegion             *frame;
     StretRegion             *region;
     StretRegion             *foos[8];
     DFBPoint                 foo_motion;

     DFBInsets                insets;

     DFBRectangle             bounds;        /* absolute bounds of the content */
     DFBRectangle             full;          /* absolute bounds of the full frame */

     int                      opacity;       /* global alpha factor */

     DFBWindowStackingClass   stacking;      /* level boundaries */
     int                      priority;      /* derived from stacking class */

     DFBWindowOptions         options;       /* flags for appearance/behaviour */
     DFBWindowEventType       events;        /* mask of enabled events */

     u32                      color_key;     /* transparent pixel */
     DFBRegion                opaque;        /* region of the window forced to be opaque */
};

struct __UniQuE_UniqueDecoration {
     FusionObject             object;

     int                      magic;

     UniqueWindow            *window;
     UniqueContext           *context;

     UniqueDecorationFlags    flags;
};

struct __UniQuE_UniqueDecorationItem {
     const UniqueLayout      *layout;        

     DFBPoint                 pos;           /* current offset from window origin */
     DFBDimension             size;          /* current dimensions */
};

struct __UniQuE_StretRegion {
     int                      magic;

     StretRegion             *parent;        /* Is NULL for the root region. */

     int                      level;         /* Level within the parent. */
     int                      index;         /* Index within the level. */

     int                      levels;        /* Number of levels provided. */
     FusionVector            *children;      /* Children of each level. */

     StretRegionFlags         flags;         /* Control appearance and activity. */

     DFBRegion                bounds;        /* Relative to its parent. */

     StretRegionClassID       clazz;         /* Region class (implementation) used for rendering etc. */

     void                    *data;          /* Optional private data of region class. */
     unsigned long            arg;           /* Optional argument for region class instance. */

     FusionSHMPoolShared     *shmpool;
};

struct __UniQuE_UniqueDevice {
     int                      magic;

     UniqueContext           *context;

     UniqueDeviceClassID      clazz;         /* Device class (implementation) used for processing etc. */

     void                    *data;          /* Optional private data of device class. */
     void                    *ctx;           /* Optional context for device class instance. */

     FusionReactor           *reactor;       /* UniqueInputEvent deployment */

     DirectLink              *connections;   /* CoreInputDevice connections */
};


struct __UniQuE_UniqueInputFilter {
     DirectLink               link;

     int                      magic;

     UniqueDeviceClassIndex   index;

     UniqueInputChannel      *channel;

     UniqueInputEvent         filter;
};

typedef struct {
     UniqueDeviceClassID      clazz;

     UniqueInputChannel      *current;

     UniqueInputChannel      *normal;
     UniqueInputChannel      *fixed;

     UniqueInputChannel      *implicit;

     DirectLink              *filters;
} UniqueInputTarget;


struct __UniQuE_UniqueInputSwitch {
     int                      magic;

     UniqueContext           *context;

     DirectLink              *connections;  /* UniqueDevice connections */

     int                      x;
     int                      y;

     UniqueInputTarget        targets[_UDCI_NUM];
};

struct __UniQuE_UniqueInputChannel {
     int                      magic;

     UniqueContext           *context;

     FusionReactor           *reactor;      /* UniqueInputEvent arrival */
};


DFBResult unique_wm_module_init  ( CoreDFB  *core,
                                   WMData   *data,
                                   WMShared *shared,
                                   bool      master );

void      unique_wm_module_deinit( WMData   *data,
                                   WMShared *shared,
                                   bool      master,
                                   bool      emergency );

UniqueContext    *unique_wm_create_context( void );
UniqueDecoration *unique_wm_create_decoration( void );
UniqueWindow     *unique_wm_create_window( void );

/* HACK: temporary, will move into cursor class */
void unique_draw_cursor( CoreWindowStack *stack, UniqueContext *context, CardState *state, DFBRegion *region );


/* global reactions */
ReactionResult _unique_device_listener              ( const void *msg_data,
                                                      void       *ctx );

ReactionResult _unique_wm_module_context_listener   ( const void *msg_data,
                                                      void       *ctx );

ReactionResult _unique_wm_module_window_listener    ( const void *msg_data,
                                                      void       *ctx );

ReactionResult _unique_cursor_device_listener       ( const void *msg_data,
                                                      void       *ctx );

ReactionResult _unique_input_switch_device_listener ( const void *msg_data,
                                                      void       *ctx );

ReactionResult _unique_window_input_channel_listener( const void *msg_data,
                                                      void       *ctx );

#endif