KWindowSystem

kselectionwatcher.h
1 /*
2  SPDX-FileCopyrightText: 2003 Lubos Lunak <[email protected]>
3 
4  SPDX-License-Identifier: MIT
5 */
6 
7 #ifndef KSELECTIONWATCHER_H
8 #define KSELECTIONWATCHER_H
9 
10 #include <QObject>
11 #include <kwindowsystem_export.h>
12 
13 #include <xcb/xcb.h>
14 #include <xcb/xproto.h>
15 
16 /**
17  This class implements watching manager selections, as described in the ICCCM
18  section 2.8. It emits signal newOwner() when a new owner claim the selection,
19  and emits lostOwner() when the selection ownership is given up. To find
20  out current owner of the selection, owner() can be used.
21  @short ICCCM manager selection watching
22 
23  This class is only useful on the xcb platform. On other platforms the code is only
24  functional if the constructor overloads taking an xcb_connection_t are used. In case
25  you inherit from this class ensure that you don't use xcb and/or XLib without verifying
26  the platform.
27 */
28 class KWINDOWSYSTEM_EXPORT KSelectionWatcher : public QObject
29 {
30  Q_OBJECT
31 public:
32  /**
33  * This constructor initializes the object, but doesn't perform any
34  * operation on the selection.
35  *
36  * @param selection atom representing the manager selection
37  * @param screen X screen, or -1 for default
38  * @param parent parent object, or nullptr if there is none
39  */
40  explicit KSelectionWatcher(xcb_atom_t selection, int screen = -1, QObject *parent = nullptr);
41  /**
42  * @overload
43  * This constructor accepts the selection name and creates the appropriate atom
44  * for it automatically.
45  *
46  * @param selection name of the manager selection
47  * @param screen X screen, or -1 for default
48  * @param parent parent object, or nullptr if there is none
49  */
50  explicit KSelectionWatcher(const char *selection, int screen = -1, QObject *parent = nullptr);
51  /**
52  * @overload
53  * This constructor accepts the xcb_connection_t and root window and doesn't depend on
54  * running on the xcb platform. Otherwise this constructor behaves like the similar one
55  * without the xcb_connection_t.
56  *
57  * @param selection atom representing the manager selection
58  * @param c the xcb connection this KSelectionWatcher should use
59  * @param root the root window this KSelectionWatcher should use
60  * @since 5.8
61  **/
62  explicit KSelectionWatcher(xcb_atom_t selection, xcb_connection_t *c, xcb_window_t root, QObject *parent = nullptr);
63  /**
64  * @overload
65  * This constructor accepts the xcb_connection_t and root window and doesn't depend on
66  * running on the xcb platform. Otherwise this constructor behaves like the similar one
67  * without the xcb_connection_t.
68  *
69  * @param selection name of the manager selection
70  * @param c the xcb connection this KSelectionWatcher should use
71  * @param root the root window this KSelectionWatcher should use
72  * @since 5.8
73  **/
74  explicit KSelectionWatcher(const char *selection, xcb_connection_t *c, xcb_window_t root, QObject *parent = nullptr);
75  ~KSelectionWatcher() override;
76  /**
77  * Return the current owner of the manager selection, if any. Note that if the event
78  * informing about the owner change is still in the input queue, newOwner() might
79  * have been emitted yet.
80  */
81  xcb_window_t owner();
82  /**
83  * @internal
84  */
85  void filterEvent(void *ev_P); // internal
86 Q_SIGNALS:
87  /**
88  * This signal is emitted when the selection is successfully claimed by a new
89  * owner.
90  * @param owner the new owner of the selection
91  */
92  void newOwner(xcb_window_t owner);
93  /**
94  * This signal is emitted when the selection is given up, i.e. there's no
95  * owner. Note that the selection may be immediately claimed again,
96  * so the newOwner() signal may be emitted right after this one.
97  * It's safe to delete the instance in a slot connected to this signal.
98  */
99  void lostOwner();
100 
101 private:
102  void init();
103 
104  class Private;
105  Private *const d;
106 };
107 
108 Q_DECLARE_METATYPE(xcb_window_t)
109 
110 #endif
This class implements watching manager selections, as described in the ICCCM section 2...
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 22:41:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.