]> Dogcows Code - chaz/openbox/commitdiff
add application opacity configuration
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Mon, 13 Aug 2012 18:29:17 +0000 (12:29 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Mon, 13 Aug 2012 18:29:17 +0000 (12:29 -0600)
data/rc.xml
data/rc.xsd
openbox/client.c
openbox/client.h
openbox/config.c
openbox/config.h
openbox/session.c
openbox/session.h

index 2607ecee9d2d140ece401f2ceed37f44d8802446..70ad9bf9c39bdc72fc83caa0d1c2f2726e2995f8 100644 (file)
 
     <maximized>true</maximized>
     # 'Horizontal', 'Vertical' or boolean (yes/no)
+
+    <opacity>255</opacity>
+    # make the window semi-transparent
+    # value between 0 and 255, inclusive; 0 invisible, 255 fully opaque
   </application>
 
   # end of the example
index 180e2154370ba2bd877141c9c9feb6f0542b50b0..4585f7cc461fcbf36fc9f8fdd7c6578581fb8d86 100644 (file)
             <xsd:element minOccurs="0" name="skip_taskbar" type="ob:bool"/>
             <xsd:element minOccurs="0" name="fullscreen" type="ob:bool"/>
             <xsd:element minOccurs="0" name="maximized" type="ob:maximization"/>
+            <xsd:element minOccurs="0" name="opacity" type="xsd:unsignedByte"/>
         </xsd:all>
         <!-- at least one of these must be present -->
         <xsd:attribute name="role" type="xsd:string"/>
index f3b4bdac905aac72d2b163283258850b46d629de..46162c319791a118aab0b2c8bcf1f057d3480152 100644 (file)
@@ -959,6 +959,9 @@ static ObAppSettings *client_get_settings_state(ObClient *self)
             self->desktop = settings->desktop - 1;
     }
 
+    if (settings->opacity != -1)
+       self->opacity = settings->opacity;
+
     if (settings->layer == -1) {
         self->below = TRUE;
         self->above = FALSE;
@@ -1017,6 +1020,8 @@ static void client_restore_session_state(ObClient *self)
     self->max_horz = self->session->max_horz;
     self->max_vert = self->session->max_vert;
     self->undecorated = self->session->undecorated;
+
+    self->opacity = self->session->opacity;
 }
 
 static gboolean client_restore_session_stacking(ObClient *self)
@@ -2787,6 +2792,7 @@ static void client_apply_startup_state(ObClient *self,
     gboolean demands_attention = self->demands_attention;
     gboolean max_horz = self->max_horz;
     gboolean max_vert = self->max_vert;
+    guint8   opacity = self->opacity;
     Rect oldarea;
     gint l;
 
@@ -2836,6 +2842,9 @@ static void client_apply_startup_state(ObClient *self,
     /* make sure client_setup_decor_and_functions() is called at least once */
     client_setup_decor_and_functions(self, FALSE);
 
+    /* make the client semi-transparent */
+    client_set_opacity(self, opacity);
+
     /* if the window hasn't been configured yet, then do so now, in fact the
        x,y,w,h may _not_ be the same as the area rect, which can end up
        meaning that the client isn't properly moved/resized by the fullscreen
@@ -3724,6 +3733,12 @@ void client_set_desktop(ObClient *self, guint target,
     focus_cycle_addremove(NULL, TRUE);
 }
 
+void client_set_opacity(ObClient *self, guint8 opacity)
+{
+    OBT_PROP_SET32(self->window, NET_WM_WINDOW_OPACITY, CARDINAL, 
+           opacity * 16777216);
+}
+
 gboolean client_is_direct_child(ObClient *parent, ObClient *child)
 {
     while (child != parent && (child = client_direct_parent(child)));
index d5b344ff5dfce01f5311553220b920d604013dbb..99fdfd053fc3a99811bc3a16c23c38a32658b9de 100644 (file)
@@ -264,6 +264,8 @@ struct _ObClient
     gboolean max_vert;
     /*! The window is maximized to fill the screen horizontally */
     gboolean max_horz;
+    /*! The window is semi-transparent */
+    guint8 opacity;
     /*! The window should not be displayed by pagers */
     gboolean skip_pager;
     /*! The window should not be displayed by taskbars */
@@ -539,6 +541,9 @@ void client_kill(ObClient *self);
 void client_set_desktop(ObClient *self, guint target, gboolean donthide,
                         gboolean dontraise);
 
+/*! Adjust the client opacity */
+void client_set_opacity(ObClient *self, guint8 opacity);
+
 /*! Show the client if it should be shown. Returns if the window is shown. */
 gboolean client_show(ObClient *self);
 
index 460a3f85f5a8d557568e144b97e8dae9557e893b..f0f6c7b3de73d7fa25f938aff22a3eeaff55dcb9 100644 (file)
@@ -124,6 +124,7 @@ ObAppSettings* config_create_app_settings(void)
     settings->fullscreen = -1;
     settings->max_horz = -1;
     settings->max_vert = -1;
+    settings->opacity = -1;
     return settings;
 }
 
@@ -149,6 +150,7 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
     copy_if(fullscreen, -1);
     copy_if(max_horz, -1);
     copy_if(max_vert, -1);
+    copy_if(opacity, -1);
 
     if (src->pos_given) {
         dst->pos_given = TRUE;
@@ -375,6 +377,10 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
                     g_free(s);
                 }
 
+            if ((n = obt_xml_find_node(app->children, "opacity")))
+                if (!obt_xml_node_contains(n, "default"))
+                    settings->opacity = obt_xml_node_int(n);
+
             config_per_app_settings = g_slist_append(config_per_app_settings,
                                                      (gpointer) settings);
             g_free(name);
index 500c7b467f8c23b04db2fb8935bdaf42c429c7f0..beb54be4e6393102c23e521a9aeb12774efa5c75 100644 (file)
@@ -57,8 +57,9 @@ struct _ObAppSettings
     gint max_horz;
     gint max_vert;
     gint fullscreen;
-
     gint layer;
+
+    guint8 opacity;
 };
 
 /*! Should new windows be focused */
index d6c6f76704f3c73923ba00b354821627b92041d0..1a81b90dbe81ad3546c79f987a379a167866db75 100644 (file)
@@ -583,6 +583,7 @@ static gboolean session_save_to_file(const ObSMSaveData *savedata)
             fprintf(f, "\t<y>%d</y>\n", prey);
             fprintf(f, "\t<width>%d</width>\n", prew);
             fprintf(f, "\t<height>%d</height>\n", preh);
+            fprintf(f, "\t<opacity>%d</opacity>\n", c->opacity);
             if (c->shaded)
                 fprintf(f, "\t<shaded />\n");
             if (c->iconic)
@@ -763,6 +764,9 @@ static void session_load_file(const gchar *path)
         if (!(n = obt_xml_find_node(node->children, "height")))
             goto session_load_bail;
         state->h = obt_xml_node_int(n);
+        if (!(n = obt_xml_find_node(node->children, "opacity")))
+            goto session_load_bail;
+        state->opacity = obt_xml_node_int(n);
 
         state->shaded =
             obt_xml_find_node(node->children, "shaded") != NULL;
index f37e2111710913002d20a10c9b36c06c91e46b61..8cfcb8e71b3c68458d979811145b3daae50dc8c9 100644 (file)
@@ -34,6 +34,7 @@ struct _ObSessionState {
     gboolean shaded, iconic, skip_pager, skip_taskbar, fullscreen;
     gboolean above, below, max_horz, max_vert, undecorated;
     gboolean focused;
+    guint8 opacity;
 
     gboolean matched;
 };
This page took 0.042609 seconds and 4 git commands to generate.