From 8112ec2cca6a4f24688589eaf24204ffaa94bd36 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 28 Sep 2007 11:30:51 +0200 Subject: [PATCH] introduce move_client_to_screen to move a client in a new screen and tag it with good tags --- client.c | 10 ++++++---- client.h | 2 +- event.c | 4 ++-- layout.c | 4 ++-- layouts/floating.c | 4 ++-- layouts/max.c | 2 +- layouts/tile.c | 4 ++-- screen.c | 13 ++++++++++++- screen.h | 3 ++- tag.c | 2 +- 10 files changed, 31 insertions(+), 17 deletions(-) diff --git a/client.c b/client.c index 24b104b2..f4faa4db 100644 --- a/client.c +++ b/client.c @@ -403,7 +403,7 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_ ScreenInfo *si = get_display_info(disp, awesomeconf->screen, &awesomeconf->statusbar); c = p_new(Client, 1); - c->tags = p_new(Bool, awesomeconf->ntags); + move_client_to_screen(c, awesomeconf); c->win = w; c->ftview = True; c->x = c->rw = wa->x; @@ -412,7 +412,6 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_ c->h = c->rh = wa->height; c->oldborder = wa->border_width; c->display = disp; - c->screen = awesomeconf->screen; if(c->w == si->width && c->h == si->height) { c->x = 0; @@ -463,7 +462,7 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_ } void -resize(Client * c, int x, int y, int w, int h, Bool sizehints) +resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf, Bool sizehints) { double dx, dy, max, min, ratio; XWindowChanges wc; @@ -536,7 +535,10 @@ resize(Client * c, int x, int y, int w, int h, Bool sizehints) configure(c); XSync(c->display, False); if(XineramaIsActive(c->display)) + { c->screen = get_screen_bycoord(c->display, c->x, c->y); + move_client_to_screen(c, &awesomeconf[c->screen - awesomeconf->screen]); + } } } @@ -568,7 +570,7 @@ uicb_moveresize(Display *disp __attribute__ ((unused)), oh = sel->h; Bool xqp = XQueryPointer(sel->display, RootWindow(sel->display, sel->screen), &dummy, &dummy, &mx, &my, &dx, &dy, &dui); - resize(sel, nx, ny, nw, nh, True); + resize(sel, nx, ny, nw, nh, awesomeconf, True); if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my) { nmx = mx-ox+sel->w-ow-1 < 0 ? 0 : mx-ox+sel->w-ow-1; diff --git a/client.h b/client.h index e0e0af7d..4037bcc6 100644 --- a/client.h +++ b/client.h @@ -66,7 +66,7 @@ void configure(Client *); /* send synthetic configure event */ void detach(Client *); /* detaches c from global client list */ void focus(Display *, DC *, Client *, Bool, awesome_config *); /* focus c if visible && !NULL, or focus top visible */ void manage(Display *, DC *, Window, XWindowAttributes *, awesome_config *); -void resize(Client *, int, int, int, int, Bool); /* resize with given coordinates c */ +void resize(Client *, int, int, int, int, awesome_config *, Bool); /* resize with given coordinates c */ void unban(Client *); /* unbans c */ void unmanage(Client *, DC *, long, awesome_config *); /* unmanage c */ void updatesizehints(Client *); /* update the size hint variables of c */ diff --git a/event.c b/event.c index 8a5fadf5..46e23da3 100644 --- a/event.c +++ b/event.c @@ -98,7 +98,7 @@ movemouse(Client * c, awesome_config *awesomeconf) ny = si->y_org; else if(abs((si->y_org + si->height) - (ny + c->h + 2 * c->border)) < awesomeconf->snap) ny = si->y_org + si->height - c->h - 2 * c->border; - resize(c, nx, ny, c->w, c->h, False); + resize(c, nx, ny, c->w, c->h, awesomeconf, False); break; } } @@ -144,7 +144,7 @@ resizemouse(Client * c, awesome_config *awesomeconf) nw = 1; if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0) nh = 1; - resize(c, c->x, c->y, nw, nh, True); + resize(c, c->x, c->y, nw, nh, awesomeconf, True); break; } } diff --git a/layout.c b/layout.c index a4cbc744..921acf8c 100644 --- a/layout.c +++ b/layout.c @@ -208,10 +208,10 @@ maximize(int x, int y, int w, int h, DC *drawcontext, awesome_config *awesomecon sel->ry = sel->y; sel->rw = sel->w; sel->rh = sel->h; - resize(sel, x, y, w, h, True); + resize(sel, x, y, w, h, awesomeconf, True); } else if(sel->wasfloating) - resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True); + resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, awesomeconf, True); else sel->isfloating = False; diff --git a/layouts/floating.c b/layouts/floating.c index ef306422..f64e9598 100644 --- a/layouts/floating.c +++ b/layouts/floating.c @@ -35,10 +35,10 @@ layout_floating(Display *disp __attribute__ ((unused)), awesome_config *awesomec { if(c->ftview) { - resize(c, c->rx, c->ry, c->rw, c->rh, True); + resize(c, c->rx, c->ry, c->rw, c->rh, awesomeconf, True); c->ftview = False; } else - resize(c, c->x, c->y, c->w, c->h, True); + resize(c, c->x, c->y, c->w, c->h, awesomeconf, True); } } diff --git a/layouts/max.c b/layouts/max.c index ac97fbbc..15668e9f 100644 --- a/layouts/max.c +++ b/layouts/max.c @@ -37,6 +37,6 @@ layout_max(Display *disp, awesome_config *awesomeconf) if(IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags)) resize(c, si[awesomeconf->screen].x_org, si[awesomeconf->screen].y_org, si[awesomeconf->screen].width - 2 * c->border, - si[awesomeconf->screen].height - 2 * c->border, awesomeconf->resize_hints); + si[awesomeconf->screen].height - 2 * c->border, awesomeconf, awesomeconf->resize_hints); XFree(si); } diff --git a/layouts/tile.c b/layouts/tile.c index 870ead84..694c57a6 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -131,7 +131,7 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right) { /* master */ ny = way + i * mh; nx = wax + (right ? 0 : waw - mw); - resize(c, nx, ny, mw - 2 * c->border, mh - 2 * c->border, awesomeconf->resize_hints); + resize(c, nx, ny, mw - 2 * c->border, mh - 2 * c->border, awesomeconf, awesomeconf->resize_hints); } else { /* tile window */ @@ -157,7 +157,7 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right) ny = way + ((i - awesomeconf->nmaster) % win_by_col) * (nh + 2 * c->border); nx = wax + current_col * nw + (right ? mw : 0); - resize(c, nx, ny, nw, nh, awesomeconf->resize_hints); + resize(c, nx, ny, nw, nh, awesomeconf, awesomeconf->resize_hints); } i++; } diff --git a/screen.c b/screen.c index e7825bd4..7607d0ae 100644 --- a/screen.c +++ b/screen.c @@ -138,6 +138,17 @@ get_screen_count(Display *disp) return screen_number; } +void +move_client_to_screen(Client *c, awesome_config *acf_new) +{ + int i; + + c->screen = acf_new->screen; + p_realloc(&c->tags, acf_new->ntags); + for(i = 0; i < acf_new->ntags; i++) + c->tags[i] = acf_new->tags[i].selected; +} + static void move_mouse_pointer_to_screen(Display *disp, int screen) { @@ -208,7 +219,7 @@ uicb_movetoscreen(Display *disp, else screen = sel->screen + 1 >= get_screen_count(disp) ? 0 : sel->screen + 1; - sel->screen = screen; + move_client_to_screen(sel, &awesomeconf[screen - awesomeconf->screen]); move_mouse_pointer_to_screen(disp, screen); arrange(disp, drawcontext, awesomeconf); arrange(disp, &drawcontext[screen - awesomeconf->screen], &awesomeconf[screen - awesomeconf->screen]); diff --git a/screen.h b/screen.h index 40e04d17..68cebab1 100644 --- a/screen.h +++ b/screen.h @@ -22,7 +22,7 @@ #ifndef AWESOME_SCREEN_H #define AWESOME_SCREEN_H -#include "common.h" +#include "client.h" #include @@ -32,6 +32,7 @@ ScreenInfo * get_screen_info(Display *, int, Statusbar *, int *); ScreenInfo * get_display_info(Display *, int, Statusbar *); int get_screen_bycoord(Display *, int, int); int get_screen_count(Display *); +void move_client_to_screen(Client *, awesome_config *); UICB_PROTO(uicb_focusnextscreen); UICB_PROTO(uicb_focusprevscreen); UICB_PROTO(uicb_movetoscreen); diff --git a/tag.c b/tag.c index df83e7a3..0d51ac50 100644 --- a/tag.c +++ b/tag.c @@ -192,7 +192,7 @@ uicb_togglefloating(Display *disp, sel->isfloating = !sel->isfloating; if(sel->isfloating) /*restore last known float dimensions*/ - resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True); + resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, awesomeconf, True); else { /*save last known float dimensions*/