From 8b167ce7302d973460cc8ee0790616283114d4c3 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Fri, 1 Jun 2012 10:05:56 +0100 Subject: Avoid whoosh down, whooosh up on Mac when opening chat windows. This changes so that the chat window will appear without focus if being shown without the user requesting it, but it will no longer appear minimised. Resolves: #1022 diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index 9921754..90be786 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -25,6 +25,8 @@ namespace Swift { QtChatTabs::QtChatTabs() : QWidget() { #ifndef Q_WS_MAC setWindowIcon(QIcon(":/logo-chat-16.png")); +#else + setAttribute(Qt::WA_ShowWithoutActivating); #endif tabs_ = new QtTabWidget(this); @@ -270,7 +272,20 @@ void QtChatTabs::moveEvent(QMoveEvent*) { void QtChatTabs::checkForFirstShow() { if (!isVisible()) { +#ifndef Q_WS_MAC showMinimized(); +#else + /* https://bugreports.qt-project.org/browse/QTBUG-19194 + * ^ When the above is fixed we can swap the below for just show(); + * WA_ShowWithoutActivating seems to helpfully not work, so... */ + + QWidget* currentWindow = QApplication::activeWindow(); /* Remember who had focus if we're the current application*/ + show(); + QCoreApplication::processEvents(); /* Run through the eventloop to clear the show() */ + if (currentWindow) { + currentWindow->activateWindow(); /* Set focus back */ + } +#endif } } -- cgit v0.10.2-6-g49f6