layout.c
changeset 837 123231b9eb87
parent 831 8b84189854dc
child 857 453788ae925c
equal deleted inserted replaced
836:52c1caae3fab 837:123231b9eb87
    29 	for(i = 0, c = clients; c; c = c->next)
    29 	for(i = 0, c = clients; c; c = c->next)
    30 		if(isvisible(c)) {
    30 		if(isvisible(c)) {
    31 			if(c->isbanned)
    31 			if(c->isbanned)
    32 				XMoveWindow(dpy, c->win, c->x, c->y);
    32 				XMoveWindow(dpy, c->win, c->x, c->y);
    33 			c->isbanned = False;
    33 			c->isbanned = False;
    34 			if(c->isuntiled)
    34 			if(c->isfloating)
    35 				continue;
    35 				continue;
    36 			c->ismax = False;
    36 			c->ismax = False;
    37 			nx = wax;
    37 			nx = wax;
    38 			ny = way;
    38 			ny = way;
    39 			if(i < nmaster) {
    39 			if(i < nmaster) {
    68 LAYOUTS
    68 LAYOUTS
    69 
    69 
    70 /* extern */
    70 /* extern */
    71 
    71 
    72 void
    72 void
       
    73 floating(void) {
       
    74 	Client *c;
       
    75 
       
    76 	for(c = clients; c; c = c->next) {
       
    77 		if(isvisible(c)) {
       
    78 			if(c->isbanned)
       
    79 				XMoveWindow(dpy, c->win, c->x, c->y);
       
    80 			c->isbanned = False;
       
    81 			resize(c, c->x, c->y, c->w, c->h, True);
       
    82 		}
       
    83 		else {
       
    84 			c->isbanned = True;
       
    85 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
       
    86 		}
       
    87 	}
       
    88 	if(!sel || !isvisible(sel)) {
       
    89 		for(c = stack; c && !isvisible(c); c = c->snext);
       
    90 		focus(c);
       
    91 	}
       
    92 	restack();
       
    93 }
       
    94 
       
    95 void
    73 focusclient(const char *arg) {
    96 focusclient(const char *arg) {
    74 	Client *c;
    97 	Client *c;
    75    
    98    
    76 	if(!sel || !arg)
    99 	if(!sel || !arg)
    77 		return;
   100 		return;
   142 	}
   165 	}
   143 }
   166 }
   144 
   167 
   145 Client *
   168 Client *
   146 nexttiled(Client *c) {
   169 nexttiled(Client *c) {
   147 	for(; c && (c->isuntiled || !isvisible(c)); c = c->next);
   170 	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
   148 	return c;
   171 	return c;
   149 }
   172 }
   150 
   173 
   151 void
   174 void
   152 restack(void) {
   175 restack(void) {
   154 	XEvent ev;
   177 	XEvent ev;
   155 
   178 
   156 	drawstatus();
   179 	drawstatus();
   157 	if(!sel)
   180 	if(!sel)
   158 		return;
   181 		return;
   159 	if(sel->isuntiled || lt->arrange == untile)
   182 	if(sel->isfloating || lt->arrange == floating)
   160 		XRaiseWindow(dpy, sel->win);
   183 		XRaiseWindow(dpy, sel->win);
   161 	if(lt->arrange != untile) {
   184 	if(lt->arrange != floating) {
   162 		if(!sel->isuntiled)
   185 		if(!sel->isfloating)
   163 			XLowerWindow(dpy, sel->win);
   186 			XLowerWindow(dpy, sel->win);
   164 		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
   187 		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
   165 			if(c == sel)
   188 			if(c == sel)
   166 				continue;
   189 				continue;
   167 			XLowerWindow(dpy, c->win);
   190 			XLowerWindow(dpy, c->win);
   196 
   219 
   197 void
   220 void
   198 togglemax(const char *arg) {
   221 togglemax(const char *arg) {
   199 	XEvent ev;
   222 	XEvent ev;
   200 
   223 
   201 	if(!sel || (lt->arrange != untile && !sel->isuntiled) || sel->isfixed)
   224 	if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
   202 		return;
   225 		return;
   203 	if((sel->ismax = !sel->ismax)) {
   226 	if((sel->ismax = !sel->ismax)) {
   204 		sel->rx = sel->x;
   227 		sel->rx = sel->x;
   205 		sel->ry = sel->y;
   228 		sel->ry = sel->y;
   206 		sel->rw = sel->w;
   229 		sel->rw = sel->w;
   212 	drawstatus();
   235 	drawstatus();
   213 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
   236 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
   214 }
   237 }
   215 
   238 
   216 void
   239 void
   217 untile(void) {
       
   218 	Client *c;
       
   219 
       
   220 	for(c = clients; c; c = c->next) {
       
   221 		if(isvisible(c)) {
       
   222 			if(c->isbanned)
       
   223 				XMoveWindow(dpy, c->win, c->x, c->y);
       
   224 			c->isbanned = False;
       
   225 			resize(c, c->x, c->y, c->w, c->h, True);
       
   226 		}
       
   227 		else {
       
   228 			c->isbanned = True;
       
   229 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
       
   230 		}
       
   231 	}
       
   232 	if(!sel || !isvisible(sel)) {
       
   233 		for(c = stack; c && !isvisible(c); c = c->snext);
       
   234 		focus(c);
       
   235 	}
       
   236 	restack();
       
   237 }
       
   238 
       
   239 void
       
   240 zoom(const char *arg) {
   240 zoom(const char *arg) {
   241 	unsigned int n;
   241 	unsigned int n;
   242 	Client *c;
   242 	Client *c;
   243 
   243 
   244 	if(!sel || lt->arrange != tile || sel->isuntiled)
   244 	if(!sel || lt->arrange != tile || sel->isfloating)
   245 		return;
   245 		return;
   246 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
   246 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
   247 		n++;
   247 		n++;
   248 	if((c = sel) == nexttiled(clients))
   248 	if((c = sel) == nexttiled(clients))
   249 		if(!(c = nexttiled(c->next)))
   249 		if(!(c = nexttiled(c->next)))