summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbscreen.cpp
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2013-04-15 23:52:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-23 21:02:50 +0200
commit1ea1abeb91f544b4cf595d229249ee859090bee5 (patch)
tree745075108bd4b70f50e89f8be9d94ce749e762de /src/plugins/platforms/xcb/qxcbscreen.cpp
parent71a1ff39bcf67117e94b669aa0ee059bf1f03b3a (diff)
Implement startup notification spec again.
This functionality was in Qt4's qapplication_x11.cpp and was missing from the XCB QPA plugin. Ported the code from xlib to xcb. This code was actually tested (with plasma), unlike the Qt-4.8 code which skipped every other character... for (uint i = 0; i < 20 && i + sent <= length; i++) xevent.xclient.data.b[i] = message[i + sent++]; Provide a QPA native-function for accessing the startup id, for cases where an application doesn't show a window, but starts another app instead, or asks a running app to show the window on its behalf. Change-Id: If392179efddd70a51c45a8fab4fb9d753913094a Reviewed-by: David Faure (KDE) <faure@kde.org>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbscreen.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 38b4c873ad..a6ead49a27 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -233,6 +233,40 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const
return 0;
}
+void QXcbScreen::windowShown(QXcbWindow *window)
+{
+ // Freedesktop.org Startup Notification
+ if (!connection()->startupId().isEmpty() && window->window()->isTopLevel()) {
+ sendStartupMessage(QByteArrayLiteral("remove: ID=") + connection()->startupId());
+ connection()->clearStartupId();
+ }
+}
+
+void QXcbScreen::sendStartupMessage(const QByteArray &message) const
+{
+ xcb_window_t rootWindow = root();
+
+ xcb_client_message_event_t ev;
+ ev.response_type = XCB_CLIENT_MESSAGE;
+ ev.format = 8;
+ ev.type = connection()->atom(QXcbAtom::_NET_STARTUP_INFO_BEGIN);
+ ev.window = rootWindow;
+ int sent = 0;
+ int length = message.length() + 1; // include NUL byte
+ const char *data = message.constData();
+ do {
+ if (sent == 20)
+ ev.type = connection()->atom(QXcbAtom::_NET_STARTUP_INFO);
+
+ const int start = sent;
+ const int numBytes = qMin(length - start, 20);
+ memcpy(ev.data.data8, data + start, numBytes);
+ xcb_send_event(connection()->xcb_connection(), false, rootWindow, XCB_EVENT_MASK_PROPERTY_CHANGE, (const char *) &ev);
+
+ sent += numBytes;
+ } while (sent < length);
+}
+
const xcb_visualtype_t *QXcbScreen::visualForId(xcb_visualid_t visualid) const
{
QMap<xcb_visualid_t, xcb_visualtype_t>::const_iterator it = m_visuals.find(visualid);