From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Prince Newsgroups: gmane.emacs.devel Subject: w32term.c -- Improved icon support in Win32 Emacs Date: Sat, 10 Sep 2005 19:29:15 -0700 Message-ID: <769fe25d05091019296ed96ab9@mail.gmail.com> References: <769fe25d050910165850d3503a@mail.gmail.com> Reply-To: cprince@gmail.com NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1126406004 26247 80.91.229.2 (11 Sep 2005 02:33:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Sep 2005 02:33:24 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 11 04:33:22 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EEHeW-0004b9-7n for ged-emacs-devel@m.gmane.org; Sun, 11 Sep 2005 04:33:08 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EEHeU-0006P4-BJ for ged-emacs-devel@m.gmane.org; Sat, 10 Sep 2005 22:33:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EEHdh-00066T-46 for emacs-devel@gnu.org; Sat, 10 Sep 2005 22:32:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EEHdc-00063V-2l for emacs-devel@gnu.org; Sat, 10 Sep 2005 22:32:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EEHdb-00062x-Ne for emacs-devel@gnu.org; Sat, 10 Sep 2005 22:32:11 -0400 Original-Received: from [64.233.170.195] (helo=rproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EEHb4-0001li-4q for emacs-devel@gnu.org; Sat, 10 Sep 2005 22:29:34 -0400 Original-Received: by rproxy.gmail.com with SMTP id 1so369831rny for ; Sat, 10 Sep 2005 19:29:15 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ekgxBmepPUfK4plLtsPD84MkwO7OK39SYt4/myffPbXzSdA9qbolOAK9bx2gYigtyCJz4quOaWgrDNmNsHWQT6ZTlbgsrpRC9uXdKO4qQ0AOMDUa4gKq5m/d0GZteq8qKh9GSWEpIrgUW3p+9nlUW3WUX9pEHmeJDSgBx+O2uGg= Original-Received: by 10.11.119.21 with SMTP id r21mr14502cwc; Sat, 10 Sep 2005 19:29:15 -0700 (PDT) Original-Received: by 10.11.117.70 with HTTP; Sat, 10 Sep 2005 19:29:15 -0700 (PDT) Original-To: emacs-devel@gnu.org In-Reply-To: <769fe25d050910165850d3503a@mail.gmail.com> Content-Disposition: inline X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:42815 Archived-At: 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 =3D NULL; // also load 16x16 version if present if (FRAME_W32_WINDOW (f) =3D=3D 0) return 1; *************** x_bitmap_icon (f, icon) *** 5275,5282 **** if (NILP (icon)) hicon =3D LoadIcon (hinst, EMACS_CLASS); else if (STRINGP (icon)) ! hicon =3D 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 =3D LoadIcon (hinst, EMACS_CLASS); else if (STRINGP (icon)) ! { ! hicon =3D LoadImage (NULL, (LPCTSTR) SDATA (icon), IMAGE_ICON, 0, 0= , ! LR_DEFAULTSIZE | LR_LOADFROMFILE); ! hicon_small =3D 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; }