From 7a299a9a28544526803004cf899dcd729953fe74 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 11 Dec 2015 19:26:09 +0200 Subject: [PATCH] Process ConfigureNotify events All of the basic functionality should be done now, and the compositor is in a usable state. Rendering of non-rectangular windows is still buggy. --- source/main.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/source/main.c b/source/main.c index 6886685..f7780a0 100644 --- a/source/main.c +++ b/source/main.c @@ -333,6 +333,43 @@ void remove_window(Compositor *compositor, CompositedScreen *screen, CompositedW screen->windows[i] = screen->windows[i+1]; } +CompositedWindow *reorder_window(CompositedScreen *screen, CompositedWindow *window, Window above) +{ + unsigned i, j; + CompositedWindow hold; + + i = window-screen->windows; + if(above) + { + for(j=0; jnwindows; ++j) + if(screen->windows[j].window==above) + break; + + if(j>=screen->nwindows || i==j+1) + return window; + + if(jwindows[i] = screen->windows[i+1]; + } + else + { + for(; i>j; --i) + screen->windows[i] = screen->windows[i-1]; + } + screen->windows[j] = hold; + + return &screen->windows[j]; +} + CompositedScreen *find_screen_by_root(Compositor *compositor, Window root) { unsigned i; @@ -578,6 +615,31 @@ void process_reparent_event(Compositor *compositor, XReparentEvent *event) mark_dirty(compositor, screen); } +void process_configure_event(Compositor *compositor, XConfigureEvent *event) +{ + CompositedScreen *screen = find_screen_by_root(compositor, event->event); + if(!screen) + return; + + CompositedWindow *window = find_window(screen, event->window); + if(!window) + return; + + window->x = event->x; + window->y = event->y; + if((unsigned)event->width!=window->width || (unsigned)event->height!=window->height || (unsigned)event->border_width!=window->border) + { + window->width = event->width; + window->height = event->height; + window->border = event->border_width; + create_window_pixmap(compositor, screen, window); + } + reorder_window(screen, window, event->above); + + if(window->map_state==IsViewable) + mark_dirty(compositor, screen); +} + void process_damage_event(Compositor *compositor, XDamageNotifyEvent *event) { CompositedScreen *screen = find_screen_by_window(compositor, event->drawable); @@ -617,6 +679,9 @@ int process_event(Compositor *compositor) case ReparentNotify: process_reparent_event(compositor, &event.xreparent); break; + case ConfigureNotify: + process_configure_event(compositor, &event.xconfigure); + break; default: if(event.type==compositor->damage_event+XDamageNotify) process_damage_event(compositor, (XDamageNotifyEvent *)&event); -- 2.45.2