dwm.c
changeset 1147 def76530f636
parent 1145 607015ddb091
child 1148 d49ff154375f
equal deleted inserted replaced
1146:29b0911adab8 1147:def76530f636
    97 	void (*arrange)(void);
    97 	void (*arrange)(void);
    98 	Bool isfloating;
    98 	Bool isfloating;
    99 } Layout; 
    99 } Layout; 
   100 
   100 
   101 typedef struct {
   101 typedef struct {
   102 	const char *prop;
   102 	const char *class;
       
   103 	const char *instance;
       
   104 	const char *title;
   103 	const char *tag;
   105 	const char *tag;
   104 	Bool isfloating;
   106 	Bool isfloating;
   105 } Rule;
   107 } Rule;
   106 
   108 
   107 /* function declarations */
   109 /* function declarations */
   159 void resizemouse(Client *c);
   161 void resizemouse(Client *c);
   160 void restack(void);
   162 void restack(void);
   161 void run(void);
   163 void run(void);
   162 void scan(void);
   164 void scan(void);
   163 void setclientstate(Client *c, long state);
   165 void setclientstate(Client *c, long state);
   164 void setdefaultgeoms(void);
   166 void setdefgeoms(void);
   165 void setlayout(const char *arg);
   167 void setlayout(const char *arg);
   166 void setup(void);
   168 void setup(void);
   167 void spawn(const char *arg);
   169 void spawn(const char *arg);
   168 void tag(const char *arg);
   170 void tag(const char *arg);
   169 unsigned int textnw(const char *text, unsigned int len);
   171 unsigned int textnw(const char *text, unsigned int len);
   222 Cursor cursor[CurLast];
   224 Cursor cursor[CurLast];
   223 Display *dpy;
   225 Display *dpy;
   224 DC dc = {0};
   226 DC dc = {0};
   225 Layout *lt = NULL;
   227 Layout *lt = NULL;
   226 Window root, barwin;
   228 Window root, barwin;
   227 void (*setgeoms)(void) = setdefaultgeoms;
       
   228 
   229 
   229 /* configuration, allows nested code to access above variables */
   230 /* configuration, allows nested code to access above variables */
   230 #include "config.h"
   231 #include "config.h"
   231 #define TAGSZ (LENGTH(tags) * sizeof(Bool))
   232 #define TAGSZ (LENGTH(tags) * sizeof(Bool))
   232 static Bool tmp[LENGTH(tags)];
   233 static Bool tmp[LENGTH(tags)];
   242 
   243 
   243 	/* rule matching */
   244 	/* rule matching */
   244 	XGetClassHint(dpy, c->win, &ch);
   245 	XGetClassHint(dpy, c->win, &ch);
   245 	for(i = 0; i < LENGTH(rules); i++) {
   246 	for(i = 0; i < LENGTH(rules); i++) {
   246 		r = &rules[i];
   247 		r = &rules[i];
   247 		if(strstr(c->name, r->prop)
   248 		if(strstr(c->name, r->title)
   248 		|| (ch.res_class && strstr(ch.res_class, r->prop))
   249 		|| (ch.res_class && r->class && strstr(ch.res_class, r->class))
   249 		|| (ch.res_name && strstr(ch.res_name, r->prop)))
   250 		|| (ch.res_name && r->instance && strstr(ch.res_name, r->instance)))
   250 		{
   251 		{
   251 			c->isfloating = r->isfloating;
   252 			c->isfloating = r->isfloating;
   252 			if(r->tag) {
   253 			if(r->tag) {
   253 				c->tags[idxoftag(r->tag)] = True;
   254 				c->tags[idxoftag(r->tag)] = True;
   254 				matched = True;
   255 				matched = True;
  1049 	if(!getclient(ev->window))
  1050 	if(!getclient(ev->window))
  1050 		manage(ev->window, &wa);
  1051 		manage(ev->window, &wa);
  1051 }
  1052 }
  1052 
  1053 
  1053 void
  1054 void
  1054 monocle(void) { 
  1055 monocle(void) {
  1055 	Client *c;
  1056 	Client *c;
  1056 
  1057 
  1057 	for(c = clients; c; c = c->next)
  1058 	for(c = clients; c; c = c->next)
  1058 		if(isvisible(c))
  1059 		if(isvisible(c))
  1059 			resize(c, mox, moy, mow, moh, RESIZEHINTS);
  1060 			resize(c, mox, moy, mow, moh, RESIZEHINTS);
  1388 	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
  1389 	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
  1389 			PropModeReplace, (unsigned char *)data, 2);
  1390 			PropModeReplace, (unsigned char *)data, 2);
  1390 }
  1391 }
  1391 
  1392 
  1392 void
  1393 void
  1393 setdefaultgeoms(void) {
  1394 setdefgeoms(void) {
  1394 
  1395 
  1395 	/* screen dimensions */
  1396 	/* screen dimensions */
  1396 	sx = 0;
  1397 	sx = 0;
  1397 	sy = 0;
  1398 	sy = 0;
  1398 	sw = DisplayWidth(dpy, screen);
  1399 	sw = DisplayWidth(dpy, screen);