X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=plugins%2Fplacement%2Fplacement.c;h=23ffbb5d9a47929b6280df8c3030f9e130c8da4e;hb=185d1337e553283530e23b1edff3bb709f04e9bb;hp=a6dbd868dd8772656021567afcab84d70e4676cb;hpb=1f8f4ffef56c7a43c763638975517ce0e6175d74;p=chaz%2Fopenbox diff --git a/plugins/placement/placement.c b/plugins/placement/placement.c index a6dbd868..23ffbb5d 100644 --- a/plugins/placement/placement.c +++ b/plugins/placement/placement.c @@ -1,19 +1,41 @@ -#include "../../kernel/dispatch.h" -#include "../../kernel/client.h" -#include "../../kernel/frame.h" -#include "../../kernel/screen.h" -#include "../../kernel/openbox.h" +#include "kernel/dispatch.h" +#include "kernel/client.h" +#include "kernel/frame.h" +#include "kernel/screen.h" +#include "kernel/openbox.h" +#include "kernel/parse.h" #include "history.h" #include -gboolean history = TRUE; +static gboolean history; -void place_random(Client *c) +static void parse_assign(char *name, ParseToken *value) +{ + if (!g_ascii_strcasecmp(name, "remember")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else + history = value->data.bool; + } else + yyerror("invalid option"); + parse_free_token(value); +} + +void plugin_setup_config() +{ + history = TRUE; + + parse_reg_section("placement", NULL, parse_assign); +} + +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; @@ -31,26 +53,27 @@ void place_random(Client *c) TRUE, TRUE); } -void place_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; - if (!place_history(e->data.c.client)) + if (!history || !place_history(e->data.c.client)) place_random(e->data.c.client); } void plugin_startup() { - dispatch_register(Event_Client_New, (EventHandler)place_event, NULL); + dispatch_register(Event_Client_New, (EventHandler)event, NULL); history_startup(); } void plugin_shutdown() { - dispatch_register(0, (EventHandler)place_event, NULL); + dispatch_register(0, (EventHandler)event, NULL); history_shutdown(); }