~ubuntu-branches/ubuntu/quantal/libcm/quantal

« back to all changes in this revision

Viewing changes to src/wsdrawable.c

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier, Josselin Mouette, Loic Minier
  • Date: 2008-05-26 14:43:19 UTC
  • mfrom: (3.1.4 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080526144319-ddwovigo7i925ewr
Tags: 0.1.1-4
[ Josselin Mouette ]
* Allow libgl-dev and libglu-dev as alternative dependencies for
  libcm-dev. Closes: #478887.

[ Loic Minier ]
* Don't copy config.guess/.sub after unpatch in clean; should avoid having
  them in the .diff.gz -- not needed as we always update them after patching
  anyway -- and should fix conversion to source format 3.0; closes: #482728.
* Stop shipping *.la files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* libcm - A library with a xlib wrapper and a gl based scene graph
 
2
 * Copyright (C) 2005, 2006  Red Hat, Inc.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Library 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
 * Library General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Library 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
 * Author: Soren Sandmann (sandmann@redhat.com)
 
20
 */
1
21
#include "wsint.h"
2
22
 
3
23
G_DEFINE_TYPE (WsDrawable, ws_drawable, WS_TYPE_RESOURCE);
6
26
                                          guint                  n_construct_properties,
7
27
                                          GObjectConstructParam *construct_params);
8
28
 
 
29
enum
 
30
{
 
31
    DAMAGE_NOTIFY_EVENT,
 
32
    N_SIGNALS
 
33
};
 
34
 
 
35
static guint signals[N_SIGNALS] = { 0 };
 
36
 
9
37
static void
10
38
ws_drawable_finalize (GObject *object)
11
39
{
 
40
    WsDrawable *drawable = WS_DRAWABLE (object);
 
41
 
 
42
    if (drawable->damage)
 
43
    {
 
44
        _ws_display_unregister_damage (WS_RESOURCE (object)->display,
 
45
                                       drawable->damage);
 
46
    }
 
47
    
12
48
    G_OBJECT_CLASS (ws_drawable_parent_class)->finalize (object);
13
49
}
14
50
 
19
55
    
20
56
    object_class->constructor = ws_drawable_constructor;
21
57
    object_class->finalize = ws_drawable_finalize;
 
58
 
 
59
    signals[DAMAGE_NOTIFY_EVENT] =
 
60
        g_signal_new ("damage_notify_event",
 
61
                      G_OBJECT_CLASS_TYPE (object_class),
 
62
                      G_SIGNAL_RUN_LAST,
 
63
                      0,
 
64
                      NULL, NULL,
 
65
                      g_cclosure_marshal_VOID__VOID,
 
66
                      G_TYPE_NONE, 0);
 
67
}
 
68
 
 
69
static void
 
70
on_damage (WsDisplay *display,
 
71
           Damage     damage,
 
72
           gpointer   data)
 
73
{
 
74
    WsDrawable *drawable = data;
 
75
 
 
76
    if (drawable->damage)
 
77
    {
 
78
        ws_display_begin_error_trap (display);
 
79
        
 
80
        XDamageSubtract (WS_RESOURCE_XDISPLAY (drawable),
 
81
                         drawable->damage,
 
82
                         None, None);
 
83
    
 
84
        ws_display_end_error_trap (display);
 
85
    }
 
86
    
 
87
    g_signal_emit (drawable, signals[DAMAGE_NOTIFY_EVENT], 0);
22
88
}
23
89
 
24
90
static void
33
99
{
34
100
    GObject *object;
35
101
    WsDrawable *drawable;
 
102
    XID xdamage;
36
103
    
37
104
    object = G_OBJECT_CLASS (ws_drawable_parent_class)->constructor (
38
105
        type, n_construct_properties, construct_params);
39
106
    
40
107
    drawable = WS_DRAWABLE (object);
 
108
 
 
109
    /* We need to trap errors here as the drawable could be
 
110
     * an input-only window
 
111
     *
 
112
     * FIXME: maybe it's better to not use the _with_return variant
 
113
     * and instead just treat the drawable->damage as untrusted.
 
114
     */
 
115
    ws_display_begin_error_trap (WS_RESOURCE (drawable)->display);
41
116
    
 
117
    xdamage = XDamageCreate (WS_RESOURCE_XDISPLAY (drawable),
 
118
                             WS_RESOURCE_XID (drawable),
 
119
                             XDamageReportNonEmpty);
 
120
 
 
121
    XDamageSubtract (WS_RESOURCE_XDISPLAY (drawable),
 
122
                     xdamage,
 
123
                     None, None);
 
124
 
 
125
    if (!ws_display_end_error_trap_with_return (WS_RESOURCE (drawable)->display))
 
126
    {
 
127
        drawable->damage = xdamage;
 
128
        
 
129
        _ws_display_register_damage (WS_RESOURCE (drawable)->display,
 
130
                                     drawable->damage,
 
131
                                     on_damage, drawable);
 
132
    }
 
133
 
42
134
    return object;
43
135
}
44
136
 
62
154
                       int sx, int sy, int width, int height,
63
155
                       WsDrawable *dest,
64
156
                       int dx, int dy,
65
 
                       WsRegion *clip)
 
157
                       WsServerRegion *clip)
66
158
{
67
159
    Display *xdisplay = WS_RESOURCE_XDISPLAY (src);
68
160
    
75
167
    
76
168
    XSetForeground (xdisplay, gc, 0x00FFFF00);
77
169
    
78
 
#if 0
79
 
    g_print ("copying from %lx to %lx\n", src->xid, dest->xid);
80
 
#endif
81
 
    
82
170
    XFillRectangle (xdisplay, WS_RESOURCE_XID (dest), gc, 0, 0, width, height);
83
171
    
84
172
    XCopyArea (xdisplay,
169
257
WsScreen *
170
258
ws_drawable_query_screen (WsDrawable *drawable)
171
259
{
172
 
    int i;
173
 
    Screen *xscreen = drawable_get_xscreen (drawable);
 
260
    g_return_val_if_fail (WS_IS_DRAWABLE (drawable), NULL);
174
261
    
175
 
    for (i = 0; i < WS_RESOURCE (drawable)->display->n_screens; ++i)
 
262
    if (!drawable->screen)
176
263
    {
177
 
        if (WS_RESOURCE (drawable)->display->screens[i]->xscreen == xscreen)
178
 
            return WS_RESOURCE (drawable)->display->screens[i];
 
264
        int i;
 
265
        Screen *xscreen;
 
266
        WsDisplay *display;
 
267
        
 
268
        display = WS_RESOURCE (drawable)->display;
 
269
        xscreen = drawable_get_xscreen (drawable);
 
270
        
 
271
        for (i = 0; i < WS_RESOURCE (drawable)->display->n_screens; ++i)
 
272
        {
 
273
            if (display->screens[i]->xscreen == xscreen)
 
274
                drawable->screen = display->screens[i];
 
275
        }
179
276
    }
180
277
    
181
 
    return NULL;
 
278
    return drawable->screen;
182
279
}
183
280
 
184
281
gboolean