From 28dd75b4330b15ab0c0f10406521a9c615e4bcdf Mon Sep 17 00:00:00 2001 From: NaiJi Date: Sun, 7 Jun 2026 01:59:52 -0400 Subject: [PATCH] Recolor on resize window --- main.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 1cd78e5..1ef2a96 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,17 @@ int main() { Display *display = XOpenDisplay(NULL); Window main_window = XDefaultRootWindow(display); - Window window = XCreateSimpleWindow(display, main_window, 0, 0, 250, 250, 1, 0, 0x00aade87); + int screen = DefaultScreen(display); + GC context = XDefaultGC(display, screen); + + XSetWindowAttributes attributes = {}; + attributes.background_pixel = 0xffffccaa; + attributes.event_mask = ResizeRedirectMask | ExposureMask; + Window window = XCreateWindow(display, main_window, + 0, 0, 1920, 1080, + 1, CopyFromParent, CopyFromParent, CopyFromParent, + CWBackPixel | CWEventMask, &attributes); + XMapWindow(display, window); XFlush(display); @@ -23,7 +33,7 @@ int main() XEvent general_event = {}; XNextEvent(display, &general_event); - printf("Type: %d", general_event.type); + printf("Type: %d \n", general_event.type); switch(general_event.type) { case ClientMessage: @@ -39,13 +49,15 @@ int main() { static unsigned long color = 0x00aade87; if(color == 0x00aade87) - color = 0x00bbde87; + color = 0xd000d087; else color = 0x00aade87; XSetWindowBackground(display, window, color); } break; } + + XClearWindow(display, window); } return 0;