1 /*
2    (c) Copyright 2001-2009  The world wide DirectFB Open Source Community (directfb.org)
3    (c) Copyright 2000-2004  Convergence (integrated media) GmbH
4 
5    All rights reserved.
6 
7    Written by Denis Oliver Kropp <dok@directfb.org>,
8               Andreas Hundt <andi@fischlustig.de>,
9               Sven Neumann <neo@directfb.org>,
10               Ville Syrjälä <syrjala@sci.fi> and
11               Claudio Ciccani <klan@users.sf.net>.
12 
13    This library is free software; you can redistribute it and/or
14    modify it under the terms of the GNU Lesser General Public
15    License as published by the Free Software Foundation; either
16    version 2 of the License, or (at your option) any later version.
17 
18    This library is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21    Lesser General Public License for more details.
22 
23    You should have received a copy of the GNU Lesser General Public
24    License along with this library; if not, write to the
25    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26    Boston, MA 02111-1307, USA.
27 */
28 
29 #ifndef __DFB__CORE__WM_H__
30 #define __DFB__CORE__WM_H__
31 
32 #include <directfb.h>
33 
34 #include <direct/modules.h>
35 
36 #include <core/coretypes.h>
37 #include <core/windows.h>
38 
39 
40 DECLARE_MODULE_DIRECTORY( dfb_core_wm_modules );
41 
42 
43 /*
44  * Increase this number when changes result in binary incompatibility!
45  */
46 #define DFB_CORE_WM_ABI_VERSION           9
47 
48 #define DFB_CORE_WM_INFO_NAME_LENGTH     60
49 #define DFB_CORE_WM_INFO_VENDOR_LENGTH   80
50 #define DFB_CORE_WM_INFO_URL_LENGTH     120
51 #define DFB_CORE_WM_INFO_LICENSE_LENGTH  40
52 
53 
54 typedef struct {
55      int            major;
56      int            minor;
57 
58      int            binary;
59 } CoreWMVersion;
60 
61 typedef struct {
62      CoreWMVersion  version;
63 
64      char           name   [DFB_CORE_WM_INFO_NAME_LENGTH];
65      char           vendor [DFB_CORE_WM_INFO_VENDOR_LENGTH];
66      char           url    [DFB_CORE_WM_INFO_URL_LENGTH];
67      char           license[DFB_CORE_WM_INFO_LICENSE_LENGTH];
68 
69      unsigned int   wm_data_size;
70      unsigned int   wm_shared_size;
71      unsigned int   stack_data_size;
72      unsigned int   window_data_size;
73 } CoreWMInfo;
74 
75 typedef struct {
76      CoreWMGrabTarget            target;
77 
78      /* Both for CWMGT_KEY only. */
79      DFBInputDeviceKeySymbol     symbol;
80      DFBInputDeviceModifierMask  modifiers;
81 } CoreWMGrab;
82 
83 /* FIXME: move to cursor.h when it's there */
84 typedef enum {
85      CCUF_NONE      = 0x00000000,
86 
87      CCUF_ENABLE    = 0x00000001,
88      CCUF_DISABLE   = 0x00000002,
89 
90      CCUF_POSITION  = 0x00000010,
91      CCUF_SIZE      = 0x00000020,
92      CCUF_SHAPE     = 0x00000040,
93      CCUF_OPACITY   = 0x00000080,
94 
95      CCUF_ALL       = 0x000000F3
96 } CoreCursorUpdateFlags;
97 
98 typedef DFBEnumerationResult (*CoreWMWindowCallback) (CoreWindow *window,
99                                                       void       *ctx);
100 
101 typedef struct {
102 
103    /** Module **/
104 
105      void      (*GetWMInfo)         ( CoreWMInfo             *info );
106 
107      DFBResult (*Initialize)        ( CoreDFB                *core,
108                                       void                   *wm_data,
109                                       void                   *shared_data );
110 
111      DFBResult (*Join)              ( CoreDFB                *core,
112                                       void                   *wm_data,
113                                       void                   *shared_data );
114 
115      DFBResult (*Shutdown)          ( bool                    emergency,
116                                       void                   *wm_data,
117                                       void                   *shared_data );
118 
119      DFBResult (*Leave)             ( bool                    emergency,
120                                       void                   *wm_data,
121                                       void                   *shared_data );
122 
123      DFBResult (*Suspend)           ( void                   *wm_data,
124                                       void                   *shared_data );
125 
126      DFBResult (*Resume)            ( void                   *wm_data,
127                                       void                   *shared_data );
128 
129      DFBResult (*PostInit)          ( void                   *wm_data,
130                                       void                   *shared_data );
131 
132 
133    /** Stack **/
134 
135      DFBResult (*InitStack)         ( CoreWindowStack        *stack,
136                                       void                   *wm_data,
137                                       void                   *stack_data );
138 
139      DFBResult (*CloseStack)        ( CoreWindowStack        *stack,
140                                       void                   *wm_data,
141                                       void                   *stack_data );
142 
143      DFBResult (*SetActive)         ( CoreWindowStack        *stack,
144                                       void                   *wm_data,
145                                       void                   *stack_data,
146                                       bool                    active );
147 
148      DFBResult (*ResizeStack)       ( CoreWindowStack        *stack,
149                                       void                   *wm_data,
150                                       void                   *stack_data,
151                                       int                     width,
152                                       int                     height );
153 
154      DFBResult (*ProcessInput)      ( CoreWindowStack        *stack,
155                                       void                   *wm_data,
156                                       void                   *stack_data,
157                                       const DFBInputEvent    *event );
158 
159      DFBResult (*FlushKeys)         ( CoreWindowStack        *stack,
160                                       void                   *wm_data,
161                                       void                   *stack_data );
162 
163      DFBResult (*WindowAt)          ( CoreWindowStack        *stack,
164                                       void                   *wm_data,
165                                       void                   *stack_data,
166                                       int                     x,
167                                       int                     y,
168                                       CoreWindow            **ret_window );
169 
170      DFBResult (*WindowLookup)      ( CoreWindowStack        *stack,
171                                       void                   *wm_data,
172                                       void                   *stack_data,
173                                       DFBWindowID             window_id,
174                                       CoreWindow            **ret_window );
175 
176      DFBResult (*EnumWindows)       ( CoreWindowStack        *stack,
177                                       void                   *wm_data,
178                                       void                   *stack_data,
179                                       CoreWMWindowCallback    callback,
180                                       void                   *callback_ctx );
181 
182 
183    /** Window **/
184     DFBResult (*SetWindowProperty)( CoreWindowStack  *stack,
185                                     void             *wm_data,
186                                     void             *stack_data,
187                                     CoreWindow       *window,
188                                     void             *window_data,
189                                     const char       *key,
190                                     void             *value,
191                                     void            **old_value );
192 
193     DFBResult (*GetWindowProperty)( CoreWindowStack  *stack,
194                                     void             *wm_data,
195                                     void             *stack_data,
196                                     CoreWindow       *window,
197                                     void             *window_data,
198                                     const char       *key,
199                                     void            **value);
200 
201     DFBResult (*RemoveWindowProperty)( CoreWindowStack  *stack,
202                                        void             *wm_data,
203                                        void             *stack_data,
204                                        CoreWindow       *window,
205                                        void             *window_data,
206                                        const char       *key,
207                                        void            **value );
208 
209      DFBResult (*GetInsets)         ( CoreWindowStack        *stack,
210                                       CoreWindow             *window,
211                                       DFBInsets              *insets );
212 
213      DFBResult (*PreConfigureWindow)( CoreWindowStack        *stack,
214                                       void                   *wm_data,
215                                       void                   *stack_data,
216                                       CoreWindow             *window,
217                                       void                   *window_data );
218 
219      DFBResult (*AddWindow)         ( CoreWindowStack        *stack,
220                                       void                   *wm_data,
221                                       void                   *stack_data,
222                                       CoreWindow             *window,
223                                       void                   *window_data );
224 
225      DFBResult (*RemoveWindow)      ( CoreWindowStack        *stack,
226                                       void                   *wm_data,
227                                       void                   *stack_data,
228                                       CoreWindow             *window,
229                                       void                   *window_data );
230 
231      DFBResult (*SetWindowConfig)   ( CoreWindow             *window,
232                                       void                   *wm_data,
233                                       void                   *window_data,
234                                       const CoreWindowConfig *config,
235                                       CoreWindowConfigFlags   flags );
236 
237      DFBResult (*RestackWindow)     ( CoreWindow             *window,
238                                       void                   *wm_data,
239                                       void                   *window_data,
240                                       CoreWindow             *relative,
241                                       void                   *relative_data,
242                                       int                     relation );
243 
244      DFBResult (*Grab)              ( CoreWindow             *window,
245                                       void                   *wm_data,
246                                       void                   *window_data,
247                                       CoreWMGrab             *grab );
248 
249      DFBResult (*Ungrab)            ( CoreWindow             *window,
250                                       void                   *wm_data,
251                                       void                   *window_data,
252                                       CoreWMGrab             *grab );
253 
254      DFBResult (*RequestFocus)      ( CoreWindow             *window,
255                                       void                   *wm_data,
256                                       void                   *window_data );
257 
258      DFBResult (*BeginUpdates)      ( CoreWindow             *window,
259                                       void                   *wm_data,
260                                       void                   *window_data,
261                                       const DFBRegion        *update );
262 
263      DFBResult (*SetCursorPosition) ( CoreWindow             *window,
264                                       void                   *wm_data,
265                                       void                   *window_data,
266                                       int                     x,
267                                       int                     y );
268 
269 
270    /** Updates **/
271 
272      DFBResult (*UpdateStack)       ( CoreWindowStack        *stack,
273                                       void                   *wm_data,
274                                       void                   *stack_data,
275                                       const DFBRegion        *region,
276                                       DFBSurfaceFlipFlags     flags );
277 
278      DFBResult (*UpdateWindow)      ( CoreWindow             *window,
279                                       void                   *wm_data,
280                                       void                   *window_data,
281                                       const DFBRegion        *region,
282                                       DFBSurfaceFlipFlags     flags );
283 
284      DFBResult (*UpdateCursor)      ( CoreWindowStack        *stack,
285                                       void                   *wm_data,
286                                       void                   *stack_data,
287                                       CoreCursorUpdateFlags   flags );
288 } CoreWMFuncs;
289 
290 
291 void dfb_wm_get_info( CoreWMInfo *info );
292 
293 DFBResult dfb_wm_post_init          ( CoreDFB                *core );
294 
295 DFBResult dfb_wm_init_stack         ( CoreWindowStack        *stack );
296 
297 DFBResult dfb_wm_close_stack        ( CoreWindowStack        *stack );
298 
299 DFBResult dfb_wm_set_active         ( CoreWindowStack        *stack,
300                                       bool                    active );
301 
302 DFBResult dfb_wm_resize_stack       ( CoreWindowStack        *stack,
303                                       int                     width,
304                                       int                     height );
305 
306 DFBResult dfb_wm_process_input      ( CoreWindowStack        *stack,
307                                       const DFBInputEvent    *event );
308 
309 DFBResult dfb_wm_flush_keys         ( CoreWindowStack        *stack );
310 
311 DFBResult dfb_wm_window_at          ( CoreWindowStack        *stack,
312                                       int                     x,
313                                       int                     y,
314                                       CoreWindow            **ret_window );
315 
316 DFBResult dfb_wm_window_lookup      ( CoreWindowStack        *stack,
317                                       DFBWindowID             window_id,
318                                       CoreWindow            **ret_window );
319 
320 DFBResult dfb_wm_enum_windows       ( CoreWindowStack        *stack,
321                                       CoreWMWindowCallback    callback,
322                                       void                   *callback_ctx );
323 
324 DFBResult dfb_wm_get_insets         ( CoreWindowStack        *stack,
325                                       CoreWindow             *window,
326                                       DFBInsets              *insets );
327 
328 DFBResult dfb_wm_set_window_property ( CoreWindowStack  *stack,
329                                        CoreWindow       *window,
330                                        const char       *key,
331                                        void             *value,
332                                        void            **ret_old_value );
333 
334 DFBResult dfb_wm_get_window_property ( CoreWindowStack  *stack,
335                                        CoreWindow       *window,
336                                        const char       *key,
337                                        void            **ret_value );
338 
339 DFBResult dfb_wm_remove_window_property ( CoreWindowStack  *stack,
340                                           CoreWindow       *window,
341                                           const char       *key,
342                                           void            **ret_value );
343 
344 DFBResult dfb_wm_preconfigure_window ( CoreWindowStack        *stack,
345                                        CoreWindow             *window );
346 
347 
348 DFBResult dfb_wm_add_window         ( CoreWindowStack        *stack,
349                                       CoreWindow             *window );
350 
351 DFBResult dfb_wm_remove_window      ( CoreWindowStack        *stack,
352                                       CoreWindow             *window );
353 
354 DFBResult dfb_wm_set_window_config  ( CoreWindow             *window,
355                                       const CoreWindowConfig *config,
356                                       CoreWindowConfigFlags   flags );
357 
358 DFBResult dfb_wm_restack_window     ( CoreWindow             *window,
359                                       CoreWindow             *relative,
360                                       int                     relation );
361 
362 DFBResult dfb_wm_grab               ( CoreWindow             *window,
363                                       CoreWMGrab             *grab );
364 
365 DFBResult dfb_wm_ungrab             ( CoreWindow             *window,
366                                       CoreWMGrab             *grab );
367 
368 DFBResult dfb_wm_request_focus      ( CoreWindow             *window );
369 
370 DFBResult dfb_wm_begin_updates      ( CoreWindow             *window,
371                                       const DFBRegion        *update );
372 
373 DFBResult dfb_wm_set_cursor_position( CoreWindow             *window,
374                                       int                     x,
375                                       int                     y );
376 
377 
378 DFBResult dfb_wm_update_stack       ( CoreWindowStack        *stack,
379                                       const DFBRegion        *region,
380                                       DFBSurfaceFlipFlags     flags );
381 
382 DFBResult dfb_wm_update_window      ( CoreWindow             *window,
383                                       const DFBRegion        *region,
384                                       DFBSurfaceFlipFlags     flags );
385 
386 DFBResult dfb_wm_update_cursor      ( CoreWindowStack        *stack,
387                                       CoreCursorUpdateFlags   flags );
388 
389 #endif
390