]>
Dogcows Code - chaz/openbox/blob - 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 "parser/parse.h"
10 static gboolean history
;
12 static void parse_xml(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
16 node
= node
->xmlChildrenNode
;
17 if ((n
= parse_find_node("remember", node
)))
18 history
= parse_bool(doc
, n
);
21 void plugin_setup_config()
25 parse_register("placement", parse_xml
, NULL
);
28 static void place_random(ObClient
*c
)
34 if (ob_state() == OB_STATE_STARTING
) return;
36 area
= screen_area_monitor(c
->desktop
,
37 g_random_int_range(0, screen_num_monitors
));
41 r
= area
->x
+ area
->width
- c
->frame
->area
.width
;
42 b
= area
->y
+ area
->height
- c
->frame
->area
.height
;
44 if (r
> l
) x
= g_random_int_range(l
, r
+ 1);
46 if (b
> t
) y
= g_random_int_range(t
, b
+ 1);
49 frame_frame_gravity(c
->frame
, &x
, &y
); /* get where the client should be */
50 client_configure(c
, OB_CORNER_TOPLEFT
, x
, y
, c
->area
.width
, c
->area
.height
,
54 static void event(ObEvent
*e
, void *foo
)
56 g_assert(e
->type
== Event_Client_New
);
58 /* requested a position */
59 if (e
->data
.c
.client
->positioned
) return;
61 if (!history
|| !place_history(e
->data
.c
.client
))
62 place_random(e
->data
.c
.client
);
67 dispatch_register(Event_Client_New
, (EventHandler
)event
, NULL
);
72 void plugin_shutdown()
74 dispatch_register(0, (EventHandler
)event
, NULL
);
This page took 0.034778 seconds and 4 git commands to generate.