diff --git a/examples/image.c b/examples/image.c index 8511966..a658ed7 100644 --- a/examples/image.c +++ b/examples/image.c @@ -8,11 +8,13 @@ int main() { MwWidget button = MwCreateWidget(MwButtonClass, "button", window, 50, 50, 400, 400); MwLLPixmap px = MwLoadImage(window, "examples/picture.png"); + MwVaApply(window, + MwNiconPixmap, px, + NULL); + MwVaApply(button, MwNpixmap, px, NULL); - MwWindowSetIcon(window, px); - MwLoop(window); } diff --git a/include/Mw/StringDefs.h b/include/Mw/StringDefs.h index af1d7ba..e2aee5a 100644 --- a/include/Mw/StringDefs.h +++ b/include/Mw/StringDefs.h @@ -17,6 +17,7 @@ #define MwNforeground "Sforeground" #define MwNpixmap "Vpixmap" +#define MwNiconPixmap "ViconPixmap" #define MwNactivateHandler "Cactivate" #define MwNresizeHandler "Cresize" diff --git a/include/Mw/Window.h b/include/Mw/Window.h index e3db384..6e11144 100644 --- a/include/Mw/Window.h +++ b/include/Mw/Window.h @@ -18,13 +18,6 @@ extern "C" { */ MWDECL MwClass MwWindowClass; -/*! - * %brief Sets a window icon - * %param handle Widget - * %param pixmap Pixmap - */ -MWDECL void MwWindowSetIcon(MwWidget handle, MwLLPixmap pixmap); - #ifdef __cplusplus } #endif diff --git a/src/core.c b/src/core.c index 3820295..a198715 100644 --- a/src/core.c +++ b/src/core.c @@ -186,7 +186,11 @@ void MwSetText(MwWidget handle, const char* key, const char* value) { } void MwSetVoid(MwWidget handle, const char* key, void* value) { - shput(handle->data, key, value); + if(strcmp(key, MwNiconPixmap) == 0) { + MwLLSetIcon(handle->lowlevel, value); + } else { + shput(handle->data, key, value); + } } int MwGetInteger(MwWidget handle, const char* key) { diff --git a/src/x11.c b/src/x11.c index 227cc4a..7b80ea4 100644 --- a/src/x11.c +++ b/src/x11.c @@ -290,7 +290,7 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) { unsigned long* icon = malloc((2 + pixmap->width * pixmap->height) * sizeof(*icon)); int i; - Atom atom = XInternAtom(lowlevel->display, "_NET_WM_ICON", False); + Atom atom = XInternAtom(handle->display, "_NET_WM_ICON", False); icon[0] = pixmap->width; icon[1] = pixmap->height; @@ -299,7 +299,7 @@ void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) { icon[2 + i] = *(unsigned long*)(&pixmap->image->data[i * 4]); } - XChangeProperty(lowlevel->display, lowlevel->window, atom, 6, 32, PropModeReplace, (unsigned char*)icon, 2 + pixmap->width * pixmap->height); + XChangeProperty(handle->display, handle->window, atom, 6, 32, PropModeReplace, (unsigned char*)icon, 2 + pixmap->width * pixmap->height); free(icon); }