git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@84 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-30 22:23:54 +00:00
parent 13164f0ed5
commit a5200bdb3f
5 changed files with 12 additions and 12 deletions

View File

@@ -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);
}

View File

@@ -17,6 +17,7 @@
#define MwNforeground "Sforeground"
#define MwNpixmap "Vpixmap"
#define MwNiconPixmap "ViconPixmap"
#define MwNactivateHandler "Cactivate"
#define MwNresizeHandler "Cresize"

View File

@@ -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

View File

@@ -186,7 +186,11 @@ void MwSetText(MwWidget handle, const char* key, const char* value) {
}
void MwSetVoid(MwWidget handle, const char* key, void* value) {
if(strcmp(key, MwNiconPixmap) == 0) {
MwLLSetIcon(handle->lowlevel, value);
} else {
shput(handle->data, key, value);
}
}
int MwGetInteger(MwWidget handle, const char* key) {

View File

@@ -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);
}