示例#1
0
文件: qapp.cpp 项目: iattilagy/qlwm
void qapp::run_client(Window w)  // start new client
{
	xwindow *client;
	int apnumber,format;
	Atom type;
	unsigned long nitems=0;
	unsigned long extra=0;
	unsigned char *data=NULL;

	stopautofocus();

	if((client = cwindows[w]) != NULL)
	{
		client->map();
	}
	else  // new client
	{
		XClassHint ch;
		if(XGetClassHint(QX11Info::display(), w, &ch))
		{
			QString clname(ch.res_class);
			QString cclname(ch.res_name);
			cclname += ',';
			cclname += clname;
			
			XFree(ch.res_name);
			XFree(ch.res_class);
			XGetWindowProperty(QX11Info::display(), w, kde_net_wm_system_tray_window_for, 0, 1L, FALSE, XA_WINDOW, &type, &format, &nitems, &extra, &data);

			if(data != NULL)
				XFree(data);

			if(! clname.isEmpty() && ((apnumber = apclients[clname]) || nitems))
			{
				if(tb_ap->add(w, apnumber, clname))  // add to toolbar
					return;
			}

			if(! cclname.isEmpty() && ((apnumber = apclients[cclname]) || nitems))
			{
				if(tb_ap->add(w, apnumber, cclname))
					return;
			}
		}
		clients.prepend((client = new xwindow(w)));

		if(client->is_tileable() && tdesks[adesk] && ! client->is_unmapped())
		{
			tile_order(tmaxclient);

	    		client->show();
	    		XMapWindow(QX11Info::display(), client->client_id());
	    		client->set_clientstate(NormalState);
	    		XSync(QX11Info::display(), FALSE);
			client->raise();
		}	
	}
}
示例#2
0
文件: qapp.cpp 项目: zchydem/qtablet
void qapp::run_client(Window w)  // start new client
{
	xwindow *client;
        int format;
	Atom type;
	unsigned long nitems=0;
	unsigned long extra=0;
	unsigned char *data=NULL;

        stopautofocus();

        qDebug() << "qapp::run_client";
	if((client = cwindows[w]) != NULL)
	{                
                client->map();                
	}
	else  // new client
	{
		XClassHint ch;
		if(XGetClassHint(QX11Info::display(), w, &ch))
		{
			QString clname(ch.res_class);
			QString cclname(ch.res_name);
			cclname += ',';
			cclname += clname;
			
			XFree(ch.res_name);
			XFree(ch.res_class);
			XGetWindowProperty(QX11Info::display(), w, kde_net_wm_system_tray_window_for, 0, 1L, FALSE, XA_WINDOW, &type, &format, &nitems, &extra, &data);

			if(data != NULL)
				XFree(data);

		}


                client = new xwindow(w);
                clients.prepend(client);                

		if(client->is_tileable() && tdesks[adesk] && ! client->is_unmapped())
		{
			tile_order(tmaxclient);

                        client->show();
	    		XMapWindow(QX11Info::display(), client->client_id());
	    		client->set_clientstate(NormalState);                        
	    		XSync(QX11Info::display(), FALSE);
			client->raise();
                        qDebug()  << "New client created and raised **";
		}	
	}
}
示例#3
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;
}