1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-02-05 21:48:33 +00:00

Improve handling of ARGB visuals a bit.

Conflicts:

	src/conky.cc
This commit is contained in:
Brenden Matthews 2010-01-02 11:43:29 -08:00
parent 2951f5571c
commit 0f5f2a1afe
5 changed files with 77 additions and 53 deletions

View File

@ -675,11 +675,22 @@
<varlistentry> <varlistentry>
<term> <term>
<command> <command>
<option>own_window_argb</option> <option>own_window_argb_visual</option>
</command> </command>
</term> </term>
<listitem>Boolean, use ARGB visual? ARGB can be used for real transparency, <listitem>Boolean, use ARGB visual? ARGB can be used for real
note that a composite manager is required for real transparency. 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> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -688,8 +699,8 @@
<option>own_window_transparent</option> <option>own_window_transparent</option>
</command> </command>
</term> </term>
<listitem>Boolean, set transparency? If argb visual is configured <listitem>Boolean, set transparency? If ARGB visual is enabled, sets
true transparency is used, else pseudo transparency is used. background opacity to 0%.
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -168,105 +168,105 @@ static void print_version(void)
printf(PACKAGE_NAME" "VERSION" compiled "BUILD_DATE" for "BUILD_ARCH"\n"); printf(PACKAGE_NAME" "VERSION" compiled "BUILD_DATE" for "BUILD_ARCH"\n");
printf("\nCompiled in features:\n\n" printf("\nCompiled in features:\n\n"
"System config file: "SYSTEM_CONFIG_FILE"\n" "System config file: "SYSTEM_CONFIG_FILE"\n"
"Package library path: "PACKAGE_LIBDIR"\n\n" "Package library path: "PACKAGE_LIBDIR"\n\n"
#ifdef X11 #ifdef X11
" X11:\n" " X11:\n"
# ifdef HAVE_XDAMAGE # ifdef HAVE_XDAMAGE
" * Xdamage extension\n" " * Xdamage extension\n"
# endif /* HAVE_XDAMAGE */ # endif /* HAVE_XDAMAGE */
# ifdef HAVE_XDBE # ifdef HAVE_XDBE
" * XDBE (double buffer extension)\n" " * XDBE (double buffer extension)\n"
# endif /* HAVE_XDBE */ # endif /* HAVE_XDBE */
# ifdef XFT # ifdef XFT
" * Xft\n" " * Xft\n"
# endif /* XFT */ # endif /* XFT */
# ifdef USE_ARGB # ifdef USE_ARGB
" * ARGB visual\n" " * ARGB visual\n"
# endif /* USE_ARGB */ # endif /* USE_ARGB */
#endif /* X11 */ #endif /* X11 */
"\n Music detection:\n" "\n Music detection:\n"
#ifdef AUDACIOUS #ifdef AUDACIOUS
" * Audacious\n" " * Audacious\n"
#endif /* AUDACIOUS */ #endif /* AUDACIOUS */
#ifdef BMPX #ifdef BMPX
" * BMPx\n" " * BMPx\n"
#endif /* BMPX */ #endif /* BMPX */
#ifdef MPD #ifdef MPD
" * MPD\n" " * MPD\n"
#endif /* MPD */ #endif /* MPD */
#ifdef MOC #ifdef MOC
" * MOC\n" " * MOC\n"
#endif /* MOC */ #endif /* MOC */
#ifdef XMMS2 #ifdef XMMS2
" * XMMS2\n" " * XMMS2\n"
#endif /* XMMS2 */ #endif /* XMMS2 */
"\n General:\n" "\n General:\n"
#ifdef HAVE_OPENMP #ifdef HAVE_OPENMP
" * OpenMP\n" " * OpenMP\n"
#endif /* HAVE_OPENMP */ #endif /* HAVE_OPENMP */
#ifdef MATH #ifdef MATH
" * math\n" " * math\n"
#endif /* Math */ #endif /* Math */
#ifdef HDDTEMP #ifdef HDDTEMP
" * hddtemp\n" " * hddtemp\n"
#endif /* HDDTEMP */ #endif /* HDDTEMP */
#ifdef TCP_PORT_MONITOR #ifdef TCP_PORT_MONITOR
" * portmon\n" " * portmon\n"
#endif /* TCP_PORT_MONITOR */ #endif /* TCP_PORT_MONITOR */
#ifdef HAVE_CURL #ifdef HAVE_CURL
" * Curl\n" " * Curl\n"
#endif /* HAVE_CURL */ #endif /* HAVE_CURL */
#ifdef RSS #ifdef RSS
" * RSS\n" " * RSS\n"
#endif /* RSS */ #endif /* RSS */
#ifdef WEATHER #ifdef WEATHER
" * Weather (METAR)\n" " * Weather (METAR)\n"
#ifdef XOAP #ifdef XOAP
" * Weather (XOAP)\n" " * Weather (XOAP)\n"
#endif /* XOAP */ #endif /* XOAP */
#endif /* WEATHER */ #endif /* WEATHER */
#ifdef HAVE_IWLIB #ifdef HAVE_IWLIB
" * wireless\n" " * wireless\n"
#endif /* HAVE_IWLIB */ #endif /* HAVE_IWLIB */
#ifdef IBM #ifdef IBM
" * support for IBM/Lenovo notebooks\n" " * support for IBM/Lenovo notebooks\n"
#endif /* IBM */ #endif /* IBM */
#ifdef NVIDIA #ifdef NVIDIA
" * nvidia\n" " * nvidia\n"
#endif /* NVIDIA */ #endif /* NVIDIA */
#ifdef EVE #ifdef EVE
" * eve-online\n" " * eve-online\n"
#endif /* EVE */ #endif /* EVE */
#ifdef CONFIG_OUTPUT #ifdef CONFIG_OUTPUT
" * config-output\n" " * config-output\n"
#endif /* CONFIG_OUTPUT */ #endif /* CONFIG_OUTPUT */
#ifdef IMLIB2 #ifdef IMLIB2
" * Imlib2\n" " * Imlib2\n"
#endif /* IMLIB2 */ #endif /* IMLIB2 */
#ifdef MIXER_IS_ALSA #ifdef MIXER_IS_ALSA
" * ALSA mixer support\n" " * ALSA mixer support\n"
#endif /* MIXER_IS_ALSA */ #endif /* MIXER_IS_ALSA */
#ifdef APCUPSD #ifdef APCUPSD
" * apcupsd\n" " * apcupsd\n"
#endif /* APCUPSD */ #endif /* APCUPSD */
#ifdef IOSTATS #ifdef IOSTATS
" * iostats\n" " * iostats\n"
#endif /* IOSTATS */ #endif /* IOSTATS */
#ifdef NCURSES #ifdef NCURSES
" * ncurses\n" " * ncurses\n"
#endif /* NCURSES */ #endif /* NCURSES */
#ifdef HAVE_LUA #ifdef HAVE_LUA
" * Lua\n" " * Lua\n"
"\n Lua bindings:\n" "\n Lua bindings:\n"
#ifdef HAVE_LUA_CAIRO #ifdef HAVE_LUA_CAIRO
" * Cairo\n" " * Cairo\n"
#endif /* HAVE_LUA_CAIRO */ #endif /* HAVE_LUA_CAIRO */
#ifdef HAVE_LUA_IMLIB2 #ifdef HAVE_LUA_IMLIB2
" * Imlib2\n" " * Imlib2\n"
#endif /* IMLIB2 */ #endif /* IMLIB2 */
#endif /* HAVE_LUA */ #endif /* HAVE_LUA */
); );
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -440,10 +440,10 @@ static inline int calc_text_width(const char *s)
if (utf8_mode) { if (utf8_mode) {
XftTextExtentsUtf8(display, fonts[selected_font].xftfont, XftTextExtentsUtf8(display, fonts[selected_font].xftfont,
(const FcChar8 *) s, slen, &gi); (const FcChar8 *) s, slen, &gi);
} else { } else {
XftTextExtents8(display, fonts[selected_font].xftfont, XftTextExtents8(display, fonts[selected_font].xftfont,
(const FcChar8 *) s, slen, &gi); (const FcChar8 *) s, slen, &gi);
} }
return gi.xOff; return gi.xOff;
} else } else
@ -1093,7 +1093,7 @@ static inline void set_foreground_color(long c)
if (output_methods & TO_X) { if (output_methods & TO_X) {
#ifdef USE_ARGB #ifdef USE_ARGB
if (have_argb_visual) { if (have_argb_visual) {
current_color = c | (0xff << 24); current_color = c | (own_window_argb_value << 24);
} else { } else {
#endif /* USE_ARGB */ #endif /* USE_ARGB */
current_color = c; current_color = c;
@ -1963,7 +1963,7 @@ static void main_loop(void)
draw_stuff(); /* redraw everything in our newly sized window */ draw_stuff(); /* redraw everything in our newly sized window */
XResizeWindow(display, window.window, window.width, XResizeWindow(display, window.window, window.width,
window.height); /* resize window */ window.height); /* resize window */
set_transparent_background(window.window); set_transparent_background(window.window, own_window_argb_value);
#ifdef HAVE_XDBE #ifdef HAVE_XDBE
/* swap buffers */ /* swap buffers */
xdbe_swap_buffers(); xdbe_swap_buffers();
@ -2065,7 +2065,7 @@ static void main_loop(void)
case ReparentNotify: case ReparentNotify:
/* make background transparent */ /* make background transparent */
if (own_window) { if (own_window) {
set_transparent_background(window.window); set_transparent_background(window.window, own_window_argb_value);
} }
break; break;
@ -2652,6 +2652,7 @@ static void set_default_configurations(void)
sprintf(window.title, PACKAGE_NAME" (%s)", info.uname_s.nodename); sprintf(window.title, PACKAGE_NAME" (%s)", info.uname_s.nodename);
#ifdef USE_ARGB #ifdef USE_ARGB
use_argb_visual = 0; use_argb_visual = 0;
own_window_argb_value = 255;
#endif #endif
#endif #endif
stippled_borders = 0; stippled_borders = 0;
@ -2788,7 +2789,7 @@ static void X11_create_window(void)
XMoveWindow(display, window.window, window.x, window.y); XMoveWindow(display, window.window, window.x, window.y);
} }
if (own_window) { if (own_window) {
set_transparent_background(window.window); set_transparent_background(window.window, own_window_argb_value);
} }
#endif #endif
@ -3431,6 +3432,12 @@ char load_config_file(const char *f)
CONF("own_window_argb_visual") { CONF("own_window_argb_visual") {
use_argb_visual = string_to_bool(value); 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 /* USE_ARGB */
#endif #endif
CONF("stippled_borders") { CONF("stippled_borders") {

View File

@ -1664,9 +1664,9 @@ int extract_variable_text_internal(struct text_object *retval, const char *const
s = orig_p = p; s = orig_p = p;
if (strcmp(p, const_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 { } else {
DBGP("no templates to replace"); DBGP2("no templates to replace");
} }
memset(retval, 0, sizeof(struct text_object)); memset(retval, 0, sizeof(struct text_object));

View File

@ -53,6 +53,7 @@ int use_xdbe;
#ifdef USE_ARGB #ifdef USE_ARGB
int use_argb_visual; int use_argb_visual;
int own_window_argb_value;
int have_argb_visual; int have_argb_visual;
#endif /* USE_ARGB */ #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, /* if no argb visual is configured sets background to ParentRelative for the Window and all parents,
else real transparency is used */ else real transparency is used */
void set_transparent_background(Window win) void set_transparent_background(Window win, int alpha)
{ {
static int colour_set = -1; static int colour_set = -1;
(void)alpha; /* disable warnings when unused */
#ifdef USE_ARGB #ifdef USE_ARGB
if (have_argb_visual) { if (have_argb_visual) {
@ -189,7 +191,7 @@ void set_transparent_background(Window win)
XSetWindowBackground(display, win, 0x00); XSetWindowBackground(display, win, 0x00);
} else if (colour_set != background_colour) { } else if (colour_set != background_colour) {
XSetWindowBackground(display, win, XSetWindowBackground(display, win,
background_colour | (0xff << 24)); background_colour | (alpha << 24));
colour_set = background_colour; colour_set = background_colour;
} }
} else { } else {
@ -235,10 +237,12 @@ static int get_argb_visual(Visual** visual, int *depth) {
visual_list[i].blue_mask == 0x0000ff)) { visual_list[i].blue_mask == 0x0000ff)) {
*visual = visual_list[i].visual; *visual = visual_list[i].visual;
*depth = visual_list[i].depth; *depth = visual_list[i].depth;
DBGP("Found ARGB Visual");
return 1; return 1;
} }
} }
// no argb visual available // no argb visual available
DBGP("No ARGB Visual found");
return 0; return 0;
} }
#endif /* USE_ARGB */ #endif /* USE_ARGB */

View File

@ -80,6 +80,8 @@ extern int use_xft;
extern int use_argb_visual; extern int use_argb_visual;
/* 1 if use_argb_visual=1 and argb visual was found, otherwise 0 */ /* 1 if use_argb_visual=1 and argb visual was found, otherwise 0 */
extern int have_argb_visual; extern int have_argb_visual;
/* range of 0-255 for alpha */
extern int own_window_argb_value;
#endif #endif
extern Display *display; extern Display *display;
@ -101,7 +103,7 @@ void init_window(int use_own_window, int width, int height, int set_trans,
int back_colour, char **argv, int argc); int back_colour, char **argv, int argc);
void destroy_window(void); void destroy_window(void);
void create_gc(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 get_x11_desktop_info(Display *display, Atom atom);
void set_struts(int); void set_struts(int);