use the client's size instead of the frames size so the real size is used, not the...
[dana/openbox.git] / engines / openbox / obrender.c
1 #include "obengine.h"
2 #include "../../kernel/openbox.h"
3 #include "../../kernel/screen.h"
4
5 static void obrender_label(ObFrame *self, Appearance *a);
6 static void obrender_max(ObFrame *self, Appearance *a);
7 static void obrender_icon(ObFrame *self, Appearance *a);
8 static void obrender_iconify(ObFrame *self, Appearance *a);
9 static void obrender_desk(ObFrame *self, Appearance *a);
10 static void obrender_close(ObFrame *self, Appearance *a);
11
12 void obrender_frame(ObFrame *self)
13 {
14     if (client_focused(self->frame.client)) {
15         XSetWindowBorder(ob_display, self->frame.plate,
16                          ob_s_cb_focused_color->pixel);
17     } else {
18         XSetWindowBorder(ob_display, self->frame.plate,
19                          ob_s_cb_unfocused_color->pixel);
20     }
21
22     if (self->frame.client->decorations & Decor_Titlebar) {
23         Appearance *t, *l, *m, *n, *i, *d, *c;
24
25         t = (client_focused(self->frame.client) ?
26              self->a_focused_title : self->a_unfocused_title);
27         l = (client_focused(self->frame.client) ?
28              self->a_focused_label : self->a_unfocused_label);
29         m = (client_focused(self->frame.client) ?
30              (self->frame.client->max_vert || self->frame.client->max_horz ?
31               ob_a_focused_pressed_set_max :
32               (self->max_press ?
33                ob_a_focused_pressed_max : ob_a_focused_unpressed_max)) :
34              (self->frame.client->max_vert || self->frame.client->max_horz ?
35               ob_a_unfocused_pressed_set_max :
36               (self->max_press ?
37                ob_a_unfocused_pressed_max : ob_a_unfocused_unpressed_max)));
38         n = self->a_icon;
39         i = (client_focused(self->frame.client) ?
40              (self->iconify_press ?
41               ob_a_focused_pressed_iconify : ob_a_focused_unpressed_iconify) :
42              (self->iconify_press ?
43               ob_a_unfocused_pressed_iconify :
44               ob_a_unfocused_unpressed_iconify));
45         d = (client_focused(self->frame.client) ?
46              (self->frame.client->desktop == DESKTOP_ALL ?
47               ob_a_focused_pressed_set_desk :
48               (self->desk_press ?
49                ob_a_focused_pressed_desk : ob_a_focused_unpressed_desk)) :
50              (self->frame.client->desktop == DESKTOP_ALL ?
51               ob_a_unfocused_pressed_set_desk :
52               (self->desk_press ?
53                ob_a_unfocused_pressed_desk : ob_a_unfocused_unpressed_desk)));
54         c = (client_focused(self->frame.client) ?
55              (self->close_press ?
56               ob_a_focused_pressed_close : ob_a_focused_unpressed_close) :
57              (self->close_press ?
58               ob_a_unfocused_pressed_close : ob_a_unfocused_unpressed_close));
59
60         paint(self->title, t);
61
62         /* set parents for any parent relative guys */
63         l->surface.data.planar.parent = t;
64         l->surface.data.planar.parentx = self->label_x;
65         l->surface.data.planar.parenty = ob_s_bevel;
66
67         m->surface.data.planar.parent = t;
68         m->surface.data.planar.parentx = self->max_x;
69         m->surface.data.planar.parenty = ob_s_bevel + 1;
70
71         n->surface.data.planar.parent = t;
72         n->surface.data.planar.parentx = self->icon_x;
73         n->surface.data.planar.parenty = ob_s_bevel + 1;
74
75         i->surface.data.planar.parent = t;
76         i->surface.data.planar.parentx = self->iconify_x;
77         i->surface.data.planar.parenty = ob_s_bevel + 1;
78
79         d->surface.data.planar.parent = t;
80         d->surface.data.planar.parentx = self->desk_x;
81         d->surface.data.planar.parenty = ob_s_bevel + 1;
82
83         c->surface.data.planar.parent = t;
84         c->surface.data.planar.parentx = self->close_x;
85         c->surface.data.planar.parenty = ob_s_bevel + 1;
86
87         obrender_label(self, l);
88         obrender_max(self, m);
89         obrender_icon(self, n);
90         obrender_iconify(self, i);
91         obrender_desk(self, d);
92         obrender_close(self, c);
93     }
94
95     if (self->frame.client->decorations & Decor_Handle) {
96         Appearance *h, *g;
97
98         h = (client_focused(self->frame.client) ?
99              self->a_focused_handle : self->a_unfocused_handle);
100         g = (client_focused(self->frame.client) ?
101              ob_a_focused_grip : ob_a_unfocused_grip);
102
103         if (g->surface.data.planar.grad == Background_ParentRelative) {
104             g->surface.data.planar.parent = h;
105             paint(self->handle, h);
106         } else
107             paint(self->handle, h);
108
109         g->surface.data.planar.parentx = 0;
110         g->surface.data.planar.parenty = 0;
111
112         paint(self->lgrip, g);
113
114         g->surface.data.planar.parentx = self->width - GRIP_WIDTH;
115         g->surface.data.planar.parenty = 0;
116
117         paint(self->rgrip, g);
118     }
119 }
120
121 static void obrender_label(ObFrame *self, Appearance *a)
122 {
123     if (self->label_x < 0) return;
124
125
126     /* set the texture's text! */
127     a->texture[0].data.text.string = self->frame.client->title;
128     RECT_SET(a->texture[0].position, 0, 0, self->label_width, LABEL_HEIGHT);
129
130     paint(self->label, a);
131 }
132
133 static void obrender_icon(ObFrame *self, Appearance *a)
134 {
135     if (self->icon_x < 0) return;
136
137     if (self->frame.client->nicons) {
138         Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE);
139         a->texture[0].type = RGBA;
140         a->texture[0].data.rgba.width = icon->width;
141         a->texture[0].data.rgba.height = icon->height;
142         a->texture[0].data.rgba.data = icon->data;
143         RECT_SET(self->a_icon->texture[0].position, 0, 0,
144                  BUTTON_SIZE,BUTTON_SIZE);
145     } else
146         a->texture[0].type = NoTexture;
147
148     paint(self->icon, a);
149 }
150
151 static void obrender_max(ObFrame *self, Appearance *a)
152 {
153     if (self->max_x < 0) return;
154
155     RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
156     paint(self->max, a);
157 }
158
159 static void obrender_iconify(ObFrame *self, Appearance *a)
160 {
161     if (self->iconify_x < 0) return;
162
163     RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
164     paint(self->iconify, a);
165 }
166
167 static void obrender_desk(ObFrame *self, Appearance *a)
168 {
169     if (self->desk_x < 0) return;
170
171     RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
172     paint(self->desk, a);
173 }
174
175 static void obrender_close(ObFrame *self, Appearance *a)
176 {
177     if (self->close_x < 0) return;
178
179     RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
180     paint(self->close, a);
181 }