/* * Callback routine that is executed once per window class. * Removes or creates custom window settings depending on LPARAM */ static wBOOL CALLBACK ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam) { HICON hicon; if (!hwnd) { ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n"); return FALSE; } /* It's our baby, either clean or dirty it */ if (lParam == FALSE) { /* Reset the window's icon to undefined. */ hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_BIG, 0); /* If the old icon is generated on-the-fly, get rid of it, will regen */ winDestroyIcon(hicon); /* Same for the small icon */ hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0); winDestroyIcon(hicon); /* Remove any menu additions; bRevert=TRUE destroys any modified menus */ GetSystemMenu(hwnd, TRUE); /* This window is now clean of our taint (but with undefined icons) */ } else { /* Send a message to WM thread telling it re-evaluate the icon for this window */ { winWMMessageRec wmMsg; WindowPtr pWin = GetProp(hwnd, WIN_WINDOW_PROP); if (pWin) { winPrivWinPtr pWinPriv = winGetWindowPriv(pWin); winPrivScreenPtr s_pScreenPriv = pWinPriv->pScreenPriv; wmMsg.msg = WM_WM_ICON_EVENT; wmMsg.hwndWindow = hwnd; wmMsg.iWindow = (Window) (INT_PTR) GetProp(hwnd, WIN_WID_PROP); winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); } } /* Update the system menu for this window */ SetupSysMenu(hwnd); /* That was easy... */ } return TRUE; }
void winMWExtWMUpdateIcon(Window id) { WindowPtr pWin; HICON hIcon, hiconOld; dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess); hIcon = winOverrideIcon((unsigned long) pWin); if (!hIcon) hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON)); if (hIcon) { win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE); if (pRLWinPriv->hWnd) { hiconOld = (HICON) SendMessage(pRLWinPriv->hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon); winDestroyIcon(hiconOld); } hIcon = NULL; } }
void winMWExtWMUpdateIcon (Window id) { WindowPtr pWin; HICON hIcon, hiconOld; pWin = LookupIDByType (id, RT_WINDOW); hIcon = (HICON)winOverrideIcon ((unsigned long)pWin); if (!hIcon) hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON)); if (hIcon) { win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); if (pRLWinPriv->hWnd) { hiconOld = (HICON) SetClassLong (pRLWinPriv->hWnd, GCL_HICON, (int) hIcon); winDestroyIcon(hiconOld); } } }
/* * Callback routine that is executed once per window class. * Removes or creates custom window settings depending on LPARAM */ static wBOOL CALLBACK ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam) { HICON hicon; Window wid; if (!hwnd) { ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n"); return FALSE; } /* It's our baby, either clean or dirty it */ if (lParam==FALSE) { /* Reset the window's icon to undefined. */ hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0); /* If the old icon is generated on-the-fly, get rid of it, will regen */ winDestroyIcon (hicon); /* Same for the small icon */ hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0); winDestroyIcon (hicon); /* Remove any menu additions; bRevert=TRUE destroys any modified menus */ GetSystemMenu (hwnd, TRUE); /* This window is now clean of our taint (but with undefined icons) */ } else { /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */ wid = (Window)GetProp (hwnd, WIN_WID_PROP); if (wid) winUpdateIcon (wid); /* Update the system menu for this window */ SetupSysMenu ((unsigned long)hwnd); /* That was easy... */ } return TRUE; }
/* * winDestroyWindowsWindow - Destroy a Windows window associated * with an X window */ static void winDestroyWindowsWindow (WindowPtr pWin) { MSG msg; winWindowPriv(pWin); HICON hiconClass; HICON hiconSmClass; HMODULE hInstance; int iReturn; char pszClass[512]; BOOL oldstate = winInDestroyWindowsWindow; #if CYGMULTIWINDOW_DEBUG ErrorF ("winDestroyWindowsWindow\n"); #endif /* Bail out if the Windows window handle is invalid */ if (pWinPriv->hWnd == NULL) return; winInDestroyWindowsWindow = TRUE; /* Store the info we need to destroy after this window is gone */ hInstance = (HINSTANCE) GetClassLong (pWinPriv->hWnd, GCL_HMODULE); hiconClass = (HICON) GetClassLong (pWinPriv->hWnd, GCL_HICON); hiconSmClass = (HICON) GetClassLong (pWinPriv->hWnd, GCL_HICONSM); iReturn = GetClassName (pWinPriv->hWnd, pszClass, 512); SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL); /* Destroy the Windows window */ DestroyWindow (pWinPriv->hWnd); /* Null our handle to the Window so referencing it will cause an error */ pWinPriv->hWnd = NULL; /* Process all messages on our queue */ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { if (g_hDlgDepthChange == 0 || !IsDialogMessage (g_hDlgDepthChange, &msg)) { DispatchMessage (&msg); } } /* Only if we were able to get the name */ if (iReturn) { #if CYGMULTIWINDOW_DEBUG ErrorF ("winDestroyWindowsWindow - Unregistering %s: ", pszClass); #endif iReturn = UnregisterClass (pszClass, hInstance); #if CYGMULTIWINDOW_DEBUG ErrorF ("winDestroyWindowsWindow - %d Deleting Icon: ", iReturn); #endif winDestroyIcon(hiconClass); winDestroyIcon(hiconSmClass); } winInDestroyWindowsWindow = oldstate; #if CYGMULTIWINDOW_DEBUG ErrorF ("-winDestroyWindowsWindow\n"); #endif }