add a window placement plugin
This commit is contained in:
parent
eb6ef3533c
commit
29e3748605
7 changed files with 73 additions and 1 deletions
|
@ -23,3 +23,4 @@ depcomp
|
|||
config.rpath
|
||||
py-compile
|
||||
ABOUT-NLS
|
||||
compile
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
plugindir=$(libdir)/openbox/plugins
|
||||
|
||||
SUBDIRS = keyboard mouse
|
||||
SUBDIRS = keyboard mouse placement
|
||||
|
||||
CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
|
||||
-DPLUGINDIR=\"$(plugindir)\"
|
||||
|
|
6
plugins/placement/.cvsignore
Normal file
6
plugins/placement/.cvsignore
Normal file
|
@ -0,0 +1,6 @@
|
|||
Makefile.in
|
||||
Makefile
|
||||
placement.la
|
||||
placement.lo
|
||||
.deps
|
||||
.libs
|
17
plugins/placement/Makefile.am
Normal file
17
plugins/placement/Makefile.am
Normal 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 .\#*
|
46
plugins/placement/placement.c
Normal file
46
plugins/placement/placement.c
Normal 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);
|
||||
}
|
Loading…
Reference in a new issue