make the root background color a config option, and add name_window_pixmap() helper...
authorDana Jansens <danakj@orodu.net>
Sun, 27 Jun 2010 18:18:40 +0000 (14:18 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 27 Jun 2010 21:18:34 +0000 (17:18 -0400)
openbox/composite.c
openbox/config.c
openbox/config.h

index 202e64c..023bf51 100644 (file)
@@ -49,9 +49,6 @@ Atom   composite_cm_atom = None;
 
 #ifdef USE_COMPOSITING
 #define MAX_DEPTH 32
-#define ROOT_COLOR_R 0.4f
-#define ROOT_COLOR_G 0.6f
-#define ROOT_COLOR_B 0.8f
 
 typedef struct _ObCompositeFBConfig {
     GLXFBConfig fbc; /* the fbconfig */
@@ -159,6 +156,22 @@ static void get_best_fbcon(GLXFBConfig *in, int count, int depth,
     out->tf = rgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT;
 }
 
+static Pixmap name_window_pixmap(Window w)
+{
+    Pixmap p;
+    obt_display_ignore_errors(TRUE);
+    p = XCompositeNameWindowPixmap(obt_display, w);
+    obt_display_ignore_errors(FALSE);
+    if (obt_display_error_occured) {
+        ob_debug_type(OB_DEBUG_CM, "Error in XCompositeNameWindowPixmap for "
+                      "window 0x%x", w);
+        /* it can error but still return an ID, which will cause an
+           error to occur if you try to free it etc */
+        p = None;
+    }
+    return p;
+}
+
 static GLXPixmap create_glx_pixmap(Pixmap px, gint depth)
 {
     GLXPixmap gpx;
@@ -418,7 +431,8 @@ gboolean composite_enable(void)
         ob_debug_type(OB_DEBUG_CM, "Vsync control not available.");
     }
 
-    glClearColor(ROOT_COLOR_R, ROOT_COLOR_G, ROOT_COLOR_B, 0.0f);
+    glClearColor(config_comp_root_color_r, config_comp_root_color_g,
+                 config_comp_root_color_b, 0.0f);
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glXSwapBuffers(obt_display, composite_overlay);
     glMatrixMode(GL_PROJECTION);
@@ -497,10 +511,9 @@ void composite_startup(gboolean reconfig)
     }
 
     if (composite_enabled)
-        /* XXX this will be a config option sometime so it can be changed
-           on reconfigure */
-        glClearColor(ROOT_COLOR_R, ROOT_COLOR_G, ROOT_COLOR_B, 0.0f);
-
+        /* this is a config option so it can be changed on reconfigure */
+        glClearColor(config_comp_root_color_r, config_comp_root_color_g,
+                     config_comp_root_color_b, 0.0f);
 }
 
 void composite_shutdown(gboolean reconfig)
@@ -548,12 +561,10 @@ static gboolean composite(gpointer data)
     glClear(GL_DEPTH_BUFFER_BIT);
 
     /* draw the screen background */
-    if (!root_gpixmap) {
-        if (root_pixmap) {
-            const int depth = DefaultDepth(obt_display, ob_screen);
-            root_gpixmap = create_glx_pixmap(root_pixmap, depth);
-            root_bound = bind_glx_pixmap(root_gpixmap, root_texture);
-        }
+    if (root_pixmap && !root_gpixmap) {
+        const int depth = DefaultDepth(obt_display, ob_screen);
+        root_gpixmap = create_glx_pixmap(root_pixmap, depth);
+        root_bound = bind_glx_pixmap(root_gpixmap, root_texture);
     }
     if (root_bound) {
         const Rect *rw = screen_physical_area_all_monitors();
@@ -589,28 +600,11 @@ static gboolean composite(gpointer data)
             client = WINDOW_AS_CLIENT(win);
             if (!client->frame->visible)
                 continue;
-        } else client = NULL;
+        }
+        else client = NULL;
 
         if (win->pixmap == None) {
-            obt_display_ignore_errors(TRUE);
-            win->pixmap = XCompositeNameWindowPixmap(obt_display,
-                                                     window_redir(win));
-            obt_display_ignore_errors(FALSE);
-            if (obt_display_error_occured) {
-                ob_debug_type(OB_DEBUG_CM,
-                              "Error in XCompositeNameWindowPixmap for "
-                              "window 0x%x of 0x%x",
-                              window_redir(win), window_top(win));
-                /* it can error but still return an ID, which will cause an
-                   error to occur if you try to free it etc */
-                if (win->pixmap) {
-                    obt_display_ignore_errors(TRUE);
-                    XFreePixmap(obt_display, win->pixmap);
-                    obt_display_ignore_errors(FALSE);
-                    win->pixmap = None;
-                }
-            }
-            if (win->pixmap == None)
+            if (!(win->pixmap = name_window_pixmap(window_redir(win))))
                 continue;
         }
 
index b932b9a..c0be54c 100644 (file)
@@ -51,6 +51,9 @@ gboolean config_theme_keepborder;
 guint    config_theme_window_list_icon_size;
 
 gboolean config_comp;
+gfloat   config_comp_root_color_r;
+gfloat   config_comp_root_color_g;
+gfloat   config_comp_root_color_b;
 
 gchar   *config_title_layout;
 
@@ -1015,6 +1018,9 @@ void config_startup(ObtXmlInst *i)
     config_theme = NULL;
 
     config_comp = TRUE;
+    config_comp_root_color_r = 0.4f;
+    config_comp_root_color_g = 0.6f;
+    config_comp_root_color_b = 0.8f;
 
     config_animate_iconify = TRUE;
     config_title_layout = g_strdup("NLIMC");
index 7b16143..52e7d96 100644 (file)
@@ -138,6 +138,10 @@ extern gchar *config_theme;
 /*! Whether to act as a compositing manager or not */
 extern gboolean config_comp;
 
+extern gfloat   config_comp_root_color_r;
+extern gfloat   config_comp_root_color_g;
+extern gfloat   config_comp_root_color_b;
+
 /*! Show the one-pixel border after toggleDecor */
 extern gboolean config_theme_keepborder;
 /*! Titlebar button layout */