wedesktop.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Stand-in desktop shell windows so live WE under Wine runs in desktop mode. WE 2.8.42 (sub_14003C840/sub_14003C760)
  3. * sends Progman 0x52C, then parents its window to the WorkerW below the one holding SHELLDLL_DefView.
  4. * Run before wallpaper64.exe with the same wine prefix; we_full.sh builds it.
  5. */
  6. #include <windows.h>
  7. static HWND g_progman, g_defView, g_iconHost, g_wallpaperHost;
  8. static LRESULT CALLBACK windowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  9. if (msg == WM_ERASEBKGND) {
  10. RECT rect;
  11. GetClientRect (hwnd, &rect);
  12. FillRect ((HDC) wParam, &rect, (HBRUSH) GetStockObject (BLACK_BRUSH));
  13. return 1;
  14. }
  15. if (hwnd == g_progman && msg == 0x52C && g_wallpaperHost == NULL) {
  16. const int x = GetSystemMetrics (SM_XVIRTUALSCREEN), y = GetSystemMetrics (SM_YVIRTUALSCREEN);
  17. const int w = GetSystemMetrics (SM_CXVIRTUALSCREEN), h = GetSystemMetrics (SM_CYVIRTUALSCREEN);
  18. HINSTANCE instance = GetModuleHandleW (NULL);
  19. g_iconHost = CreateWindowExW (
  20. WS_EX_TOOLWINDOW, L"WorkerW", L"", WS_POPUP | WS_CLIPCHILDREN, x, y, 1, 1, NULL, NULL, instance, NULL
  21. );
  22. SetParent (g_defView, g_iconHost);
  23. g_wallpaperHost = CreateWindowExW (
  24. WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, L"WorkerW", L"", WS_POPUP | WS_CLIPCHILDREN | WS_VISIBLE, x, y, w, h,
  25. NULL, NULL, instance, NULL
  26. );
  27. SetWindowPos (g_wallpaperHost, g_iconHost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
  28. return 0;
  29. }
  30. if (msg == WM_DESTROY && hwnd == g_progman) {
  31. PostQuitMessage (0);
  32. }
  33. return DefWindowProcW (hwnd, msg, wParam, lParam);
  34. }
  35. static void registerClass (const wchar_t* name) {
  36. WNDCLASSW cls = { 0 };
  37. cls.lpfnWndProc = windowProc;
  38. cls.hInstance = GetModuleHandleW (NULL);
  39. cls.lpszClassName = name;
  40. cls.hCursor = LoadCursorW (NULL, (LPCWSTR) IDC_ARROW);
  41. RegisterClassW (&cls);
  42. }
  43. int WINAPI wWinMain (HINSTANCE instance, HINSTANCE previous, PWSTR commandLine, int show) {
  44. registerClass (L"Progman");
  45. registerClass (L"WorkerW");
  46. registerClass (L"SHELLDLL_DefView");
  47. registerClass (L"SysListView32");
  48. const int w = GetSystemMetrics (SM_CXVIRTUALSCREEN), h = GetSystemMetrics (SM_CYVIRTUALSCREEN);
  49. g_progman = CreateWindowExW (
  50. WS_EX_TOOLWINDOW, L"Progman", L"Program Manager", WS_POPUP | WS_CLIPCHILDREN, 0, 0, w, h, NULL, NULL, instance,
  51. NULL
  52. );
  53. g_defView = CreateWindowExW (
  54. 0, L"SHELLDLL_DefView", L"", WS_CHILD | WS_VISIBLE, 0, 0, w, h, g_progman, NULL, instance, NULL
  55. );
  56. CreateWindowExW (
  57. 0, L"SysListView32", L"FolderView", WS_CHILD | WS_VISIBLE, 0, 0, w, h, g_defView, NULL, instance, NULL
  58. );
  59. MSG msg;
  60. while (GetMessageW (&msg, NULL, 0, 0) > 0) {
  61. TranslateMessage (&msg);
  62. DispatchMessageW (&msg);
  63. }
  64. return 0;
  65. }