reverted to old updategeom() after several complains, we need to optimize the old way
This commit is contained in:
		
							parent
							
								
									606b44179d
								
							
						
					
					
						commit
						940feed314
					
				| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
# dwm version
 | 
					# dwm version
 | 
				
			||||||
VERSION = 6.1
 | 
					VERSION = 6.0-tip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Customize below to fit your system
 | 
					# Customize below to fit your system
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										71
									
								
								dwm.c
								
								
								
								
							
							
						
						
									
										71
									
								
								dwm.c
								
								
								
								
							| 
						 | 
					@ -236,7 +236,7 @@ static void toggleview(const Arg *arg);
 | 
				
			||||||
static void unfocus(Client *c, Bool setfocus);
 | 
					static void unfocus(Client *c, Bool setfocus);
 | 
				
			||||||
static void unmanage(Client *c, Bool destroyed);
 | 
					static void unmanage(Client *c, Bool destroyed);
 | 
				
			||||||
static void unmapnotify(XEvent *e);
 | 
					static void unmapnotify(XEvent *e);
 | 
				
			||||||
static void updategeom(void);
 | 
					static Bool updategeom(void);
 | 
				
			||||||
static void updatebarpos(Monitor *m);
 | 
					static void updatebarpos(Monitor *m);
 | 
				
			||||||
static void updatebars(void);
 | 
					static void updatebars(void);
 | 
				
			||||||
static void updateclientlist(void);
 | 
					static void updateclientlist(void);
 | 
				
			||||||
| 
						 | 
					@ -574,10 +574,14 @@ void
 | 
				
			||||||
configurenotify(XEvent *e) {
 | 
					configurenotify(XEvent *e) {
 | 
				
			||||||
	Monitor *m;
 | 
						Monitor *m;
 | 
				
			||||||
	XConfigureEvent *ev = &e->xconfigure;
 | 
						XConfigureEvent *ev = &e->xconfigure;
 | 
				
			||||||
 | 
						Bool dirty;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// TODO: updategeom handling sucks, needs to be simplified
 | 
				
			||||||
	if(ev->window == root) {
 | 
						if(ev->window == root) {
 | 
				
			||||||
 | 
							dirty = (sw != ev->width || sh != ev->height);
 | 
				
			||||||
		sw = ev->width;
 | 
							sw = ev->width;
 | 
				
			||||||
		sh = ev->height;
 | 
							sh = ev->height;
 | 
				
			||||||
 | 
							if(updategeom() || dirty) {
 | 
				
			||||||
			if(dc.drawable != 0)
 | 
								if(dc.drawable != 0)
 | 
				
			||||||
				XFreePixmap(dpy, dc.drawable);
 | 
									XFreePixmap(dpy, dc.drawable);
 | 
				
			||||||
			dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
 | 
								dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
 | 
				
			||||||
| 
						 | 
					@ -588,6 +592,7 @@ configurenotify(XEvent *e) {
 | 
				
			||||||
			arrange(NULL);
 | 
								arrange(NULL);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
configurerequest(XEvent *e) {
 | 
					configurerequest(XEvent *e) {
 | 
				
			||||||
| 
						 | 
					@ -1072,8 +1077,8 @@ initfont(const char *fontstr) {
 | 
				
			||||||
static Bool
 | 
					static Bool
 | 
				
			||||||
isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) {
 | 
					isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) {
 | 
				
			||||||
	while(n--)
 | 
						while(n--)
 | 
				
			||||||
		/* treat origin (x, y) as fixpoint for uniqueness only, first screen wins */
 | 
							if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org
 | 
				
			||||||
		if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org)
 | 
							&& unique[n].width == info->width && unique[n].height == info->height)
 | 
				
			||||||
			return False;
 | 
								return False;
 | 
				
			||||||
	return True;
 | 
						return True;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1883,37 +1888,41 @@ updateclientlist() {
 | 
				
			||||||
			                (unsigned char *) &(c->win), 1);
 | 
								                (unsigned char *) &(c->win), 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					Bool
 | 
				
			||||||
updategeom(void) {
 | 
					updategeom(void) {
 | 
				
			||||||
	/* Starting with dwm 6.1 this function uses a new (simpler) strategy:
 | 
						Bool dirty = False;
 | 
				
			||||||
	 * whenever screen changes are reported, we destroy all monitors
 | 
					 | 
				
			||||||
	 * and recreate all unique origin monitors and add all clients to
 | 
					 | 
				
			||||||
	 * the first monitor, only. In several circumstances this may suck,
 | 
					 | 
				
			||||||
	 * but dealing with all corner-cases sucks even more.*/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef XINERAMA
 | 
					#ifdef XINERAMA
 | 
				
			||||||
	if(XineramaIsActive(dpy)) {
 | 
						if(XineramaIsActive(dpy)) {
 | 
				
			||||||
		int i, j, n;
 | 
							int i, j, n, nn;
 | 
				
			||||||
		Client *c;
 | 
							Client *c;
 | 
				
			||||||
		Monitor *m, *oldmons = mons;
 | 
							Monitor *m;
 | 
				
			||||||
		XineramaScreenInfo *info = XineramaQueryScreens(dpy, &n);
 | 
							XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn);
 | 
				
			||||||
		XineramaScreenInfo *unique = NULL;
 | 
							XineramaScreenInfo *unique = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for(n = 0, m = mons; m; m = m->next, n++);
 | 
				
			||||||
		/* only consider unique geometries as separate screens */
 | 
							/* only consider unique geometries as separate screens */
 | 
				
			||||||
		if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * n)))
 | 
							if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn)))
 | 
				
			||||||
			die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * n);
 | 
								die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn);
 | 
				
			||||||
		for(i = 0, j = 0; i < n; i++)
 | 
							for(i = 0, j = 0; i < nn; i++)
 | 
				
			||||||
			if(isuniquegeom(unique, j, &info[i]))
 | 
								if(isuniquegeom(unique, j, &info[i]))
 | 
				
			||||||
				memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
 | 
									memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
 | 
				
			||||||
		XFree(info);
 | 
							XFree(info);
 | 
				
			||||||
		/* create new monitor structure */
 | 
							nn = j;
 | 
				
			||||||
		n = j;
 | 
							if(n <= nn) {
 | 
				
			||||||
		mons = m = createmon(); /* new first monitor */
 | 
								for(i = 0; i < (nn - n); i++) { /* new monitors available */
 | 
				
			||||||
		for(i = 1; i < n; i++) {
 | 
									for(m = mons; m && m->next; m = m->next);
 | 
				
			||||||
 | 
									if(m)
 | 
				
			||||||
					m->next = createmon();
 | 
										m->next = createmon();
 | 
				
			||||||
			m = m->next;
 | 
									else
 | 
				
			||||||
 | 
										mons = createmon();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		for(i = 0, m = mons; i < n && m; m = m->next, i++) {
 | 
								for(i = 0, m = mons; i < nn && m; m = m->next, i++)
 | 
				
			||||||
 | 
									if(i >= n
 | 
				
			||||||
 | 
									|| (unique[i].x_org != m->mx || unique[i].y_org != m->my
 | 
				
			||||||
 | 
									    || unique[i].width != m->mw || unique[i].height != m->mh))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										dirty = True;
 | 
				
			||||||
					m->num = i;
 | 
										m->num = i;
 | 
				
			||||||
					m->mx = m->wx = unique[i].x_org;
 | 
										m->mx = m->wx = unique[i].x_org;
 | 
				
			||||||
					m->my = m->wy = unique[i].y_org;
 | 
										m->my = m->wy = unique[i].y_org;
 | 
				
			||||||
| 
						 | 
					@ -1921,11 +1930,12 @@ updategeom(void) {
 | 
				
			||||||
					m->mh = m->wh = unique[i].height;
 | 
										m->mh = m->wh = unique[i].height;
 | 
				
			||||||
					updatebarpos(m);
 | 
										updatebarpos(m);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
		free(unique);
 | 
							}
 | 
				
			||||||
		/* re-attach old clients and cleanup old monitor structure */
 | 
							else { /* less monitors available nn < n */
 | 
				
			||||||
		while(oldmons) {
 | 
								for(i = nn; i < n; i++) {
 | 
				
			||||||
			m = oldmons;
 | 
									for(m = mons; m && m->next; m = m->next);
 | 
				
			||||||
				while(m->clients) {
 | 
									while(m->clients) {
 | 
				
			||||||
 | 
										dirty = True;
 | 
				
			||||||
					c = m->clients;
 | 
										c = m->clients;
 | 
				
			||||||
					m->clients = c->next;
 | 
										m->clients = c->next;
 | 
				
			||||||
					detachstack(c);
 | 
										detachstack(c);
 | 
				
			||||||
| 
						 | 
					@ -1933,25 +1943,32 @@ updategeom(void) {
 | 
				
			||||||
					attach(c);
 | 
										attach(c);
 | 
				
			||||||
					attachstack(c);
 | 
										attachstack(c);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			oldmons = m->next;
 | 
									if(m == selmon)
 | 
				
			||||||
 | 
										selmon = mons;
 | 
				
			||||||
				cleanupmon(m);
 | 
									cleanupmon(m);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							free(unique);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
#endif /* XINERAMA */
 | 
					#endif /* XINERAMA */
 | 
				
			||||||
	/* default monitor setup */
 | 
						/* default monitor setup */
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if(!mons) /* only true if !XINERAMA compile flag */
 | 
							if(!mons)
 | 
				
			||||||
			mons = createmon();
 | 
								mons = createmon();
 | 
				
			||||||
		if(mons->mw != sw || mons->mh != sh) {
 | 
							if(mons->mw != sw || mons->mh != sh) {
 | 
				
			||||||
 | 
								dirty = True;
 | 
				
			||||||
			mons->mw = mons->ww = sw;
 | 
								mons->mw = mons->ww = sw;
 | 
				
			||||||
			mons->mh = mons->wh = sh;
 | 
								mons->mh = mons->wh = sh;
 | 
				
			||||||
			updatebarpos(mons);
 | 
								updatebarpos(mons);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if(dirty) {
 | 
				
			||||||
		selmon = mons;
 | 
							selmon = mons;
 | 
				
			||||||
		selmon = wintomon(root);
 | 
							selmon = wintomon(root);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return dirty;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
updatenumlockmask(void) {
 | 
					updatenumlockmask(void) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue