Show
Ignore:
Timestamp:
04/12/08 21:25:28 (8 months ago)
Author:
flynd
Message:

Improved event auto popup to prevent focus stealing from other event windows. Focus is still stolen when opening new windows and minimized windows do not become active after they are restored.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/core/licqgui.cpp

    r6143 r6145  
    870870    return NULL; 
    871871 
     872  // Check if a message window should be made active 
     873  bool activateMsgwin = Config::Chat::instance()->autoFocus(); 
     874 
     875  // Don't change focus if another message window is already active 
     876  const QWidget* activeWin = QApplication::activeWindow(); 
     877  if (activeWin != NULL && ((qobject_cast<const UserEventCommon*>(activeWin)) != NULL || 
     878      (qobject_cast<const UserEventTabDlg*>(activeWin)) != NULL)) 
     879    activateMsgwin = false; 
     880 
    872881  if (Config::Chat::instance()->msgChatView()) 
    873882  { 
     
    886895        //  e->convoJoin(id); 
    887896 
    888         if (myUserEventTabDlg && myUserEventTabDlg->tabExists(e)) 
     897        QWidget* msgWindow = e; 
     898        if (myUserEventTabDlg != NULL && myUserEventTabDlg->tabExists(e)) 
    889899        { 
    890           myUserEventTabDlg->show(); 
    891           if (Config::Chat::instance()->autoFocus()) 
    892           { 
     900          msgWindow = myUserEventTabDlg; 
     901          if (activateMsgwin) 
    893902            myUserEventTabDlg->selectTab(e); 
    894             myUserEventTabDlg->raise(); 
    895             myUserEventTabDlg->activateWindow(); 
    896           } 
    897903        } 
    898         else 
     904 
     905        msgWindow->show(); 
     906        msgWindow->setWindowState(msgWindow->windowState() & ~Qt::WindowMinimized); 
     907        if (activateMsgwin) 
    899908        { 
    900           e->show(); 
    901           if (Config::Chat::instance()->autoFocus() && 
    902               (!qApp->activeWindow() || !qApp->activeWindow()->inherits("UserEventCommon"))) 
    903           { 
    904             e->raise(); 
    905             e->activateWindow(); 
    906           } 
     909          // FIXME: When restoring from minimized, the window isn't activated (at least not on KDE) 
     910          msgWindow->raise(); 
     911          msgWindow->activateWindow(); 
    907912        } 
     913 
    908914        // Make the existing event dialog change to the new event type 
    909915        e->changeEventType(fcn); 
     
    917923  if (Config::Chat::instance()->tabbedChatting()) 
    918924  { 
    919     if (myUserEventTabDlg != NULL) 
    920     { 
    921       if (Config::Chat::instance()->autoFocus()) 
    922       { 
    923         myUserEventTabDlg->raise(); 
    924         myUserEventTabDlg->activateWindow(); 
    925       } 
    926     } 
    927     else 
     925    if (myUserEventTabDlg == NULL) 
    928926    { 
    929927      // create the tab dialog if it does not exist 
     
    970968  connect(e, SIGNAL(viewUrl(QWidget*, QString)), SLOT(viewUrl(QWidget*, QString))); 
    971969 
     970  QWidget* msgWindow = e; 
    972971  if (Config::Chat::instance()->tabbedChatting()) 
    973972  { 
     973    msgWindow = myUserEventTabDlg; 
     974 
    974975    myUserEventTabDlg->addTab(e); 
    975     myUserEventTabDlg->show(); 
    976     if (newtabw) 
    977       e->setFocus(); 
    978  
    979     if (Config::Chat::instance()->autoFocus()) 
    980     { 
    981       myUserEventTabDlg->raise(); 
    982       myUserEventTabDlg->activateWindow(); 
    983     } 
     976    if (activateMsgwin) 
     977      myUserEventTabDlg->selectTab(e); 
    984978 
    985979    // Check if we want the window sticky 
     
    987981      QTimer::singleShot(100, myUserEventTabDlg, SLOT(slotSetMsgWinSticky())); 
    988982  } 
    989   else 
    990     e->show(); 
     983 
     984  // FIXME: New windows always become active stealing focus from other event windows (at least on KDE) 
     985  msgWindow->show(); 
     986  msgWindow->setWindowState(msgWindow->windowState() & ~Qt::WindowMinimized); 
     987  if (activateMsgwin) 
     988  { 
     989    // FIXME: When restoring from minimized, the window isn't activated (at least not on KDE) 
     990    msgWindow->raise(); 
     991    msgWindow->activateWindow(); 
     992  } 
    991993 
    992994  // there might be more than one send window open