From 9d6db31fee1eff278e06cbf2dcad5f49c028cc22 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 6 Jan 2021 05:23:11 +0200 Subject: [PATCH] move startup message to QWidgetPrivate::sendStartupMessage() Signed-off-by: Ivailo Monev --- src/gui/kernel/qwidget_p.h | 2 +- src/gui/kernel/qwidget_x11.cpp | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index a6f3cfec9..846e11f39 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -599,7 +599,7 @@ public: static QWidget *keyboardGrabber; void setWindowRole(); - void sendStartupMessage(const char *message) const; + void sendStartupMessage() const; void setNetWmWindowTypes(); void x11UpdateIsOpaque(); bool isBackgroundInherited() const; diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 866d8a318..d0e9907ca 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1956,10 +1956,7 @@ void QWidgetPrivate::show_sys() // Freedesktop.org Startup Notification if (qt_x11Data->startupId && q->isWindow()) { - QByteArray message("remove: ID="); - message.append(qt_x11Data->startupId); - sendStartupMessage(message.constData()); - qt_x11Data->startupId = 0; + sendStartupMessage(); } } @@ -1968,12 +1965,12 @@ void QWidgetPrivate::show_sys() Platform-specific part of QWidget::show(). */ -void QWidgetPrivate::sendStartupMessage(const char *message) const +void QWidgetPrivate::sendStartupMessage() const { Q_Q(const QWidget); - if (!message) - return; + QByteArray message("remove: ID="); + message.append(qt_x11Data->startupId); XEvent xevent; xevent.xclient.type = ClientMessage; @@ -1984,7 +1981,7 @@ void QWidgetPrivate::sendStartupMessage(const char *message) const Window rootWindow = RootWindow(qt_x11Data->display, DefaultScreen(qt_x11Data->display)); uint sent = 0; - uint length = strlen(message) + 1; + uint length = message.size() + 1; do { if (sent == 20) xevent.xclient.message_type = ATOM(_NET_STARTUP_INFO); @@ -1994,6 +1991,8 @@ void QWidgetPrivate::sendStartupMessage(const char *message) const XSendEvent(qt_x11Data->display, rootWindow, false, PropertyChangeMask, &xevent); } while (sent <= length); + + qt_x11Data->startupId = 0; } void QWidgetPrivate::setNetWmWindowTypes() -- 2.11.0