~dbarth/compiz/reworked-fix-744104

« back to all changes in this revision

Viewing changes to unity/unity_window_decorator/src/decorprops.c

  • Committer: David Barth
  • Date: 2011-04-05 20:20:54 UTC
  • Revision ID: david.barth@canonical.com-20110405202054-fnh0y5t2s228mf4k
re-integrate the unity-window-decorator, for real this time

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "gtk-window-decorator.h"
 
2
 
 
3
void
 
4
decor_update_window_property (decor_t *d)
 
5
{
 
6
    long            data[256];
 
7
    Display         *xdisplay =
 
8
        GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
 
9
    decor_extents_t extents = _win_extents;
 
10
    gint            nQuad;
 
11
    decor_quad_t    quads[N_QUADS_MAX];
 
12
    int             w, h;
 
13
    gint            stretch_offset;
 
14
    REGION          top, bottom, left, right;
 
15
 
 
16
    w = d->border_layout.top.x2 - d->border_layout.top.x1 -
 
17
        d->context->left_space - d->context->right_space;
 
18
 
 
19
    if (d->border_layout.rotation)
 
20
        h = d->border_layout.left.x2 - d->border_layout.left.x1;
 
21
    else
 
22
        h = d->border_layout.left.y2 - d->border_layout.left.y1;
 
23
 
 
24
    stretch_offset = w - d->button_width - 1;
 
25
 
 
26
    nQuad = decor_set_lSrStXbS_window_quads (quads, d->context,
 
27
                                             &d->border_layout,
 
28
                                             stretch_offset);
 
29
 
 
30
    extents.top += titlebar_height;
 
31
 
 
32
    if (d->frame_window)
 
33
    {
 
34
        decor_gen_window_property (data, &extents, &extents, 20, 20);
 
35
    }
 
36
    else
 
37
    {
 
38
        decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap),
 
39
                             &extents, &extents, &extents, &extents,
 
40
                             ICON_SPACE + d->button_width,
 
41
                             0,
 
42
                             quads, nQuad);
 
43
    }
 
44
 
 
45
    gdk_error_trap_push ();
 
46
    XChangeProperty (xdisplay, d->prop_xid,
 
47
                     win_decor_atom,
 
48
                     XA_INTEGER,
 
49
                     32, PropModeReplace, (guchar *) data,
 
50
                     BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad);
 
51
    gdk_display_sync (gdk_display_get_default ());
 
52
    gdk_error_trap_pop ();
 
53
 
 
54
    top.rects = &top.extents;
 
55
    top.numRects = top.size = 1;
 
56
 
 
57
    top.extents.x1 = -extents.left;
 
58
    top.extents.y1 = -extents.top;
 
59
    top.extents.x2 = w + extents.right;
 
60
    top.extents.y2 = 0;
 
61
 
 
62
    bottom.rects = &bottom.extents;
 
63
    bottom.numRects = bottom.size = 1;
 
64
 
 
65
    bottom.extents.x1 = -extents.left;
 
66
    bottom.extents.y1 = 0;
 
67
    bottom.extents.x2 = w + extents.right;
 
68
    bottom.extents.y2 = extents.bottom;
 
69
 
 
70
    left.rects = &left.extents;
 
71
    left.numRects = left.size = 1;
 
72
 
 
73
    left.extents.x1 = -extents.left;
 
74
    left.extents.y1 = 0;
 
75
    left.extents.x2 = 0;
 
76
    left.extents.y2 = h;
 
77
 
 
78
    right.rects = &right.extents;
 
79
    right.numRects = right.size = 1;
 
80
 
 
81
    right.extents.x1 = 0;
 
82
    right.extents.y1 = 0;
 
83
    right.extents.x2 = extents.right;
 
84
    right.extents.y2 = h;
 
85
 
 
86
    decor_update_blur_property (d,
 
87
                                w, h,
 
88
                                &top, stretch_offset,
 
89
                                &bottom, w / 2,
 
90
                                &left, h / 2,
 
91
                                &right, h / 2);
 
92
}
 
93
 
 
94
void
 
95
decor_update_switcher_property (decor_t *d)
 
96
{
 
97
    long         data[256];
 
98
    Display      *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
 
99
    gint         nQuad;
 
100
    decor_quad_t quads[N_QUADS_MAX];
 
101
    GtkStyle     *style;
 
102
    long         fgColor[4];
 
103
    
 
104
    nQuad = decor_set_lSrStSbX_window_quads (quads, &switcher_context,
 
105
                                             &d->border_layout,
 
106
                                             d->border_layout.top.x2 -
 
107
                                             d->border_layout.top.x1 -
 
108
                                             switcher_context.extents.left -
 
109
                                                 switcher_context.extents.right -
 
110
                                                     32);
 
111
    
 
112
    decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap),
 
113
                             &_switcher_extents, &_switcher_extents,
 
114
                             &_switcher_extents, &_switcher_extents,
 
115
                             0, 0, quads, nQuad);
 
116
    
 
117
    style = gtk_widget_get_style (style_window_rgba);
 
118
    
 
119
    fgColor[0] = style->fg[GTK_STATE_NORMAL].red;
 
120
    fgColor[1] = style->fg[GTK_STATE_NORMAL].green;
 
121
    fgColor[2] = style->fg[GTK_STATE_NORMAL].blue;
 
122
    fgColor[3] = SWITCHER_ALPHA;
 
123
    
 
124
    gdk_error_trap_push ();
 
125
    XChangeProperty (xdisplay, d->prop_xid,
 
126
                     win_decor_atom,
 
127
                     XA_INTEGER,
 
128
                     32, PropModeReplace, (guchar *) data,
 
129
                     BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad);
 
130
    XChangeProperty (xdisplay, d->prop_xid, switcher_fg_atom,
 
131
                     XA_INTEGER, 32, PropModeReplace, (guchar *) fgColor, 4);
 
132
    gdk_display_sync (gdk_display_get_default ());
 
133
    gdk_error_trap_pop ();
 
134
    
 
135
}