]> git.tdb.fi Git - geometrycompositor.git/commitdiff
Process ConfigureNotify events
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Dec 2015 17:26:09 +0000 (19:26 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Dec 2015 17:33:55 +0000 (19:33 +0200)
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

index 6886685605d828f59c05af77b61358d841e6f464..f7780a0e20a37955a69579bad3aae0666845a688 100644 (file)
@@ -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; j<screen->nwindows; ++j)
+                       if(screen->windows[j].window==above)
+                               break;
+
+               if(j>=screen->nwindows || i==j+1)
+                       return window;
+
+               if(j<i)
+                       ++j;
+       }
+       else
+               j = 0;
+
+       hold = *window;
+       if(i<j)
+       {
+               for(; i<j; ++i)
+                       screen->windows[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);