From: Charles McGarvey Date: Mon, 13 Aug 2012 18:29:17 +0000 (-0600) Subject: add application opacity configuration X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=32c93f09f03bd2d7c7bf3408febbe9fa7f8dd1cc;p=chaz%2Fopenbox add application opacity configuration --- diff --git a/data/rc.xml b/data/rc.xml index 2607ecee..70ad9bf9 100644 --- a/data/rc.xml +++ b/data/rc.xml @@ -723,6 +723,10 @@ true # 'Horizontal', 'Vertical' or boolean (yes/no) + + 255 + # make the window semi-transparent + # value between 0 and 255, inclusive; 0 invisible, 255 fully opaque # end of the example diff --git a/data/rc.xsd b/data/rc.xsd index 180e2154..4585f7cc 100644 --- a/data/rc.xsd +++ b/data/rc.xsd @@ -249,6 +249,7 @@ + diff --git a/openbox/client.c b/openbox/client.c index f3b4bdac..46162c31 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -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))); diff --git a/openbox/client.h b/openbox/client.h index d5b344ff..99fdfd05 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -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); diff --git a/openbox/config.c b/openbox/config.c index 460a3f85..f0f6c7b3 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -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); diff --git a/openbox/config.h b/openbox/config.h index 500c7b46..beb54be4 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -57,8 +57,9 @@ struct _ObAppSettings gint max_horz; gint max_vert; gint fullscreen; - gint layer; + + guint8 opacity; }; /*! Should new windows be focused */ diff --git a/openbox/session.c b/openbox/session.c index d6c6f767..1a81b90d 100644 --- a/openbox/session.c +++ b/openbox/session.c @@ -583,6 +583,7 @@ static gboolean session_save_to_file(const ObSMSaveData *savedata) fprintf(f, "\t%d\n", prey); fprintf(f, "\t%d\n", prew); fprintf(f, "\t%d\n", preh); + fprintf(f, "\t%d\n", c->opacity); if (c->shaded) fprintf(f, "\t\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; diff --git a/openbox/session.h b/openbox/session.h index f37e2111..8cfcb8e7 100644 --- a/openbox/session.h +++ b/openbox/session.h @@ -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; };