I am new to this part of coding, so here i am trying to name the icon which is popped in the taskbar when we open an application. I have created test.c file for testing but it is not giving me the output what i want, it's showing "unknown" for the icon name in the taskbar. If anyone could help in this, that would be a great help. I've attached the code below and thanks in advance.
#include </usr/include/X11/Xlib.h>
#include </usr/include/X11/Xatom.h>
bool quited = false;
void on_delete(Display * display, Window window)
{
XDestroyWindow(display, window);
quited = true;
}
int main(int argc, char *argv[])
{
Display * display = XOpenDisplay(NULL);
if (NULL == display) {
fprintf(stderr, "Failed to initialize display");
return EXIT_FAILURE;
}
Window root = DefaultRootWindow(display);
if (None == root) {
fprintf(stderr, "No root window found");
XCloseDisplay(display);
return EXIT_FAILURE;
}
Window window = XCreateSimpleWindow(display, root, 0, 0, 800, 600, 0, 0, 0xffffffff);
if (None == window) {
fprintf(stderr, "Failed to create window");
XCloseDisplay(display);
return EXIT_FAILURE;
}
XStoreName(display, window, "Test-Application");
Atom net_wm_name = XInternAtom(display, "_NET_WM_NAME", False);
XChangeProperty(display, window, net_wm_name, XA_STRING, 8,
PropModeReplace, (unsigned char *)"Testing", strlen("Testing"));
XMapWindow(display, window);
Atom wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
XSetWMProtocols(display, window, &wm_delete_window, 1);
XEvent event;
while (!quited) {
XNextEvent(display, &event);
switch(event.type) {
case ClientMessage:
if(event.xclient.data.l[0] == wm_delete_window) {
on_delete(event.xclient.display, event.xclient.window);
}
break;
}
}
XCloseDisplay(display);
return 0;
}