1 /***************************************************************************
2 * Copyright (C) 2005-2006 by Tarek Saidi, Felix Geyer *
3 * tarek.saidi@arcor.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "HelperX11.h"
24 #ifdef GLOBAL_AUTOTYPE
25 #include "AutoTypeGlobalX11.h"
27 uint HelperX11::getShortcutModifierMask(const Shortcut& s){
28 AutoTypeGlobalX11* autoTypeGlobal = static_cast<AutoTypeGlobalX11*>(autoType);
31 if (s.ctrl) mod |= ControlMask;
32 if (s.shift) mod |= ShiftMask;
33 if (s.alt) mod |= autoTypeGlobal->maskAlt();
34 if (s.altgr) mod |= autoTypeGlobal->maskAltGr();
35 if (s.win) mod |= autoTypeGlobal->maskMeta();
41 unsigned int HelperX11::keyboardModifiers(Display* d){
43 int root_x, root_y, x, y;
45 XQueryPointer(d, RootWindow(d, DefaultScreen(d)), &root, &child, &root_x, &root_y, &x, &y, &mask);
49 void HelperX11:: startCatchErrors(){
50 Q_ASSERT(!catchErrors);
52 pErrorOccurred = false;
53 oldHandler = XSetErrorHandler(x11ErrorHandler);
56 void HelperX11::stopCatchErrors(){
57 Q_ASSERT(catchErrors);
58 XSync(QX11Info::display(), false);
59 XSetErrorHandler(oldHandler);
63 int HelperX11::x11ErrorHandler(Display* display, XErrorEvent* error){
67 pErrorOccurred = true;
71 int (*HelperX11::oldHandler) (Display*, XErrorEvent*) = NULL;
72 bool HelperX11::catchErrors = false;
73 bool HelperX11::pErrorOccurred = false;
75 KeySym HelperX11::getKeysym(const QChar& c){
76 ushort unicode = c.unicode();
78 /* first check for Latin-1 characters (1:1 mapping) */
79 if ((unicode >= 0x0020 && unicode <= 0x007e) ||
80 (unicode >= 0x00a0 && unicode <= 0x00ff))
82 else if (unicode >= 0x0100)
83 return unicode|0x01000000;