[英]xlib get icon data to draw on a window
For my program i need other programs icons, which i have saved in a list: 对于我的程序,我需要其他程序图标,我已保存在列表中:
Window *windowlist(Display *display, unsigned long *length)
{
Atom prop = XInternAtom(display, "_NET_CLIENT_LIST", False);
Atom type;
int form;
unsigned long remain;
unsigned char *list;
if(XGetWindowProperty(display, XDefaultRootWindow(display), prop, 0, 1024, False, XA_WINDOW, &type, &form, length, &remain, &list) != Success)
{
return 0;
}
return (Window*)list;
}
I could only find solutions using Imlib2, but am searching for an easier way if possible. 我只能使用Imlib2找到解决方案,但如果可能的话,我正在寻找一种更简单的方法。 Basically I only want to draw these icons on a window.
基本上我只想在窗口上绘制这些图标。
Atom prop = XInternAtom(display, "_NET_WM_ICON", False);
XGetWindowProperty(display, window, prop, 0, 1 or what i need to do here?, False, XA_CARDINAl, &actual_type_return, &actual_format_return, &nitems_return, &bytes_after_return, &data);
width = (int)data;
height = (int)data;
size = width * height;
XGetWindowProperty(display, window, prop, 2 ???, size, False, XA_CARDINAl, &actual_type_return, &actual_format_return, &nitems_return, &bytes_after_return, &data);
Pixmap = ....
I really have no clue what to do. 我真的不知道该怎么做。 Does someone have an example of how to get the right data or how to use it (eg for a pixmap)?
有人有一个如何获得正确数据或如何使用它的例子(例如pixmap)? Thank you!
谢谢!
Edit: Now i have a other solution (its in the source of libwnck) with XWMHints: 编辑:现在我有一个XWMHints的另一个解决方案(在libwnck的源代码中):
Pixmap icon;
int width, height;
XWMHints *hints;
hints = XGetWMHints(display, window);
if(hints)
{
if(hints->flags & IconPixmapHint)
icon = hints->icon_pixmap;
if(icon != 0)
{
get_pixmap_geometry(icon, &width, &height) //its just XGetGeometry stuff
XCopyArea(display, icon, drawable, gc, 0, 0, width, height 0, 0);
}
}
Something like that. 这样的事情。
Use this 用这个
gulong i=0;
int result;
Atom type;
int format;
gulong bytes_after;
gulong *data;
gulong nitems;
XGetWindowProperty (display,
w,
prop,
0, G_MAXLONG,
False, XA_CARDINAL , &type, &format, &nitems,
&bytes_after, ((guchar **)&data));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.