From 69ba67b2549b6c6a46abd19879b67e1545c9ae3b Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Wed, 27 Jul 2011 09:04:58 +0200 Subject: fix xtray keyboard shortcut handling --- plugins/xtray/utility.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++-- plugins/xtray/utility.h | 3 +++ 2 files changed, 48 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/xtray/utility.cpp b/plugins/xtray/utility.cpp index 60f3f2f0..4faed90b 100644 --- a/plugins/xtray/utility.cpp +++ b/plugins/xtray/utility.cpp @@ -29,6 +29,49 @@ TCHAR BACKUP_INI_FILE[] = _T(".\\plugins\\config\\xtray.conf"); struct HOTKEY g_hHotKey; +/* we need to convert ALT and SHIFT modifiers +// from +#define MOD_ALT 0x0001 +#define MOD_CONTROL 0x0002 +#define MOD_SHIFT 0x0004 +// from +#define HOTKEYF_SHIFT 0x01 +#define HOTKEYF_CONTROL 0x02 +#define HOTKEYF_ALT 0x04 +*/ + +WORD HotkeyfToMod(WORD modifiers) +{ + WORD newmods = 0; + + if (modifiers & HOTKEYF_SHIFT) + newmods |= MOD_SHIFT; + + if (modifiers & HOTKEYF_CONTROL) + newmods |= MOD_CONTROL; + + if (modifiers & HOTKEYF_ALT) + newmods |= MOD_ALT; + + return newmods; +} + +WORD ModToHotkeyf(WORD modifiers) +{ + WORD newmods = 0; + + if (modifiers & MOD_SHIFT) + newmods |= HOTKEYF_SHIFT; + + if (modifiers & MOD_CONTROL) + newmods |= HOTKEYF_CONTROL; + + if (modifiers & MOD_ALT) + newmods |= HOTKEYF_ALT; + + return newmods; +} + void SavePrefs(int iDlg) { /**************************************************************************************************/ @@ -292,7 +335,7 @@ void CheckPrefs(HWND hwnd, int iDlg) hHotkey = SendDlgItemMessage(hwnd, IDC_ALERT_HOTKEY, HKM_GETHOTKEY, 0, 0); g_hHotKey.key = LOBYTE(hHotkey); - g_hHotKey.mod = HIBYTE(hHotkey); + g_hHotKey.mod = HotkeyfToMod(HIBYTE(hHotkey)); if(IsDlgButtonChecked(hwnd, PREF_UWIOB) == BST_CHECKED) { @@ -403,7 +446,7 @@ void SetDialog(HWND hwnd, int iDlg) /**********************************************************/ TCHAR tTime[255]; SendDlgItemMessage(hwnd, IDC_ALERT_TIME, WM_SETTEXT, 0, (LPARAM)_itot(g_iTime, tTime, 10)); - SendDlgItemMessage(hwnd, IDC_ALERT_HOTKEY, HKM_SETHOTKEY, MAKEWORD(g_hHotKey.key, g_hHotKey.mod), 0); + SendDlgItemMessage(hwnd, IDC_ALERT_HOTKEY, HKM_SETHOTKEY, MAKEWORD(g_hHotKey.key, ModToHotkeyf(g_hHotKey.mod)), 0); } break; } diff --git a/plugins/xtray/utility.h b/plugins/xtray/utility.h index ce3d541c..6bee8aed 100644 --- a/plugins/xtray/utility.h +++ b/plugins/xtray/utility.h @@ -19,6 +19,9 @@ #ifndef _H_UTILITY_H #define _H_UTILITY_H +WORD HotkeyfToMod (WORD); +WORD ModToHotkeyf (WORD); + int SetOption (HWND, unsigned int, unsigned int); int SetCheck (HWND, unsigned int, unsigned int); int SetToggle (HWND, unsigned int, unsigned int, bool); -- cgit 1.4.1