KGlobalAccel

kglobalaccel_x11.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef _KGLOBALACCEL_X11_H
9 #define _KGLOBALACCEL_X11_H
10 
11 #include "../../kglobalaccel_interface.h"
12 
13 #include <QAbstractNativeEventFilter>
14 #include <QObject>
15 
16 struct xcb_key_press_event_t;
17 typedef struct _XCBKeySymbols xcb_key_symbols_t;
18 /**
19  * @internal
20  *
21  * The KGlobalAccel private class handles grabbing of global keys,
22  * and notification of when these keys are pressed.
23  */
25 {
26  Q_OBJECT
27  Q_PLUGIN_METADATA(IID "org.kde.kglobalaccel5.KGlobalAccelInterface" FILE "xcb.json")
29 
30 public:
31  KGlobalAccelImpl(QObject *parent = nullptr);
32  ~KGlobalAccelImpl() override;
33 
34 public:
35  /**
36  * This function registers or unregisters a certain key for global capture,
37  * depending on \b grab.
38  *
39  * Before destruction, every grabbed key will be released, so this
40  * object does not need to do any tracking.
41  *
42  * \param key the Qt keycode to grab or release.
43  * \param grab true to grab they key, false to release the key.
44  *
45  * \return true if successful, otherwise false.
46  */
47  bool grabKey(int key, bool grab) override;
48 
49  /// Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point.
50  void setEnabled(bool) override;
51 
52  bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override;
53 
54  static void syncX();
55 
56 private:
57  /**
58  * Filters X11 events ev for key bindings in the accelerator dictionary.
59  * If a match is found the activated activated is emitted and the function
60  * returns true. Return false if the event is not processed.
61  *
62  * This is public for compatibility only. You do not need to call it.
63  */
64  void x11MappingNotify();
65  bool x11KeyPress(xcb_key_press_event_t *event);
66 
67  xcb_key_symbols_t *m_keySymbols;
68  uint8_t m_xkb_first_event;
69 };
70 
71 #endif // _KGLOBALACCEL_X11_H
void setEnabled(bool)
Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point.
QPixmap grab(const QRect &rectangle)
Abstract interface for plugins to implement.
Q_OBJECTQ_OBJECT
bool grabKey(int key, bool grab)
This function registers or unregisters a certain key for global capture, depending on grab...
Q_INTERFACES(...)
QObject * parent() const const
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:48:22 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.