mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-11 18:38:45 +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:
parent
7bdb0501dc
commit
72ea302dfb
@ -3,7 +3,9 @@
|
|||||||
2005-08-24
|
2005-08-24
|
||||||
* More configure and makefile updates
|
* More configure and makefile updates
|
||||||
* Added scale arg for net graphs
|
* 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
|
2005-08-23
|
||||||
* Added maximum_width
|
* Added maximum_width
|
||||||
|
10
README
10
README
@ -245,6 +245,16 @@ CONFIGURATION SETTINGS
|
|||||||
Boolean, create own window to draw?
|
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_percents
|
||||||
Pad percentages to this many decimals (0 = no padding)
|
Pad percentages to this many decimals (0 = no padding)
|
||||||
|
|
||||||
|
@ -213,6 +213,22 @@
|
|||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term><command><option>pad_percents</option></command></term>
|
<term><command><option>pad_percents</option></command></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
19
src/conky.c
19
src/conky.c
@ -232,6 +232,9 @@ static long default_fg_color, default_bg_color, default_out_color;
|
|||||||
|
|
||||||
/* create own window or draw stuff to root? */
|
/* create own window or draw stuff to root? */
|
||||||
static int own_window = 0;
|
static int own_window = 0;
|
||||||
|
static int set_transparent = 0;
|
||||||
|
static int background_colour = 0;
|
||||||
|
|
||||||
|
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
/* fixed size/pos is set if wm/user changes them */
|
/* fixed size/pos is set if wm/user changes them */
|
||||||
@ -3425,7 +3428,6 @@ static void main_loop()
|
|||||||
need_to_update = 0;
|
need_to_update = 0;
|
||||||
|
|
||||||
update_text_area();
|
update_text_area();
|
||||||
|
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
if (own_window) {
|
if (own_window) {
|
||||||
/* resize window if it isn't right size */
|
/* resize window if it isn't right size */
|
||||||
@ -3444,6 +3446,7 @@ static void main_loop()
|
|||||||
window.window,
|
window.window,
|
||||||
window.width,
|
window.width,
|
||||||
window.height);
|
window.height);
|
||||||
|
set_transparent_background(window.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move window if it isn't in right position */
|
/* move window if it isn't in right position */
|
||||||
@ -3475,7 +3478,6 @@ static void main_loop()
|
|||||||
while (XPending(display)) {
|
while (XPending(display)) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
XNextEvent(display, &ev);
|
XNextEvent(display, &ev);
|
||||||
|
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
{
|
{
|
||||||
@ -3492,9 +3494,10 @@ static void main_loop()
|
|||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
case ReparentNotify:
|
case ReparentNotify:
|
||||||
/* set background to ParentRelative for all parents */
|
/* set background to ParentRelative for all parents */
|
||||||
if (own_window)
|
if (own_window) {
|
||||||
set_transparent_background(window.
|
set_transparent_background(window.
|
||||||
window);
|
window);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
@ -4094,6 +4097,12 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, a) == 0)
|
|||||||
use_xdbe = 0;
|
use_xdbe = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
CONF("own_window_transparent") {
|
||||||
|
set_transparent = string_to_bool(value);
|
||||||
|
}
|
||||||
|
CONF("own_window_colour") {
|
||||||
|
background_colour = get_x11_color(value);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
CONF("stippled_borders") {
|
CONF("stippled_borders") {
|
||||||
if (value)
|
if (value)
|
||||||
@ -4398,13 +4407,13 @@ int main(int argc, char **argv)
|
|||||||
(own_window,
|
(own_window,
|
||||||
text_width + border_margin * 2 + 1,
|
text_width + border_margin * 2 + 1,
|
||||||
text_height + border_margin * 2 + 1,
|
text_height + border_margin * 2 + 1,
|
||||||
on_bottom, fixed_pos);
|
on_bottom, fixed_pos, set_transparent, background_colour);
|
||||||
#else
|
#else
|
||||||
init_window
|
init_window
|
||||||
(own_window,
|
(own_window,
|
||||||
text_width + border_margin * 2 + 1,
|
text_width + border_margin * 2 + 1,
|
||||||
text_height + border_margin * 2 + 1,
|
text_height + border_margin * 2 + 1,
|
||||||
on_bottom);
|
on_bottom, set_transparent, background_colour);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -224,9 +224,9 @@ extern struct conky_window window;
|
|||||||
|
|
||||||
void init_X11();
|
void init_X11();
|
||||||
#if defined OWN_WINDOW
|
#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
|
#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
|
#endif
|
||||||
void create_gc();
|
void create_gc();
|
||||||
void set_transparent_background(Window win);
|
void set_transparent_background(Window win);
|
||||||
|
36
src/x11.c
36
src/x11.c
@ -27,6 +27,8 @@ Display *display;
|
|||||||
int display_width;
|
int display_width;
|
||||||
int display_height;
|
int display_height;
|
||||||
int screen;
|
int screen;
|
||||||
|
static int set_transparent;
|
||||||
|
static int background_colour;
|
||||||
|
|
||||||
/* workarea from _NET_WORKAREA, this is where window / text is aligned */
|
/* workarea from _NET_WORKAREA, this is where window / text is aligned */
|
||||||
int workarea[4];
|
int workarea[4];
|
||||||
@ -145,32 +147,38 @@ static Window find_window_to_draw()
|
|||||||
/* sets background to ParentRelative for the Window and all parents */
|
/* sets background to ParentRelative for the Window and all parents */
|
||||||
void set_transparent_background(Window win)
|
void set_transparent_background(Window win)
|
||||||
{
|
{
|
||||||
Window parent = win;
|
if (set_transparent) {
|
||||||
unsigned int i;
|
Window parent = win;
|
||||||
for (i = 0; i < 16 && parent != RootWindow(display, screen); i++) {
|
unsigned int i;
|
||||||
Window r, *children;
|
for (i = 0; i < 16 && parent != RootWindow(display, screen); i++) {
|
||||||
unsigned int n;
|
Window r, *children;
|
||||||
|
unsigned int n;
|
||||||
XSetWindowBackgroundPixmap(display, parent,
|
|
||||||
ParentRelative);
|
XSetWindowBackgroundPixmap(display, parent, ParentRelative);
|
||||||
|
|
||||||
XQueryTree(display, parent, &r, &parent, &children, &n);
|
XQueryTree(display, parent, &r, &parent, &children, &n);
|
||||||
XFree(children);
|
XFree(children);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
XSetWindowBackground(display, win, background_colour);
|
||||||
}
|
}
|
||||||
XClearWindow(display, win);
|
XClearWindow(display, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined OWN_WINDOW
|
#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
|
#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
|
#endif
|
||||||
{
|
{
|
||||||
/* There seems to be some problems with setting transparent background (on
|
/* 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
|
* fluxbox this time). It doesn't happen always and I don't know why it
|
||||||
* happens but I bet the bug is somewhere here. */
|
* happens but I bet the bug is somewhere here. */
|
||||||
|
set_transparent = set_trans;
|
||||||
|
background_colour = back_colour;
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
if (own_window) {
|
if (own_window) {
|
||||||
|
|
||||||
/* looks like root pixmap isn't needed for anything */
|
/* looks like root pixmap isn't needed for anything */
|
||||||
{
|
{
|
||||||
XSetWindowAttributes attrs;
|
XSetWindowAttributes attrs;
|
||||||
@ -280,7 +288,7 @@ void init_window(int own_window, int w, int h, int l)
|
|||||||
|
|
||||||
XFlush(display);
|
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
|
#ifdef OWN_WINDOW
|
||||||
if (own_window) {
|
if (own_window) {
|
||||||
set_transparent_background(window.window);
|
set_transparent_background(window.window);
|
||||||
|
Loading…
Reference in New Issue
Block a user