[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
w32term.c -- Improved icon support in Win32 Emacs
From: |
Chris Prince |
Subject: |
w32term.c -- Improved icon support in Win32 Emacs |
Date: |
Sat, 10 Sep 2005 16:58:15 -0700 |
The patch below helps Emacs icons look better in Win32, by avoiding
some stretching / pixelation problems.
Please let me know if this is the wrong list for submitting patches.
--Chris
EXPLANATION:
Win32 uses two different icon sizes:
- 32x32 (shown on the desktop, and when alt-tabbing between apps, etc)
- 16x16 (shown in top-left corner of app, and on system taskbar, etc)
Win32 .ico files often contain both sizes internally.
In Emacs, you can set the icon using something like this:
(modify-frame-parameters nil (list (cons 'icon-type "C:/emacs.ico")))
But this only loads one version of the icon. So either the 32x32 or
16x16 icon (or both) will be stretched and pixelated.
With this patch, Emacs will correctly try to load the 16x16 version
if available, so that both sizes can look smooth.
I'm not doing anything tricky; this is pretty standard Win32 programming.
I tested by loading the following icon types. All work as expected:
- Icon containing 16x16 and 32x32 versions.
Result: small and large versions are smooth.
- Icon containing 16x16 only.
Result: small is smooth, large is stretched.
- Icon containing 32x32 only.
Result: large is smooth, small is stretched.
- Icon containing 48x48 only.
Result: small and large are stretched.
PATCH:
*** w32term.c.CVS-20050910 Sat Sep 10 15:58:48 2005
--- w32term.c.NEW Sat Sep 10 16:13:40 2005
*************** x_bitmap_icon (f, icon)
*** 5268,5273 ****
--- 5268,5274 ----
Lisp_Object icon;
{
HANDLE hicon;
+ HANDLE hicon_small = NULL; // also load 16x16 version if present
if (FRAME_W32_WINDOW (f) == 0)
return 1;
*************** x_bitmap_icon (f, icon)
*** 5275,5282 ****
if (NILP (icon))
hicon = LoadIcon (hinst, EMACS_CLASS);
else if (STRINGP (icon))
! hicon = LoadImage (NULL, (LPCTSTR) SDATA (icon), IMAGE_ICON, 0, 0,
! LR_DEFAULTSIZE | LR_LOADFROMFILE);
else if (SYMBOLP (icon))
{
LPCTSTR name;
--- 5276,5288 ----
if (NILP (icon))
hicon = LoadIcon (hinst, EMACS_CLASS);
else if (STRINGP (icon))
! {
! hicon = LoadImage (NULL, (LPCTSTR) SDATA (icon), IMAGE_ICON, 0, 0,
! LR_DEFAULTSIZE | LR_LOADFROMFILE);
! hicon_small = LoadImage (NULL, (LPCTSTR) SDATA (icon), IMAGE_ICON,
! GetSystemMetrics (SM_CXSMICON),
! GetSystemMetrics (SM_CYSMICON),
LR_LOADFROMFILE);
! }
else if (SYMBOLP (icon))
{
LPCTSTR name;
*************** x_bitmap_icon (f, icon)
*** 5306,5311 ****
--- 5312,5320 ----
PostMessage (FRAME_W32_WINDOW (f), WM_SETICON, (WPARAM) ICON_BIG,
(LPARAM) hicon);
+ if (hicon_small)
+ PostMessage (FRAME_W32_WINDOW (f), WM_SETICON, (WPARAM) ICON_SMALL,
+ (LPARAM) hicon_small);
return 0;
}
- w32term.c -- Improved icon support in Win32 Emacs,
Chris Prince <=