Example #1
0
Client::Client(Window id) : id(id), dialog(false)
{
    getWMName();
}
Example #2
0
void Client::init()
{
	XGrabServer(display());
	
	// reparent client with parent (qt)
	XSetWindowBorderWidth(display(), clientId, 0);  //client
	XSetWindowBorderWidth(display(), winId(), 0);  //parent
	
	XReparentWindow(display(), clientId, winId(), BORDER_WIDTH, Titlebar::getPreferedHeight(0));
	qDebug() << "CLIENT INIT - Reparent window:" << clientId << "with Qt parent:" << winId();
	
	XSetWindowAttributes at;
	at.event_mask = DECOR_EVENT_MASK;
	XChangeWindowAttributes(display(), winId(), CWEventMask, &at);
	at.event_mask = CLIENT_EVENT_MASK;
	XChangeWindowAttributes(display(), clientId, CWEventMask, &at);
	
	XAddToSaveSet(display(), clientId);
	
	XGrabButton(display(), Button1, AnyModifier, clientId, FALSE,
			ButtonPressMask|ButtonReleaseMask, 
			GrabModeSync, GrabModeAsync, None, None);
	
	// get initial client geometry
	XWindowAttributes attr;
	XGetWindowAttributes(display(), clientId, &attr);
	n_px = attr.x;
	n_py = attr.y;
	base_w = attr.width;
	base_h = attr.height;

	fixSizes();
	
	n_pw = base_w;// + DBL_BORDER_WIDTH;
	n_ph = base_h + TITLEBAR_HEIGHT + 8;
	
	getWMHints();
	getAppName();
	getWMName();
	getWMProtocols();

	windowRole = Atoms::windowType(clientId);
	
	int bx, by;
	if (windowRole == Atoms::Splash) {
		bx = by = 0;
		n_ph = n_ph - TITLEBAR_HEIGHT - 8;
	} else {
		bx = BORDER_WIDTH;
		by = TITLEBAR_HEIGHT;
	}

	XMoveResizeWindow(display(), clientId, bx, by, base_w, base_h);

	// move (in desktop center) and resize parent (qt)
	n_px = (desktop->width()-base_w)/2;
	n_py = ((desktop->height()-dock->height() - n_ph)*2)/3 + tbHeight;

	qDebug() << "desktop h = " << desktop->height() << "dock h = " << dock->height();
	qDebug() << "n_px = " << n_px << " n_py = " << n_py << " base_w = " << base_w << " base_h = " << base_h;

	move(n_px, n_py);
	resize(n_pw, n_ph);
	
	createDecor();
	
	// map client
	show();
	XMapWindow(display(), clientId);
	XSync(display(), false);
	XUngrabServer(display());
	
	maximized = false;
	// TODO: get and restore initial client state
	clientState = NormalState;
}