[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/kmail
From:       Torgny Nyblom <kde () nyblom ! org>
Date:       2010-11-24 14:49:51
Message-ID: 20101124144951.A7758AC8A4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1200286 by tnyblom:

Patch from George Metaxas, Thanks!

This patch fixes bug 74938, which is related to the way in which the
systray icon of KMail behaves. Currently, clicking on the systray icon
has the effect of minimizing the KMail window, irrespective of its
position in the window stack, and maximizing it if it was previously
minimized. In the latter case, the current virtual desktop is changed to
the virtual desktop where the KMail window was minimized. As noted in
the corresponding bug entry, this behavior is different than the
corresponding behavior of other KDE applications (e.g. Akregator).

The patch modifies the behavior of the KMail systray clicking handling,
by making it identical to other applications (e.g. Akregator). When
the KMail window is the top level window in the virtual desktop, it
is minimized. If it is visible in the desktop, but not at the top,
it is brought to the top. If the window is minimized, then it is
maximized to the current virtual desktop.

BUG: 74938


 M  +26 -58    kmsystemtray.cpp  
 M  +0 -2      kmsystemtray.h  


--- trunk/KDE/kdepim/kmail/kmsystemtray.cpp #1200285:1200286
@@ -60,7 +60,6 @@
  */
 KMSystemTray::KMSystemTray(QObject *parent)
   : KStatusNotifierItem( parent),
-    mParentVisible( true ),
     mPosOfMainWin( 0, 0 ),
     mDesktopOfMainWin( 0 ),
     mMode( GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ),
@@ -227,10 +226,32 @@
  */
 void KMSystemTray::slotActivated()
 {
-  if( mParentVisible && mainWindowIsOnCurrentDesktop() )
-    hideKMail();
-  else
-    showKMail();
+  KMMainWidget * mainWidget = kmkernel->getKMMainWidget();
+  if ( !mainWidget )
+    return ;
+
+  QWidget *mainWin = kmkernel->getKMMainWidget()->topLevelWidget();
+  if ( !mainWin )
+    return ;
+
+  KWindowInfo cur = KWindowSystem::windowInfo( mainWin->winId(), NET::WMDesktop );
+  
+  int currentDesktop = KWindowSystem::currentDesktop();
+  bool wasMinimized = cur.isMinimized();
+  
+  if ( cur.valid() )
+    mDesktopOfMainWin = cur.desktop();
+
+  if (wasMinimized  && (currentDesktop != mDesktopOfMainWin) && ( mDesktopOfMainWin \
== NET::OnAllDesktops )) +    KWindowSystem::setOnDesktop(mainWin->winId(), \
currentDesktop); +
+  if ( mDesktopOfMainWin == NET::OnAllDesktops )
+    KWindowSystem::setOnAllDesktops( mainWin->winId(), true );
+  
+  KWindowSystem::activateWindow( mainWin->winId() );
+  
+  if (wasMinimized )
+    kmkernel->raise();
 }
 
 void KMSystemTray::slotContextMenuAboutToShow()
@@ -297,58 +318,6 @@
 
 
 
-bool KMSystemTray::mainWindowIsOnCurrentDesktop()
-{
-#ifdef Q_WS_X11
-  KMMainWidget * mainWidget = kmkernel->getKMMainWidget();
-  if ( !mainWidget )
-    return false;
-
-  QWidget *mainWin = kmkernel->getKMMainWidget()->topLevelWidget();
-  if ( !mainWin )
-    return false;
-
-  return KWindowSystem::windowInfo( mainWin->winId(),
-                           NET::WMDesktop ).isOnCurrentDesktop();
-#else
-  return true;
-#endif
-}
-
-/**
- * Shows and raises the first KMMainWidget and
- * switches to the appropriate virtual desktop.
- */
-void KMSystemTray::showKMail()
-{
-  if (!kmkernel->getKMMainWidget())
-    return;
-  QWidget *mainWin = kmkernel->getKMMainWidget()->topLevelWidget();
-  assert(mainWin);
-#ifdef Q_WS_X11
-  if(mainWin)
-  {
-    KWindowInfo cur = KWindowSystem::windowInfo( mainWin->winId(), NET::WMDesktop );
-    if ( cur.valid() ) mDesktopOfMainWin = cur.desktop();
-    // switch to appropriate desktop
-    if ( mDesktopOfMainWin != NET::OnAllDesktops )
-      KWindowSystem::setCurrentDesktop( mDesktopOfMainWin );
-    if ( !mParentVisible ) {
-      if ( mDesktopOfMainWin == NET::OnAllDesktops )
-        KWindowSystem::setOnAllDesktops( mainWin->winId(), true );
-    }
-    KWindowSystem::activateWindow( mainWin->winId() );
-  }
-#endif
-  if ( !mParentVisible ) {
-    mainWin->move( mPosOfMainWin );
-    mainWin->show();
-    mParentVisible = true;
-  }
-  kmkernel->raise();
-
-}
-
 void KMSystemTray::hideKMail()
 {
   if (!kmkernel->getKMMainWidget())
@@ -365,7 +334,6 @@
     KWindowSystem::minimizeWindow( mainWin->winId() );
 #endif
     mainWin->hide();
-    mParentVisible = false;
   }
 }
 
--- trunk/KDE/kdepim/kmail/kmsystemtray.h #1200285:1200286
@@ -61,7 +61,6 @@
 
 protected:
   bool mainWindowIsOnCurrentDesktop();
-  void showKMail();
   void buildPopupMenu();
   void updateCount();
   void fillFoldersMenu( QMenu *menu, const QAbstractItemModel *model, const QString& \
parentName = QString(), const QModelIndex& parentIndex = QModelIndex() ); @@ -70,7 \
+69,6 @@  
 private:
 
-  bool mParentVisible;
   QPoint mPosOfMainWin;
   int mDesktopOfMainWin;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic