introduce move_client_to_screen to move a client in a new screen and tag it with good tags

This commit is contained in:
Julien Danjou 2007-09-28 11:30:51 +02:00
parent ab738c9cab
commit 8112ec2cca
10 changed files with 31 additions and 17 deletions

View File

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

View File

@ -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 */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
#ifndef AWESOME_SCREEN_H
#define AWESOME_SCREEN_H
#include "common.h"
#include "client.h"
#include <X11/extensions/Xinerama.h>
@ -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);

2
tag.c
View File

@ -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*/