Reactos

[EXPLORER][SHELL32][SHELL32_APITEST][SDK] AppBar Part 2 (#7946)

Follow-up of #7778.
JIRA issue: CORE-7237
- Rename APPBARDATA3264 structure
as APPBARDATAINTEROP.
- Fix structures for WoW64.
- Use trace instead of DPRINT1.
- Add CAppBarManager::
RecomputeAllWorkareas function.
- Fix WM_DISPLAYCHANGE handling
to re-compute the work areas.

authored by

Katayama Hirofumi MZ and committed by
GitHub
7073bdfe 24c2e443

+71 -30
+27 -2
base/shell/explorer/appbar.cpp
··· 130 130 return; 131 131 } 132 132 133 - PAPPBARDATA3264 pOutput = AppBar_LockOutput(pData); 133 + PAPPBARDATAINTEROP pOutput = AppBar_LockOutput(pData); 134 134 if (!pOutput) 135 135 { 136 136 ERR("!pOutput: %d\n", pData->dwProcessId); ··· 187 187 188 188 OnAppBarQueryPos(pData); 189 189 190 - PAPPBARDATA3264 pOutput = AppBar_LockOutput(pData); 190 + PAPPBARDATAINTEROP pOutput = AppBar_LockOutput(pData); 191 191 if (!pOutput) 192 192 return; 193 193 ··· 423 423 return WORKAREA_NO_TRAY_AREA; 424 424 425 425 return WORKAREA_SAME_AS_MONITOR; 426 + } 427 + 428 + BOOL CALLBACK 429 + CAppBarManager::MonitorEnumProc( 430 + _In_ HMONITOR hMonitor, 431 + _In_ HDC hDC, 432 + _In_ LPRECT prc, 433 + _Inout_ LPARAM lParam) 434 + { 435 + CAppBarManager *pThis = (CAppBarManager *)lParam; 436 + UNREFERENCED_PARAMETER(hDC); 437 + 438 + RECT rcWorkArea; 439 + if (pThis->RecomputeWorkArea(prc, hMonitor, &rcWorkArea) != WORKAREA_IS_NOT_MONITOR) 440 + return TRUE; 441 + 442 + HWND hwndDesktop = pThis->GetDesktopWnd(); 443 + ::SystemParametersInfoW(SPI_SETWORKAREA, 0, &rcWorkArea, hwndDesktop ? SPIF_SENDCHANGE : 0); 444 + pThis->RedrawDesktop(hwndDesktop, &rcWorkArea); 445 + return TRUE; 446 + } 447 + 448 + void CAppBarManager::RecomputeAllWorkareas() 449 + { 450 + ::EnumDisplayMonitors(NULL, NULL, CAppBarManager::MonitorEnumProc, (LPARAM)this); 426 451 } 427 452 428 453 PAPPBAR_COMMAND
+11 -3
base/shell/explorer/appbar.h
··· 15 15 RECT rc; 16 16 } APPBAR, *PAPPBAR; 17 17 18 - static inline PAPPBARDATA3264 18 + static inline PAPPBARDATAINTEROP 19 19 AppBar_LockOutput(_In_ PAPPBAR_COMMAND pData) 20 20 { 21 - return (PAPPBARDATA3264)SHLockShared(UlongToHandle(pData->hOutput32), pData->dwProcessId); 21 + return (PAPPBARDATAINTEROP)SHLockShared((HANDLE)pData->hOutput, pData->dwProcessId); 22 22 } 23 23 24 24 static inline VOID 25 - AppBar_UnLockOutput(_Out_ PAPPBARDATA3264 pOutput) 25 + AppBar_UnLockOutput(_Out_ PAPPBARDATAINTEROP pOutput) 26 26 { 27 27 SHUnlockShared(pOutput); 28 28 } ··· 77 77 _In_ const RECT *prcTray, 78 78 _In_ HMONITOR hMonitor, 79 79 _Out_ PRECT prcWorkArea); 80 + void RecomputeAllWorkareas(); 80 81 81 82 void StuckAppChange( 82 83 _In_opt_ HWND hwndTarget, ··· 93 94 virtual INT GetPosition() const = 0; 94 95 virtual const RECT* GetTrayRect() = 0; 95 96 virtual HWND GetDesktopWnd() const = 0; 97 + 98 + static BOOL CALLBACK 99 + MonitorEnumProc( 100 + _In_ HMONITOR hMonitor, 101 + _In_ HDC hDC, 102 + _In_ LPRECT prc, 103 + _Inout_ LPARAM lParam); 96 104 };
+3
base/shell/explorer/traywnd.cpp
··· 2492 2492 2493 2493 LRESULT OnDisplayChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 2494 2494 { 2495 + /* Refresh workareas */ 2496 + RecomputeAllWorkareas(); 2497 + 2495 2498 /* Load the saved tray window settings */ 2496 2499 RegLoadSettings(); 2497 2500
+8 -9
dll/win32/shell32/appbar.c
··· 19 19 20 20 WINE_DEFAULT_DEBUG_CHANNEL(appbar); 21 21 22 - static UINT32 22 + static HANDLE 23 23 AppBar_CopyIn( 24 24 _In_ const VOID *pvSrc, 25 25 _In_ SIZE_T dwSize, ··· 38 38 39 39 CopyMemory(pvDest, pvSrc, dwSize); 40 40 SHUnlockShared(pvDest); 41 - return HandleToUlong(hMem); 41 + return hMem; 42 42 } 43 43 44 44 static BOOL 45 45 AppBar_CopyOut( 46 - _In_ UINT32 hOutput32, 46 + _In_ HANDLE hOutput, 47 47 _Out_ PVOID pvDest, 48 48 _In_ SIZE_T cbDest, 49 49 _In_ DWORD dwProcessId) 50 50 { 51 - HANDLE hOutput = UlongToHandle(hOutput32); 52 51 PVOID pvSrc = SHLockShared(hOutput, dwProcessId); 53 52 if (pvSrc) 54 53 { ··· 86 85 cmd.abd.rc = pData->rc; 87 86 cmd.abd.lParam64 = pData->lParam; 88 87 cmd.dwMessage = dwMessage; 89 - cmd.hOutput32 = 0; 88 + cmd.hOutput = (APPBAR_OUTPUT)NULL; 90 89 cmd.dwProcessId = GetCurrentProcessId(); 91 90 92 91 /* Make output data if necessary */ ··· 95 94 case ABM_QUERYPOS: 96 95 case ABM_SETPOS: 97 96 case ABM_GETTASKBARPOS: 98 - cmd.hOutput32 = AppBar_CopyIn(&cmd.abd, sizeof(cmd.abd), cmd.dwProcessId); 99 - if (!cmd.hOutput32) 97 + cmd.hOutput = (APPBAR_OUTPUT)AppBar_CopyIn(&cmd.abd, sizeof(cmd.abd), cmd.dwProcessId); 98 + if (!cmd.hOutput) 100 99 { 101 100 ERR("AppBar_CopyIn: %d\n", dwMessage); 102 101 return FALSE; ··· 111 110 UINT_PTR ret = SendMessageW(hTrayWnd, WM_COPYDATA, (WPARAM)pData->hWnd, (LPARAM)&copyData); 112 111 113 112 /* Copy back output data */ 114 - if (cmd.hOutput32) 113 + if (cmd.hOutput) 115 114 { 116 - if (!AppBar_CopyOut(cmd.hOutput32, &cmd.abd, sizeof(cmd.abd), cmd.dwProcessId)) 115 + if (!AppBar_CopyOut((HANDLE)cmd.hOutput, &cmd.abd, sizeof(cmd.abd), cmd.dwProcessId)) 117 116 { 118 117 ERR("AppBar_CopyOut: %d\n", dwMessage); 119 118 return FALSE;
+5 -11
modules/rostests/apitests/shell32/SHAppBarMessage.cpp
··· 10 10 #include <shlwapi.h> 11 11 #include <stdio.h> 12 12 13 - #define NDEBUG 14 - #include <debug.h> 15 - 16 13 /* Based on https://github.com/katahiromz/AppBarSample */ 17 14 18 15 //#define VERBOSE ··· 469 466 case ABE_RIGHT: 470 467 rc.left = rc.right - m_cxWidth; 471 468 break; 472 - default: 473 - ASSERT(FALSE); 474 - break; 475 469 } 476 470 477 471 APPBARDATA abd = { sizeof(abd) }; ··· 688 682 AppBar_Register(hwnd); 689 683 AppBar_SetSide(hwnd, ABE_TOP); 690 684 691 - DPRINT1("OnCreate(%p) done\n", hwnd); 685 + trace("OnCreate(%p) done\n", hwnd); 692 686 return TRUE; 693 687 } 694 688 ··· 984 978 RECT rc1, rc2, rcWork; 985 979 DWORD dwTID = GetWindowThreadProcessId(s_hwnd1, NULL); 986 980 987 - DPRINT1("DoAction\n"); 981 + trace("DoAction\n"); 988 982 Sleep(INTERVAL); 989 983 990 984 GetWindowRect(s_hwnd1, &rc1); ··· 1136 1130 return; 1137 1131 } 1138 1132 1139 - DPRINT1("SM_CMONITORS: %d\n", GetSystemMetrics(SM_CMONITORS)); 1133 + trace("SM_CMONITORS: %d\n", GetSystemMetrics(SM_CMONITORS)); 1140 1134 if (GetSystemMetrics(SM_CMONITORS) != 1) 1141 1135 { 1142 1136 skip("Multi-monitor not supported yet\n"); ··· 1144 1138 } 1145 1139 1146 1140 SystemParametersInfo(SPI_GETWORKAREA, 0, &s_rcWorkArea, FALSE); 1147 - DPRINT1("s_rcWorkArea: %d, %d, %d, %d\n", 1148 - s_rcWorkArea.left, s_rcWorkArea.top, s_rcWorkArea.right, s_rcWorkArea.bottom); 1141 + trace("s_rcWorkArea: %ld, %ld, %ld, %ld\n", 1142 + s_rcWorkArea.left, s_rcWorkArea.top, s_rcWorkArea.right, s_rcWorkArea.bottom); 1149 1143 1150 1144 HWND hwnd1 = Window::DoCreateMainWnd(hInstance, TEXT("Test1"), 80, 80, 1151 1145 WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN);
+17 -5
sdk/include/reactos/undocshell.h
··· 1222 1222 1223 1223 #include <poppack.h> 1224 1224 1225 + #if defined(_WIN64) || defined(BUILD_WOW6432) 1226 + typedef UINT64 APPBAR_OUTPUT; 1227 + #else 1228 + typedef HANDLE APPBAR_OUTPUT; 1229 + #endif 1230 + 1225 1231 /* 1226 1232 * Private structures for internal AppBar messaging. 1227 1233 * These structures can be sent from 32-bit shell32 to 64-bit Explorer. 1228 1234 * See also: https://learn.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication 1229 1235 * > ... only the lower 32 bits are significant, so it is safe to truncate the handle 1236 + * See also: https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle 1237 + * > DuplicateHandle can be used to duplicate a handle between a 32-bit process and a 64-bit process. 1230 1238 */ 1231 1239 #include <pshpack8.h> 1232 - typedef struct tagAPPBARDATA3264 1240 + typedef struct tagAPPBARDATAINTEROP 1233 1241 { 1234 - DWORD cbSize; /* == sizeof(APPBARDATA3264) */ 1242 + DWORD cbSize; /* == sizeof(APPBARDATAINTEROP) */ 1235 1243 UINT32 hWnd32; 1236 1244 UINT uCallbackMessage; 1237 1245 UINT uEdge; 1238 1246 RECT rc; 1239 1247 LONGLONG lParam64; 1240 - } APPBARDATA3264, *PAPPBARDATA3264; 1248 + } APPBARDATAINTEROP, *PAPPBARDATAINTEROP; 1241 1249 typedef struct tagAPPBAR_COMMAND 1242 1250 { 1243 - APPBARDATA3264 abd; 1251 + APPBARDATAINTEROP abd; 1244 1252 DWORD dwMessage; 1245 - UINT32 hOutput32; /* For shlwapi!SHAllocShared */ 1253 + APPBAR_OUTPUT hOutput; /* For shlwapi!SHAllocShared */ 1246 1254 DWORD dwProcessId; 1247 1255 } APPBAR_COMMAND, *PAPPBAR_COMMAND; 1248 1256 #include <poppack.h> 1249 1257 1258 + #if defined(_WIN64) || defined(BUILD_WOW6432) 1259 + C_ASSERT(sizeof(APPBAR_COMMAND) == 0x40); 1260 + #else 1250 1261 C_ASSERT(sizeof(APPBAR_COMMAND) == 0x38); 1262 + #endif 1251 1263 1252 1264 #ifdef __cplusplus 1253 1265 } /* extern "C" */