all repos — openbox @ 0327c5a77894a9a8a325631c9e18fa223e5406d0

openbox fork - make it a bit more like ryudo

engines/openbox/obrender.c (raw)

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
#include "obengine.h"
#include "../../kernel/openbox.h"
#include "../../kernel/screen.h"

static void obrender_label(ObFrame *self, Appearance *a);
static void obrender_max(ObFrame *self, Appearance *a);
static void obrender_icon(ObFrame *self, Appearance *a);
static void obrender_iconify(ObFrame *self, Appearance *a);
static void obrender_desk(ObFrame *self, Appearance *a);
static void obrender_close(ObFrame *self, Appearance *a);

void obrender_frame(ObFrame *self)
{
    if (client_focused(self->frame.client)) {
        XSetWindowBorder(ob_display, self->frame.plate,
                         ob_s_cb_focused_color->pixel);
    } else {
        XSetWindowBorder(ob_display, self->frame.plate,
                         ob_s_cb_unfocused_color->pixel);
    }

    if (self->frame.client->decorations & Decor_Titlebar) {
        Appearance *t, *l, *m, *n, *i, *d, *c;

        t = (client_focused(self->frame.client) ?
             self->a_focused_title : self->a_unfocused_title);
        l = (client_focused(self->frame.client) ?
             self->a_focused_label : self->a_unfocused_label);
        m = (client_focused(self->frame.client) ?
             ((self->max_press ||
              self->frame.client->max_vert || self->frame.client->max_horz) ?
              ob_a_focused_pressed_max : ob_a_focused_unpressed_max) :
             ((self->max_press ||
              self->frame.client->max_vert || self->frame.client->max_horz) ?
              ob_a_unfocused_pressed_max : ob_a_unfocused_unpressed_max));
        n = self->a_icon;
        i = (client_focused(self->frame.client) ?
             (self->iconify_press ?
              ob_a_focused_pressed_iconify : ob_a_focused_unpressed_iconify) :
             (self->iconify_press ?
              ob_a_unfocused_pressed_iconify :
              ob_a_unfocused_unpressed_iconify));
        d = (client_focused(self->frame.client) ?
             (self->desk_press || self->frame.client->desktop == DESKTOP_ALL ?
              ob_a_focused_pressed_desk : ob_a_focused_unpressed_desk) :
             (self->desk_press || self->frame.client->desktop == DESKTOP_ALL ?
              ob_a_unfocused_pressed_desk : ob_a_unfocused_unpressed_desk));
        c = (client_focused(self->frame.client) ?
             (self->close_press ?
              ob_a_focused_pressed_close : ob_a_focused_unpressed_close) :
             (self->close_press ?
              ob_a_unfocused_pressed_close : ob_a_unfocused_unpressed_close));

        paint(self->title, t);

        /* set parents for any parent relative guys */
        l->surface.data.planar.parent = t;
        l->surface.data.planar.parentx = self->label_x;
        l->surface.data.planar.parenty = ob_s_bevel;

        m->surface.data.planar.parent = t;
        m->surface.data.planar.parentx = self->max_x;
        m->surface.data.planar.parenty = ob_s_bevel + 1;

        n->surface.data.planar.parent = t;
        n->surface.data.planar.parentx = self->icon_x;
        n->surface.data.planar.parenty = ob_s_bevel + 1;

        i->surface.data.planar.parent = t;
        i->surface.data.planar.parentx = self->iconify_x;
        i->surface.data.planar.parenty = ob_s_bevel + 1;

        d->surface.data.planar.parent = t;
        d->surface.data.planar.parentx = self->desk_x;
        d->surface.data.planar.parenty = ob_s_bevel + 1;

        c->surface.data.planar.parent = t;
        c->surface.data.planar.parentx = self->close_x;
        c->surface.data.planar.parenty = ob_s_bevel + 1;

        obrender_label(self, l);
        obrender_max(self, m);
        obrender_icon(self, n);
        obrender_iconify(self, i);
        obrender_desk(self, d);
        obrender_close(self, c);
    }

    if (self->frame.client->decorations & Decor_Handle) {
        Appearance *h, *g;

        h = (client_focused(self->frame.client) ?
             self->a_focused_handle : self->a_unfocused_handle);
        g = (client_focused(self->frame.client) ?
             ob_a_focused_grip : ob_a_unfocused_grip);

        if (g->surface.data.planar.grad == Background_ParentRelative) {
            g->surface.data.planar.parent = h;
            paint(self->handle, h);
        } else
            paint(self->handle, h);

        g->surface.data.planar.parentx = 0;
        g->surface.data.planar.parenty = 0;

        paint(self->lgrip, g);

        g->surface.data.planar.parentx = self->width - GRIP_WIDTH;
        g->surface.data.planar.parenty = 0;

        paint(self->rgrip, g);
    }
}

static void obrender_label(ObFrame *self, Appearance *a)
{
    if (self->label_x < 0) return;


    /* set the texture's text! */
    a->texture[0].data.text.string = self->frame.client->title;
    RECT_SET(a->texture[0].position, 0, 0, self->label_width, LABEL_HEIGHT);

    paint(self->label, a);
}

static void obrender_icon(ObFrame *self, Appearance *a)
{
    if (self->icon_x < 0) return;

    if (self->frame.client->nicons) {
        Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE);
        a->texture[0].type = RGBA;
        a->texture[0].data.rgba.width = icon->width;
        a->texture[0].data.rgba.height = icon->height;
        a->texture[0].data.rgba.data = icon->data;
        RECT_SET(self->a_icon->texture[0].position, 0, 0,
                 BUTTON_SIZE,BUTTON_SIZE);
    } else
        a->texture[0].type = NoTexture;

    paint(self->icon, a);
}

static void obrender_max(ObFrame *self, Appearance *a)
{
    if (self->max_x < 0) return;

    RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
    paint(self->max, a);
}

static void obrender_iconify(ObFrame *self, Appearance *a)
{
    if (self->iconify_x < 0) return;

    RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
    paint(self->iconify, a);
}

static void obrender_desk(ObFrame *self, Appearance *a)
{
    if (self->desk_x < 0) return;

    RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
    paint(self->desk, a);
}

static void obrender_close(ObFrame *self, Appearance *a)
{
    if (self->close_x < 0) return;

    RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
    paint(self->close, a);
}