diff --git a/examples/glclock.c b/examples/glclock.c index c36d9a9..182743f 100644 --- a/examples/glclock.c +++ b/examples/glclock.c @@ -18,9 +18,9 @@ void tick(MwWidget handle, void* user, void* call) { time_t t = time(NULL); int i; double rad; - int render = 0; - int w = MwGetInteger(opengl, MwNwidth); - int h = MwGetInteger(opengl, MwNheight); + int render = 0; + int w = MwGetInteger(opengl, MwNwidth); + int h = MwGetInteger(opengl, MwNheight); if(last != t) { char* wday[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; char* mon[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; @@ -73,25 +73,25 @@ void tick(MwWidget handle, void* user, void* call) { glVertex2f(cos(rad) * 0.5, sin(rad) * 0.5); glEnd(); - if(render && w > 0 && h > 0){ + if(render && w > 0 && h > 0) { unsigned char* buffer = malloc(w * h * 4); - MwLLPixmap px; - int j; + MwLLPixmap px; + int j; glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - for(i = 0; i < h / 2; i++){ - for(j = 0; j < w * 4; j++){ + for(i = 0; i < h / 2; i++) { + for(j = 0; j < w * 4; j++) { unsigned char b = buffer[i * w * 4 + j]; - buffer[i * w * 4 + j] = buffer[(h - i - 1) * w * 4 + j]; + buffer[i * w * 4 + j] = buffer[(h - i - 1) * w * 4 + j]; buffer[(h - i - 1) * w * 4 + j] = b; } } px = MwLoadRaw(window, buffer, w, h); MwVaApply(window, - MwNiconPixmap, px, - NULL); + MwNiconPixmap, px, + NULL); MwLLDestroyPixmap(px); free(buffer); diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index 36be614..0b8252d 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -115,6 +115,8 @@ MWDECL void MwLLMakeBorderless(MwLL handle, int toggle); MWDECL long MwLLGetTick(void); +MWDECL void MwLLSetBackground(MwLL handle, MwLLColor color); + #ifdef __cplusplus } #endif diff --git a/src/backend/gdi.c b/src/backend/gdi.c index e18f8b5..016da63 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -276,6 +276,11 @@ void MwLLFreeColor(MwLLColor color) { free(color); } +void MwLLSetBackground(MwLL handle, MwLLColor color) { + (void)handle; + (void)color; +} + void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) { RECT rc; diff --git a/src/backend/x11.c b/src/backend/x11.c index fce0a2a..55a3e3a 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -174,6 +174,10 @@ void MwLLFreeColor(MwLLColor color) { free(color); } +void MwLLSetBackground(MwLL handle, MwLLColor color) { + XSetWindowBackground(handle->display, handle->window, color->pixel); +} + int MwLLPending(MwLL handle) { XEvent ev; if(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) { diff --git a/src/core.c b/src/core.c index 75dd9a3..024d2d0 100644 --- a/src/core.c +++ b/src/core.c @@ -275,6 +275,11 @@ void MwSetText(MwWidget handle, const char* key, const char* value) { shput(handle->text, key, v); } if(handle->prop_event) MwDispatch3(handle, prop_change, key); + if(strcmp(key, MwNbackground) == 0) { + MwLLColor c = MwParseColor(handle, value); + MwLLSetBackground(handle->lowlevel, c); + MwLLFreeColor(c); + } if(strcmp(key, MwNbackground) == 0 || strcmp(key, MwNforeground) == 0) { MwForceRender(handle); }