Example #1
0
void qapp::tile_maximize(xwindow *client)
{
	int i;
	
	if(tmaxclient != NULL && (i = clients.find(tmaxclient)) != -1)
		clients.insert(clients.find(client),  clients.take(i));
		
	tile_order(client);
}
Example #2
0
void qapp::toggle_tiled(void) // toggle overlapped/tiled desk 
{
	xwindow *client;
	
	if(smode)
		return;
	
	if(tdesks[adesk])
	{
		for(client = clients.first(); client != NULL; client = clients.next())
		{
			if(is_curdesk(client))
				client->unset_tile();
		}	
			
		tdesks[adesk] = FALSE;
		tmaxclient = NULL;

		if(focusclient != NULL && clients.find(client) != -1)
			focusclient->focus_mouse();
			
		tb_wl->set_pixmap();

		return;
	}
	tile_order(focusclient);
	tdesks[adesk] = TRUE;
	tb_wl->set_pixmap();
}
Example #3
0
void qapp::setinactive(xwindow *client)  // set last active client to inactive
{
	if(client != focusclient)
	{
	
		if(focusclient != NULL && clients.find(focusclient) != -1)  // still there
			focusclient->setinactive();

		focusclient = client;
	}
}
Example #4
0
void qapp::stopautofocus(void)
{
	if(focusclient != NULL && clients.find(focusclient) != -1)
		focusclient->stopautofocus();
}
Example #5
0
bool qapp::x11EventFilter(XEvent *event)  
{
	xwindow *client;
	Window w;
	XEvent ev;
	XConfigureRequestEvent *cev;
	XClientMessageEvent *mev;
	XCrossingEvent *xev;
	XCirculateRequestEvent *rev;
	XPropertyEvent *pev;
			
#ifdef DEBUGMSG		
#include "eventnames.h"
	if(event->type < 36)
		logmsg << "Received: " << event_names[event->type] << " (WId:" << event->xany.window << ")\n";
#endif
	while(waitpid(-1, NULL, WNOHANG) > 0);

	if(sighup)
	{
		wm_restart();
		tb_mn->readmenu();
		read_cprops();
		sighup = FALSE;
	}

	switch(event->type)
	{
		case DestroyNotify:
			w = event->xdestroywindow.window;

			if((client = cwindows.find(w)) != NULL)
			{
				clients.remove(client);
				
				if(smode && client->isstate())
					keyboard::tscreen();  // turn off screen mode

				tb_pg->draw_pager();
				
				return TRUE;
			}	
			if(tb_ap->remove(w))  // client on toolbar
				return TRUE;
				
			if(event->xdestroywindow.event != w)
				return TRUE;

			if(w == tb->winId() || w == tb_pg->winId() || w == tb_wl->winId() || w == tb_mn->winId() || w == tb_pb->winId())
				sig_term(SIGTERM);

			return FALSE;

		case MapNotify:
			if(event->xmap.event != event->xmap.window)
				return TRUE;
		
			if((client = pwindows.find(event->xmap.window)) != NULL)
				tb_pg->add(client);  // add to pager

			return FALSE;

		case UnmapNotify:
			if((client = cwindows.find(event->xunmap.window)) != NULL)
			{
				if(event->xunmap.send_event)
				{
					// client requested transitions 
					// normal -> withdrawn
					// iconic -> withdrawn
					
					client->withdraw();
				}
				else
					client->unmap();
				
				return TRUE;	
			}
			if(event->xunmap.event != event->xunmap.window)
				return TRUE;

			if(pwindows.find(event->xunmap.window) != NULL)
				tb_pg->draw_pager();
		
			return FALSE;

		case EnterNotify:
			xev = &event->xcrossing;
			
			if(event->xcrossing.window == qt_xrootwin())
			{
				stopautofocus();
				rootptr = TRUE;
			}
			else if(mrb == FALSE && menu_open == FALSE && (client = (xwindow *)widgetAt(xev->x_root, xev->y_root)) != NULL && 
			clients.find(client) != -1 && ((client = clients.current()) != focusclient || rootptr))
			{
				rootptr = FALSE;
				setinactive(client);  // old client to inactive, save new client
				
				if(xev->detail != NotifyInferior)
					client->startautofocus();

				client->setchildfocus(xev->time);
				client->setcmapfocus();
			}
			return FALSE;

		case ColormapNotify:
			if((client = cwindows.find(event->xcolormap.window)) != NULL)
			{
				client->setcmap(event->xcolormap.colormap);
				return TRUE;
			}	
			return FALSE;

		case PropertyNotify:
			pev = &event->xproperty;
			
			if((client = cwindows.find(pev->window)) != NULL)
			{
				if(pev->atom == XA_WM_NORMAL_HINTS)
				{
					client->get_wmnormalhints();
				}	
				else if(pev->atom == XA_WM_HINTS)
				{
					client->get_wmhints();
				}
				else if(pev->atom == XA_WM_NAME || pev->atom == XA_WM_ICON_NAME)
				{
					client->get_wmname();
				}
				else if(pev->atom == wm_colormaps)
				{
					client->get_colormaps();
					
					if(client == focusclient)
						client->setcmapfocus();
				}
				return TRUE;
			}
			return FALSE;

		case ConfigureNotify:
			if(event->xconfigure.event != event->xconfigure.window)
				return TRUE;
				
			if((client = pwindows.find(event->xconfigure.window)) != NULL)
			{
				tb_pg->draw_pager();
				while(XCheckTypedEvent(qt_xdisplay(), ConfigureNotify, &ev));
			}
			return TRUE;

		case ReparentNotify:
			if((client = cwindows.find(event->xreparent.window)) != NULL &&
			event->xreparent.parent != client->winId())
			{
				clients.remove(client);
				tb_pg->draw_pager();
			}	
			return TRUE;
		
		case ButtonPress:
			w = event->xbutton.window;
			
			if(w == qt_xrootwin())  // set focus to root window
				XSetInputFocus(qt_xdisplay(), w, RevertToPointerRoot, CurrentTime);

			if(w == tb->winId() || w == tb_pb->winId() || w == tb_ap->winId())
				XRaiseWindow(qt_xdisplay(), tb->winId());

			if(w == qt_xrootwin() || w == tb_pg->winId())
				install_colormap(None);
				
			return FALSE;

		case FocusOut:
			if(menu_open) // Qt 2.2.4 does not seem to like this if a menu is open
				return TRUE;

			return FALSE;

		case ClientMessage:
			mev = &event->xclient;
			
			if(mev->message_type == wm_change_state && mev->format == 32 && 
			mev->data.l[0] == IconicState && (client = cwindows.find(mev->window)) != NULL)
				client->iconify();

			return TRUE;	

		case CirculateRequest:
			rev = &event->xcirculaterequest;
			
			if(rev->place == PlaceOnTop)
				XRaiseWindow(qt_xdisplay(), rev->window);
			else
				XLowerWindow(qt_xdisplay(), rev->window);
				
			return TRUE;

		case ConfigureRequest:
			cev = &event->xconfigurerequest;
			XWindowChanges wc;
			
			if((client = cwindows.find(cev->window)) != NULL)
			{
#ifdef DEBUGMSG
	logmsg << "configure request to client (WId:" << client->winId() << ")\n";
#endif	
				if(cev->value_mask & (CWWidth|CWHeight|CWX|CWY))
				{
					if(smode && client->isstate())
						keyboard::tscreen(); 
					
					if(! client->is_tiled() || client == tmaxclient)
					{	
						int cx,cy,cw,ch;

						if(cev->value_mask & CWWidth)
						cw = cev->width;
						else	
							cw = client->width();

						if(cev->value_mask & CWHeight)
							ch = cev->height;
						else
							ch = client->getcheight();

						if((cev->value_mask & CWX) && ! client->is_tiled())
							cx = cev->x;
						else
							cx = client->x();

						if((cev->value_mask & CWY) && ! client->is_tiled())
					    		cy = cev->y;
						else
							cy = client->y();
						
						client->resize_request(cx, cy, cw, ch);
					}
					cev->value_mask &= ~(CWWidth|CWHeight|CWX|CWY);
				}
				
				if(! cev->value_mask)
					return TRUE;

				wc.width = client->width();
				wc.height = client->height();
				wc.x = client->x();
				wc.y = client->y();
				wc.border_width = 0;
				wc.sibling = cev->above;
				wc.stack_mode = cev->detail;

				XConfigureWindow(qt_xdisplay(), client->winId(), cev->value_mask, &wc);
				send_configurenotify(client);
			}
			else  // never mapped window
			{
				if(cev->window == tb->winId() || tb_ap->client_exists(cev->window))  // deny requests on toolbar
					return TRUE;

#ifdef DEBUGMSG
	logmsg << "configure request to unreparented window (WId:" << cev->window << ")\n";

#endif	

				wc.x = cev->x;
				wc.y = cev->y;
				wc.width = cev->width;
				wc.height = cev->height;
				cev->value_mask &= (CWX|CWY|CWWidth|CWHeight);
				
				XConfigureWindow(qt_xdisplay(), cev->window, cev->value_mask, &wc);	
			}
			return TRUE;
			
		case MapRequest:
			run_client(event->xmaprequest.window);
			return TRUE;
			
		case KeyPress:
			return(keyboard::keypress(&event->xkey));

		default:
			if(servershapes && event->type == (ShapeEventBase + ShapeNotify))
			{
				XShapeEvent *sev = (XShapeEvent *)event;
		
				if((client = cwindows.find(sev->window)) != NULL)
				{
					client->reshape();
					return TRUE;
				}	
			}
	}
	return FALSE;
}
Example #6
0
void qapp::tile_order(xwindow *actclient)
{
	if(smode)
		return;

	xwindow *client,*tmcl=NULL;

	int cct=0,cheight,lh=0;
	QWidget *dt = QApplication::desktop();

	if(actclient != NULL && (clients.find(actclient) == -1 || ! actclient->is_tileable() || actclient->is_unmapped() || ! is_curdesk(actclient)))
		actclient = NULL;

	for(client = clients.first(); client != NULL; client = clients.next())
	{
		if(client != actclient && ! client->is_unmapped() && is_curdesk(client) && client->is_tileable())
			cct++;
	}

	if(actclient == NULL && cct > 0)
		cct--;

	tmaxclient = NULL;
		
	if(cct)
		cheight = (dt->height()-defaults::tb_height)/cct;

	int xpos,xcw,ypos,yp;
	ypos = yp = defaults::toolbar_top?defaults::tb_height+1:0;
	xpos = (int)(dt->width()*defaults::tleftspace);
	xcw = dt->width()-xpos-1;
	
	for(client = clients.first(); client != NULL; client = clients.next())
	{
		if(! client->is_tileable() || client->is_unmapped() || ! is_curdesk(client)) 
			continue;

		if(actclient == NULL || cct == 0)
			actclient = client;
			
		if(client == actclient)
		{
			tmcl = tmaxclient = client;
			continue;
		}
		
		if(lh < 0)
			lh = 0;
			
		client->minimize_frame(cct > defaults::wminframe?TRUE:FALSE);
			
		lh = client->set_tile(xpos+1, ypos-lh, xcw, cheight+lh);
		ypos += cheight;
	}

	if(tmcl != NULL)
	{
		tmcl->minimize_frame(FALSE);
		tmcl->set_tile(0, yp, xpos, dt->height()-defaults::tb_height);
	}
	
	if(actclient != NULL)
		clients.prepend(clients.take(clients.find(actclient)));
}