KWindowSystem

kxmessages.h
1 /*
2  SPDX-FileCopyrightText: 2001-2003 Lubos Lunak <[email protected]>
3 
4  SPDX-License-Identifier: MIT
5 */
6 
7 #ifndef KXMESSAGES_H
8 #define KXMESSAGES_H
9 
10 #include <QObject>
11 #include <kwindowsystem_export.h>
12 
13 #include <config-kwindowsystem.h> // KWINDOWSYSTEM_HAVE_X11
14 #if KWINDOWSYSTEM_HAVE_X11
15 #include <xcb/xcb.h>
16 typedef struct _XDisplay Display;
17 
18 class QString;
19 
20 class KXMessagesPrivate;
21 
22 /**
23  * Sending string messages to other applications using the X Client Messages.
24  *
25  * Used internally by KStartupInfo and kstart.
26  * You usually don't want to use this, use D-Bus instead.
27  *
28  * @internal
29  *
30  * @author Lubos Lunak <[email protected]>
31  */
32 class KWINDOWSYSTEM_EXPORT KXMessages : public QObject
33 {
34  Q_OBJECT
35 public:
36  /**
37  * Creates an instance which will receive X messages.
38  *
39  * @param accept_broadcast if non-nullptr, all broadcast messages with
40  * this message type will be received.
41  * @param parent the parent of this widget
42  */
43  explicit KXMessages(const char *accept_broadcast = nullptr, QObject *parent = nullptr);
44 
45  /**
46  * @overload
47  * Overload passing in the xcb_connection_t to use instead relying on platform xcb.
48  *
49  * @param connection The xcb connection
50  * @param rootWindow The rootWindow to use
51  * @param accept_broadcast if non-nullptr, all broadcast messages with
52  * this message type will be received.
53  * @param parent the parent of this object
54  * @since 5.8
55  **/
56  explicit KXMessages(xcb_connection_t *connection, xcb_window_t rootWindow, const char *accept_broadcast = nullptr, QObject *parent = nullptr);
57 
58  ~KXMessages() override;
59  /**
60  * Broadcasts the given message with the given message type.
61  * @param msg_type the type of the message
62  * @param message the message itself
63  * @param screen X11 screen to use, -1 for the default
64  */
65  void broadcastMessage(const char *msg_type, const QString &message, int screen = -1);
66 // Not 5.0, as KStartupInfo::sendStartupX uses this, and is only deprecated for 5.18
67 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18)
68  /**
69  * Broadcasts the given message with the given message type.
70  *
71  * @param disp X11 connection which will be used instead of
72  * QX11Info::display()
73  * @param msg_type the type of the message
74  * @param message the message itself
75  * @param screen X11 screen to use, -1 for the default
76  * @return false when an error occurred, true otherwise
77  * @deprecated since 5.0 use xcb variant
78  */
79  KWINDOWSYSTEM_DEPRECATED_VERSION(
80  5,
81  0,
82  "Use KXMessages::broadcastMessageX(xcb_connection_t *, const char *, const QString &, int)")
83  static bool broadcastMessageX(Display *disp, const char *msg_type, const QString &message, int screen = -1);
84 #endif
85  /**
86  * Broadcasts the given message with the given message type.
87  *
88  * @param c X11 connection which will be used instead of
89  * QX11Info::connection()
90  * @param msg_type the type of the message
91  * @param message the message itself
92  * @param screenNumber X11 screen to use
93  * @return false when an error occurred, true otherwise
94  */
95  static bool broadcastMessageX(xcb_connection_t *c, const char *msg_type, const QString &message, int screenNumber);
96 
97 #if 0 // currently unused
98  /**
99  * Sends the given message with the given message type only to given
100  * window.
101  *
102  * @param w X11 handle for the destination window
103  * @param msg_type the type of the message
104  * @param message the message itself
105  */
106  void sendMessage(WId w, const char *msg_type, const QString &message);
107  /**
108  * Sends the given message with the given message type only to given
109  * window.
110  *
111  * @param disp X11 connection which will be used instead of
112  * QX11Info::display()
113  * @param w X11 handle for the destination window
114  * @param msg_type the type of the message
115  * @param message the message itself
116  * @return false when an error occurred, true otherwise
117  */
118  static bool sendMessageX(Display *disp, WId w, const char *msg_type,
119  const QString &message);
120 #endif
121 
122 Q_SIGNALS:
123  /**
124  * Emitted when a message was received.
125  * @param message the message that has been received
126  */
127  void gotMessage(const QString &message);
128 
129 private:
130  friend class KXMessagesPrivate;
131  KXMessagesPrivate *const d;
132 };
133 
134 #endif
135 #endif
Sending string messages to other applications using the X Client Messages.
Definition: kxmessages.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:41:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.