mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed problem with single click on a systemtray icon in Qt 4.7 or above running on Windows XP or lower
- before Qt 4.7.0 the message MYWM_NOTIFYICON/WM_LBUTTONUP was handled to emit activted(QSystemTrayIcon::Trigger) - after Qt 4.7.0 the message MYWM_NOTIFYICON/NIN_SELECT is handled. This message is not sent in Windows XP Solution: set an event filter and modify the message from WM_LBUTTONUP to NIN_SELECT git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5458 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
70cbd3c84d
commit
e00f64450b
@ -156,6 +156,43 @@
|
||||
|
||||
/*static*/ MainWindow *MainWindow::_instance = NULL;
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
#if QT_VERSION >= 0x040700
|
||||
|
||||
#define INSTALL_SYSTRAYICON_EVENT
|
||||
|
||||
QCoreApplication::EventFilter g_eventFilter = NULL;
|
||||
|
||||
// Fix problem with single click on a systemtray icon in Qt 4.7 or above running on Windows XP or lower
|
||||
// - before Qt 4.7.0 the message MYWM_NOTIFYICON/WM_LBUTTONUP was handled to emit activted(QSystemTrayIcon::Trigger)
|
||||
// - after Qt 4.7.0 the message MYWM_NOTIFYICON/NIN_SELECT is handled. This message is not sent in Windows XP
|
||||
|
||||
// Solution: set an event filter and modify the message from WM_LBUTTONUP to NIN_SELECT
|
||||
|
||||
// taken from qsystemtrayicon_win.cpp
|
||||
#define MYWM_NOTIFYICON (WM_APP+101)
|
||||
#ifndef NIN_SELECT
|
||||
#define NIN_SELECT (WM_USER + 0)
|
||||
#endif
|
||||
|
||||
bool sysTrayIconEventFilter(void *message, long *result)
|
||||
{
|
||||
MSG *msg = (MSG*) message;
|
||||
if (msg->message == MYWM_NOTIFYICON) {
|
||||
if (msg->lParam == WM_LBUTTONUP) {
|
||||
msg->lParam = NIN_SELECT;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_eventFilter)
|
||||
return g_eventFilter(message, result);
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif // QT_VERSION >= 0x040700
|
||||
#endif // WINDOWS_SYS
|
||||
|
||||
/** create main window */
|
||||
/*static*/ MainWindow *MainWindow::Create ()
|
||||
{
|
||||
@ -179,6 +216,13 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||
/* Invoke the Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
#ifdef INSTALL_SYSTRAYICON_EVENT
|
||||
if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA) {
|
||||
std::cerr << "Running Windows XP or older, install systemtray icon event filter" << std::endl;
|
||||
g_eventFilter = qApp->setEventFilter(sysTrayIconEventFilter);
|
||||
}
|
||||
#endif
|
||||
|
||||
_instance = this;
|
||||
|
||||
m_bStatusLoadDone = false;
|
||||
|
Loading…
Reference in New Issue
Block a user