emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 412247c53f: Fix Emacs icon not appearing on Haiku


From: Po Lu
Subject: master 412247c53f: Fix Emacs icon not appearing on Haiku
Date: Mon, 17 Jan 2022 06:13:12 -0500 (EST)

branch: master
commit 412247c53f3708e96f7a16aaeee55a747a91d22d
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix Emacs icon not appearing on Haiku
    
    * lib-src/be_resources.cc (main): Scale input bitmap
    appropriately before setting it as the mini and large icons.
    * src/Makefile.in (Emacs): Add dependency on
    `lib-src/be-resources'.
---
 lib-src/be_resources.cc | 39 ++++++++++++++++++++++++++++++++++++---
 src/Makefile.in         |  2 +-
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/lib-src/be_resources.cc b/lib-src/be_resources.cc
index d18fe30dd7..414f91a192 100644
--- a/lib-src/be_resources.cc
+++ b/lib-src/be_resources.cc
@@ -29,6 +29,9 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <Application.h>
 #include <Catalog.h>
 #include <Roster.h>
+#include <Bitmap.h>
+#include <Rect.h>
+#include <View.h>
 
 using namespace std;
 
@@ -79,11 +82,25 @@ main (int argc, char **argv)
   BApplication app ("application/x-vnd.GNU-emacs-resource-helper");
   BFile file;
   BBitmap *icon;
+  BBitmap scale32 (BRect (0, 0, 31, 31), B_RGBA32, true);
+  BBitmap scale16 (BRect (0, 0, 15, 15), B_RGBA32, true);
   BAppFileInfo info;
   status_t code;
   struct version_info vinfo;
   char *v = strdup (PACKAGE_VERSION);
 
+  if (scale32.InitCheck () != B_OK
+      || scale16.InitCheck () != B_OK)
+    {
+      fprintf (stderr, "Bitmap initialization ran out of memory\n");
+      return EXIT_FAILURE;
+    }
+
+  BView scale32view (scale32.Bounds (), NULL,
+                    B_FOLLOW_NONE, B_WILL_DRAW);
+  BView scale16view (scale16.Bounds (), NULL,
+                    B_FOLLOW_NONE, B_WILL_DRAW);
+
   if (argc != 3)
     {
       printf ("be-resources ICON FILE: make FILE appropriate for Emacs.\n");
@@ -117,8 +134,24 @@ main (int argc, char **argv)
       return EXIT_FAILURE;
     }
 
-  info.SetIcon (icon, B_MINI_ICON);
-  info.SetIcon (icon, B_LARGE_ICON);
+  scale32.AddChild (&scale32view);
+  scale16.AddChild (&scale16view);
+
+  if (!scale32view.LockLooper ()
+      || !scale16view.LockLooper ())
+    {
+      fprintf (stderr, "Failed to lock bitmap looper\n");
+      return EXIT_FAILURE;
+    }
+
+  scale32view.DrawBitmapAsync (icon, scale32.Bounds ());
+  scale16view.DrawBitmapAsync (icon, scale16.Bounds ());
+
+  scale32view.Sync ();
+  scale16view.Sync ();
+
+  info.SetIcon (&scale16, B_MINI_ICON);
+  info.SetIcon (&scale32, B_LARGE_ICON);
   info.SetSignature ("application/x-vnd.GNU-emacs");
 
   v = strtok (v, ".");
@@ -140,5 +173,5 @@ main (int argc, char **argv)
 
   info.SetVersionInfo (&vinfo, B_APP_VERSION_KIND);
 
-  return EXIT_SUCCESS;
+  exit (EXIT_SUCCESS);
 }
diff --git a/src/Makefile.in b/src/Makefile.in
index 04fabd5f42..0b465b8cd6 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -616,7 +616,7 @@ endif
 ## icon set.
 
 ifeq ($(HAVE_BE_APP),yes)
-Emacs: emacs$(EXEEXT)
+Emacs: emacs$(EXEEXT) $(libsrc)/be-resources
        $(AM_V_GEN) cp -f emacs$(EXEEXT) $@
        $(AM_V_at) $(libsrc)/be-resources \
          $(etc)/images/icons/hicolor/32x32/apps/emacs.png $@



reply via email to

[Prev in Thread] Current Thread [Next in Thread]