KWindowSystem

kxmessages.h
1/*
2 SPDX-FileCopyrightText: 2001-2003 Lubos Lunak <l.lunak@kde.org>
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>
16typedef struct _XDisplay Display;
17
18class QString;
19
20class 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 <l.lunak@kde.org>
31 */
32class KWINDOWSYSTEM_EXPORT KXMessages : public QObject
33{
34 Q_OBJECT
35public:
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
67 /**
68 * Broadcasts the given message with the given message type.
69 *
70 * @param c X11 connection which will be used instead of
71 * QX11Info::connection()
72 * @param msg_type the type of the message
73 * @param message the message itself
74 * @param screenNumber X11 screen to use
75 * @return false when an error occurred, true otherwise
76 */
77 static bool broadcastMessageX(xcb_connection_t *c, const char *msg_type, const QString &message, int screenNumber);
78
80 /**
81 * Emitted when a message was received.
82 * @param message the message that has been received
83 */
84 void gotMessage(const QString &message);
85
86private:
87 friend class KXMessagesPrivate;
88 KXMessagesPrivate *const d;
89};
90
91#endif
92#endif
Sending string messages to other applications using the X Client Messages.
Definition kxmessages.h:33
void gotMessage(const QString &message)
Emitted when a message was received.
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.