Implement glfwSetWindowIcons on Linux

This commit is contained in:
Ioannis Tsakpinis 2015-09-07 16:21:27 +03:00
parent cca7589486
commit c0974ca09c
3 changed files with 36 additions and 1 deletions

View File

@ -443,6 +443,8 @@ static void detectEWMH(void)
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
_glfw.x11.NET_WM_NAME =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_NAME");
_glfw.x11.NET_WM_ICON =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_ICON");
_glfw.x11.NET_WM_ICON_NAME =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_ICON_NAME");
_glfw.x11.NET_WM_PID =

View File

@ -129,6 +129,7 @@ typedef struct _GLFWlibraryX11
Atom WM_STATE;
Atom WM_DELETE_WINDOW;
Atom NET_WM_NAME;
Atom NET_WM_ICON;
Atom NET_WM_ICON_NAME;
Atom NET_WM_PID;
Atom NET_WM_PING;

View File

@ -1647,7 +1647,39 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
void _glfwPlatformSetWindowIcons(_GLFWwindow* window, GLFWimage* icons, int count)
{
// TODO: Implement this
int i, d, p;
long* data;
// calculate number of elements
int nelements = count * 2; // width & height per icon
for (i = 0, nelements = 0; i < count; i++)
nelements += icons[i].width * icons[i].height; // pixel data
data = (long*)malloc(sizeof(long), nelements);
// build property data
for (i = 0, d = 0; i < count; i++)
{
data[d++] = icons[i].width;
data[d++] = icons[i].height;
for (p = 0; p < icons[i].width * icons[i].height; p++)
{
unsigned char* pixel = icons[i].pixels + p * 4;
data[d++] = // pack to ARGB integer
(pixel[3] << 24) |
(pixel[0] << 16) |
(pixel[1] << 8) |
(pixel[2] << 0) ;
}
}
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_ICON,
XA_CARDINAL,
32, PropModeReplace, (unsigned char*)data, nelements);
free(data);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)