From 58abf74d431f98c744683ff7f4e60eda260cd0e5 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 16 Sep 2007 01:35:44 +0200 Subject: [PATCH] spawn X client in the right head and add screen arg to layouts --- config.h | 2 +- layout.c | 2 +- layouts/floating.c | 4 ++-- layouts/floating.h | 2 +- layouts/spiral.c | 16 ++++++++++------ layouts/spiral.h | 4 ++-- layouts/tile.c | 14 ++++---------- layouts/tile.h | 4 ++-- util.c | 15 ++++++++++++++- 9 files changed, 37 insertions(+), 26 deletions(-) diff --git a/config.h b/config.h index 5c9f40c60..58988c925 100644 --- a/config.h +++ b/config.h @@ -65,7 +65,7 @@ typedef struct awesome_config awesome_config; typedef struct { const char *symbol; - void (*arrange) (Display *, awesome_config *); + void (*arrange) (Display *, int, awesome_config *); } Layout; typedef struct diff --git a/layout.c b/layout.c index 3c30c4e60..1331026fc 100644 --- a/layout.c +++ b/layout.c @@ -42,7 +42,7 @@ arrange(Display * disp, int screen, DC *drawcontext, awesome_config *awesomeconf unban(c); else ban(c); - awesomeconf->current_layout->arrange(disp, awesomeconf); + awesomeconf->current_layout->arrange(disp, screen, awesomeconf); focus(disp, screen, drawcontext, NULL, True, awesomeconf); restack(disp, screen, drawcontext, awesomeconf); } diff --git a/layouts/floating.c b/layouts/floating.c index 118f333dc..982f84013 100644 --- a/layouts/floating.c +++ b/layouts/floating.c @@ -27,12 +27,12 @@ extern Client *clients; /* global client */ void -floating(Display *disp __attribute__ ((unused)), awesome_config *awesomeconf) +floating(Display *disp __attribute__ ((unused)), int screen, awesome_config *awesomeconf) { /* default floating layout */ Client *c; for(c = clients; c; c = c->next) - if(isvisible(c, awesomeconf->selected_tags, awesomeconf->ntags)) + if(isvisible(c, awesomeconf->selected_tags, awesomeconf->ntags) && c->screen == screen) { if(c->ftview) { diff --git a/layouts/floating.h b/layouts/floating.h index e413991c5..5295a2285 100644 --- a/layouts/floating.h +++ b/layouts/floating.h @@ -23,6 +23,6 @@ #ifndef AWESOME_FLOATING_H #define AWESOME_FLOATING_H -void floating(Display *, awesome_config *); /* floating layout */ +void floating(Display *, int, awesome_config *); /* floating layout */ #endif diff --git a/layouts/spiral.c b/layouts/spiral.c index 7685d3949..a87621c45 100644 --- a/layouts/spiral.c +++ b/layouts/spiral.c @@ -28,7 +28,7 @@ extern Client *clients; /* global client list */ static void -fibonacci(Display *disp, awesome_config *awesomeconf, int shape) +fibonacci(Display *disp, int screen, awesome_config *awesomeconf, int shape) { int n, nx, ny, nh, nw, i; Client *c; @@ -38,10 +38,14 @@ fibonacci(Display *disp, awesome_config *awesomeconf, int shape) nw = get_windows_area_width(disp, awesomeconf->statusbar); nh = get_windows_area_height(disp, awesomeconf->statusbar); for(n = 0, c = clients; c; c = c->next) - if(IS_TILED(c, awesomeconf->selected_tags, awesomeconf->ntags)) + if(IS_TILED(c, awesomeconf->selected_tags, awesomeconf->ntags) && c->screen == screen) n++; + for(i = 0, c = clients; c; c = c->next) { + if(c->screen != screen) + continue; + c->ismax = False; if((i % 2 && nh / 2 > 2 * c->border) || (!(i % 2) && nw / 2 > 2 * c->border)) @@ -83,13 +87,13 @@ fibonacci(Display *disp, awesome_config *awesomeconf, int shape) void -dwindle(Display *disp, awesome_config *awesomeconf) +dwindle(Display *disp, int screen, awesome_config *awesomeconf) { - fibonacci(disp, awesomeconf, 1); + fibonacci(disp, screen, awesomeconf, 1); } void -spiral(Display *disp, awesome_config *awesomeconf) +spiral(Display *disp, int screen, awesome_config *awesomeconf) { - fibonacci(disp, awesomeconf, 0); + fibonacci(disp, screen, awesomeconf, 0); } diff --git a/layouts/spiral.h b/layouts/spiral.h index 0df48d062..34c739334 100644 --- a/layouts/spiral.h +++ b/layouts/spiral.h @@ -23,7 +23,7 @@ #ifndef AWESOME_SPIRAL_H #define AWESOME_SPIRAL_H -void dwindle(Display *, awesome_config *); /* dwindle windows */ -void spiral(Display *, awesome_config *); /* spiral windows */ +void dwindle(Display *, int, awesome_config *); /* dwindle windows */ +void spiral(Display *, int, awesome_config *); /* spiral windows */ #endif diff --git a/layouts/tile.c b/layouts/tile.c index b52e4e3ea..d464cb957 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -195,19 +195,13 @@ _tile(Display *disp, int screen, awesome_config *awesomeconf, const Bool right) } void -tile(Display *disp, awesome_config *awesomeconf) +tile(Display *disp, int screen, awesome_config *awesomeconf) { - int screen; - - for(screen = 0; screen < ScreenCount(disp); screen++) - _tile(disp, screen, awesomeconf, True); + _tile(disp, screen, awesomeconf, True); } void -tileleft(Display *disp, awesome_config *awesomeconf) +tileleft(Display *disp, int screen, awesome_config *awesomeconf) { - int screen; - - for(screen = 0; screen < ScreenCount(disp); screen++) - _tile(disp, screen, awesomeconf, False); + _tile(disp, screen, awesomeconf, False); } diff --git a/layouts/tile.h b/layouts/tile.h index c7bee2bb5..5965a0414 100644 --- a/layouts/tile.h +++ b/layouts/tile.h @@ -28,7 +28,7 @@ void uicb_setnmaster(Display *, int, DC *, awesome_config *, const char *); /* change number of master windows */ void uicb_setncols(Display *, int, DC *, awesome_config *, const char *); void uicb_setmwfact(Display *, int, DC *, awesome_config *, const char *); /* sets master width factor */ -void tile(Display *, awesome_config *); -void tileleft(Display *, awesome_config *); +void tile(Display *, int, awesome_config *); +void tileleft(Display *, int, awesome_config *); #endif diff --git a/util.c b/util.c index d6b5f56da..5230dbe82 100644 --- a/util.c +++ b/util.c @@ -43,17 +43,30 @@ eprint(const char *fmt, ...) void uicb_spawn(Display * disp, - int screen __attribute__ ((unused)), + int screen, DC *drawcontext __attribute__ ((unused)), awesome_config * awesomeconf __attribute__ ((unused)), const char *arg) { static char *shell = NULL; + char *display = NULL; + char *tmp, newdisplay[128]; if(!shell && !(shell = getenv("SHELL"))) shell = strdup("/bin/sh"); if(!arg) return; + + if((tmp = getenv("DISPLAY"))) + { + display = strdup(tmp); + if((tmp = strrchr(display, '.'))) + *tmp = '\0'; + snprintf(newdisplay, sizeof(newdisplay), "%s.%d", display, screen); + setenv("DISPLAY", newdisplay, 1); + } + + /* The double-fork construct avoids zombie processes and keeps the code * clean from stupid signal handlers. */ if(fork() == 0)