add a window placement plugin

This commit is contained in:
Dana Jansens 2003-03-21 07:33:07 +00:00
parent eb6ef3533c
commit 29e3748605
7 changed files with 73 additions and 1 deletions

View file

@ -23,3 +23,4 @@ depcomp
config.rpath config.rpath
py-compile py-compile
ABOUT-NLS ABOUT-NLS
compile

View file

@ -64,6 +64,7 @@ AC_CONFIG_FILES([Makefile po/Makefile.in
plugins/Makefile plugins/Makefile
plugins/keyboard/Makefile plugins/keyboard/Makefile
plugins/mouse/Makefile plugins/mouse/Makefile
plugins/placement/Makefile
doc/Makefile doc/Makefile
doc/doxygen/Makefile doc/doxygen/Makefile
data/Makefile data/Makefile

View file

@ -150,6 +150,7 @@ int main(int argc, char **argv)
plugin_open("focus"); plugin_open("focus");
plugin_open("keyboard"); plugin_open("keyboard");
plugin_open("mouse"); plugin_open("mouse");
plugin_open("placement");
/* get all the existing windows */ /* get all the existing windows */
client_manage_all(); client_manage_all();

View file

@ -1,6 +1,6 @@
plugindir=$(libdir)/openbox/plugins plugindir=$(libdir)/openbox/plugins
SUBDIRS = keyboard mouse SUBDIRS = keyboard mouse placement
CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \ CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
-DPLUGINDIR=\"$(plugindir)\" -DPLUGINDIR=\"$(plugindir)\"

View file

@ -0,0 +1,6 @@
Makefile.in
Makefile
placement.la
placement.lo
.deps
.libs

View file

@ -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 .\#*

View file

@ -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);
}