Add comment regarding the removal of X11 hacks to GraphicalUi
[quassel.git] / src / uisupport / graphicalui.cpp
index 5d85500..d1e106d 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2012 by the Quassel Project                        *
+ *   Copyright (C) 2005-2015 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This contains code from KStatusNotifierItem, part of the KDE libs     *
@@ -18,7 +18,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
 #include "graphicalui.h"
@@ -31,7 +31,7 @@
 #ifdef Q_WS_X11
 #  include <QX11Info>
 #endif
-#ifdef HAVE_KDE
+#ifdef HAVE_KDE4
 #  include <KWindowInfo>
 #  include <KWindowSystem>
 #endif
@@ -49,7 +49,7 @@ GraphicalUi::GraphicalUi(QObject *parent) : AbstractUi(parent)
     Q_ASSERT(!_instance);
     _instance = this;
 
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
     _dwTickCount = 0;
 #endif
 }
@@ -57,7 +57,7 @@ GraphicalUi::GraphicalUi(QObject *parent) : AbstractUi(parent)
 
 void GraphicalUi::init()
 {
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
     mainWidget()->installEventFilter(this);
 #endif
 }
@@ -137,7 +137,7 @@ void GraphicalUi::disconnectedFromCore()
 
 bool GraphicalUi::eventFilter(QObject *obj, QEvent *event)
 {
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
     if (obj == mainWidget() && event->type() == QEvent::ActivationChange) {
         _dwTickCount = GetTickCount();
     }
@@ -146,11 +146,14 @@ bool GraphicalUi::eventFilter(QObject *obj, QEvent *event)
 }
 
 
+// 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 :)
@@ -166,7 +169,7 @@ bool GraphicalUi::checkMainWidgetVisibility(bool perform)
         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();
@@ -261,7 +264,7 @@ void GraphicalUi::minimizeRestore(bool show)
 
 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) {
@@ -282,7 +285,7 @@ void GraphicalUi::activateMainWidget()
     KWindowSystem::forceActiveWindow(mainWidget()->winId());
 #  endif
 
-#else /* HAVE_KDE */
+#else /* HAVE_KDE4 */
 
 #ifdef Q_WS_X11
     // Bypass focus stealing prevention
@@ -300,13 +303,13 @@ void GraphicalUi::activateMainWidget()
     mainWidget()->raise();
     mainWidget()->activateWindow();
 
-#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