unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chris Prince <cprince@gmail.com>
Subject: w32term.c -- Improved icon support in Win32 Emacs
Date: Sat, 10 Sep 2005 19:29:15 -0700	[thread overview]
Message-ID: <769fe25d05091019296ed96ab9@mail.gmail.com> (raw)
In-Reply-To: <769fe25d050910165850d3503a@mail.gmail.com>

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

       reply	other threads:[~2005-09-11  2:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <769fe25d050910165850d3503a@mail.gmail.com>
2005-09-11  2:29 ` Chris Prince [this message]
2005-09-11 21:19   ` w32term.c -- Improved icon support in Win32 Emacs Jason Rumney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=769fe25d05091019296ed96ab9@mail.gmail.com \
    --to=cprince@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).