]> icculus.org git repositories - dana/openbox.git/blob - openbox/framerender.c
add some more font metrics api
[dana/openbox.git] / openbox / framerender.c
1 #include "frame.h"
2 #include "openbox.h"
3 #include "screen.h"
4 #include "framerender.h"
5 #include "render2/theme.h"
6
7 void framerender_frame(Frame *self)
8 {
9     /* XXX plate, client border */
10
11     if (self->client->decorations & Decor_Titlebar) {
12         struct RrSurface *t, *l, *m, *n, *i, *d, *s, *c;
13
14         t = (self->focused ?
15              ob_theme->title_f : ob_theme->title);
16         l = (self->focused ?
17              ob_theme->label_f : ob_theme->label);
18         m = (self->focused ?
19              (self->client->max_vert || self->client->max_horz ?
20               ob_theme->max_p_f : (self->max_press ?
21                                    ob_theme->max_p_f : ob_theme->max_f)) :
22              (self->client->max_vert || self->client->max_horz ?
23               ob_theme->max_p : (self->max_press ?
24                                  ob_theme->max_p : ob_theme->max)));
25         n = ob_theme->icon;
26         i = (self->focused ?
27              (self->iconify_press ?
28               ob_theme->iconify_p_f : ob_theme->iconify_f) :
29              (self->iconify_press ?
30               ob_theme->iconify_p : ob_theme->iconify));
31         d = (self->focused ?
32              (self->client->desktop == DESKTOP_ALL ?
33               ob_theme->desk_p_f : (self->desk_press ?
34                                     ob_theme->desk_p_f : ob_theme->desk_f)) :
35              (self->client->desktop == DESKTOP_ALL ?
36               ob_theme->desk_p : (self->desk_press ?
37                                   ob_theme->desk_p : ob_theme->desk)));
38         s = (self->focused ?
39              (self->client->shaded ?
40               ob_theme->shade_p_f : (self->shade_press ?
41                                      ob_theme->shade_p_f : ob_theme->shade_f)):
42              (self->client->shaded ?
43               ob_theme->shade_p : (self->shade_press ?
44                                    ob_theme->shade_p : ob_theme->shade)));
45         c = (self->focused ?
46              (self->close_press ?
47               ob_theme->close_p_f : ob_theme->close_f) :
48              (self->close_press ?
49               ob_theme->close_p : ob_theme->close));
50
51         RrSurfaceCopy(self->s_title, t);
52         RrSurfaceCopy(self->s_label, l);
53
54         RrTextureSetText(self->s_label, 0, ob_theme->title_font,
55                          ob_theme->title_justify,
56                          (self->focused ?
57                           &ob_theme->title_color_f : &ob_theme->title_color),
58                          self->client->title);
59
60         if (self->icon_x >= 0) {
61             Icon *icon;
62
63             RrSurfaceCopy(self->s_icon, n);
64
65             icon = client_icon(self->client,
66                              RrThemeButtonSize(ob_theme) + 2,
67                              RrThemeButtonSize(ob_theme) + 2);
68             if (icon)
69                 RrTextureSetRGBA(self->s_icon, 0,
70                                  icon->data,
71                                  0, 0, icon->width, icon->height);
72             else
73                 RrTextureSetNone(self->s_icon, 0);
74         }
75         if (self->iconify_x >= 0)
76             RrSurfaceCopy(self->s_iconify, i);
77         if (self->desk_x >= 0)
78             RrSurfaceCopy(self->s_desk, d);
79         if (self->shade_x >= 0)
80             RrSurfaceCopy(self->s_shade, s);
81         if (self->close_x >= 0)
82             RrSurfaceCopy(self->s_close, c);
83     }
84
85     if (self->client->decorations & Decor_Handle) {
86         struct RrSurface *h, *g;
87
88         h = (self->focused ?
89              ob_theme->handle_f : ob_theme->handle);
90         g = (self->focused ?
91              ob_theme->grip_f : ob_theme->grip);
92
93         RrSurfaceCopy(self->s_handle, h);
94         RrSurfaceCopy(self->s_lgrip, g);
95         RrSurfaceCopy(self->s_rgrip, g);
96     }
97     /* XXX this could be more efficient */
98     RrPaint(self->s_frame);
99 }