1/* This file is part of the KDE libraries
2 Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library 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 GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef _KGLOBALACCEL_X11_H
21#define _KGLOBALACCEL_X11_H
22
23#include <QWidget>
24
25class GlobalShortcutsRegistry;
26/**
27 * @internal
28 *
29 * The KGlobalAccel private class handles grabbing of global keys,
30 * and notification of when these keys are pressed.
31 */
32class KGlobalAccelImpl : public QWidget
33{
34 Q_OBJECT
35
36public:
37 KGlobalAccelImpl( GlobalShortcutsRegistry *owner);
38
39public:
40 /**
41 * This function registers or unregisters a certain key for global capture,
42 * depending on \b grab.
43 *
44 * Before destruction, every grabbed key will be released, so this
45 * object does not need to do any tracking.
46 *
47 * \param key the Qt keycode to grab or release.
48 * \param grab true to grab they key, false to release the key.
49 *
50 * \return true if successful, otherwise false.
51 */
52 bool grabKey(int key, bool grab);
53
54 /// Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point.
55 void setEnabled(bool);
56
57private:
58 /**
59 * Filters X11 events ev for key bindings in the accelerator dictionary.
60 * If a match is found the activated activated is emitted and the function
61 * returns true. Return false if the event is not processed.
62 *
63 * This is public for compatibility only. You do not need to call it.
64 */
65 virtual bool x11Event( XEvent* );
66 void x11MappingNotify();
67 bool x11KeyPress( const XEvent *pEvent );
68
69 GlobalShortcutsRegistry *m_owner;
70};
71
72#endif // _KGLOBALACCEL_X11_H
73