File indexing completed on 2024-04-28 03:59:25
0001 /* 0002 SPDX-FileCopyrightText: 2001-2003 Lubos Lunak <l.lunak@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KXMESSAGES_H 0008 #define KXMESSAGES_H 0009 0010 #include <QObject> 0011 #include <kwindowsystem_export.h> 0012 0013 #include <config-kwindowsystem.h> // KWINDOWSYSTEM_HAVE_X11 0014 #if KWINDOWSYSTEM_HAVE_X11 0015 #include <xcb/xcb.h> 0016 typedef struct _XDisplay Display; 0017 0018 class QString; 0019 0020 class KXMessagesPrivate; 0021 0022 /** 0023 * Sending string messages to other applications using the X Client Messages. 0024 * 0025 * Used internally by KStartupInfo and kstart. 0026 * You usually don't want to use this, use D-Bus instead. 0027 * 0028 * @internal 0029 * 0030 * @author Lubos Lunak <l.lunak@kde.org> 0031 */ 0032 class KWINDOWSYSTEM_EXPORT KXMessages : public QObject 0033 { 0034 Q_OBJECT 0035 public: 0036 /** 0037 * Creates an instance which will receive X messages. 0038 * 0039 * @param accept_broadcast if non-nullptr, all broadcast messages with 0040 * this message type will be received. 0041 * @param parent the parent of this widget 0042 */ 0043 explicit KXMessages(const char *accept_broadcast = nullptr, QObject *parent = nullptr); 0044 0045 /** 0046 * @overload 0047 * Overload passing in the xcb_connection_t to use instead relying on platform xcb. 0048 * 0049 * @param connection The xcb connection 0050 * @param rootWindow The rootWindow to use 0051 * @param accept_broadcast if non-nullptr, all broadcast messages with 0052 * this message type will be received. 0053 * @param parent the parent of this object 0054 * @since 5.8 0055 **/ 0056 explicit KXMessages(xcb_connection_t *connection, xcb_window_t rootWindow, const char *accept_broadcast = nullptr, QObject *parent = nullptr); 0057 0058 ~KXMessages() override; 0059 /** 0060 * Broadcasts the given message with the given message type. 0061 * @param msg_type the type of the message 0062 * @param message the message itself 0063 * @param screen X11 screen to use, -1 for the default 0064 */ 0065 void broadcastMessage(const char *msg_type, const QString &message, int screen = -1); 0066 0067 /** 0068 * Broadcasts the given message with the given message type. 0069 * 0070 * @param c X11 connection which will be used instead of 0071 * QX11Info::connection() 0072 * @param msg_type the type of the message 0073 * @param message the message itself 0074 * @param screenNumber X11 screen to use 0075 * @return false when an error occurred, true otherwise 0076 */ 0077 static bool broadcastMessageX(xcb_connection_t *c, const char *msg_type, const QString &message, int screenNumber); 0078 0079 Q_SIGNALS: 0080 /** 0081 * Emitted when a message was received. 0082 * @param message the message that has been received 0083 */ 0084 void gotMessage(const QString &message); 0085 0086 private: 0087 friend class KXMessagesPrivate; 0088 KXMessagesPrivate *const d; 0089 }; 0090 0091 #endif 0092 #endif