kdeui: remove obsolete KXMessages method arguments

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-10-19 04:13:39 +03:00
parent 92f104fc52
commit c7633132a8
3 changed files with 39 additions and 94 deletions

View file

@ -162,7 +162,7 @@ class KStartupInfo::Private
: q( q ),
timeout( 60 ),
#ifdef Q_WS_X11
msgs( NET_STARTUP_MSG, NULL, false ),
msgs( NET_STARTUP_MSG, NULL ),
#endif
flags( flags_P )
{
@ -425,7 +425,7 @@ bool KStartupInfo::sendStartup( const KStartupInfoId& id_P, const KStartupInfoDa
QX11Info inf;
msg = Private::check_required_startup_fields( msg, data_P, inf.screen());
kDebug( 172 ) << "sending " << msg;
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1 );
#endif
return true;
}
@ -442,7 +442,7 @@ bool KStartupInfo::sendStartupX( Display* disp_P, const KStartupInfoId& id_P,
#ifdef KSTARTUPINFO_ALL_DEBUG
kDebug( 172 ) << "sending " << msg;
#endif
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1 );
#else
return true;
#endif
@ -473,7 +473,7 @@ bool KStartupInfo::sendChange( const KStartupInfoId& id_P, const KStartupInfoDat
QString msg = QString::fromLatin1( "change: %1 %2" )
.arg( id_P.d->to_text()).arg( data_P.d->to_text());
kDebug( 172 ) << "sending " << msg;
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1 );
#endif
return true;
}
@ -489,7 +489,7 @@ bool KStartupInfo::sendChangeX( Display* disp_P, const KStartupInfoId& id_P,
#ifdef KSTARTUPINFO_ALL_DEBUG
kDebug( 172 ) << "sending " << msg;
#endif
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1 );
#else
return true;
#endif
@ -503,7 +503,7 @@ bool KStartupInfo::sendFinish( const KStartupInfoId& id_P )
KXMessages msgs;
QString msg = QString::fromLatin1( "remove: %1" ).arg( id_P.d->to_text());
kDebug( 172 ) << "sending " << msg;
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1 );
#endif
return true;
}
@ -517,7 +517,7 @@ bool KStartupInfo::sendFinishX( Display* disp_P, const KStartupInfoId& id_P )
#ifdef KSTARTUPINFO_ALL_DEBUG
kDebug( 172 ) << "sending " << msg;
#endif
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1 );
#else
return true;
#endif
@ -532,7 +532,7 @@ bool KStartupInfo::sendFinish( const KStartupInfoId& id_P, const KStartupInfoDat
QString msg = QString::fromLatin1( "remove: %1 %2" )
.arg( id_P.d->to_text()).arg( data_P.d->to_text());
kDebug( 172 ) << "sending " << msg;
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1 );
#endif
return true;
}
@ -548,7 +548,7 @@ bool KStartupInfo::sendFinishX( Display* disp_P, const KStartupInfoId& id_P,
#ifdef KSTARTUPINFO_ALL_DEBUG
kDebug( 172 ) << "sending " << msg;
#endif
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1 );
#else
return true;
#endif

View file

@ -23,12 +23,24 @@ DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "kxmessages.h"
#include "kdebug.h"
#include <qx11info_x11.h>
#include <X11/Xlib.h>
#include <fixx11h.h>
#include "kapplication.h"
static QByteArray makeMessageAtomName(const char* const msg_type_P)
{
QByteArray result(msg_type_P);
if (Q_UNLIKELY(result.endsWith("_BEGIN"))) {
kWarning() << "Message" << msg_type_P << "should not end with _BEGIN";
return result;
}
result.append("_BEGIN");
return result;
}
class KXMessagesPrivate
{
public:
@ -46,27 +58,13 @@ const long BROADCAST_MASK = PropertyChangeMask;
KXMessages::KXMessages(const char* accept_broadcast_P, QWidget* parent_P)
: QWidget(parent_P)
, d(new KXMessagesPrivate())
{
if ( accept_broadcast_P != NULL ) {
(void)qApp->desktop(); //trigger desktop widget creation to select root window events
kapp->installX11EventFilter(this); // i.e. PropertyChangeMask
d->accept_atom1 = XInternAtom(QX11Info::display(), accept_broadcast_P, false);
d->accept_atom2 = d->accept_atom1;
} else {
d->accept_atom1 = d->accept_atom2 = None;
}
d->handle = new QWidget( this );
}
KXMessages::KXMessages(const char* accept_broadcast_P, QWidget* parent_P, bool obsolete_P)
: QWidget(parent_P)
, d(new KXMessagesPrivate())
{
if (accept_broadcast_P != NULL) {
(void)qApp->desktop(); //trigger desktop widget creation to select root window events
kapp->installX11EventFilter(this); // i.e. PropertyChangeMask
d->accept_atom2 = XInternAtom(QX11Info::display(), accept_broadcast_P, false);
d->accept_atom1 = obsolete_P ? d->accept_atom2 : XInternAtom( QX11Info::display(), QByteArray(QByteArray(accept_broadcast_P) + "_BEGIN").constData(), false);
const QByteArray a1name = makeMessageAtomName(accept_broadcast_P);
d->accept_atom1 = XInternAtom( QX11Info::display(), a1name.constData(), false);
} else {
d->accept_atom1 = d->accept_atom2 = None;
}
@ -78,47 +76,34 @@ KXMessages::~KXMessages()
delete d;
}
void KXMessages::broadcastMessage(const char* msg_type_P, const QString& message_P)
void KXMessages::broadcastMessage(const char* msg_type_P, const QString& message_P, int screen_P)
{
broadcastMessage(msg_type_P, message_P, -1, true);
}
void KXMessages::broadcastMessage(const char* msg_type_P, const QString& message_P, int screen_P, bool obsolete_P)
{
Atom a2 = XInternAtom( QX11Info::display(), msg_type_P, false );
Atom a1 = obsolete_P ? a2 : XInternAtom(QX11Info::display(), QByteArray(QByteArray(msg_type_P) + "_BEGIN").constData(), false);
Atom a2 = XInternAtom( QX11Info::display(), msg_type_P, false);
const QByteArray a1name = makeMessageAtomName(msg_type_P);
Atom a1 = XInternAtom(QX11Info::display(), a1name.constData(), false);
Window root = screen_P == -1 ? QX11Info::appRootWindow() : QX11Info::appRootWindow( screen_P );
send_message_internal(root, message_P, BROADCAST_MASK, QX11Info::display(), a1, a2, d->handle->winId());
}
void KXMessages::sendMessage( WId w_P, const char* msg_type_P, const QString& message_P )
{
sendMessage( w_P, msg_type_P, message_P, true );
}
void KXMessages::sendMessage(WId w_P, const char* msg_type_P, const QString& message_P, bool obsolete_P)
void KXMessages::sendMessage(WId w_P, const char* msg_type_P, const QString& message_P)
{
Atom a2 = XInternAtom(QX11Info::display(), msg_type_P, false);
Atom a1 = obsolete_P ? a2 : XInternAtom(QX11Info::display(), QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false);
const QByteArray a1name = makeMessageAtomName(msg_type_P);
Atom a1 = XInternAtom(QX11Info::display(), a1name.constData(), false);
send_message_internal(w_P, message_P, 0, QX11Info::display(), a1, a2, d->handle->winId());
}
bool KXMessages::broadcastMessageX(Display* disp, const char* msg_type_P, const QString& message_P )
{
return broadcastMessageX(disp, msg_type_P, message_P, -1, true);
}
bool KXMessages::broadcastMessageX( Display* disp, const char* msg_type_P,
const QString& message_P, int screen_P, bool obsolete_P )
bool KXMessages::broadcastMessageX(Display* disp, const char* msg_type_P, const QString& message_P, int screen_P)
{
if (disp == NULL) {
return false;
}
Atom a2 = XInternAtom(disp, msg_type_P, false);
Atom a1 = obsolete_P ? a2 : XInternAtom(disp, QByteArray(QByteArray(msg_type_P) + "_BEGIN").constData(), false);
const QByteArray a1name = makeMessageAtomName(msg_type_P);
Atom a1 = XInternAtom(disp, a1name.constData(), false);
Window root = screen_P == -1 ? DefaultRootWindow(disp) : RootWindow(disp, screen_P);
Window win = XCreateSimpleWindow(
disp, root, 0, 0, 1, 1,
@ -131,19 +116,15 @@ bool KXMessages::broadcastMessageX( Display* disp, const char* msg_type_P,
return true;
}
bool KXMessages::sendMessageX( Display* disp, WId w_P, const char* msg_type_P, const QString& message_P)
{
return sendMessageX(disp, w_P, msg_type_P, message_P, true);
}
bool KXMessages::sendMessageX(Display* disp, WId w_P, const char* msg_type_P, const QString& message_P, bool obsolete_P)
bool KXMessages::sendMessageX(Display* disp, WId w_P, const char* msg_type_P, const QString& message_P)
{
if (disp == NULL) {
return false;
}
Atom a2 = XInternAtom(disp, msg_type_P, false);
Atom a1 = obsolete_P ? a2 : XInternAtom(disp, QByteArray(QByteArray(msg_type_P) + "_BEGIN").constData(), false);
const QByteArray a1name = makeMessageAtomName(msg_type_P);
Atom a1 = XInternAtom(disp, a1name.constData(), false);
Window win = XCreateSimpleWindow(
disp, DefaultRootWindow(disp), 0, 0, 1, 1,
0, BlackPixelOfScreen( DefaultScreenOfDisplay(disp)),

View file

@ -52,16 +52,8 @@ public:
* @param accept_broadcast if non-NULL, all broadcast messages with
* this message type will be received.
* @param parent the parent of this widget
* @param obsolete always set to false (needed for backwards compatibility
* with KDE3.1 and older)
*/
KXMessages(const char* accept_broadcast, QWidget* parent, bool obsolete);
/**
* @deprecated
* This method is equivalent to the other constructor with obsolete = true.
*/
explicit KXMessages(const char* accept_broadcast = NULL, QWidget* parent = NULL);
KXMessages(const char* accept_broadcast = NULL, QWidget* parent = NULL);
virtual ~KXMessages();
@ -72,13 +64,6 @@ public:
* @param w X11 handle for the destination window
* @param msg_type the type of the message
* @param message the message itself
* @param obsolete always set to false (needed for backwards compatibility
* with KDE3.1 and older)
*/
void sendMessage(WId w, const char* msg_type, const QString& message, bool obsolete);
/**
* @deprecated
* This method is equivalent to sendMessage() with obsolete = true.
*/
void sendMessage(WId w, const char* msg_type, const QString& message);
@ -87,15 +72,8 @@ public:
* @param msg_type the type of the message
* @param message the message itself
* @param screen X11 screen to use, -1 for the default
* @param obsolete always set to false (needed for backwards compatibility
* with KDE3.1 and older)
*/
void broadcastMessage(const char* msg_type, const QString& message, int screen, bool obsolete);
/**
* @deprecated
* This method is equivalent to broadcastMessage() with obsolete = true.
*/
void broadcastMessage(const char* msg_type, const QString& message);
void broadcastMessage(const char* msg_type, const QString& message, int screen);
/**
* Sends the given message with the given message type only to given
@ -106,15 +84,8 @@ public:
* @param w X11 handle for the destination window
* @param msg_type the type of the message
* @param message the message itself
* @param obsolete always set to false (needed for backwards compatibility
* with KDE3.1 and older)
* @return false when an error occurred, true otherwise
*/
static bool sendMessageX(Display* disp, WId w, const char* msg_type, const QString& message, bool obsolete);
/**
* @deprecated
* This method is equivalent to sendMessageX() with obsolete = true.
*/
static bool sendMessageX(Display* disp, WId w, const char* msg_type, const QString& message);
/**
@ -125,16 +96,9 @@ public:
* @param msg_type the type of the message
* @param message the message itself
* @param screen X11 screen to use, -1 for the default
* @param obsolete always set to false (needed for backwards compatibility
* with KDE3.1 and older)
* @return false when an error occurred, true otherwise
*/
static bool broadcastMessageX(Display* disp, const char* msg_type, const QString& message, int screen, bool obsolete);
/**
* @deprecated
* This method is equivalent to broadcastMessageX() with obsolete = true.
*/
static bool broadcastMessageX(Display* disp, const char* msg_type, const QString& message);
static bool broadcastMessageX(Display* disp, const char* msg_type, const QString& message, int screen);
Q_SIGNALS:
/**