From: Mikko Rasa Date: Sun, 13 Dec 2015 15:26:29 +0000 (+0200) Subject: Be more efficient when finding the window for a damage event X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=15cc4fad4138cd30e1fe239cad5a2e6215c38b7b;p=geometrycompositor.git Be more efficient when finding the window for a damage event --- diff --git a/source/main.c b/source/main.c index adb5827..afcd764 100644 --- a/source/main.c +++ b/source/main.c @@ -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; inscreens; ++i) + for(j=0; jscreens[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; inscreens; ++i) - for(j=0; jscreens[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); }