]> Dogcows Code - chaz/openbox/blob - plugins/placement/placement.c
rename event() to place_event()
[chaz/openbox] / plugins / placement / placement.c
1 #include "../../kernel/dispatch.h"
2 #include "../../kernel/client.h"
3 #include "../../kernel/frame.h"
4 #include "../../kernel/screen.h"
5 #include "../../kernel/openbox.h"
6 #include "history.h"
7 #include <glib.h>
8
9 gboolean history = TRUE;
10
11 void place_random(Client *c)
12 {
13 int l, r, t, b;
14 int x, y;
15 Rect *area;
16
17 area = screen_area(c->desktop);
18
19 l = area->x;
20 t = area->y;
21 r = area->x + area->width - c->frame->area.width;
22 b = area->y + area->height - c->frame->area.height;
23
24 if (r > l) x = g_random_int_range(l, r + 1);
25 else x = 0;
26 if (b > t) y = g_random_int_range(t, b + 1);
27 else y = 0;
28
29 frame_frame_gravity(c->frame, &x, &y); /* get where the client should be */
30 client_configure(c, Corner_TopLeft, x, y, c->area.width, c->area.height,
31 TRUE, TRUE);
32 }
33
34 void place_event(ObEvent *e, void *foo)
35 {
36 g_assert(e->type == Event_Client_New);
37
38 if (ob_state == State_Starting) return;
39
40 if (!place_history(e->data.c.client))
41 place_random(e->data.c.client);
42 }
43
44 void plugin_startup()
45 {
46 dispatch_register(Event_Client_New, (EventHandler)place_event, NULL);
47
48 history_startup();
49 }
50
51 void plugin_shutdown()
52 {
53 dispatch_register(0, (EventHandler)place_event, NULL);
54
55 history_shutdown();
56 }
This page took 0.04009 seconds and 5 git commands to generate.