]> Dogcows Code - chaz/openbox/blob - openbox/frame.c
add functions to the engine interface for rendering and sizing a text label
[chaz/openbox] / openbox / frame.c
1 #include "frame.h"
2
3 Context frame_context_from_string(char *name)
4 {
5 if (!g_ascii_strcasecmp("root", name))
6 return Context_Root;
7 else if (!g_ascii_strcasecmp("client", name))
8 return Context_Client;
9 else if (!g_ascii_strcasecmp("titlebar", name))
10 return Context_Titlebar;
11 else if (!g_ascii_strcasecmp("handle", name))
12 return Context_Handle;
13 else if (!g_ascii_strcasecmp("frame", name))
14 return Context_Frame;
15 else if (!g_ascii_strcasecmp("blcorner", name))
16 return Context_BLCorner;
17 else if (!g_ascii_strcasecmp("tlcorner", name))
18 return Context_TLCorner;
19 else if (!g_ascii_strcasecmp("brcorner", name))
20 return Context_BRCorner;
21 else if (!g_ascii_strcasecmp("trcorner", name))
22 return Context_TRCorner;
23 else if (!g_ascii_strcasecmp("maximize", name))
24 return Context_Maximize;
25 else if (!g_ascii_strcasecmp("alldesktops", name))
26 return Context_AllDesktops;
27 else if (!g_ascii_strcasecmp("shade", name))
28 return Context_Shade;
29 else if (!g_ascii_strcasecmp("iconify", name))
30 return Context_Iconify;
31 else if (!g_ascii_strcasecmp("icon", name))
32 return Context_Icon;
33 else if (!g_ascii_strcasecmp("close", name))
34 return Context_Close;
35 return Context_None;
36 }
37
38 void frame_client_gravity(Frame *self, int *x, int *y)
39 {
40 /* horizontal */
41 switch (self->client->gravity) {
42 default:
43 case NorthWestGravity:
44 case SouthWestGravity:
45 case WestGravity:
46 break;
47
48 case NorthGravity:
49 case SouthGravity:
50 case CenterGravity:
51 *x -= (self->size.left + self->size.right) / 2;
52 break;
53
54 case NorthEastGravity:
55 case SouthEastGravity:
56 case EastGravity:
57 *x -= self->size.left + self->size.right;
58 break;
59
60 case ForgetGravity:
61 case StaticGravity:
62 *x -= self->size.left;
63 break;
64 }
65
66 /* vertical */
67 switch (self->client->gravity) {
68 default:
69 case NorthWestGravity:
70 case NorthEastGravity:
71 case NorthGravity:
72 break;
73
74 case CenterGravity:
75 case EastGravity:
76 case WestGravity:
77 *y -= (self->size.top + self->size.bottom) / 2;
78 break;
79
80 case SouthWestGravity:
81 case SouthEastGravity:
82 case SouthGravity:
83 *y -= self->size.top + self->size.bottom;
84 break;
85
86 case ForgetGravity:
87 case StaticGravity:
88 *y -= self->size.top;
89 break;
90 }
91 }
92
93 void frame_frame_gravity(Frame *self, int *x, int *y)
94 {
95 /* horizontal */
96 switch (self->client->gravity) {
97 default:
98 case NorthWestGravity:
99 case WestGravity:
100 case SouthWestGravity:
101 break;
102 case NorthGravity:
103 case CenterGravity:
104 case SouthGravity:
105 *x += (self->size.left + self->size.right) / 2;
106 break;
107 case NorthEastGravity:
108 case EastGravity:
109 case SouthEastGravity:
110 *x += self->size.left + self->size.right;
111 break;
112 case StaticGravity:
113 case ForgetGravity:
114 *x += self->size.left;
115 break;
116 }
117
118 /* vertical */
119 switch (self->client->gravity) {
120 default:
121 case NorthWestGravity:
122 case WestGravity:
123 case SouthWestGravity:
124 break;
125 case NorthGravity:
126 case CenterGravity:
127 case SouthGravity:
128 *y += (self->size.top + self->size.bottom) / 2;
129 break;
130 case NorthEastGravity:
131 case EastGravity:
132 case SouthEastGravity:
133 *y += self->size.top + self->size.bottom;
134 break;
135 case StaticGravity:
136 case ForgetGravity:
137 *y += self->size.top;
138 break;
139 }
140 }
This page took 0.040973 seconds and 4 git commands to generate.