all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* w32term.c -- Improved icon support in Win32 Emacs
       [not found] <769fe25d050910165850d3503a@mail.gmail.com>
@ 2005-09-11  2:29 ` Chris Prince
  2005-09-11 21:19   ` Jason Rumney
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Prince @ 2005-09-11  2:29 UTC (permalink / raw)


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;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: w32term.c -- Improved icon support in Win32 Emacs
  2005-09-11  2:29 ` w32term.c -- Improved icon support in Win32 Emacs Chris Prince
@ 2005-09-11 21:19   ` Jason Rumney
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Rumney @ 2005-09-11 21:19 UTC (permalink / raw)
  Cc: emacs-devel

Chris Prince <cprince@gmail.com> writes:

> The patch below helps Emacs icons look better in Win32, by avoiding
> some stretching / pixelation problems.

Thanks, I installed your patch.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-11 21:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <769fe25d050910165850d3503a@mail.gmail.com>
2005-09-11  2:29 ` w32term.c -- Improved icon support in Win32 Emacs Chris Prince
2005-09-11 21:19   ` Jason Rumney

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.