mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-14 19:39:47 +00:00
Improve handling of ARGB visuals a bit.
This commit is contained in:
parent
bc59f90c3c
commit
62f1e47f4a
@ -675,11 +675,22 @@
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>own_window_argb</option>
|
||||
<option>own_window_argb_visual</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>Boolean, use ARGB visual? ARGB can be used for real transparency,
|
||||
note that a composite manager is required for real transparency.
|
||||
<listitem>Boolean, use ARGB visual? ARGB can be used for real
|
||||
transparency, note that a composite manager is required for real
|
||||
transparency. This option will not work as desired (in most cases)
|
||||
in conjunction with 'own_window_type override'.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>own_window_argb_value</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>When ARGB visuals are enabled, this use this to modify the alpha value used. Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity. Note that if own_window_transparent is enabled, this value has no effect.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -688,8 +699,8 @@
|
||||
<option>own_window_transparent</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>Boolean, set transparency? If argb visual is configured
|
||||
true transparency is used, else pseudo transparency is used.
|
||||
<listitem>Boolean, set transparency? If ARGB visual is enabled, sets
|
||||
background opacity to 0%.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
17
src/conky.c
17
src/conky.c
@ -2394,7 +2394,7 @@ void evaluate(const char *text, char *p, int p_max_size)
|
||||
tmp_info = malloc(sizeof(struct information));
|
||||
memcpy(tmp_info, &info, sizeof(struct information));
|
||||
parse_conky_vars(&subroot, text, p, p_max_size, tmp_info);
|
||||
DBGP("evaluated '%s' to '%s'", text, p);
|
||||
DBGP2("evaluated '%s' to '%s'", text, p);
|
||||
|
||||
free_text_objects(&subroot, 1);
|
||||
free(tmp_info);
|
||||
@ -2705,7 +2705,7 @@ static inline void set_foreground_color(long c)
|
||||
if (output_methods & TO_X) {
|
||||
#ifdef USE_ARGB
|
||||
if (have_argb_visual) {
|
||||
current_color = c | (0xff << 24);
|
||||
current_color = c | (own_window_argb_value << 24);
|
||||
} else {
|
||||
#endif /* USE_ARGB */
|
||||
current_color = c;
|
||||
@ -3575,7 +3575,7 @@ static void main_loop(void)
|
||||
draw_stuff(); /* redraw everything in our newly sized window */
|
||||
XResizeWindow(display, window.window, window.width,
|
||||
window.height); /* resize window */
|
||||
set_transparent_background(window.window);
|
||||
set_transparent_background(window.window, own_window_argb_value);
|
||||
#ifdef HAVE_XDBE
|
||||
/* swap buffers */
|
||||
xdbe_swap_buffers();
|
||||
@ -3677,7 +3677,7 @@ static void main_loop(void)
|
||||
case ReparentNotify:
|
||||
/* make background transparent */
|
||||
if (own_window) {
|
||||
set_transparent_background(window.window);
|
||||
set_transparent_background(window.window, own_window_argb_value);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4256,6 +4256,7 @@ static void set_default_configurations(void)
|
||||
sprintf(window.title, PACKAGE_NAME" (%s)", info.uname_s.nodename);
|
||||
#ifdef USE_ARGB
|
||||
use_argb_visual = 0;
|
||||
own_window_argb_value = 255;
|
||||
#endif
|
||||
#endif
|
||||
stippled_borders = 0;
|
||||
@ -4392,7 +4393,7 @@ static void X11_create_window(void)
|
||||
XMoveWindow(display, window.window, window.x, window.y);
|
||||
}
|
||||
if (own_window) {
|
||||
set_transparent_background(window.window);
|
||||
set_transparent_background(window.window, own_window_argb_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -5033,6 +5034,12 @@ char load_config_file(const char *f)
|
||||
CONF("own_window_argb_visual") {
|
||||
use_argb_visual = string_to_bool(value);
|
||||
}
|
||||
CONF("own_window_argb_value") {
|
||||
own_window_argb_value = strtol(value, 0, 0);
|
||||
if (own_window_argb_value > 255 || own_window_argb_value < 0) {
|
||||
CONF_ERR2("own_window_argb_value must be <= 255 and >= 0");
|
||||
}
|
||||
}
|
||||
#endif /* USE_ARGB */
|
||||
#endif
|
||||
CONF("stippled_borders") {
|
||||
|
@ -1196,9 +1196,9 @@ int extract_variable_text_internal(struct text_object *retval, const char *const
|
||||
s = orig_p = p;
|
||||
|
||||
if (strcmp(p, const_p)) {
|
||||
DBGP("replaced all templates in text: input is\n'%s'\noutput is\n'%s'", const_p, p);
|
||||
DBGP2("replaced all templates in text: input is\n'%s'\noutput is\n'%s'", const_p, p);
|
||||
} else {
|
||||
DBGP("no templates to replace");
|
||||
DBGP2("no templates to replace");
|
||||
}
|
||||
|
||||
memset(retval, 0, sizeof(struct text_object));
|
||||
|
@ -53,6 +53,7 @@ int use_xdbe;
|
||||
|
||||
#ifdef USE_ARGB
|
||||
int use_argb_visual;
|
||||
int own_window_argb_value;
|
||||
int have_argb_visual;
|
||||
#endif /* USE_ARGB */
|
||||
|
||||
@ -178,9 +179,10 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop)
|
||||
|
||||
/* if no argb visual is configured sets background to ParentRelative for the Window and all parents,
|
||||
else real transparency is used */
|
||||
void set_transparent_background(Window win)
|
||||
void set_transparent_background(Window win, int alpha)
|
||||
{
|
||||
static int colour_set = -1;
|
||||
(void)alpha; /* disable warnings when unused */
|
||||
|
||||
#ifdef USE_ARGB
|
||||
if (have_argb_visual) {
|
||||
@ -189,7 +191,7 @@ void set_transparent_background(Window win)
|
||||
XSetWindowBackground(display, win, 0x00);
|
||||
} else if (colour_set != background_colour) {
|
||||
XSetWindowBackground(display, win,
|
||||
background_colour | (0xff << 24));
|
||||
background_colour | (alpha << 24));
|
||||
colour_set = background_colour;
|
||||
}
|
||||
} else {
|
||||
@ -235,10 +237,12 @@ static int get_argb_visual(Visual** visual, int *depth) {
|
||||
visual_list[i].blue_mask == 0x0000ff)) {
|
||||
*visual = visual_list[i].visual;
|
||||
*depth = visual_list[i].depth;
|
||||
DBGP("Found ARGB Visual");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// no argb visual available
|
||||
DBGP("No ARGB Visual found");
|
||||
return 0;
|
||||
}
|
||||
#endif /* USE_ARGB */
|
||||
|
@ -80,6 +80,8 @@ extern int use_xft;
|
||||
extern int use_argb_visual;
|
||||
/* 1 if use_argb_visual=1 and argb visual was found, otherwise 0 */
|
||||
extern int have_argb_visual;
|
||||
/* range of 0-255 for alpha */
|
||||
extern int own_window_argb_value;
|
||||
#endif
|
||||
|
||||
extern Display *display;
|
||||
@ -97,7 +99,7 @@ void init_window(int use_own_window, int width, int height, int set_trans,
|
||||
int back_colour, char **argv, int argc);
|
||||
void destroy_window(void);
|
||||
void create_gc(void);
|
||||
void set_transparent_background(Window win);
|
||||
void set_transparent_background(Window win, int alpha);
|
||||
void get_x11_desktop_info(Display *display, Atom atom);
|
||||
void set_struts(int);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user