Skip to content

Commit

Permalink
fix: Restored icon and tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Knoblauchpilze committed Jan 24, 2024
1 parent 2481d67 commit 28590d1
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/pge/olc/olcPixelGameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -5687,6 +5687,57 @@ namespace olc
XMapWindow(olc_Display, olc_Window);
XStoreName(olc_Display, olc_Window, "OneLoneCoder.com - Pixel Game Engine");

// As per this topic:
// https://stackoverflow.com/questions/50123173/how-to-set-icon-name-in-x11-ubuntu
// Assign the name of the app to the tooltip that
// is visible for the application.
char appTooltip[] = "bsgalone";
XClassHint *class_hint = XAllocClassHint();
if (class_hint) {
class_hint->res_name = appTooltip;
class_hint->res_class = appTooltip;
XSetClassHint(olc_Display, olc_Window, class_hint);
XFree(class_hint);
}

// Change the icon to something nicer, as defined in this topic:
// https://stackoverflow.com/questions/10699927/xlib-argb-window-icon
// In order to define the buffer, we have to use the ARGB syntax
// and represent each pixel as a unsigned integer.
// For example the value
// (4278190080)10 =
// (1111 1111 0000 0000 0000 0000 0000 0000)b
// + A + R + G + B +
// The following buffer represents a simplified version of the hand
// that is characteristic of the application.
unsigned long buffer[] = {
// Dimensions
16, 16,
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
/* 0 */ 4278190080, 4278190080, 4278190080, 4278190080, 4280418304, 4283367424, 4283367424, 4283367424, 4283367424, 4283367424, 4283367424, 4280418304, 4278190080, 4278190080, 4278190080, 4278190080,
/* 1 */ 4278190080, 4278190080, 4278190080, 4280418304, 4288413696, 4291559424, 4291559424, 4291559424, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304, 4278190080, 4278190080, 4278190080,
/* 2 */ 4278190080, 4278190080, 4280418304, 4288413696, 4291559424, 4291559424, 4291559424, 4291085508, 4291085508, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304, 4278190080, 4278190080,
/* 3 */ 4278190080, 4280418304, 4288413696, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4291085508, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304, 4278190080,
/* 4 */ 4280418304, 4288413696, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4294967295, 4291085508, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304,
/* 5 */ 4283367424, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4291085508, 4291559424, 4291559424, 4291559424, 4291559424, 4283367424,
/* 6 */ 4283367424, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4291085508, 4291559424, 4291085508, 4291559424, 4291559424, 4283367424,
/* 7 */ 4283367424, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4291085508, 4291085508, 4291085508, 4291559424, 4291559424, 4283367424,
/* 8 */ 4283367424, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4294967295, 4291085508, 4291085508, 4294967295, 4291085508, 4291559424, 4291559424, 4283367424,
/* 9 */ 4283367424, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4291085508, 4294967295, 4294967295, 4291085508, 4291085508, 4291559424, 4291559424, 4283367424,
/* 10 */ 4283367424, 4291559424, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4291085508, 4294967295, 4294967295, 4291085508, 4291559424, 4291559424, 4291559424, 4283367424,
/* 11 */ 4280418304, 4288413696, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4291085508, 4294967295, 4294967295, 4291085508, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304,
/* 12 */ 4278190080, 4280418304, 4288413696, 4291559424, 4291559424, 4291085508, 4294967295, 4294967295, 4294967295, 4291085508, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304, 4278190080,
/* 13 */ 4278190080, 4278190080, 4280418304, 4288413696, 4291559424, 4291559424, 4291085508, 4291085508, 4291085508, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304, 4278190080, 4278190080,
/* 14 */ 4278190080, 4278190080, 4278190080, 4280418304, 4288413696, 4291559424, 4291559424, 4291559424, 4291559424, 4291559424, 4291559424, 4288413696, 4280418304, 4278190080, 4278190080, 4278190080,
/* 15 */ 4278190080, 4278190080, 4278190080, 4278190080, 4280418304, 4283367424, 4283367424, 4283367424, 4283367424, 4283367424, 4283367424, 4280418304, 4278190080, 4278190080, 4278190080, 4278190080,
};

Display *d = XOpenDisplay(0);
Atom net_wm_icon = XInternAtom(d, "_NET_WM_ICON", False);
Atom cardinal = XInternAtom(olc_Display, "CARDINAL", False);
int length = 2 + 16 * 16;
XChangeProperty(olc_Display, olc_Window, net_wm_icon, cardinal, 32, PropModeReplace, (const unsigned char*) buffer, length);

if (bFullScreen) // Thanks DragonEye, again :D
{
Atom wm_state;
Expand Down

0 comments on commit 28590d1

Please sign in to comment.