]> git.tdb.fi Git - geometrycompositor.git/commitdiff
Be more efficient when finding the window for a damage event
authorMikko Rasa <tdb@tdb.fi>
Sun, 13 Dec 2015 15:26:29 +0000 (17:26 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 13 Dec 2015 15:26:29 +0000 (17:26 +0200)
source/main.c

index adb582799936b0d75d504c7d183cd608e046dd81..afcd7646b9ecdd38df1d7a557d85f8a366a64d82 100644 (file)
@@ -308,6 +308,24 @@ CompositedWindow *find_window(CompositedScreen *screen, Window w)
        return NULL;
 }
 
+CompositedWindow *find_window_global(Compositor *compositor, Window w, CompositedScreen **screen)
+{
+       unsigned i, j;
+
+       for(i=0; i<compositor->nscreens; ++i)
+               for(j=0; j<compositor->screens[i].nwindows; ++j)
+                       if(compositor->screens[i].windows[j].window==w)
+                       {
+                               if(screen)
+                                       *screen = &compositor->screens[i];
+                               return &compositor->screens[i].windows[j];
+                       }
+
+       if(screen)
+               *screen = NULL;
+       return NULL;
+}
+
 void create_window_pixmap(Compositor *compositor, CompositedScreen *screen, CompositedWindow *window)
 {
        int attribs[5];
@@ -447,18 +465,6 @@ CompositedScreen *find_screen_by_root(Compositor *compositor, Window root)
        return NULL;
 }
 
-CompositedScreen *find_screen_by_window(Compositor *compositor, Window w)
-{
-       unsigned i, j;
-
-       for(i=0; i<compositor->nscreens; ++i)
-               for(j=0; j<compositor->screens[i].nwindows; ++j)
-                       if(compositor->screens[i].windows[j].window==w)
-                               return &compositor->screens[i];
-
-       return NULL;
-}
-
 void update_monitor_vertices(CompositedScreen *screen, CompositedMonitor *monitor)
 {
        unsigned t;
@@ -1000,12 +1006,8 @@ void process_damage_event(Compositor *compositor, XDamageNotifyEvent *event)
        CompositedScreen *screen;
        CompositedWindow *window;
 
-       screen = find_screen_by_window(compositor, event->drawable);
-       if(!screen)
-               return;
-
-       window = find_window(screen, event->drawable);
-       if(window->map_state==IsViewable)
+       window = find_window_global(compositor, event->drawable, &screen);
+       if(window && window->map_state==IsViewable)
                mark_dirty(compositor, screen);
 }