merge the C branch into HEAD
[mikachu/openbox.git] / openbox / frame.c
1 #include "frame.h"
2
3 void frame_client_gravity(Frame *self, int *x, int *y)
4 {
5     /* horizontal */
6     switch (self->client->gravity) {
7     default:
8     case NorthWestGravity:
9     case SouthWestGravity:
10     case WestGravity:
11         break;
12
13     case NorthGravity:
14     case SouthGravity:
15     case CenterGravity:
16         *x -= (self->size.left + self->size.right) / 2;
17         break;
18
19     case NorthEastGravity:
20     case SouthEastGravity:
21     case EastGravity:
22         *x -= self->size.left + self->size.right;
23         break;
24
25     case ForgetGravity:
26     case StaticGravity:
27         *x -= self->size.left;
28         break;
29     }
30
31     /* vertical */
32     switch (self->client->gravity) {
33     default:
34     case NorthWestGravity:
35     case NorthEastGravity:
36     case NorthGravity:
37         break;
38
39     case CenterGravity:
40     case EastGravity:
41     case WestGravity:
42         *y -= (self->size.top + self->size.bottom) / 2;
43         break;
44
45     case SouthWestGravity:
46     case SouthEastGravity:
47     case SouthGravity:
48         *y -= self->size.top + self->size.bottom;
49         break;
50
51     case ForgetGravity:
52     case StaticGravity:
53         *y -= self->size.top;
54         break;
55     }
56 }
57
58 void frame_frame_gravity(Frame *self, int *x, int *y)
59 {
60     /* horizontal */
61     switch (self->client->gravity) {
62     default:
63     case NorthWestGravity:
64     case WestGravity:
65     case SouthWestGravity:
66         break;
67     case NorthGravity:
68     case CenterGravity:
69     case SouthGravity:
70         *x += (self->size.left + self->size.right) / 2;
71         break;
72     case NorthEastGravity:
73     case EastGravity:
74     case SouthEastGravity:
75         *x += self->size.left + self->size.right;
76         break;
77     case StaticGravity:
78     case ForgetGravity:
79         x += self->size.left;
80         break;
81     }
82
83     /* vertical */
84     switch (self->client->gravity) {
85     default:
86     case NorthWestGravity:
87     case WestGravity:
88     case SouthWestGravity:
89         break;
90     case NorthGravity:
91     case CenterGravity:
92     case SouthGravity:
93         *y += (self->size.top + self->size.bottom) / 2;
94         break;
95     case NorthEastGravity:
96     case EastGravity:
97     case SouthEastGravity:
98         *y += self->size.top + self->size.bottom;
99         break;
100     case StaticGravity:
101     case ForgetGravity:
102         *y += self->size.top;
103         break;
104     }
105 }