/***************************************************************************
- * Copyright (C) 2005-2013 by the Quassel Project *
+ * Copyright (C) 2005-2016 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This contains code from KStatusNotifierItem, part of the KDE libs *
#ifdef Q_WS_X11
# include <QX11Info>
#endif
-#ifdef HAVE_KDE
+#ifdef HAVE_KDE4
# include <KWindowInfo>
# include <KWindowSystem>
#endif
Q_ASSERT(!_instance);
_instance = this;
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
_dwTickCount = 0;
#endif
+#ifdef Q_OS_MAC
+ GetFrontProcess(&_procNum);
+#endif
}
void GraphicalUi::init()
{
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
mainWidget()->installEventFilter(this);
#endif
}
bool GraphicalUi::eventFilter(QObject *obj, QEvent *event)
{
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
if (obj == mainWidget() && event->type() == QEvent::ActivationChange) {
_dwTickCount = GetTickCount();
}
}
+// NOTE: Window activation stuff seems to work just fine in Plasma 5 without requiring X11 hacks.
+// TODO: Evaluate cleaning all this up once we can get rid of Qt4/KDE4
+
// Code taken from KStatusNotifierItem for handling minimize/restore
bool GraphicalUi::checkMainWidgetVisibility(bool perform)
{
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
// the problem is that we lose focus when the systray icon is activated
// and we don't know the former active window
// therefore we watch for activation event and use our stopwatch :)
return true;
}
-#elif defined(HAVE_KDE) && defined(Q_WS_X11)
+#elif defined(HAVE_KDE4) && defined(Q_WS_X11)
KWindowInfo info1 = KWindowSystem::windowInfo(mainWidget()->winId(), NET::XAWMState | NET::WMState | NET::WMDesktop);
// mapped = visible (but possibly obscured)
bool mapped = (info1.mappingState() == NET::Visible) && !info1.isMinimized();
void GraphicalUi::activateMainWidget()
{
-#ifdef HAVE_KDE
+#ifdef HAVE_KDE4
# ifdef Q_WS_X11
KWindowInfo info = KWindowSystem::windowInfo(mainWidget()->winId(), NET::WMDesktop | NET::WMFrameExtents);
if (_onAllDesktops) {
KWindowSystem::forceActiveWindow(mainWidget()->winId());
# endif
-#else /* HAVE_KDE */
+#else /* HAVE_KDE4 */
#ifdef Q_WS_X11
// Bypass focus stealing prevention
// this does not actually work on all platforms... and causes more evil than good
// mainWidget()->move(mainWidget()->frameGeometry().topLeft()); // avoid placement policies
+#ifdef Q_OS_MAC
+ SetFrontProcess(&instance()->_procNum);
+#else
mainWidget()->show();
mainWidget()->raise();
mainWidget()->activateWindow();
+#endif
-#endif /* HAVE_KDE */
+#endif /* HAVE_KDE4 */
}
void GraphicalUi::hideMainWidget()
{
-#if defined(HAVE_KDE) && defined(Q_WS_X11)
+#if defined(HAVE_KDE4) && defined(Q_WS_X11)
KWindowInfo info = KWindowSystem::windowInfo(mainWidget()->winId(), NET::WMDesktop | NET::WMFrameExtents);
_onAllDesktops = info.onAllDesktops();
#endif
if (instance()->isHidingMainWidgetAllowed())
+#ifdef Q_OS_MAC
+ ShowHideProcess(&instance()->_procNum, false);
+#else
mainWidget()->hide();
+#endif
}