Пример #1
0
void
view(View *ov, int index)
{
	Monitor *cm, *om;
	Client *c;
	View *cv;

	if (!ov) {
		EPRINTF("Null view pointer.\n");
		return;
	}
	if (0 > index || index >= scr->ntags) {
		XPRINTF("WARNING: bad index %d\n", index);
		return;
	}
	if (ov->index == index) {
		XPRINTF("WARNING: view already index %d\n", index);
		return;
	}
	if (!(cm = ov->curmon)) {
		XPRINTF("WARNING: view %d has no monitor\n", ov->index);
		return;
	}
	XPRINTF("VIEW: disassociating monitor %d from view %d\n", cm->num, ov->index);
	ov->curmon = NULL;
	XPRINTF("VIEW: setting previous view for monitor %d to view %d\n", cm->num, ov->index);
	cm->preview = ov;
	XPRINTF("VIEW: new view is %d\n", index);
	cv = scr->views + index;
	XPRINTF("VIEW: associating monitor %d with view %d\n", cm->num, cv->index);
	cv->curmon = cm;
	XPRINTF("VIEW: associating view %d with monitor %d\n", cv->index, cm->num);
	cm->curview = cv;
	for (om = scr->monitors; om; om = om->next) {
		if (om == cm)
			continue;
		if (om->curview == cv) {
			XPRINTF("VIEW: switching monitor %d from view %d to %d\n",
					om->num, om->curview->index, ov->index);
			om->curview = ov;
			ov->curmon = om;
			updategeom(om);
			XPRINTF("VIEW: arranging view %d\n", ov->index);
			arrange(ov);
			/* only one can match */
			break;
		}
	}
	updategeom(cm);
	XPRINTF("VIEW: arranging view %d\n", cv->index);
	arrange(cv);
	c = lastselected(cv);
	focus(c);
	focuslockclient(c);
	ewmh_update_net_current_desktop();
}
Пример #2
0
Файл: bgs.c Проект: Gottox/bgs
/* main loop */
void
run(void) {
	XEvent ev;

	for(;;) {
		updategeom();
		drawbg();
		if(!running)
			break;
		imlib_flush_loaders();
		XNextEvent(dpy, &ev);
		if(ev.type == ConfigureNotify) {
			sw = ev.xconfigure.width;
			sh = ev.xconfigure.height;
			imlib_flush_loaders();
		}
	}
}
Пример #3
0
void
run() {
	XEvent ev;
	KeySym keysym;
	char buf[256];
	char errbuf[256] = {"ERROR: "};
	char *errmsg = NULL;
	/*struct timeval t1, t2;*/
	struct config *c;

	XSync(dpy, False);
	while(!XNextEvent(dpy, &ev)) {

		if(ev.type == ButtonPress) {
			if(ev.xbutton.window == win && is_mapped) {
				XUnmapWindow(dpy, win);
				XFlush(dpy);
				is_mapped = False;
			}
			continue;
		}

		if(ev.type != KeyPress)
			continue;

		keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev.xkey.keycode, 0, 0);
		for(c=config; c; c=c->next) {
			if(c->key == keysym &&
					CLEANMASK(c->mod) == CLEANMASK(ev.xkey.state)) {
				break;
			}
		}

		if(!c)
			continue;

		if(!is_mapped) {
			updategeom();
			moveresizeclear(ww, wh);
			XMapRaised(dpy, win);
			/* Wait for window to be mapped */
			while(1) {
				XMaskEvent(dpy, SubstructureNotifyMask, &ev);
				if ((ev.type == CreateNotify || ev.type == MapNotify)
					&& ev.xcreatewindow.window == win)
				{
					break;
				}
			}
			is_mapped = True;
		}
		/* gettimeofday(&t1, NULL); */
		readcmd(c->cmd, buf, sizeof buf,
				errbuf+7/*skip the 'ERROR: ' part of the buffer */,
				sizeof(errbuf)-7);
		/*
		gettimeofday(&t2, NULL);
		printf("cmd finished after %li ms\n", ((t2.tv_sec-t1.tv_sec)*1000) + ((t2.tv_usec-t1.tv_usec)/1000));
		*/

		if(buf[strlen(buf)-1] == '\n')
			buf[strlen(buf)-1] = '\0';
		if(errbuf[strlen(errbuf)-1] == '\n')
			errbuf[strlen(errbuf)-1] = '\0';

		if(strlen(buf))
			errmsg = NULL;
		else if(strlen(errbuf+7))
			errmsg = errbuf;
		else
			errmsg = "ERROR: Command failed";

		start_timer();
		c->disp(c, errmsg ? errmsg : buf, errmsg ? True : False);
		XSync(dpy, False);
	}
}