diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/hotkey_opts.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/hotkeys.cpp | 71 | ||||
-rw-r--r-- | src/mir_app/src/keyboard.cpp | 22 | ||||
-rw-r--r-- | src/mir_app/src/menu_clist.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/skin.h | 3 |
7 files changed, 50 insertions, 68 deletions
diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp index 07fa9512cf..e4bc8f5565 100644 --- a/src/mir_app/src/hotkey_opts.cpp +++ b/src/mir_app/src/hotkey_opts.cpp @@ -185,14 +185,14 @@ static LRESULT CALLBACK sttHotkeyEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP return mir_callNextSubclass(hwnd, sttHotkeyEditProc, msg, wParam, lParam); } -void HotkeyEditCreate(HWND hwnd) +MIR_APP_DLL(void) Hotkey_Subclass(HWND hwnd) { THotkeyBoxData *data = (THotkeyBoxData *)mir_alloc(sizeof(THotkeyBoxData)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (ULONG_PTR)data); mir_subclassWindow(hwnd, sttHotkeyEditProc); } -void HotkeyEditDestroy(HWND hwnd) +MIR_APP_DLL(void) Hotkey_Unsubclass(HWND hwnd) { THotkeyBoxData *data = (THotkeyBoxData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); @@ -470,7 +470,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, TranslateDialogDefault(hwndDlg); - HotkeyEditCreate(GetDlgItem(hwndDlg, IDC_HOTKEY)); + Hotkey_Subclass(GetDlgItem(hwndDlg, IDC_HOTKEY)); { HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 3, 1); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOWS); diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp index d621a4565d..b2b0247ab7 100644 --- a/src/mir_app/src/hotkeys.cpp +++ b/src/mir_app/src/hotkeys.cpp @@ -117,36 +117,21 @@ static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam) return CallNextHookEx(hhkKeyboard, code, wParam, lParam);
}
-static INT_PTR svcHotkeySubclass(WPARAM wParam, LPARAM)
-{
- HotkeyEditCreate((HWND)wParam);
- return 0;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR svcHotkeyUnsubclass(WPARAM wParam, LPARAM)
+MIR_APP_DLL(int) Hotkey_Register(const HOTKEYDESC *desc, int _hLangpack)
{
- HotkeyEditDestroy((HWND)wParam);
- return 0;
-}
-
-static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam)
-{
- HOTKEYDESC *desc = (HOTKEYDESC *)lParam;
- if (desc->cbSize != sizeof(HOTKEYDESC))
- return 0;
-
THotkeyItem *p = (THotkeyItem*)mir_alloc(sizeof(THotkeyItem));
- DWORD dwFlags = (desc->cbSize >= sizeof(HOTKEYDESC)) ? desc->dwFlags : 0;
- if (dwFlags & HKD_UNICODE) {
- p->pwszSection = mir_wstrdup(desc->pwszSection);
- p->pwszDescription = mir_wstrdup(desc->pwszDescription);
+ if (desc->dwFlags & HKD_UNICODE) {
+ p->pwszSection = mir_wstrdup(desc->szSection.w);
+ p->pwszDescription = mir_wstrdup(desc->szDescription.w);
}
else {
- p->pwszSection = mir_a2u(desc->pszSection);
- p->pwszDescription = mir_a2u(desc->pszDescription);
+ p->pwszSection = mir_a2u(desc->szSection.a);
+ p->pwszDescription = mir_a2u(desc->szDescription.a);
}
- p->hLangpack = (int)wParam;
+ p->hLangpack = _hLangpack;
p->allowSubHotkeys = TRUE;
p->rootHotkey = nullptr;
p->nSubHotkeys = 0;
@@ -187,7 +172,8 @@ static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam) if (p->Enabled) {
BYTE mod, vk;
sttWordToModAndVk(p->Hotkey, &mod, &vk);
- if (vk) RegisterHotKey(g_hwndHotkeyHost, p->idHotkey, mod, vk);
+ if (vk)
+ RegisterHotKey(g_hwndHotkeyHost, p->idHotkey, mod, vk);
}
}
@@ -195,15 +181,14 @@ static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam) if (!p->rootHotkey) {
/* try to load alternatives from db */
- int count, i;
mir_snprintf(buf, "%s$count", p->pszName);
- count = (int)db_get_dw(0, DBMODULENAME, buf, -1);
- for (i = 0; i < count; i++) {
+ int count = (int)db_get_dw(0, DBMODULENAME, buf, -1);
+ for (int i = 0; i < count; i++) {
mir_snprintf(buf, "%s$%d", p->pszName, i);
if (!db_get_w(0, DBMODULENAME, buf, 0))
continue;
- svcHotkeyRegister(wParam, lParam);
+ Hotkey_Register(desc, _hLangpack);
}
p->allowSubHotkeys = count < 0;
}
@@ -215,9 +200,10 @@ static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam) return p->idHotkey;
}
-static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) Hotkey_Unregister(const char *pszName)
{
- char *pszName = (char *)lParam;
char pszNamePrefix[MAXMODULELABELLENGTH];
size_t cbNamePrefix;
mir_snprintf(pszNamePrefix, "%s$", pszName);
@@ -247,22 +233,20 @@ static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam) return 0;
}
-static INT_PTR svcHotkeyCheck(WPARAM wParam, LPARAM lParam)
-{
- MSG *msg = (MSG *)wParam;
- wchar_t *pszSection = mir_a2u((char *)lParam);
+/////////////////////////////////////////////////////////////////////////////////////////
- if ((msg->message == WM_KEYDOWN) || (msg->message == WM_SYSKEYDOWN)) {
- int i;
+MIR_APP_DLL(int) Hotkey_Check(MSG *msg, const char *szSection)
+{
+ if (msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN) {
BYTE mod = 0, vk = msg->wParam;
-
if (vk) {
if (GetAsyncKeyState(VK_CONTROL)) mod |= MOD_CONTROL;
if (GetAsyncKeyState(VK_MENU)) mod |= MOD_ALT;
if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT;
if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN;
- for (i = 0; i < hotkeys.getCount(); i++) {
+ ptrW pszSection(mir_a2u(szSection));
+ for (int i = 0; i < hotkeys.getCount(); i++) {
THotkeyItem *p = hotkeys[i];
if ((p->type != HKT_MANUAL) || mir_wstrcmp(pszSection, p->pwszSection))
continue;
@@ -271,15 +255,12 @@ static INT_PTR svcHotkeyCheck(WPARAM wParam, LPARAM lParam) sttWordToModAndVk(p->Hotkey, &hkMod, &hkVk);
if (!hkVk) continue;
if (!p->Enabled) continue;
- if ((vk == hkVk) && (mod == hkMod)) {
- mir_free(pszSection);
+ if (vk == hkVk && mod == hkMod)
return p->lParam;
- }
}
}
}
- mir_free(pszSection);
return 0;
}
@@ -370,12 +351,6 @@ int LoadSkinHotkeys(void) hEvChanged = CreateHookableEvent(ME_HOTKEYS_CHANGED);
- CreateServiceFunction("CoreHotkeys/Register", svcHotkeyRegister);
- CreateServiceFunction(MS_HOTKEY_UNREGISTER, svcHotkeyUnregister);
- CreateServiceFunction(MS_HOTKEY_SUBCLASS, svcHotkeySubclass);
- CreateServiceFunction(MS_HOTKEY_UNSUBCLASS, svcHotkeyUnsubclass);
- CreateServiceFunction(MS_HOTKEY_CHECK, svcHotkeyCheck);
-
HookEvent(ME_SYSTEM_MODULESLOADED, sttModulesLoaded);
for (int i = 0; i < _countof(oldSettings); i++) {
diff --git a/src/mir_app/src/keyboard.cpp b/src/mir_app/src/keyboard.cpp index 79d81620ec..f9ee746c40 100644 --- a/src/mir_app/src/keyboard.cpp +++ b/src/mir_app/src/keyboard.cpp @@ -52,39 +52,39 @@ int InitClistHotKeys(void) CreateServiceFunction("CLIST/HK/Opts", hkOpts);
CreateServiceFunction("CLIST/HK/Read", hkRead);
- HOTKEYDESC shk = { sizeof(shk) };
+ HOTKEYDESC shk = {};
shk.dwFlags = HKD_UNICODE;
- shk.pwszDescription = LPGENW("Show/Hide contact list");
+ shk.szDescription.w = LPGENW("Show/Hide contact list");
shk.pszName = "ShowHide";
- shk.pwszSection = L"Main";
+ shk.szSection.w = L"Main";
shk.pszService = "CLIST/HK/SHOWHIDE";
shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'A');
Hotkey_Register(&shk);
- shk.pwszDescription = LPGENW("Read message");
+ shk.szDescription.w = LPGENW("Read message");
shk.pszName = "ReadMessage";
- shk.pwszSection = L"Main";
+ shk.szSection.w = L"Main";
shk.pszService = "CLIST/HK/Read";
shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'I');
Hotkey_Register(&shk);
- shk.pwszDescription = LPGENW("Open Options page");
+ shk.szDescription.w = LPGENW("Open Options page");
shk.pszName = "ShowOptions";
- shk.pwszSection = L"Main";
+ shk.szSection.w = L"Main";
shk.pszService = "CLIST/HK/Opts";
shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'O') | HKF_MIRANDA_LOCAL;
Hotkey_Register(&shk);
- shk.pwszDescription = LPGENW("Open logging options");
+ shk.szDescription.w = LPGENW("Open logging options");
shk.pszName = "ShowLogOptions";
- shk.pwszSection = L"Main";
+ shk.szSection.w = L"Main";
shk.pszService = "Netlib/Log/Win";
shk.DefHotKey = 0;
Hotkey_Register(&shk);
- shk.pwszDescription = LPGENW("Open 'Find user' dialog");
+ shk.szDescription.w = LPGENW("Open 'Find user' dialog");
shk.pszName = "FindUsers";
- shk.pwszSection = L"Main";
+ shk.szSection.w = L"Main";
shk.pszService = "FindAdd/FindAddCommand";
shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'F') | HKF_MIRANDA_LOCAL;
Hotkey_Register(&shk);
diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index 6146eacd2b..16700e7878 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -1141,15 +1141,15 @@ void InitCustomMenus(void) // initialize hotkeys
CreateServiceFunction(MS_CLIST_HKSTATUS, HotkeySetStatus);
- HOTKEYDESC hkd = { sizeof(hkd) };
- hkd.pwszSection = L"Status";
+ HOTKEYDESC hkd = {};
+ hkd.szSection.w = L"Status";
hkd.dwFlags = HKD_UNICODE;
for (int i = 0; i < _countof(statusHotkeys); i++) {
char szName[30];
mir_snprintf(szName, "StatusHotKey_%d", i);
hkd.pszName = szName;
hkd.lParam = statusModeList[i];
- hkd.pwszDescription = fnGetStatusModeDescription(hkd.lParam, 0);
+ hkd.szDescription.w = fnGetStatusModeDescription(hkd.lParam, 0);
hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, '0' + i) | HKF_MIRANDA_LOCAL;
hkd.pszService = MS_CLIST_HKSTATUS;
statusHotkeys[i] = Hotkey_Register(&hkd);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 21ee8846f5..890a9eec7f 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -446,3 +446,8 @@ Chat_GetTextPixelSize @449 NONAME Srmm_GetWindowData @451
Srmm_FindWindow @452
Srmm_Broadcast @453
+Hotkey_Register @454
+Hotkey_Subclass @455
+Hotkey_Unregister @456
+Hotkey_Unsubclass @457
+Hotkey_Check @458
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 1db051a51d..f5e2debc70 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -446,3 +446,8 @@ Chat_GetTextPixelSize @449 NONAME Srmm_GetWindowData @451
Srmm_FindWindow @452
Srmm_Broadcast @453
+Hotkey_Register @454
+Hotkey_Subclass @455
+Hotkey_Unregister @456
+Hotkey_Unsubclass @457
+Hotkey_Check @458
diff --git a/src/mir_app/src/skin.h b/src/mir_app/src/skin.h index e580ecbc04..d83a63cc69 100644 --- a/src/mir_app/src/skin.h +++ b/src/mir_app/src/skin.h @@ -70,6 +70,3 @@ int HotkeyOptionsInit(WPARAM, LPARAM); void FreeHotkey(THotkeyItem *item);
void RegisterHotkeys();
void UnregisterHotkeys();
-
-void HotkeyEditCreate(HWND hwnd);
-void HotkeyEditDestroy(HWND hwnd);
|