1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

own_window additions, such as background colour and transparency switch

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@183 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-08-25 09:24:26 +00:00
parent 7bdb0501dc
commit 72ea302dfb
6 changed files with 67 additions and 22 deletions

View File

@ -3,7 +3,9 @@
2005-08-24
* More configure and makefile updates
* Added scale arg for net graphs
* Fixed bug in own_window stuff
* Fixed bug in own_window stuff--amazing fake transparency now works
properly
* added own_window_colour, own_window_transparent
2005-08-23
* Added maximum_width

10
README
View File

@ -245,6 +245,16 @@ CONFIGURATION SETTINGS
Boolean, create own window to draw?
own_window_transparent
Boolean, set pseudo-transparency?
own_window_colour colour
If own_window_transparent no, set a specified background colour
(defaults to black). Takes either a hex value (#ffffff) or a
valid RGB name (see /usr/lib/X11/rgb.txt)
pad_percents
Pad percentages to this many decimals (0 = no padding)

View File

@ -213,6 +213,22 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>own_window_transparent</option></command></term>
<listitem>
Boolean, set pseudo-transparency?
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>own_window_colour</option></command>
<option>colour</option>
</term>
<listitem>
If own_window_transparent no, set a specified background colour (defaults to black). Takes either a hex value (#ffffff) or a valid RGB name (see /usr/lib/X11/rgb.txt)
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>pad_percents</option></command></term>
<listitem>

View File

@ -232,6 +232,9 @@ static long default_fg_color, default_bg_color, default_out_color;
/* create own window or draw stuff to root? */
static int own_window = 0;
static int set_transparent = 0;
static int background_colour = 0;
#ifdef OWN_WINDOW
/* fixed size/pos is set if wm/user changes them */
@ -3425,7 +3428,6 @@ static void main_loop()
need_to_update = 0;
update_text_area();
#ifdef OWN_WINDOW
if (own_window) {
/* resize window if it isn't right size */
@ -3444,6 +3446,7 @@ static void main_loop()
window.window,
window.width,
window.height);
set_transparent_background(window.window);
}
/* move window if it isn't in right position */
@ -3475,7 +3478,6 @@ static void main_loop()
while (XPending(display)) {
XEvent ev;
XNextEvent(display, &ev);
switch (ev.type) {
case Expose:
{
@ -3492,9 +3494,10 @@ static void main_loop()
#ifdef OWN_WINDOW
case ReparentNotify:
/* set background to ParentRelative for all parents */
if (own_window)
if (own_window) {
set_transparent_background(window.
window);
}
break;
case ConfigureNotify:
@ -4094,6 +4097,12 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, a) == 0)
use_xdbe = 0;
#endif
}
CONF("own_window_transparent") {
set_transparent = string_to_bool(value);
}
CONF("own_window_colour") {
background_colour = get_x11_color(value);
}
#endif
CONF("stippled_borders") {
if (value)
@ -4398,13 +4407,13 @@ int main(int argc, char **argv)
(own_window,
text_width + border_margin * 2 + 1,
text_height + border_margin * 2 + 1,
on_bottom, fixed_pos);
on_bottom, fixed_pos, set_transparent, background_colour);
#else
init_window
(own_window,
text_width + border_margin * 2 + 1,
text_height + border_margin * 2 + 1,
on_bottom);
on_bottom, set_transparent, background_colour);
#endif

View File

@ -224,9 +224,9 @@ extern struct conky_window window;
void init_X11();
#if defined OWN_WINDOW
void init_window(int use_own_window, int width, int height, int on_bottom, int fixed_pos);
void init_window(int use_own_window, int width, int height, int on_bottom, int fixed_pos, int set_trans, int back_colour);
#else
void init_window(int use_own_window, int width, int height, int on_bottom);
void init_window(int use_own_window, int width, int height, int on_bottom, int set_trans, int back_colour);
#endif
void create_gc();
void set_transparent_background(Window win);

View File

@ -27,6 +27,8 @@ Display *display;
int display_width;
int display_height;
int screen;
static int set_transparent;
static int background_colour;
/* workarea from _NET_WORKAREA, this is where window / text is aligned */
int workarea[4];
@ -145,32 +147,38 @@ static Window find_window_to_draw()
/* sets background to ParentRelative for the Window and all parents */
void set_transparent_background(Window win)
{
Window parent = win;
unsigned int i;
for (i = 0; i < 16 && parent != RootWindow(display, screen); i++) {
Window r, *children;
unsigned int n;
XSetWindowBackgroundPixmap(display, parent,
ParentRelative);
XQueryTree(display, parent, &r, &parent, &children, &n);
XFree(children);
if (set_transparent) {
Window parent = win;
unsigned int i;
for (i = 0; i < 16 && parent != RootWindow(display, screen); i++) {
Window r, *children;
unsigned int n;
XSetWindowBackgroundPixmap(display, parent, ParentRelative);
XQueryTree(display, parent, &r, &parent, &children, &n);
XFree(children);
}
} else {
XSetWindowBackground(display, win, background_colour);
}
XClearWindow(display, win);
}
#if defined OWN_WINDOW
void init_window(int own_window, int w, int h, int l, int fixed_pos)
void init_window(int own_window, int w, int h, int l, int fixed_pos, int set_trans, int back_colour)
#else
void init_window(int own_window, int w, int h, int l)
void init_window(int own_window, int w, int h, int l, int set_trans, int back_colour)
#endif
{
/* There seems to be some problems with setting transparent background (on
* fluxbox this time). It doesn't happen always and I don't know why it
* happens but I bet the bug is somewhere here. */
set_transparent = set_trans;
background_colour = back_colour;
#ifdef OWN_WINDOW
if (own_window) {
/* looks like root pixmap isn't needed for anything */
{
XSetWindowAttributes attrs;
@ -280,7 +288,7 @@ void init_window(int own_window, int w, int h, int l)
XFlush(display);
/* set_transparent_background() must be done after double buffer stuff? */
/*set_transparent_background(window.window); must be done after double buffer stuff? */
#ifdef OWN_WINDOW
if (own_window) {
set_transparent_background(window.window);