Reactos

[STOBJECT] Add support for the mouse key tray icon

+182
+1
dll/shellext/stobject/CMakeLists.txt
··· 10 10 csystray.cpp 11 11 stobject.cpp 12 12 hotplug.cpp 13 + mouse.cpp 13 14 power.cpp 14 15 volume.cpp 15 16 precomp.h)
+25
dll/shellext/stobject/csystray.cpp
··· 22 22 23 23 CSysTray::CSysTray() : dwServicesEnabled(0) 24 24 { 25 + wm_SHELLHOOK = RegisterWindowMessageW(L"SHELLHOOK"); 25 26 wm_DESTROYWINDOW = RegisterWindowMessageW(L"CSysTray_DESTROY"); 26 27 } 27 28 ··· 128 129 } 129 130 } 130 131 132 + MouseKeys_Init(this); 133 + 131 134 return InitNetShell(); 132 135 } 133 136 ··· 143 146 FAILED_UNEXPECTEDLY(hr); 144 147 } 145 148 } 149 + 150 + MouseKeys_Shutdown(this); 146 151 147 152 return ShutdownNetShell(); 148 153 } ··· 318 323 { 319 324 return DestroyWindow(); 320 325 } 326 + 327 + if (wm_SHELLHOOK && uMsg == wm_SHELLHOOK) 328 + { 329 + if (wParam == HSHELL_ACCESSIBILITYSTATE && lParam == ACCESS_MOUSEKEYS) 330 + { 331 + MouseKeys_Update(this); 332 + } 333 + lResult = 0L; 334 + return TRUE; 335 + } 336 + 321 337 switch (uMsg) 322 338 { 323 339 case WM_NCCREATE: ··· 328 344 GetServicesEnabled(); 329 345 InitIcons(); 330 346 SetTimer(1, 2000, NULL); 347 + RegisterShellHookWindow(hWnd); 331 348 return TRUE; 332 349 333 350 case WM_TIMER: ··· 337 354 ProcessIconMessage(uMsg, wParam, lParam, lResult); 338 355 return TRUE; 339 356 357 + case WM_SETTINGCHANGE: 358 + if (wParam == SPI_SETMOUSEKEYS) 359 + { 360 + MouseKeys_Update(this); 361 + } 362 + break; 363 + 340 364 case WM_DESTROY: 341 365 KillTimer(1); 366 + DeregisterShellHookWindow(hWnd); 342 367 ShutdownIcons(); 343 368 PostQuitMessage(0); 344 369 return TRUE;
+1
dll/shellext/stobject/csystray.h
··· 29 29 // TODO: keep icon handlers here 30 30 31 31 DWORD dwServicesEnabled; 32 + UINT wm_SHELLHOOK; 32 33 UINT wm_DESTROYWINDOW; 33 34 34 35 static DWORD WINAPI s_SysTrayThreadProc(PVOID param);
+125
dll/shellext/stobject/mouse.cpp
··· 1 + /* 2 + * PROJECT: ReactOS system libraries 3 + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 + * PURPOSE: Mouse keys notification icon handler 5 + * COPYRIGHT: Copyright 2022 Mark Jansen <mark.jansen@reactos.org> 6 + */ 7 + 8 + #include "precomp.h" 9 + 10 + static MOUSEKEYS g_Mk; 11 + static UINT g_MkState; 12 + static HICON g_MkStateIcon; 13 + 14 + HRESULT STDMETHODCALLTYPE 15 + MouseKeys_Init(_In_ CSysTray *pSysTray) 16 + { 17 + TRACE("MouseKeys_Init!\n"); 18 + 19 + return MouseKeys_Update(pSysTray); 20 + } 21 + 22 + HRESULT STDMETHODCALLTYPE 23 + MouseKeys_Shutdown(_In_ CSysTray *pSysTray) 24 + { 25 + TRACE("MouseKeys_Shutdown!\n"); 26 + 27 + if (g_MkStateIcon) 28 + { 29 + DestroyIcon(g_MkStateIcon); 30 + g_MkStateIcon = NULL; 31 + } 32 + 33 + if (g_MkState) 34 + { 35 + g_MkState = 0; 36 + pSysTray->NotifyIcon(NIM_DELETE, ID_ICON_MOUSE, g_MkStateIcon, L"MouseKeys"); 37 + } 38 + 39 + return S_OK; 40 + } 41 + 42 + HRESULT STDMETHODCALLTYPE 43 + MouseKeys_Update(_In_ CSysTray *pSysTray) 44 + { 45 + TRACE("MouseKeys_Update!\n"); 46 + 47 + g_Mk.cbSize = sizeof(g_Mk); 48 + SystemParametersInfoW(SPI_GETMOUSEKEYS, sizeof(g_Mk), &g_Mk, 0); 49 + 50 + UINT state = 0; 51 + if ((g_Mk.dwFlags & (MKF_INDICATOR | MKF_MOUSEKEYSON)) == (MKF_INDICATOR | MKF_MOUSEKEYSON)) 52 + { 53 + if (g_Mk.dwFlags & MKF_MOUSEMODE) 54 + { 55 + switch (g_Mk.dwFlags & (MKF_LEFTBUTTONDOWN | MKF_LEFTBUTTONSEL | MKF_RIGHTBUTTONDOWN | MKF_RIGHTBUTTONSEL)) 56 + { 57 + case 0: 58 + default: 59 + state = IDI_MOUSE_NOBTN; 60 + break; 61 + case MKF_LEFTBUTTONSEL: 62 + state = IDI_MOUSE_L_ACTIVE; 63 + break; 64 + case MKF_LEFTBUTTONDOWN: 65 + case MKF_LEFTBUTTONDOWN | MKF_LEFTBUTTONSEL: 66 + state = IDI_MOUSE_L_DOWN; 67 + break; 68 + case MKF_RIGHTBUTTONSEL: 69 + state = IDI_MOUSE_R_ACTIVE; 70 + break; 71 + case MKF_RIGHTBUTTONDOWN: 72 + case MKF_RIGHTBUTTONDOWN | MKF_RIGHTBUTTONSEL: 73 + state = IDI_MOUSE_R_DOWN; 74 + break; 75 + case MKF_LEFTBUTTONSEL | MKF_RIGHTBUTTONSEL: 76 + state = IDI_MOUSE_LR_ACTIVE; 77 + break; 78 + case MKF_RIGHTBUTTONDOWN | MKF_LEFTBUTTONDOWN: 79 + case MKF_RIGHTBUTTONDOWN | MKF_LEFTBUTTONDOWN | MKF_LEFTBUTTONSEL: 80 + case MKF_RIGHTBUTTONDOWN | MKF_LEFTBUTTONDOWN | MKF_LEFTBUTTONSEL | MKF_RIGHTBUTTONSEL: 81 + case MKF_RIGHTBUTTONDOWN | MKF_LEFTBUTTONDOWN | MKF_RIGHTBUTTONSEL: 82 + state = IDI_MOUSE_LR_DOWN; 83 + break; 84 + case MKF_LEFTBUTTONSEL | MKF_RIGHTBUTTONDOWN: 85 + case MKF_LEFTBUTTONSEL | MKF_RIGHTBUTTONDOWN | MKF_RIGHTBUTTONSEL: 86 + state = IDI_MOUSE_L_ACTIVE_R_DOWN; 87 + break; 88 + case MKF_LEFTBUTTONDOWN | MKF_RIGHTBUTTONSEL: 89 + case MKF_LEFTBUTTONDOWN | MKF_RIGHTBUTTONSEL | MKF_LEFTBUTTONSEL: 90 + state = IDI_MOUSE_R_ACTIVE_L_DOWN; 91 + break; 92 + } 93 + } 94 + else 95 + { 96 + state = IDI_MOUSE_DISABLED; 97 + } 98 + } 99 + 100 + UINT uId = NIM_MODIFY; 101 + if (state != g_MkState) 102 + { 103 + if (g_MkStateIcon) 104 + { 105 + DestroyIcon(g_MkStateIcon); 106 + g_MkStateIcon = NULL; 107 + } 108 + 109 + if (g_MkState == 0) 110 + uId = NIM_ADD; 111 + 112 + g_MkState = state; 113 + if (g_MkState) 114 + { 115 + g_MkStateIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(g_MkState)); 116 + } 117 + } 118 + 119 + if (g_MkState == 0) 120 + { 121 + uId = NIM_DELETE; 122 + } 123 + 124 + return pSysTray->NotifyIcon(uId, ID_ICON_MOUSE, g_MkStateIcon, L"MouseKeys"); 125 + }
+6
dll/shellext/stobject/precomp.h
··· 33 33 #define ID_ICON_VOLUME (WM_APP + 0x4CB) 34 34 #define ID_ICON_HOTPLUG (WM_APP + 0x4CC) 35 35 #define ID_ICON_POWER (WM_APP + 0x4CD) 36 + #define ID_ICON_MOUSE (WM_APP + 0x4CE) 36 37 37 38 #define POWER_SERVICE_FLAG 0x00000001 38 39 #define HOTPLUG_SERVICE_FLAG 0x00000002 ··· 73 74 extern HRESULT STDMETHODCALLTYPE Power_Shutdown(_In_ CSysTray * pSysTray); 74 75 extern HRESULT STDMETHODCALLTYPE Power_Update(_In_ CSysTray * pSysTray); 75 76 extern HRESULT STDMETHODCALLTYPE Power_Message(_In_ CSysTray * pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult); 77 + 78 + extern HRESULT STDMETHODCALLTYPE MouseKeys_Init(_In_ CSysTray * pSysTray); 79 + extern HRESULT STDMETHODCALLTYPE MouseKeys_Shutdown(_In_ CSysTray * pSysTray); 80 + extern HRESULT STDMETHODCALLTYPE MouseKeys_Update(_In_ CSysTray * pSysTray); 81 + 76 82 77 83 #define POWER_TIMER_ID 2 78 84 #define VOLUME_TIMER_ID 3
+12
dll/shellext/stobject/resource.h
··· 56 56 #define IDI_HOTPLUG_ERR 420 57 57 #define IDI_HOTPLUG_OK 421 58 58 59 + #define IDI_MOUSE_DISABLED 440 60 + #define IDI_MOUSE_NOBTN 441 61 + #define IDI_MOUSE_L_ACTIVE 442 62 + #define IDI_MOUSE_L_DOWN 443 63 + #define IDI_MOUSE_R_ACTIVE 444 64 + #define IDI_MOUSE_R_DOWN 445 65 + #define IDI_MOUSE_LR_ACTIVE 446 66 + #define IDI_MOUSE_LR_DOWN 447 67 + #define IDI_MOUSE_L_ACTIVE_R_DOWN 448 68 + #define IDI_MOUSE_R_ACTIVE_L_DOWN 449 69 + 70 + 59 71 #define IDR_SYSTRAY 11001
dll/shellext/stobject/resources/mouse/disabled.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/left_active.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/left_active_right_down.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/left_down.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/left_down_right_active.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/left_right_active.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/left_right_down.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/none.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/right_active.ico

This is a binary file and will not be displayed.

dll/shellext/stobject/resources/mouse/right_down.ico

This is a binary file and will not be displayed.

+12
dll/shellext/stobject/stobject.rc
··· 31 31 IDI_HOTPLUG_OK ICON "resources/hotplug/1.ico" 32 32 33 33 34 + IDI_MOUSE_DISABLED ICON "resources/mouse/disabled.ico" 35 + IDI_MOUSE_NOBTN ICON "resources/mouse/none.ico" 36 + IDI_MOUSE_L_ACTIVE ICON "resources/mouse/left_active.ico" 37 + IDI_MOUSE_L_DOWN ICON "resources/mouse/left_down.ico" 38 + IDI_MOUSE_R_ACTIVE ICON "resources/mouse/right_active.ico" 39 + IDI_MOUSE_R_DOWN ICON "resources/mouse/right_down.ico" 40 + IDI_MOUSE_LR_ACTIVE ICON "resources/mouse/left_right_active.ico" 41 + IDI_MOUSE_LR_DOWN ICON "resources/mouse/left_right_down.ico" 42 + IDI_MOUSE_L_ACTIVE_R_DOWN ICON "resources/mouse/left_active_right_down.ico" 43 + IDI_MOUSE_R_ACTIVE_L_DOWN ICON "resources/mouse/left_down_right_active.ico" 44 + 45 + 34 46 IDR_SYSTRAY REGISTRY "resources/rgs/systray.rgs" 35 47 36 48 #include <reactos/manifest_dll.rc>