summaryrefslogtreecommitdiff
path: root/Source/DirectFB/wm/unique/decoration.c
blob: 5b98dcde6fd286e96561f23858548b0d4e5bc3b9 (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
/*
   (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.
*/

#include <config.h>

#include <directfb.h>

#include <direct/debug.h>
#include <direct/messages.h>

#include <fusion/object.h>

#include <core/coretypes.h>
#include <core/layers_internal.h>  /* FIXME */
#include <core/windows_internal.h>  /* FIXME */

#include <misc/util.h>

#include <unique/decoration.h>
#include <unique/internal.h>
#include <unique/window.h>


D_DEBUG_DOMAIN( UniQuE_Decoration, "UniQuE/Decoration", "UniQuE's Decoration Object" );


static const ReactionFunc unique_decoration_globals[] = {
/*     _unique_foo_decoration_listener,*/
     NULL
};

/**************************************************************************************************/

static void
decoration_destructor( FusionObject *object, bool zombie, void *ctx )
{
     UniqueDecoration *decoration = (UniqueDecoration*) object;

     D_MAGIC_ASSERT( decoration, UniqueDecoration );

     D_DEBUG_AT( UniQuE_Decoration, "destroying %p%s\n", decoration, zombie ? " (ZOMBIE)" : "");

     unique_window_unlink( &decoration->window );
     unique_context_unlink( &decoration->context );

     D_MAGIC_CLEAR( decoration );

     fusion_object_destroy( object );
}

FusionObjectPool *
unique_decoration_pool_create( const FusionWorld *world )
{
     return fusion_object_pool_create( "UniQuE Decoration Pool",
                                       sizeof(UniqueDecoration),
                                       sizeof(UniqueDecorationNotification),
                                       decoration_destructor, NULL, world );
}

/**************************************************************************************************/

DFBResult
unique_decoration_create( UniqueWindow           *window,
                          UniqueDecorationFlags   flags,
                          UniqueDecoration      **ret_decoration )
{
     DFBResult         ret;
     UniqueDecoration *decoration;
     UniqueContext    *context;

     D_ASSERT( window != NULL );
     D_ASSERT( D_FLAGS_ARE_IN( flags, UDF_ALL ) );
     D_ASSERT( ret_decoration != NULL );

     context = window->context;

     D_MAGIC_ASSERT( context, UniqueContext );


     /* Create a decoration object. */
     decoration = unique_wm_create_decoration();
     if (!decoration)
          return DFB_FUSION;

     /* Initialize deocration data. */
     decoration->flags = flags;

     ret = unique_window_link( &decoration->window, window );
     if (ret)
          goto error;

     ret = unique_context_link( &decoration->context, window->context );
     if (ret)
          goto error;


     D_MAGIC_SET( decoration, UniqueDecoration );


     /* Change global reaction lock. */
     fusion_object_set_lock( &decoration->object, &context->stack->context->lock );

     /* activate object */
     fusion_object_activate( &decoration->object );

     /* return the new decoration */
     *ret_decoration = decoration;

     return DFB_OK;

error:
     if (decoration->context)
          unique_context_unlink( &decoration->context );

     if (decoration->window)
          unique_window_unlink( &decoration->window );

     fusion_object_destroy( &decoration->object );

     return ret;
}

DFBResult
unique_decoration_destroy( UniqueDecoration *decoration )
{
     D_MAGIC_ASSERT( decoration, UniqueDecoration );

     D_FLAGS_SET( decoration->flags, UDF_DESTROYED );

     unique_decoration_notify( decoration, UDNF_DESTROYED );

     return DFB_OK;
}

DFBResult
unique_decoration_notify( UniqueDecoration                  *decoration,
                          UniqueDecorationNotificationFlags  flags )
{
     UniqueDecorationNotification notification;

     D_MAGIC_ASSERT( decoration, UniqueDecoration );

     D_ASSERT( flags != UDNF_NONE );

     D_ASSERT( ! (flags & ~UDNF_ALL) );

     notification.flags      = flags;
     notification.decoration = decoration;

     return unique_decoration_dispatch( decoration, &notification, unique_decoration_globals );
}

DFBResult
unique_decoration_update( UniqueDecoration *decoration,
                          const DFBRegion  *region )
{
     D_MAGIC_ASSERT( decoration, UniqueDecoration );

     DFB_REGION_ASSERT_IF( region );

     D_UNIMPLEMENTED();

     return DFB_UNIMPLEMENTED;
}