]> Dogcows Code - chaz/openbox/commitdiff
add a window placement plugin
authorDana Jansens <danakj@orodu.net>
Fri, 21 Mar 2003 07:33:07 +0000 (07:33 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 21 Mar 2003 07:33:07 +0000 (07:33 +0000)
.cvsignore
configure.ac
openbox/openbox.c
plugins/Makefile.am
plugins/placement/.cvsignore [new file with mode: 0644]
plugins/placement/Makefile.am [new file with mode: 0644]
plugins/placement/placement.c [new file with mode: 0644]

index 6e0a7615c0c4cd0a89e7f12ea81c3e179e2a43e4..a285411c49eda73f9e11ccaea9b9bcf202ebeacf 100644 (file)
@@ -23,3 +23,4 @@ depcomp
 config.rpath
 py-compile
 ABOUT-NLS
+compile
index 1206cee593ea76be1c62a3488090e955892038b7..79244a3cc6be6d32ba49d6a877f2dcc96a606c76 100644 (file)
@@ -64,6 +64,7 @@ AC_CONFIG_FILES([Makefile po/Makefile.in
                plugins/Makefile
                plugins/keyboard/Makefile
                plugins/mouse/Makefile
+               plugins/placement/Makefile
                doc/Makefile
                doc/doxygen/Makefile
                data/Makefile
index 268d4e6d8242431758a0e6aee59348a5cb4972fe..e7fd79318ec9a0674c9407805f3bc0573b41bd61 100644 (file)
@@ -150,6 +150,7 @@ int main(int argc, char **argv)
         plugin_open("focus");
         plugin_open("keyboard");
         plugin_open("mouse");
+        plugin_open("placement");
 
        /* get all the existing windows */
        client_manage_all();
index 9e02e5fb0d1647cdb3b89eabd1564b03aeb95795..97d6d53fedb381f301a496c16fb8cbccc7f73564 100644 (file)
@@ -1,6 +1,6 @@
 plugindir=$(libdir)/openbox/plugins
 
-SUBDIRS = keyboard mouse
+SUBDIRS = keyboard mouse placement
 
 CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
 -DPLUGINDIR=\"$(plugindir)\"
diff --git a/plugins/placement/.cvsignore b/plugins/placement/.cvsignore
new file mode 100644 (file)
index 0000000..75afa57
--- /dev/null
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+placement.la
+placement.lo
+.deps
+.libs
diff --git a/plugins/placement/Makefile.am b/plugins/placement/Makefile.am
new file mode 100644 (file)
index 0000000..5899383
--- /dev/null
@@ -0,0 +1,17 @@
+plugindir=$(libdir)/openbox/plugins
+
+CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
+-DPLUGINDIR=\"$(plugindir)\" \
+-DG_LOG_DOMAIN=\"Plugin-Placement\"
+
+plugin_LTLIBRARIES=placement.la
+
+placement_la_LDFLAGS=-module -avoid-version
+placement_la_SOURCES=placement.c
+
+noinst_HEADERS=
+
+MAINTAINERCLEANFILES=Makefile.in
+
+distclean-local:
+       $(RM) *\~ *.orig *.rej .\#*
diff --git a/plugins/placement/placement.c b/plugins/placement/placement.c
new file mode 100644 (file)
index 0000000..f33e45d
--- /dev/null
@@ -0,0 +1,46 @@
+#include "../../kernel/dispatch.h"
+#include "../../kernel/client.h"
+#include "../../kernel/frame.h"
+#include "../../kernel/screen.h"
+#include "../../kernel/openbox.h"
+#include <glib.h>
+
+void place_random(Client *c)
+{
+    int l, r, t, b;
+    int x, y;
+    Rect *area;
+
+    area = screen_area(c->desktop);
+
+    l = area->x;
+    t = area->y;
+    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);
+
+    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)
+{
+    g_assert(e->type == Event_Client_New);
+
+    if (ob_state == State_Starting) return;
+
+    place_random(e->data.c.client);
+}
+
+void plugin_startup()
+{
+    dispatch_register(Event_Client_New, (EventHandler)event, NULL);
+}
+
+void plugin_shutdown()
+{
+    dispatch_register(0, (EventHandler)event, NULL);
+}
This page took 0.028904 seconds and 4 git commands to generate.