screen.c
changeset 785 179a71394e49
parent 784 74722317b171
child 786 d9198e713310
equal deleted inserted replaced
784:74722317b171 785:179a71394e49
    17 /* static */
    17 /* static */
    18 
    18 
    19 typedef struct {
    19 typedef struct {
    20 	const char *prop;
    20 	const char *prop;
    21 	const char *tags;
    21 	const char *tags;
    22 	Bool swimming;
    22 	Bool versatile;
    23 } Rule;
    23 } Rule;
    24 
    24 
    25 typedef struct {
    25 typedef struct {
    26 	regex_t *propregex;
    26 	regex_t *propregex;
    27 	regex_t *tagregex;
    27 	regex_t *tagregex;
    50 	for(i = 0, c = clients; c; c = c->next)
    50 	for(i = 0, c = clients; c; c = c->next)
    51 		if(isvisible(c)) {
    51 		if(isvisible(c)) {
    52 			if(c->isbanned)
    52 			if(c->isbanned)
    53 				XMoveWindow(dpy, c->win, c->x, c->y);
    53 				XMoveWindow(dpy, c->win, c->x, c->y);
    54 			c->isbanned = False;
    54 			c->isbanned = False;
    55 			if(c->swimming)
    55 			if(c->versatile)
    56 				continue;
    56 				continue;
    57 			c->ismax = False;
    57 			c->ismax = False;
    58 			nx = wax;
    58 			nx = wax;
    59 			ny = way;
    59 			ny = way;
    60 			if(i < nmaster) {
    60 			if(i < nmaster) {
   173 	XEvent ev;
   173 	XEvent ev;
   174 
   174 
   175 	drawstatus();
   175 	drawstatus();
   176 	if(!sel)
   176 	if(!sel)
   177 		return;
   177 		return;
   178 	if(sel->swimming || lt->arrange == swim)
   178 	if(sel->versatile || lt->arrange == versatile)
   179 		XRaiseWindow(dpy, sel->win);
   179 		XRaiseWindow(dpy, sel->win);
   180 	if(lt->arrange != swim) {
   180 	if(lt->arrange != versatile) {
   181 		if(!sel->swimming)
   181 		if(!sel->versatile)
   182 			XLowerWindow(dpy, sel->win);
   182 			XLowerWindow(dpy, sel->win);
   183 		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
   183 		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
   184 			if(c == sel)
   184 			if(c == sel)
   185 				continue;
   185 				continue;
   186 			XLowerWindow(dpy, c->win);
   186 			XLowerWindow(dpy, c->win);
   206 		snprintf(prop, sizeof prop, "%s:%s:%s",
   206 		snprintf(prop, sizeof prop, "%s:%s:%s",
   207 				ch.res_class ? ch.res_class : "",
   207 				ch.res_class ? ch.res_class : "",
   208 				ch.res_name ? ch.res_name : "", c->name);
   208 				ch.res_name ? ch.res_name : "", c->name);
   209 		for(i = 0; i < nrules; i++)
   209 		for(i = 0; i < nrules; i++)
   210 			if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
   210 			if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
   211 				c->swimming = rule[i].swimming;
   211 				c->versatile = rule[i].versatile;
   212 				for(j = 0; regs[i].tagregex && j < ntags; j++) {
   212 				for(j = 0; regs[i].tagregex && j < ntags; j++) {
   213 					if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
   213 					if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
   214 						matched = True;
   214 						matched = True;
   215 						c->tags[j] = True;
   215 						c->tags[j] = True;
   216 					}
   216 					}
   225 		for(i = 0; i < ntags; i++)
   225 		for(i = 0; i < ntags; i++)
   226 			c->tags[i] = seltag[i];
   226 			c->tags[i] = seltag[i];
   227 }
   227 }
   228 
   228 
   229 void
   229 void
   230 swim(void) {
       
   231 	Client *c;
       
   232 
       
   233 	for(c = clients; c; c = c->next) {
       
   234 		if(isvisible(c)) {
       
   235 			if(c->isbanned)
       
   236 				XMoveWindow(dpy, c->win, c->x, c->y);
       
   237 			c->isbanned = False;
       
   238 			resize(c, c->x, c->y, c->w, c->h, True);
       
   239 		}
       
   240 		else {
       
   241 			c->isbanned = True;
       
   242 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
       
   243 		}
       
   244 	}
       
   245 	if(!sel || !isvisible(sel)) {
       
   246 		for(c = stack; c && !isvisible(c); c = c->snext);
       
   247 		focus(c);
       
   248 	}
       
   249 	restack();
       
   250 }
       
   251 
       
   252 void
       
   253 tag(Arg *arg) {
   230 tag(Arg *arg) {
   254 	unsigned int i;
   231 	unsigned int i;
   255 
   232 
   256 	if(!sel)
   233 	if(!sel)
   257 		return;
   234 		return;
   258 	for(i = 0; i < ntags; i++)
   235 	for(i = 0; i < ntags; i++)
   259 		sel->tags[i] = (arg->i == -1) ? True : False;
   236 		sel->tags[i] = (arg->i == -1) ? True : False;
   260 	if(arg->i >= 0 && arg->i < ntags)
   237 	if(arg->i >= 0 && arg->i < ntags)
   261 		sel->tags[arg->i] = True;
   238 		sel->tags[arg->i] = True;
   262 	lt->arrange();
       
   263 }
       
   264 
       
   265 void
       
   266 toggleswimming(Arg *arg) {
       
   267 	if(!sel || lt->arrange == swim)
       
   268 		return;
       
   269 	sel->swimming = !sel->swimming;
       
   270 	lt->arrange();
   239 	lt->arrange();
   271 }
   240 }
   272 
   241 
   273 void
   242 void
   274 toggletag(Arg *arg) {
   243 toggletag(Arg *arg) {
   297 	else
   266 	else
   298 		drawstatus();
   267 		drawstatus();
   299 }
   268 }
   300 
   269 
   301 void
   270 void
       
   271 toggleversatile(Arg *arg) {
       
   272 	if(!sel || lt->arrange == versatile)
       
   273 		return;
       
   274 	sel->versatile = !sel->versatile;
       
   275 	lt->arrange();
       
   276 }
       
   277 
       
   278 void
   302 toggleview(Arg *arg) {
   279 toggleview(Arg *arg) {
   303 	unsigned int i;
   280 	unsigned int i;
   304 
   281 
   305 	seltag[arg->i] = !seltag[arg->i];
   282 	seltag[arg->i] = !seltag[arg->i];
   306 	for(i = 0; i < ntags && !seltag[i]; i++);
   283 	for(i = 0; i < ntags && !seltag[i]; i++);
   308 		seltag[arg->i] = True; /* cannot toggle last view */
   285 		seltag[arg->i] = True; /* cannot toggle last view */
   309 	lt->arrange();
   286 	lt->arrange();
   310 }
   287 }
   311 
   288 
   312 void
   289 void
       
   290 versatile(void) {
       
   291 	Client *c;
       
   292 
       
   293 	for(c = clients; c; c = c->next) {
       
   294 		if(isvisible(c)) {
       
   295 			if(c->isbanned)
       
   296 				XMoveWindow(dpy, c->win, c->x, c->y);
       
   297 			c->isbanned = False;
       
   298 			resize(c, c->x, c->y, c->w, c->h, True);
       
   299 		}
       
   300 		else {
       
   301 			c->isbanned = True;
       
   302 			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
       
   303 		}
       
   304 	}
       
   305 	if(!sel || !isvisible(sel)) {
       
   306 		for(c = stack; c && !isvisible(c); c = c->snext);
       
   307 		focus(c);
       
   308 	}
       
   309 	restack();
       
   310 }
       
   311 
       
   312 void
   313 view(Arg *arg) {
   313 view(Arg *arg) {
   314 	unsigned int i;
   314 	unsigned int i;
   315 
   315 
   316 	for(i = 0; i < ntags; i++)
   316 	for(i = 0; i < ntags; i++)
   317 		seltag[i] = (arg->i == -1) ? True : False;
   317 		seltag[i] = (arg->i == -1) ? True : False;