X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=plugins%2Fplacement%2Fplacement.c;h=2627eb84358fd27fea6a808ddf22184cb970b168;hb=c3628a36eda55cb10545abd1e90365b23b6fbfa1;hp=f33e45de22e7cb8ce1dedc6f502612f794940a27;hpb=29e3748605eaf86635aed48273bddfdcdcae05c4;p=chaz%2Fopenbox diff --git a/plugins/placement/placement.c b/plugins/placement/placement.c index f33e45de..2627eb84 100644 --- a/plugins/placement/placement.c +++ b/plugins/placement/placement.c @@ -3,14 +3,19 @@ #include "../../kernel/frame.h" #include "../../kernel/screen.h" #include "../../kernel/openbox.h" +#include "history.h" #include -void place_random(Client *c) +gboolean history = TRUE; + +static void place_random(Client *c) { int l, r, t, b; int x, y; Rect *area; + if (ob_state == State_Starting) return; + area = screen_area(c->desktop); l = area->x; @@ -18,29 +23,37 @@ void place_random(Client *c) r = area->x + area->width - c->frame->area.width; b = area->y + area->height - c->frame->area.height; - x = g_random_int_range(l, r + 1); - y = g_random_int_range(t, b + 1); + if (r > l) x = g_random_int_range(l, r + 1); + else x = 0; + if (b > t) y = g_random_int_range(t, b + 1); + else y = 0; frame_frame_gravity(c->frame, &x, &y); /* get where the client should be */ client_configure(c, Corner_TopLeft, x, y, c->area.width, c->area.height, TRUE, TRUE); } -void event(ObEvent *e, void *foo) +static void event(ObEvent *e, void *foo) { g_assert(e->type == Event_Client_New); - if (ob_state == State_Starting) return; + /* requested a position */ + if (e->data.c.client->positioned) return; - place_random(e->data.c.client); + if (!place_history(e->data.c.client)) + place_random(e->data.c.client); } void plugin_startup() { dispatch_register(Event_Client_New, (EventHandler)event, NULL); + + history_startup(); } void plugin_shutdown() { dispatch_register(0, (EventHandler)event, NULL); + + history_shutdown(); }