]>
Dogcows Code - chaz/openbox/blob - 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/parse.h"
10 static gboolean history
;
12 static void parse_assign(char *name
, ParseToken
*value
)
14 if (!g_ascii_strcasecmp(name
, "remember")) {
15 if (value
->type
!= TOKEN_BOOL
)
16 yyerror("invalid value");
18 history
= value
->data
.bool;
20 yyerror("invalid option");
21 parse_free_token(value
);
24 void plugin_setup_config()
28 parse_reg_section("placement", NULL
, parse_assign
);
31 static void place_random(Client
*c
)
37 if (ob_state
== State_Starting
) return;
39 area
= screen_area(c
->desktop
);
43 r
= area
->x
+ area
->width
- c
->frame
->area
.width
;
44 b
= area
->y
+ area
->height
- c
->frame
->area
.height
;
46 if (r
> l
) x
= g_random_int_range(l
, r
+ 1);
48 if (b
> t
) y
= g_random_int_range(t
, b
+ 1);
51 frame_frame_gravity(c
->frame
, &x
, &y
); /* get where the client should be */
52 client_configure(c
, Corner_TopLeft
, x
, y
, c
->area
.width
, c
->area
.height
,
56 static void event(ObEvent
*e
, void *foo
)
58 g_assert(e
->type
== Event_Client_New
);
60 /* requested a position */
61 if (e
->data
.c
.client
->positioned
) return;
63 if (!history
|| !place_history(e
->data
.c
.client
))
64 place_random(e
->data
.c
.client
);
69 dispatch_register(Event_Client_New
, (EventHandler
)event
, NULL
);
74 void plugin_shutdown()
76 dispatch_register(0, (EventHandler
)event
, NULL
);
This page took 0.038444 seconds and 4 git commands to generate.