Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / nsplugins / viewer / xtevents.cpp
bloba8f9aa6b3545bebd049e5a4abcc48266aa8ff4da
1 /*
2 Copyright (c) 2007 Lubos Lunak <l.lunak@suse.cz>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
20 #include "xtevents.h"
22 #include <fixx11h.h>
24 #include <kapplication.h>
25 #include <QX11Info>
27 XtEvents::XtEvents()
29 XtToolkitInitialize();
30 context = XtCreateApplicationContext();
31 int argc = qApp->argc();
32 XtDisplayInitialize( context, QX11Info::display(), qAppName().toLatin1(), QX11Info::appClass(),
33 NULL, 0, &argc, qApp->argv());
34 connect( &timer, SIGNAL( timeout()), SLOT( idleProcess()));
35 kapp->installX11EventFilter( this );
36 // No way to find out when to process Xt events, so poll :(
37 timer.start( 10 );
40 XtEvents::~XtEvents()
44 bool XtEvents::x11Event( XEvent* e )
46 return XtDispatchEvent( e );
49 void XtEvents::idleProcess()
51 for(;;)
53 XtInputMask mask = XtAppPending( context );
54 mask &= ~XtIMXEvent; // these are processed in x11Event()
55 if( mask == 0 )
56 break;
57 // TODO protect from zero timers starving everything
58 XtAppProcessEvent( context, mask );
62 #include "xtevents.moc"