summaryrefslogtreecommitdiffstats
path: root/tdeui/tdemainwindowiface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdeui/tdemainwindowiface.cpp')
-rw-r--r--tdeui/tdemainwindowiface.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tdeui/tdemainwindowiface.cpp b/tdeui/tdemainwindowiface.cpp
index 8f8a9d40c..7161ec86f 100644
--- a/tdeui/tdemainwindowiface.cpp
+++ b/tdeui/tdemainwindowiface.cpp
@@ -27,6 +27,29 @@
#include <tdeaction.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(TDEMainWindow * 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);
+}
TDEMainWindowInterface::TDEMainWindowInterface(TDEMainWindow * mainWindow)
: DCOPObject( mainWindow->name())
@@ -182,6 +205,20 @@ void TDEMainWindowInterface::show()
{
m_MainWindow->show();
}
+void TDEMainWindowInterface::setActiveWindow()
+{
+ m_MainWindow->setActiveWindow();
+}
+void TDEMainWindowInterface::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 TDEMainWindowInterface::functionsDynamic()
{
return m_dcopPropertyProxy->functions();