]> Dogcows Code - chaz/openbox/commitdiff
remove the placement plugin
authorDana Jansens <danakj@orodu.net>
Fri, 29 Aug 2003 06:55:02 +0000 (06:55 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 29 Aug 2003 06:55:02 +0000 (06:55 +0000)
plugins/placement/.cvsignore [deleted file]
plugins/placement/Makefile [deleted file]
plugins/placement/history.c [deleted file]
plugins/placement/history.h [deleted file]
plugins/placement/placement.c [deleted file]

diff --git a/plugins/placement/.cvsignore b/plugins/placement/.cvsignore
deleted file mode 100644 (file)
index 991f13f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-placement.la
-.libs
-.deps
-.dirstamp
-plugins_placement_placement_la-history.lo
-plugins_placement_placement_la-placement.lo
diff --git a/plugins/placement/Makefile b/plugins/placement/Makefile
deleted file mode 100644 (file)
index cfc4653..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-all clean install:
-       $(MAKE) -C ../.. -$(MAKEFLAGS) $@
-
-.PHONY: all clean install
diff --git a/plugins/placement/history.c b/plugins/placement/history.c
deleted file mode 100644 (file)
index 7203fe1..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-#include "kernel/debug.h"
-#include "kernel/openbox.h"
-#include "kernel/dispatch.h"
-#include "kernel/frame.h"
-#include "kernel/client.h"
-#include "kernel/screen.h"
-#include "parser/parse.h"
-#include "history.h"
-#include <glib.h>
-#include <string.h>
-#ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-#endif
-
-#define PLACED        (1 << 0)
-
-#define HAVE_POSITION (1 << 1)
-#define HAVE_SIZE     (1 << 2)
-#define HAVE_DESKTOP  (1 << 3)
-
-struct HistoryItem {
-    char *name;
-    char *class;
-    char *role;
-
-    int flags;
-
-    int x, y;
-    int w, h;
-    guint desk;
-};
-
-static GSList *history_list = NULL;
-static char *history_path = NULL;
-
-static struct HistoryItem *history_find(const char *name, const char *class,
-                                 const char *role)
-{
-    GSList *it;
-    struct HistoryItem *hi = NULL;
-
-    /* find the client */
-    for (it = history_list; it != NULL; it = it->next) {
-        hi = it->data;
-        if (!strcmp(hi->name, name) &&
-            !strcmp(hi->class, class) &&
-            !strcmp(hi->role, role))
-            return hi;
-    }
-    return NULL;
-}
-
-gboolean place_history(ObClient *c)
-{
-    struct HistoryItem *hi;
-    int x, y, w, h;
-
-    hi = history_find(c->name, c->class, c->role);
-
-    if (hi && !(hi->flags & PLACED)) {
-        hi->flags |= PLACED;
-        if (ob_state() != OB_STATE_STARTING) {
-            if (hi->flags & HAVE_POSITION ||
-                hi->flags & HAVE_SIZE) {
-                if (hi->flags & HAVE_POSITION) {
-                    x = hi->x;
-                    y = hi->y;
-                    /* get where the client should be */
-                    frame_frame_gravity(c->frame, &x, &y);
-                } else {
-                    x = c->area.x;
-                    y = c->area.y;
-                }
-                if (hi->flags & HAVE_SIZE) {
-                    w = hi->w * c->size_inc.width;
-                    h = hi->h * c->size_inc.height;
-                } else {
-                    w = c->area.width;
-                    h = c->area.height;
-                }
-                client_configure(c, OB_CORNER_TOPLEFT, x, y, w, h,
-                                 TRUE, TRUE);
-            }
-            if (hi->flags & HAVE_DESKTOP) {
-                client_set_desktop(c, hi->desk, FALSE);
-            }
-        }
-        return hi->flags & HAVE_POSITION;
-    }
-
-    return FALSE;
-}
-
-static void set_history(ObClient *c)
-{
-    struct HistoryItem *hi;
-
-    hi = history_find(c->name, c->class, c->role);
-
-    if (hi == NULL) {
-        hi = g_new(struct HistoryItem, 1);
-        history_list = g_slist_append(history_list, hi);
-        hi->name = g_strdup(c->name);
-        hi->class = g_strdup(c->class);
-        hi->role = g_strdup(c->role);
-        hi->flags = HAVE_POSITION;
-    }
-
-    if (hi->flags & HAVE_POSITION) {
-        hi->x = c->frame->area.x;
-        hi->y = c->frame->area.y;
-    }
-
-    hi->flags &= ~PLACED;
-}
-
-static void event(ObEvent *e, void *foo)
-{
-    g_assert(e->type == Event_Client_Destroy);
-
-    set_history(e->data.c.client);
-}
-
-/*
-
-<entry name="name" class="class" role="role">
-  <x>0</x>
-  <y>0</y>
-  <width>300</width>
-  <height>200</height>
-  <desktop>1</desktop>
-</entry>
-
-*/
-
-static void save_history()
-{
-    xmlDocPtr doc;
-    xmlNodePtr root, node;
-    char *s;
-    GSList *it;
-
-    doc = xmlNewDoc(NULL);
-    root = xmlNewNode(NULL, (const xmlChar*) "openbox_history");
-    xmlDocSetRootElement(doc, root);
-
-    for (it = history_list; it; it = g_slist_next(it)) {
-        struct HistoryItem *hi = it->data;
-        ob_debug("adding %s\n", hi->name);
-        node = xmlNewChild(root, NULL, (const xmlChar*) "entry", NULL);
-        xmlNewProp(node, (const xmlChar*) "name", (const xmlChar*) hi->name);
-        xmlNewProp(node, (const xmlChar*) "class", (const xmlChar*) hi->class);
-        xmlNewProp(node, (const xmlChar*) "role", (const xmlChar*) hi->role);
-        if (hi->flags & HAVE_POSITION) {
-            s = g_strdup_printf("%d", hi->x);
-            xmlNewTextChild(node, NULL,
-                            (const xmlChar*) "x", (const xmlChar*) s);
-            g_free(s);
-            s = g_strdup_printf("%d", hi->y);
-            xmlNewTextChild(node, NULL,
-                            (const xmlChar*) "y", (const xmlChar*) s);
-            g_free(s);
-        }
-        if (hi->flags & HAVE_SIZE) {
-            s = g_strdup_printf("%d", hi->w);
-            xmlNewTextChild(node, NULL,
-                            (const xmlChar*) "width", (const xmlChar*) s);
-            g_free(s);
-            s = g_strdup_printf("%d", hi->h);
-            xmlNewTextChild(node, NULL,
-                            (const xmlChar*) "height", (const xmlChar*) s);
-            g_free(s);
-        }
-        if (hi->flags & HAVE_DESKTOP) {
-            s = g_strdup_printf("%d", hi->desk < 0 ? hi->desk : hi->desk + 1);
-            xmlNewTextChild(node, NULL,
-                            (const xmlChar*) "desktop", (const xmlChar*) s);
-            g_free(s);
-        }
-    }
-
-    xmlIndentTreeOutput = 1;
-    xmlSaveFormatFile(history_path, doc, 1);
-
-    xmlFreeDoc(doc);
-}
-
-static void load_history()
-{
-    xmlDocPtr doc;
-    xmlNodePtr node, n;
-    char *name;
-    char *class;
-    char *role;
-    struct HistoryItem *hi;
-
-    if (!parse_load(history_path, "openbox_history", &doc, &node))
-        return;
-
-    node = parse_find_node("entry", node->xmlChildrenNode);
-    while (node) {
-        name = class = role = NULL;
-        if (parse_attr_string("name", node, &name) &&
-            parse_attr_string("class", node, &class) &&
-            parse_attr_string("role", node, &role)) {
-
-            hi = history_find(name, class, role);
-            if (!hi) {
-                hi = g_new(struct HistoryItem, 1);
-                hi->name = g_strdup(name);
-                hi->class = g_strdup(class);
-                hi->role = g_strdup(role);
-                hi->flags = 0;
-            }
-            if ((n = parse_find_node("x", node->xmlChildrenNode))) {
-                hi->x = parse_int(doc, n);
-                if ((n = parse_find_node("y", node->xmlChildrenNode))) {
-                    hi->y = parse_int(doc, n);
-                    hi->flags |= HAVE_POSITION;
-                }
-            }
-            if ((n = parse_find_node("width", node->xmlChildrenNode))) {
-                hi->w = parse_int(doc, n);
-                if ((n = parse_find_node("height", node->xmlChildrenNode))) {
-                    hi->h = parse_int(doc, n);
-                    hi->flags |= HAVE_SIZE;
-                }
-            }
-            if ((n = parse_find_node("desktop", node->xmlChildrenNode))) {
-                hi->desk = parse_int(doc, n);
-                if (hi->desk > 0) --hi->desk;
-                hi->flags |= HAVE_DESKTOP;
-            }
-
-            history_list = g_slist_append(history_list, hi);
-        }
-        g_free(name); g_free(class); g_free(role);
-        node = parse_find_node("entry", node->next);
-    }
-    xmlFreeDoc(doc);
-}
-
-void history_startup()
-{
-    char *path;
-
-    history_list = NULL;
-
-    path = g_build_filename(g_get_home_dir(), ".openbox", "history", NULL);
-    history_path = g_strdup_printf("%s.%d", path, ob_screen);
-    g_free(path);
-
-    /*load_history(); /\* load from the historydb file */
-
-    dispatch_register(Event_Client_Destroy, (EventHandler)event, NULL);
-}
-
-void history_shutdown()
-{
-    GSList *it;
-
-    /*save_history(); /\* save to the historydb file */
-    for (it = history_list; it != NULL; it = it->next) {
-        struct HistoryItem *hi = it->data;
-        g_free(hi->name);
-        g_free(hi->class);
-        g_free(hi->role);
-        g_free(hi);
-    }
-    g_slist_free(history_list);
-
-    dispatch_register(0, (EventHandler)event, NULL);
-
-    g_free(history_path);
-}
diff --git a/plugins/placement/history.h b/plugins/placement/history.h
deleted file mode 100644 (file)
index cbf9f68..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __plugin_placement_history_h
-#define __plugin_placement_history_h
-
-#include "kernel/client.h"
-#include <glib.h>
-
-void history_startup();
-void history_shutdown();
-
-gboolean place_history(ObClient *c);
-
-#endif
diff --git a/plugins/placement/placement.c b/plugins/placement/placement.c
deleted file mode 100644 (file)
index 18c9c39..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-#include "kernel/dispatch.h"
-#include "kernel/client.h"
-#include "kernel/group.h"
-#include "kernel/frame.h"
-#include "kernel/screen.h"
-#include "kernel/openbox.h"
-#include "parser/parse.h"
-#include "history.h"
-#include <glib.h>
-
-static gboolean history;
-
-static void parse_xml(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, void *d)
-{
-    xmlNodePtr n;
-
-    node = node->xmlChildrenNode;
-    if ((n = parse_find_node("remember", node)))
-        history = parse_bool(doc, n);
-}
-
-void plugin_setup_config(ObParseInst *i)
-{
-    history = TRUE;
-
-    parse_register(i, "placement", parse_xml, NULL);
-}
-
-static Rect* pick_head(ObClient *c)
-{
-    /* try direct parent first */
-    if (c->transient_for && c->transient_for != OB_TRAN_GROUP) {
-        return screen_area_monitor(c->desktop,
-                                   client_monitor(c->transient_for));
-    }
-
-    /* more than one guy in his group (more than just him) */
-    if (c->group && c->group->members->next) {
-        GSList *it;
-
-        /* try on the client's desktop */
-        for (it = c->group->members; it; it = g_slist_next(it)) {
-            ObClient *itc = it->data;            
-            if (itc != c &&
-                (itc->desktop == c->desktop ||
-                 itc->desktop == DESKTOP_ALL || c->desktop == DESKTOP_ALL))
-                return screen_area_monitor(c->desktop,
-                                           client_monitor(it->data));
-        }
-
-        /* try on all desktops */
-        for (it = c->group->members; it; it = g_slist_next(it)) {
-            ObClient *itc = it->data;            
-            if (itc != c)
-                return screen_area_monitor(c->desktop,
-                                           client_monitor(it->data));
-        }
-    }
-
-    return NULL;
-}
-
-static void place_random(ObClient *c)
-{
-    int l, r, t, b;
-    int x, y;
-    Rect *area;
-
-    if (ob_state() == OB_STATE_STARTING) return;
-    
-    area = pick_head(c);
-    if (!area)
-        area = screen_area_monitor(c->desktop,
-                                   g_random_int_range(0, screen_num_monitors));
-
-    l = area->x;
-    t = area->y;
-    r = area->x + area->width - c->frame->area.width;
-    b = area->y + area->height - c->frame->area.height;
-
-    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, OB_CORNER_TOPLEFT, x, y, c->area.width, c->area.height,
-                     TRUE, TRUE);
-}
-
-static void event(ObEvent *e, void *foo)
-{
-    g_assert(e->type == Event_Client_New);
-
-    /* requested a position */
-    if (e->data.c.client->positioned) return;
-
-    if (e->data.c.client->transient_for) {
-        if (e->data.c.client->transient_for != OB_TRAN_GROUP) {
-            ObClient *c = e->data.c.client;
-            ObClient *p = e->data.c.client->transient_for;
-            int x = (p->frame->area.width - c->frame->area.width) / 2 +
-                p->frame->area.x;
-            int y = (p->frame->area.height - c->frame->area.height) / 2 +
-                p->frame->area.y;
-            client_configure(c, OB_CORNER_TOPLEFT, x, y,
-                             c->area.width, c->area.height,
-                             TRUE, TRUE);
-            return;
-        } else {
-            GSList *it;
-            ObClient *c = e->data.c.client;
-            gboolean first = TRUE;
-            int l, r, t, b;
-            for (it = c->group->members; it; it = it->next) {
-                ObClient *m = it->data;
-                if (!(m == c || m->transient_for)) {
-                    if (first) {
-                        l = m->frame->area.x;
-                        t = m->frame->area.y;
-                        r = m->frame->area.x + m->frame->area.width - 1;
-                        b = m->frame->area.y + m->frame->area.height - 1;
-                        first = FALSE;
-                    } else {
-                        l = MIN(l, m->frame->area.x);
-                        t = MIN(t, m->frame->area.y);
-                        r = MAX(r, m->frame->area.x +m->frame->area.width - 1);
-                        b = MAX(b, m->frame->area.y +m->frame->area.height -1);
-                    }
-                }
-            }
-            if (!first) {
-                int x = ((r + 1 - l) - c->frame->area.width) / 2 + l; 
-                int y = ((b + 1 - t) - c->frame->area.height) / 2 + t;
-                client_configure(c, OB_CORNER_TOPLEFT, x, y,
-                                 c->area.width, c->area.height,
-                                 TRUE, TRUE);
-                return;
-            }
-        }
-    }
-
-    /* center parentless dialogs on the screen */
-    if (e->data.c.client->type == OB_CLIENT_TYPE_DIALOG) {
-        Rect *area;
-        ObClient *c = e->data.c.client;
-        int x, y;
-
-        area = pick_head(c);
-        if (!area)
-            area = screen_area_monitor(c->desktop, 0);
-
-        x = (area->width - c->frame->area.width) / 2 + area->x;
-        y = (area->height - c->frame->area.height) / 2 + area->y;
-        client_configure(c, OB_CORNER_TOPLEFT, x, y,
-                         c->area.width, c->area.height,
-                         TRUE, TRUE);
-        return;
-    }
-
-    if (!history || !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();
-}
This page took 0.033443 seconds and 4 git commands to generate.