From 3dfe2990f8856c3d837cb66f9b7c173eb539bdfb Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 25 Jun 2010 17:19:45 -0400 Subject: [PATCH] Attempt to minimize redraws when not in "animation" mode. Note: this code is incorrect. Some events seem to be delayed. --- openbox/composite.c | 22 +++++++++++++++------- openbox/composite.h | 3 +++ openbox/event.c | 20 +++++++++++++++++++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/openbox/composite.c b/openbox/composite.c index 7efe0b3b..395fe55e 100644 --- a/openbox/composite.c +++ b/openbox/composite.c @@ -64,6 +64,7 @@ static GLXContext composite_ctx = NULL; static ObCompositeFBConfig pixmap_config[MAX_DEPTH + 1]; /* depth is index */ static guint composite_idle_source = 0; static gboolean need_redraw = FALSE; +static gboolean animating = FALSE; static Window composite_support_win = None; #ifdef DEBUG static gboolean composite_started = FALSE; @@ -151,6 +152,11 @@ static void get_best_fbcon(GLXFBConfig *in, int count, int depth, out->tf = rgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT; } +void composite_dirty(void) +{ + need_redraw = 1; +} + static gboolean composite_annex(void) { gchar *astr; @@ -427,11 +433,12 @@ static gboolean composite(gpointer data) struct timeval start, end, dif; GList *it; ObWindow *win; - ObClient *client = NULL; + ObClient *client; if (!composite_enabled()) return FALSE; -/* if (!need_redraw) return FALSE; */ + if (!animating && !need_redraw) + return animating; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -450,7 +457,7 @@ static gboolean composite(gpointer data) client = WINDOW_AS_CLIENT(win); if (!client->frame->visible) continue; - } + } else client = NULL; d = window_depth(win); @@ -638,8 +645,8 @@ static gboolean composite(gpointer data) } #endif - need_redraw = 0; - return TRUE; + need_redraw = FALSE; + return animating; } static void composite_window_redir(ObWindow *w) @@ -674,8 +681,8 @@ void composite_window_setup(ObWindow *w) #endif obt_display_ignore_errors(TRUE); - w->damage = XDamageCreate(obt_display, window_top(w), - XDamageReportNonEmpty); + w->damage = XDamageCreate(obt_display, window_redir(w), + XDamageReportRawRectangles); obt_display_ignore_errors(FALSE); glGenTextures(1, &w->texture); @@ -723,6 +730,7 @@ void composite_disable (void) {} void composite_window_setup (ObWindow *w) {} void composite_window_cleanup (ObWindow *w) {} void composite_window_invalid (ObWindow *w) {} +void composite_dirty (void) {} void composite_enable(void) { diff --git a/openbox/composite.h b/openbox/composite.h index 6e159828..b61a7b1a 100644 --- a/openbox/composite.h +++ b/openbox/composite.h @@ -38,6 +38,9 @@ gboolean composite_enable(void); /*! Turn composite off */ void composite_disable(void); +/*! Flag need for a redraw */ +void composite_dirty(void); + /*! Called when the screen changes its size */ void composite_resize(void); diff --git a/openbox/event.c b/openbox/event.c index 01653b0d..e4f99d66 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -231,6 +231,13 @@ static Window event_get_window(XEvent *e) { window = None; } else +#endif +#ifdef USE_COMPOSITING + if (e->type == obt_display_extension_damage_basep + XDamageNotify) + { + XDamageNotifyEvent *d = (XDamageNotifyEvent *)e; + window = d->drawable; + } else #endif window = e->xany.window; } @@ -1757,6 +1764,7 @@ static gboolean event_handle_window(ObWindow *wi, XEvent *e) switch (e->type) { case ConfigureNotify: + composite_dirty(); if (e->xconfigure.send_event) break; if (e->xconfigure.window == window_redir(wi)) { @@ -1805,6 +1813,7 @@ static gboolean event_handle_window(ObWindow *wi, XEvent *e) break; case MapNotify: + composite_dirty(); if (e->xmap.window == window_redir(wi)) { wi->mapped = TRUE; pixchange = TRUE; @@ -1812,24 +1821,33 @@ static gboolean event_handle_window(ObWindow *wi, XEvent *e) } break; case UnmapNotify: + composite_dirty(); if (e->xunmap.window == window_top(wi)) { wi->mapped = FALSE; used = TRUE; } break; default: -#ifdef SHAPE #ifdef USE_COMPOSITING +#ifdef SHAPE if (obt_display_extension_shape && e->type == obt_display_extension_shape_basep + ShapeNotify) { XShapeEvent *s = (XShapeEvent*)e; + composite_dirty(); if (s->window == window_redir(wi) && s->kind == ShapeBounding) { window_adjust_redir_shape(wi); used = FALSE; /* let other people get this event also */ } } #endif + if (obt_display_extension_damage && + e->type == obt_display_extension_damage_basep + XDamageNotify) + { + XDamageNotifyEvent *ev = (XDamageNotifyEvent *)e; + composite_dirty(); + used = TRUE; + } #endif } if (pixchange) -- 2.34.1