]>
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 "../../kernel/config.h"
10 gboolean history
= TRUE
;
12 void plugin_setup_config()
16 config_def_set(config_def_new("placement.remember", Config_Bool
,
17 "Remember Window Positions",
18 "Place windows where they last were "
21 config_set("placement.remember", Config_Bool
, val
);
24 static void place_random(Client
*c
)
30 if (ob_state
== State_Starting
) return;
32 area
= screen_area(c
->desktop
);
36 r
= area
->x
+ area
->width
- c
->frame
->area
.width
;
37 b
= area
->y
+ area
->height
- c
->frame
->area
.height
;
39 if (r
> l
) x
= g_random_int_range(l
, r
+ 1);
41 if (b
> t
) y
= g_random_int_range(t
, b
+ 1);
44 frame_frame_gravity(c
->frame
, &x
, &y
); /* get where the client should be */
45 client_configure(c
, Corner_TopLeft
, x
, y
, c
->area
.width
, c
->area
.height
,
49 static void event(ObEvent
*e
, void *foo
)
53 g_assert(e
->type
== Event_Client_New
);
55 /* requested a position */
56 if (e
->data
.c
.client
->positioned
) return;
58 if (!config_get("placement.remember", Config_Bool
, &remember
))
59 g_assert_not_reached();
61 if (!remember
.bool || !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.035038 seconds and 4 git commands to generate.