diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-06-20 12:28:49 -0500 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-12-23 02:22:27 +0100 |
commit | 3c86967a318c01499b4129a6620f33f5118fb204 (patch) | |
tree | 1d5b4dc90a92413b3c6386b035e7b3311022ef26 | |
parent | a4be37c118fb0dbe6c5b069e15379acc33f9612f (diff) | |
download | tdelibs-3c86967a318c01499b4129a6620f33f5118fb204.tar.gz tdelibs-3c86967a318c01499b4129a6620f33f5118fb204.zip |
Add ability to set active window to TDEMainWindow
(cherry picked from commit 6f1973a708396873d12b51b32667bd0b9a530263)
-rw-r--r-- | kdeui/kmainwindowiface.cpp | 37 | ||||
-rw-r--r-- | kdeui/kmainwindowiface.h | 2 |
2 files changed, 39 insertions, 0 deletions
diff --git a/kdeui/kmainwindowiface.cpp b/kdeui/kmainwindowiface.cpp index f8ef88c31..da4d468a6 100644 --- a/kdeui/kmainwindowiface.cpp +++ b/kdeui/kmainwindowiface.cpp @@ -27,6 +27,29 @@ #include <kaction.h> #include <tqclipboard.h> +#include <X11/Xlib.h> +#include <X11/Xatom.h> + +// INTERNAL +// Originally from http://permalink.gmane.org/gmane.comp.lib.qt.general/4733 +void wmMessage(KMainWindow * mainWindow, long type, long l0, long l1, long l2, long l3, long l4) +{ + XClientMessageEvent xev; + + xev.type = ClientMessage; + xev.window = mainWindow->winId(); + xev.message_type = type; + xev.format = 32; + xev.data.l[0] = l0; + xev.data.l[1] = l1; + xev.data.l[2] = l2; + xev.data.l[3] = l3; + xev.data.l[4] = l4; + + XSendEvent(mainWindow->x11Display(), mainWindow->winId(), False, + (SubstructureNotifyMask | SubstructureRedirectMask), + (XEvent *)&xev); +} KMainWindowInterface::KMainWindowInterface(KMainWindow * mainWindow) : DCOPObject( mainWindow->name()) @@ -182,6 +205,20 @@ void KMainWindowInterface::show() { m_MainWindow->show(); } +void KMainWindowInterface::setActiveWindow() +{ + m_MainWindow->setActiveWindow(); +} +void KMainWindowInterface::setActiveWindowFocused() +{ + // just in case we don't have a WM running + m_MainWindow->raise(); + m_MainWindow->setActiveWindow(); + + // activate window (try to work around focus-stealing prevention) + static Atom NET_ACTIVE_WINDOW = XInternAtom(m_MainWindow->x11Display(), "_NET_ACTIVE_WINDOW", False); + wmMessage(m_MainWindow, NET_ACTIVE_WINDOW, 2, CurrentTime, 0, 0, 0); +} QCStringList KMainWindowInterface::functionsDynamic() { return m_dcopPropertyProxy->functions(); diff --git a/kdeui/kmainwindowiface.h b/kdeui/kmainwindowiface.h index f7f7a0bb8..8e56a2532 100644 --- a/kdeui/kmainwindowiface.h +++ b/kdeui/kmainwindowiface.h @@ -147,6 +147,8 @@ k_dcop: void restore(); void show(); void close(); + void setActiveWindow(); + void setActiveWindowFocused(); // QCStringList getQTProperties(); |