kdeui: partially revert 9c496296af

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2019-06-27 19:52:36 +00:00
parent b08f412618
commit 2e06275ade
4 changed files with 102 additions and 20 deletions

View file

@ -164,7 +164,7 @@ class KStartupInfo::Private
: q( q ),
timeout( 60 ),
#ifdef Q_WS_X11
msgs( NET_STARTUP_MSG, NULL ),
msgs( NET_STARTUP_MSG, NULL, false ),
#endif
flags( flags_P )
{
@ -446,7 +446,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);
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
#endif
return true;
}
@ -463,7 +463,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 );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
#else
return true;
#endif
@ -495,7 +495,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 );
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
#endif
return true;
}
@ -511,7 +511,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 );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
#else
return true;
#endif
@ -525,7 +525,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 );
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
#endif
return true;
}
@ -539,7 +539,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 );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
#else
return true;
#endif
@ -554,7 +554,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 );
msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false );
#endif
return true;
}
@ -570,7 +570,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 );
return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false );
#else
return true;
#endif

View file

@ -17,7 +17,6 @@
* Boston, MA 02110-1301, USA.
*/
#include <QRect>
#include <QFontMetrics>
#include <QtGui/qx11info_x11.h>
#include <qtest_kde.h>

View file

@ -63,35 +63,72 @@ KXMessages::KXMessages( const char* accept_broadcast_P, QWidget* parent_P )
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 );
}
else
{
d->accept_atom1 = d->accept_atom2 = None;
}
d->handle = new QWidget( this );
}
KXMessages::~KXMessages()
{
delete d;
}
void KXMessages::broadcastMessage( const char* msg_type_P, const QString& message_P )
{
broadcastMessage( msg_type_P, message_P, -1, true );
}
void KXMessages::broadcastMessage( const char* msg_type_P, const QString& message_P,
int screen_P )
int screen_P, bool obsolete_P )
{
Atom a2 = XInternAtom( QX11Info::display(), msg_type_P, false );
Atom a1 = XInternAtom( QX11Info::display(), QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false );
Atom a1 = obsolete_P ? a2 : XInternAtom( QX11Info::display(), QByteArray(QByteArray( msg_type_P ) + "_BEGIN").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 )
{
Atom a2 = XInternAtom( QX11Info::display(), msg_type_P, false );
Atom a1 = XInternAtom( QX11Info::display(), QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false );
Atom a1 = obsolete_P ? a2 : XInternAtom( QX11Info::display(), QByteArray(QByteArray( msg_type_P ) + "_BEGIN").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, int screen_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 )
{
if( disp == NULL )
return false;
Atom a2 = XInternAtom( disp, msg_type_P, false );
Atom a1 = XInternAtom( disp, QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false );
Atom a1 = obsolete_P ? a2 : XInternAtom( disp, QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false );
Window root = screen_P == -1 ? DefaultRootWindow( disp ) : RootWindow( disp, screen_P );
Window win = XCreateSimpleWindow( disp, root, 0, 0, 1, 1,
0, BlackPixel( disp, screen_P == -1 ? DefaultScreen( disp ) : screen_P ),
@ -105,10 +142,16 @@ bool KXMessages::broadcastMessageX( Display* disp, const char* msg_type_P,
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 )
{
if( disp == NULL )
return false;
Atom a2 = XInternAtom( disp, msg_type_P, false );
Atom a1 = XInternAtom( disp, QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false );
Atom a1 = obsolete_P ? a2 : XInternAtom( disp, QByteArray(QByteArray( msg_type_P ) + "_BEGIN").constData(), false );
Window win = XCreateSimpleWindow( disp, DefaultRootWindow( disp ), 0, 0, 1, 1,
0, BlackPixelOfScreen( DefaultScreenOfDisplay( disp )),
BlackPixelOfScreen( DefaultScreenOfDisplay( disp )));

View file

@ -54,8 +54,15 @@ class KDEUI_EXPORT KXMessages
* @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 = NULL, QWidget* parent = 0 );
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 );
virtual ~KXMessages();
/**
@ -65,6 +72,14 @@ class KDEUI_EXPORT KXMessages
* @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 );
/**
@ -72,9 +87,17 @@ class KDEUI_EXPORT KXMessages
* @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 = -1);
int screen, bool obsolete );
/**
* @deprecated
* This method is equivalent to broadcastMessage() with obsolete = true.
*/
void broadcastMessage( const char* msg_type, const QString& message );
/**
* Sends the given message with the given message type only to given
* window.
@ -84,10 +107,19 @@ class KDEUI_EXPORT KXMessages
* @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 );
/**
* Broadcasts the given message with the given message type.
*
@ -96,10 +128,18 @@ class KDEUI_EXPORT KXMessages
* @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 );
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 );
Q_SIGNALS:
/**
* Emitted when a message was received.