From dc7aa1a9f9cd89f726a54a88ff31731c56142eb8 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 2 Feb 2010 13:56:03 +0100 Subject: Qt applications not responding to WM_GETHOTKEY on windows. On windows when an application has been started through a shortcut link, (either by double-clicking or by pressing the shortcut key assigned in the link) the STARTUPINFO contains the hotkey associated to the application. This should be set on the toplevel using WM_SETHOTKEY, so that it behaves like native applications. Task-number: QUTBUG-3426 Reviewed-by: Jens Bache-Wiig Reviewed-by: bnilsen --- src/gui/kernel/qwidget_p.h | 1 + src/gui/kernel/qwidget_win.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index d3bc2d8..ff8f276 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -158,6 +158,7 @@ struct QTLWExtra { quint32 newCounterValueLo; #endif #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN + uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered. HICON winIconBig; // internal big Windows icon HICON winIconSmall; // internal small Windows icon #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 10522ed..a57aacc 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1094,6 +1094,21 @@ void QWidgetPrivate::show_sys() return; } + if (data.window_flags & Qt::Window) { + QTLWExtra *extra = topData(); + if (!extra->hotkeyRegistered) { + // Try to set the hotkey using information from STARTUPINFO + STARTUPINFO startupInfo; + GetStartupInfo(&startupInfo); + // If STARTF_USEHOTKEY is set, hStdInput is the virtual keycode + if (startupInfo.dwFlags & 0x00000200) { + WPARAM hotKey = (WPARAM)startupInfo.hStdInput; + SendMessage(data.winid, WM_SETHOTKEY, hotKey, 0); + } + extra->hotkeyRegistered = 1; + } + } + int sm = SW_SHOWNORMAL; bool fakedMaximize = false; if (q->isWindow()) { @@ -1687,6 +1702,7 @@ void QWidgetPrivate::deleteSysExtra() void QWidgetPrivate::createTLSysExtra() { + extra->topextra->hotkeyRegistered = 0; extra->topextra->savedFlags = 0; extra->topextra->winIconBig = 0; extra->topextra->winIconSmall = 0; -- cgit v0.12