Basilisk II: Add icons for X11 based on the MacOS X icons (fixes #160).

Note that it appears that a 'make clean' may be required due to the
change in user_strings_unix.h failing to cause all of the modules that
include it to be rebuilt.
This commit is contained in:
David O'Shea 2017-12-29 22:52:58 +10:30
parent ff129e8649
commit 9e2fc30ecd
5 changed files with 2925 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,166 @@
/* GIMP RGBA C-Source image dump (BasiliskII_32x32x32_icon.c) */
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
unsigned char pixel_data[32 * 32 * 4 + 1];
} icon_32x32x32 = {
32, 32, 4,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0q'\17s\377s\0\377q\37\6s\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0JJJ\377\7\7\7!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0h(\16k\377\214\0\377"
"\356b\16\357\36\27\27!\12\12\12\30%%%)\356b\16\357\315Y\40\316\263I\40\326"
"\245B)\377\203\27\0\204z\16\0{z\16\0{\203\27\0\204z\16\0{\203\27\0\204z\16"
"\0{z\16\0{\203\27\0\204\264I\27\265,\26\15""9\0\0\0\10\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\377{\0\377\377\204"
"\0\377%\22\22)\27\27\27!AAARbbb\224jjj\224\377\224\0\377\377\214\0\377\377"
"\224\0\377\377\224\0\377\377\214\0\377\377\224\0\377\377\224\0\377\377\224"
"\0\377\377\224\0\377\377\224\0\377\377\224\0\377\377\224\0\377\377\224\0"
"\377\377s\0\377,((9\37\37\37)\0\0\0\0\0\0\0\0,,,9jjj\204jjj\204aaa{jjj\204"
"\2138\40\224\377\224\0\377\377k\0\377bbb\204jjj\234zzz\306zzz\326\203\203"
"\203\316zzz\245\377\224\0\377\377\204\0\377\377s\0\377\377s\0\377\377{\0"
"\377\377s\0\377\377s\0\377\377s\0\377\377{\0\377\377s\0\377\377s\0\377\377"
"s\0\377\377s\0\377\377c\0\377zzz\306rrr\265\0\0\0\0\0\0\0\0jjj\204\234\234"
"\234\377\234\234\234\377\245\245\245\377\357c\30\377\377\224\0\377\367c\0"
"\377\224\224\224\377{{{\377ccc\377sss\377\214\214\214\377\234\234\234\377"
"\234\234\234\377\377\224\0\377\377{\0\377\377s\0\377\377k\0\377\377k\0\377"
"\377s\0\377\377k\0\377\377s\0\377\377k\0\377\377s\0\377\377s\0\377\377s\0"
"\377\377s\0\377\306Z9\377{{{\377rrr\275\0\0\0\0\0\0\0\0bbb\204\234\234\234"
"\377\245\245\245\377\367s\20\377\377\204\0\377\377k\0\377\214\214\214\377"
"kkk\377ZZZ\377{{{\377\224\224\224\377\234\234\234\377\245\245\245\377\224"
"\224\224\377\2559!\377\306\224\204\377\214kk\377kkk\377sss\377sss\377sss"
"\377sss\377sss\377sss\377sss\377\367R\10\377\377k\0\377{{{\377\203\203\203"
"\367XXX\204\0\0\0\0\0\0\0\0jjj\204\245\245\245\377\357c\30\377\377\204\0"
"\377\377s\0\377\224\204\204\377ccc\377ZZZ\377{{{\377\234\234\234\377\245"
"\245\245\377\245\245\245\377\234\234\234\377RRR\377sss\377\306\306\306\377"
"\214\214\214\377\214\214\214\377\214\214\214\377\214\214\214\377\214\214"
"\214\377\224\224\224\377\214\214\214\377\214\214\214\377\224\224\224\377"
"\377c\0\377\357R\30\377\204\204\204\377zzz\326666B\0\0\0\0\0\0\0\0aaa{\306"
"sR\377\377\224\0\377\377{\0\377\316R1\377ccc\377RRR\377JJJ\377{{{\377\234"
"\234\234\377\245\245\245\377\234\234\234\377\224\224\224\377RRR\377\336\336"
"\336\377\336\336\336\377\316\316\316\377\316\316\316\377\224\224\224\377"
"RRR\377\326\326\326\377\326\326\326\377\326\326\326\377\326\326\326\377\326"
"\306\306\377\377k\0\377\306\275\265\377\203\203\203\357jjj\234\25\25\25\30"
"\0\0\0\0\0\0\0\0jbb\204\377\224\0\377\377{\0\377\377k\0\377ccc\377RRR\377"
"kkk\377ccc\377\204\204\204\377\245\245\245\377\245\245\245\377\234\234\234"
"\377ZZZ\377ccc\377\347\347\347\377\347\347\347\377\347\347\347\377\347\347"
"\347\377\224\224\224\377RRR\377\347\347\347\377\336\336\336\377\347\347\347"
"\377\347\347\347\377\367k9\377\377c\0\377\275\275\275\377\203\203\203\347"
"IIIZ\0\0\0\0\0\0\0\0\0\0\0\0\356j\16\357\377\204\0\377\377s\0\377\234R9\377"
"RRR\377ZZZ\377\214\214\214\377ccc\377\204\204\204\377\234\234\234\377\234"
"\234\234\377\245\245\245\377RRR\377\326\326\326\377\347\347\347\377\336\336"
"\336\377\347\347\347\377\336\336\336\377\234\234\234\377JJJ\377\347\347\347"
"\377\347\347\347\377\347\347\347\377\336\336\336\377\377k\0\377\347\224\204"
"\377\234\234\234\377\203\203\203\326\36\36\36!\0\0\0\0\0\0\0\0\0\0\0\10\377"
"\224\0\377\377{\0\377\377k\0\377RRR\377RRR\377sss\377\224\224\224\377\234"
"\234\234\377\245\245\245\377\245\245\245\377\234\234\234\377\214\214\214"
"\377JJJ\377\347\347\347\377\347\347\347\377\347\347\347\377\336\336\336\377"
"\347\347\347\377\347\347\347\377\347\347\347\377\347\347\347\377\347\347"
"\347\377\336\336\336\377\347\275\265\377\377s\0\377\316\316\316\377\214\214"
"\214\377\203\203\203\265\0\0\0\10\0\0\0\0\0\0\0\0\335Y\26\336\377\214\0\377"
"\377s\0\377\316B\30\377JJJ\377ZZZ\377\204\204\204\377\234\234\234\377\245"
"\245\245\377\245\245\245\377\234\234\234\377\245\245\245\377ccc\377kkk\377"
"\347\347\347\377\336\336\336\377\347\347\347\377\347\347\347\377\347\347"
"\347\377\336\336\336\377\336\336\336\377\347\347\347\377\336\336\336\377"
"\347\347\347\377\377c!\377\367c)\377\265\265\265\377\214\214\214\377zzz\224"
"\0\0\0\0\0\0\0\0\0\0\0\0\377\224\0\377\377{\0\377\377k\0\377ZRR\377RRR\377"
"{kk\377\377Z\10\377\377s\0\377\377s\0\377\377s\0\377\357R\30\377\245\245"
"\245\377RRR\377\255\255\255\377\347\347\347\377\336\336\336\377\347\347\347"
"\377\336\336\336\377\347\347\347\377\347\347\347\377\347\347\347\377\347"
"\347\347\377\347\347\347\377\347\347\347\377\377k\0\377\336\316\316\377\234"
"\234\234\377\245\245\245\377yyy\204\0\0\0\0\0\0\0\0\36\27\27!\377\224\0\377"
"\377s\0\377\377k\0\377RRR\377ZRR\377\377k\0\377\316cJ\377\316cJ\377\377\214"
"\0\377\377s\0\377\377s\0\377\377c\0\377RRR\377\326\326\326\377\336\336\336"
"\377\347\347\347\377\347\347\347\377\347\347\347\377\336\336\336\377\347"
"\347\347\377\336\336\336\377\347\347\347\377\336\336\336\377\357\245\224"
"\377\377c\0\377\306\306\306\377\214\214\214\377\275\275\275\377yyy\204\0"
"\0\0\0\0\0\0\0\212(\16\214\377\224\0\377\377k\0\377\377R\0\377RRR\377ccc"
"\377\224\224\224\377\234\234\234\377{{{\377ccc\377\377\214\0\377\377s\0\377"
"\377s\0\377\347B\10\377\316\316\316\377\347\347\347\377\347\347\347\377\347"
"\347\347\377\336\336\336\377\347\347\347\377\347\347\347\377\347\347\347"
"\377\347\347\347\377\347\347\347\377\377R\0\377\357\204c\377\255\255\255"
"\377\224\224\224\377\326\326\326\377zzz{\0\0\0\0\0\0\0\0\335b\26\336\377"
"\214\0\377\377s\0\377\336J\20\377RRR\377kkk\377\224\224\224\377\204\204\204"
"\377kkk\377{{{\377\265ZJ\377\377\214\0\377\377s\0\377\377s\0\377111\377J"
"JJ\377RRR\377JJJ\377RRR\377\347\347\347\377\347\347\347\377\347\347\347\377"
"\336\336\336\377\347\347\347\377\377k\0\377\326\326\326\377\234\234\234\377"
"\255\255\255\377\336\336\336\377yyy\204\0\0\0\0\0\0\0\0\377Z\0\377\377\204"
"\0\377\377k\0\377\275B\30\377JJJ\377{{{\377\234\234\234\377\234\234\234\377"
"\234\234\234\377\234\234\234\377\234\234\234\377\377\224\0\377\377{\0\377"
"\377s\0\377\265B)\377sss\377\224\224\224\377kkk\377ZZZ\377\336\336\336\377"
"\336\336\336\377\347\347\347\377\347\347\347\377\367\224{\377\377Z\10\377"
"\306\306\306\377\214\214\214\377\306\306\306\377\336\336\336\377\203\203"
"\203\204\0\0\0\0\0\0\0\0\377c\0\377\377\204\0\377\377s\0\377\275B!\377RR"
"R\377{{{\377\234\234\234\377\245\245\245\377\234\234\234\377\245\245\245"
"\377\234\234\234\377\377c\0\377\377\214\0\377\377k\0\377\357J\10\377ccc\377"
"\224\224\224\377RRR\377\214\214\214\377\347\347\347\377\347\347\347\377\347"
"\347\347\377\336\336\336\377\377Z\0\377\347\245\234\377\255\255\255\377\234"
"\234\234\377\326\326\326\377\347\347\347\377zzz{\0\0\0\0\0\0\0\0\377c\0\377"
"\377\204\0\377\377s\0\377\316J\30\377RRR\377\204\204\204\377\224\224\224"
"\377kkk\377{{{\377\234\234\234\377\245\245\245\377\347c)\377\377\224\0\377"
"\377s\0\377\377R\0\377RRR\377\204\204\204\377JJJ\377\265\265\265\377\347"
"\347\347\377\336\336\336\377\347\347\347\377\336\336\336\377\377k\0\377J"
"JJ\377\214\214\214\377\265\265\265\377\336\336\336\377\347\347\347\377zz"
"z{\0\0\0\0\0\0\0\0\346b\17\347\377\214\0\377\377k\0\377\347J\10\377ZZZ\377"
"\204\204\204\377\245\245\245\377\214\214\214\377kkk\377kkk\377kkk\377\275"
"J1\377\377\224\0\377\377s\0\377\377Z\0\377JJJ\377sss\377RRR\377\214\214\214"
"\377sss\377ZZZ\377JJJ\377\275B!\377\336J\20\377\255\255\255\377\224\224\224"
"\377\316\316\316\377\336\336\336\377\347\347\347\377zzz{\0\0\0\0\0\0\0\0"
"\2437\27\245\377\214\0\377\377s\0\377\377Z\0\377RRR\377\204\204\204\377\234"
"\234\234\377\245\245\245\377\234\234\234\377\245\245\245\377\234\234\234"
"\377\306ZB\377\377\224\0\377\377s\0\377\367J\0\377111\377RRR\377RRR\377Z"
"ZZ\377sss\377\224\224\224\377\326\326\326\377\377c\0\377\336\326\316\377"
"\245\245\245\377\245\245\245\377\336\336\336\377\347\347\347\377\347\347"
"\347\377zzz{\0\0\0\0\0\0\0\0%\22\22)\377\214\0\377\377s\0\377\377k\0\377"
"RRR\377{{{\377\234\234\234\377\245\245\245\377\234\234\234\377\245\245\245"
"\377\234\234\234\377\326kJ\377\377\214\0\377\377s\0\377\306J!\377RRR\377"
"sss\377JJJ\377\265\265\265\377\336\336\336\377\347\347\347\377\347\326\326"
"\377\377c\0\377\316\316\316\377\224\224\224\377\275\275\275\377\336\336\336"
"\377\347\347\347\377\336\336\336\377zzz{\0\0\0\0\0\0\0\0\0\0\0\0\377\224"
"\0\377\377\204\0\377\377s\0\377kJJ\377kkk\377\234\234\234\377\245\245\245"
"\377\234\234\234\377\245\245\245\377\245\245\245\377\347c)\377\377\214\0"
"\377\377s\0\377cJB\377ZZZ\377{{{\377RRR\377\224\224\224\377\347\347\347\377"
"\347\347\347\377\367c)\377\367\204c\377\275\275\275\377\224\224\224\377\316"
"\316\316\377\347\347\347\377\347\347\347\377\347\347\347\377yyy\204\0\0\0"
"\0\0\0\0\0\0\0\0\0\264@\27\265\377\214\0\377\377s\0\377\357J\10\377kkk\377"
"\224\224\224\377\245\245\245\377\234\234\234\377\245\245\245\377\234\234"
"\234\377\377c\0\377\377\204\0\377\377c\0\377RRR\377ZZZ\377\204\204\204\377"
"ccc\377ccc\377\336\336\336\377\347\347\347\377\377s\0\377\326\326\326\377"
"\245\245\245\377\245\245\245\377\336\336\336\377\336\336\336\377\336\336"
"\336\377\347\347\347\377zzz{\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\377\224\0\377"
"\377\204\0\377\377k\0\377kkc\377\245\245\245\377\265\265\265\377\275\275"
"\275\377\265\265\265\377\265\265\265\377\377\224\0\377\377s\0\377\234ZR\377"
"ccc\377kkk\377\245\245\245\377\245\245\245\377RRR\377\357\357\357\377\357"
"\255\234\377\377R\0\377\326\326\326\377\234\234\234\377\326\326\326\377\357"
"\357\357\377\357\357\357\377\367\367\367\377\357\357\357\377zzz{\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0H%\37J\377\214\0\377\377{\0\377\367Z\0\377XXX\204"
"\17\17\17\20\0\0\0\0\0\0\0\0\2128\27\214\377{\0\377\335Q\16\336zzz\326zz"
"z\367bbb\224\17\17\17\20\0\0\0\0RRR\377\0\0\0\0\377Z\0\377W\37\26ZQQQkjj"
"j\234\27\27\27!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0yA0\204\377\224\0\377\377{\0\377\367Z\10\3776..B\0"
"\0\0\0P\37\17R\377{\0\377\346Y\16\357QQQk\203\203\203\357zzz\316666B\0\0"
"\0\10\0\0\0\0III\336777\234\377s\0\377\27\27\27!rrr\245QQQk\0\0\0\10\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\17\17\17\20YYY{\356Y\7\367\377k\0\377\377k\0\377\377s\0\377\377c\0\377"
"a&\27c%%%)rrr\265zzz\326QQQk\0\0\0\10\0\0\0\0\0\0\0\0\0\0\0\20RRR\377\0\0"
"\0\0""777Jrrr\265$$$1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\25\25\25\30YYY{zzz\336\203\203"
"\203\357rrr\255IIIZIIIZjjj\245zzz\316QQQk\17\17\17\20\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\10IIIZXXXs\17\17\17\20\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\10\17\17\17\20AAAJbbb\224rrr\275zzz\275jjj\255bbb\214666B\17\17\17"
"\20\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\20\17"
"\17\17\20\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0",
};

View File

@ -38,6 +38,7 @@ user_string_def platform_strings[] = {
{STR_FBDEV_NAME_ERR, "The %s frame buffer is not supported in %d bit mode."},
{STR_FBDEV_MMAP_ERR, "Cannot mmap() the frame buffer memory (%s)."},
{STR_VOSF_INIT_ERR, "Cannot initialize Video on SEGV signals."},
{STR_X_ICON_ATOM_ALLOC_ERR, "Failed to allocate X Atom. Icon will not be set."},
{STR_NO_DEV_ZERO_ERR, "Cannot open /dev/zero (%s)."},
{STR_LOW_MEM_MMAP_ERR, "Cannot map Low Memory Globals (%s)."},
{STR_SIGALTSTACK_ERR, "Cannot install alternate signal stack (%s)."},

View File

@ -29,6 +29,7 @@ enum {
STR_FBDEV_NAME_ERR,
STR_FBDEV_MMAP_ERR,
STR_VOSF_INIT_ERR,
STR_X_ICON_ATOM_ALLOC_ERR,
STR_NO_DEV_ZERO_ERR,
STR_LOW_MEM_MMAP_ERR,
STR_SIGALTSTACK_ERR,

View File

@ -29,6 +29,7 @@
#include "sysdeps.h"
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
@ -445,6 +446,87 @@ static void set_window_name(Window w, int name)
}
}
// This struct is designed to match the ones generated by GIMP in
// BasiliskII_*_icon.c
struct gimp_image {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel;
unsigned char pixel_data[0]; // Variable-length
};
// These were generated by using 'icns2png -x
// ../MacOSX/BasiliskII.icns', then using GIMP to convert the
// resulting .png files into "C source code (*.c)". GIMP doesn't
// generate corresponding .h files with extern declarations, so just
// #include the .c files here.
#include "BasiliskII_32x32x32_icon.c"
#include "BasiliskII_128x128x32_icon.c"
// Set window icons
static void set_window_icons(Window w)
{
// As per the _NET_WM_ICON documentation at
// https://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472568384,
// "The first two cardinals are width, height."
const unsigned int HEADER_SIZE = 2;
// We will pass 32-bit values to XChangeProperty()
const unsigned int FORMAT = 32;
// Icon data from GIMP to be converted and passed to the
// Window Manager
const struct gimp_image* const icons[] =
{(struct gimp_image *) &icon_32x32x32,
(struct gimp_image *) &icon_128x128x32};
const unsigned int num_icons = sizeof(icons) / sizeof(icons[0]);
unsigned int icon;
// Work out how big the buffer needs to be to store all of our icons
unsigned int buffer_size = 0;
for (icon = 0; icon < num_icons; icon++) {
buffer_size += HEADER_SIZE +
icons[icon]->width * icons[icon]->height;
}
// As per the XChangeProperty() man page, "If the specified
// format is 32, the property data must be a long array."
unsigned long buffer[buffer_size];
// This points to the start of the current icon within buffer
unsigned long *buffer_icon = buffer;
// Copy the icons into the buffer
for (icon = 0; icon < num_icons; icon++) {
const unsigned int pixel_count = icons[icon]->width *
icons[icon]->height;
assert(icons[icon]->bytes_per_pixel == 4);
buffer_icon[0] = icons[icon]->width;
buffer_icon[1] = icons[icon]->height;
unsigned long *const buffer_pixels = buffer_icon + HEADER_SIZE;
unsigned int i;
for (i = 0; i < pixel_count; i++) {
const unsigned char *src =
&icons[icon]->pixel_data[i * icons[icon]->bytes_per_pixel];
buffer_pixels[i] = (src[3] << 24 |
src[0] << 16 |
src[1] << 8 |
src[2]);
}
buffer_icon += HEADER_SIZE + pixel_count;
}
Atom net_wm_icon = XInternAtom(x_display, "_NET_WM_ICON", False);
if (net_wm_icon == None) {
ErrorAlert(STR_X_ICON_ATOM_ALLOC_ERR);
// We can still continue running, just without an icon
return;
}
XChangeProperty(x_display, w, net_wm_icon, XA_CARDINAL, FORMAT,
PropModeReplace, (const unsigned char *) buffer,
buffer_size);
}
// Set window input focus flag
static void set_window_focus(Window w)
{
@ -733,6 +815,9 @@ driver_window::driver_window(X11_monitor_desc &m)
// Set window name/class
set_window_name(w, STR_WINDOW_TITLE);
// Set window icons
set_window_icons(w);
// Indicate that we want keyboard input
set_window_focus(w);