Cygwin/X: Update icons directly, rather than modifying the window's class
Update icons directly to windows rather than modifying the window's class. Respect custom icons overriden via the configuration file. fd.o bugzilla #4491 Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
This commit is contained in:
parent
9955252564
commit
996357e905
|
@ -364,43 +364,37 @@ void
|
|||
winUpdateIcon (Window id)
|
||||
{
|
||||
WindowPtr pWin;
|
||||
HICON hIcon, hiconOld;
|
||||
HICON hIcon, hIconSmall=NULL, hIconOld;
|
||||
|
||||
pWin = (WindowPtr) LookupIDByType (id, RT_WINDOW);
|
||||
if (!pWin) return;
|
||||
hIcon = winOverrideIcon ((unsigned long)pWin);
|
||||
|
||||
if (!hIcon)
|
||||
hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
|
||||
|
||||
if (hIcon)
|
||||
{
|
||||
winWindowPriv(pWin);
|
||||
|
||||
if (pWinPriv->hWnd)
|
||||
{
|
||||
hiconOld = (HICON) SetClassLong (pWinPriv->hWnd,
|
||||
GCL_HICON,
|
||||
(int) hIcon);
|
||||
|
||||
/* Delete the icon if its not the default */
|
||||
winDestroyIcon(hiconOld);
|
||||
}
|
||||
winWindowPriv(pWin);
|
||||
if (pWinPriv->hWnd) {
|
||||
hIcon = winOverrideIcon ((unsigned long)pWin);
|
||||
if (!hIcon) {
|
||||
hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
|
||||
if (!hIcon) {
|
||||
hIcon = g_hIconX;
|
||||
hIconSmall = g_hSmallIconX;
|
||||
} else {
|
||||
/* Leave undefined if not found */
|
||||
hIconSmall = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
|
||||
}
|
||||
}
|
||||
|
||||
hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
|
||||
if (hIcon)
|
||||
{
|
||||
winWindowPriv(pWin);
|
||||
|
||||
if (pWinPriv->hWnd)
|
||||
{
|
||||
hiconOld = (HICON) SetClassLong (pWinPriv->hWnd,
|
||||
GCL_HICONSM,
|
||||
(int) hIcon);
|
||||
winDestroyIcon (hiconOld);
|
||||
}
|
||||
}
|
||||
/* Set the large icon */
|
||||
hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
|
||||
WM_SETICON, ICON_BIG, (LPARAM) hIcon);
|
||||
|
||||
/* Delete the icon if its not the default */
|
||||
winDestroyIcon(hIconOld);
|
||||
|
||||
/* Same for the small icon */
|
||||
hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
|
||||
WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
|
||||
winDestroyIcon(hIconOld);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void winInitGlobalIcons (void)
|
||||
|
|
|
@ -189,35 +189,28 @@ ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
|
|||
/* It's our baby, either clean or dirty it */
|
||||
if (lParam==FALSE)
|
||||
{
|
||||
hicon = (HICON)GetClassLong(hwnd, GCL_HICON);
|
||||
/* Reset the window's icon to undefined. */
|
||||
hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
|
||||
|
||||
/* Unselect any icon in the class structure */
|
||||
SetClassLong (hwnd, GCL_HICON, (LONG)LoadIcon (NULL, IDI_APPLICATION));
|
||||
|
||||
/* If it's generated on-the-fly, get rid of it, will regen */
|
||||
/* If the old icon is generated on-the-fly, get rid of it, will regen */
|
||||
winDestroyIcon (hicon);
|
||||
|
||||
hicon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
|
||||
|
||||
/* Unselect any icon in the class structure */
|
||||
SetClassLong (hwnd, GCL_HICONSM, 0);
|
||||
|
||||
/* If it's generated on-the-fly, get rid of it, will regen */
|
||||
/* Same for the small icon */
|
||||
hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
|
||||
winDestroyIcon (hicon);
|
||||
|
||||
/* Remove any menu additions, use bRevert flag */
|
||||
|
||||
/* Remove any menu additions; bRevert=TRUE destroys any modified menus */
|
||||
GetSystemMenu (hwnd, TRUE);
|
||||
|
||||
/* This window is now clean of our taint */
|
||||
/* This window is now clean of our taint (but with undefined icons) */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make the icon default, dynamic, or from xwinrc */
|
||||
SetClassLong (hwnd, GCL_HICON, (LONG)g_hIconX);
|
||||
SetClassLong (hwnd, GCL_HICONSM, (LONG)g_hSmallIconX);
|
||||
/* 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);
|
||||
|
||||
|
@ -241,8 +234,12 @@ ReloadPrefs (void)
|
|||
int i;
|
||||
|
||||
#ifdef XWIN_MULTIWINDOW
|
||||
/* First, iterate over all windows replacing their icon with system */
|
||||
/* default one and deleting any custom system menus */
|
||||
/* First, iterate over all windows, deleting their icons and custom menus.
|
||||
* This is really only needed because winDestroyIcon() will try to
|
||||
* destroy the old global icons, which will have changed.
|
||||
* It is probably better to set a windows USER_DATA to flag locally defined
|
||||
* icons, and use that to accurately know when to destroy old icons.
|
||||
*/
|
||||
EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -177,12 +177,12 @@ winMWExtWMUpdateIcon (Window id)
|
|||
|
||||
if (pRLWinPriv->hWnd)
|
||||
{
|
||||
hiconOld = (HICON) SetClassLong (pRLWinPriv->hWnd,
|
||||
GCL_HICON,
|
||||
(int) hIcon);
|
||||
|
||||
|
||||
hiconOld = (HICON) SendMessage (pRLWinPriv->hWnd,
|
||||
WM_SETICON, ICON_BIG, (LPARAM) hIcon);
|
||||
winDestroyIcon(hiconOld);
|
||||
}
|
||||
hIcon=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user