XChangeProperty to change icon in unity bar and alt tab menu and window of running app?

别来无恙 提交于 2019-12-11 07:09:16

问题


For X11 systems I was trying to change the icon of the application during run time. This means that the window icon should change, the icon showed in alt+tab menu, and the icon in the unity bar.

This is preview of ubuntu:

ubuntu doesnt have a window icon, but other operating systems like metacity do.

So I was thinking of using XChangeProperty like this:

unsigned int buffer[] = {16, 16, 4294901760..............., 32, 32, 0............}; //ARGB 32bit packed array

Display *d = XOpenDisplay(0);
int s = DefaultScreen(d);
Atom net_wm_icon = XInternAtom(d, "_NET_WM_ICON", False);
Atom cardinal = XInternAtom(d, "CARDINAL", False);
XEvent e;

//w == window

int length = 2 + 16 * 16 + 2 + 32 * 32;
XChangeProperty(d, w, net_wm_icon, cardinal, 32,
                 PropModeReplace, (const unsigned char*) buffer, length);


XMapWindow(d, w);
while(1) XNextEvent(d, &e);

I do this code in js-ctypes, but the above is C code i found during my research, will this work for running application?

Thanks

来源:https://stackoverflow.com/questions/26446847/xchangeproperty-to-change-icon-in-unity-bar-and-alt-tab-menu-and-window-of-runni

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!