1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

added own_window_hints

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@543 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2006-03-06 23:35:41 +00:00
parent a72572328f
commit 1d6a4ddde9
7 changed files with 287 additions and 93 deletions

5
README
View File

@ -289,6 +289,11 @@ CONFIGURATION SETTINGS
valid RGB name (see /usr/lib/X11/rgb.txt) valid RGB name (see /usr/lib/X11/rgb.txt)
own_window_hints undecorated,below,above,sticky,skip_taskbar,skip_pager
If own_window is yes, you may use these window manager hints to
affect the way conky displays
out_to_console out_to_console
Print text to stdout. Print text to stdout.

View File

@ -250,6 +250,15 @@
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><command><option>own_window_hints</option></command>
<option>undecorated,below,above,sticky,skip_taskbar,skip_pager</option>
</term>
<listitem>
If own_window is yes, you may use these window manager hints to affect the way conky displays
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><command><option>out_to_console</option></command> <term><command><option>out_to_console</option></command>
</term> </term>

View File

@ -266,6 +266,10 @@ Boolean, set pseudo-transparency?
\fBown_window_colour\fR \fBcolour\fR \fBown_window_colour\fR \fBcolour\fR
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) 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)
.TP
\fBown_window_hints\fR \fBundecorated,below,above,sticky,skip_taskbar,skip_pager\fR
If own_window is yes, you may use these window manager hints to affect the way conky displays
.TP .TP
\fBout_to_console\fR \fBout_to_console\fR
Print text to stdout. Print text to stdout.

View File

@ -59,6 +59,9 @@ own_window_transparent yes
# If own_window_transparent is set to no, you can set the background colour here # If own_window_transparent is set to no, you can set the background colour here
own_window_colour hotpink own_window_colour hotpink
# If own_window is yes, these window manager hints may be used
#own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
# Use double buffering (reduces flicker, may not work for everyone) # Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes double_buffer yes
@ -179,7 +182,7 @@ $stippled_hr
${color #ddaa00}Port(s)${alignr}#Connections ${color #ddaa00}Port(s)${alignr}#Connections
$color ALL: ${alignr}$color ${tcp_portmon 1 65535 count} $color ALL: ${alignr}$color ${tcp_portmon 1 65535 count}
$color mpd: ${alignr}$color ${tcp_portmon 6600 6600 count} $color mpd: ${alignr}$color ${tcp_portmon 6600 6600 count}
$color sshd: ${alignr}$color ${tcp_portmon 9229 9229 count} $color sshd: ${alignr}$color ${tcp_portmon 22 22 count}
$color torrent: ${alignr}$color ${tcp_portmon 6881 6999 count} $color torrent: ${alignr}$color ${tcp_portmon 6881 6999 count}
${color #ddaa00}Remote Address ${alignr} Local Service/Port$color ${color #ddaa00}Remote Address ${alignr} Local Service/Port$color
${tcp_portmon 1 65535 rhost 0} ${alignr} ${tcp_portmon 1 65535 lservice 0} ${tcp_portmon 1 65535 rhost 0} ${alignr} ${tcp_portmon 1 65535 lservice 0}

View File

@ -241,7 +241,6 @@ static int set_transparent = 0;
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
static int own_window = 0; static int own_window = 0;
static int background_colour = 0; static int background_colour = 0;
static char wm_class_name[256];
/* fixed size/pos is set if wm/user changes them */ /* fixed size/pos is set if wm/user changes them */
static int fixed_size = 0, fixed_pos = 0; static int fixed_size = 0, fixed_pos = 0;
#endif #endif
@ -4831,7 +4830,7 @@ static void set_default_configurations(void)
maximum_width = 0; maximum_width = 0;
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
own_window = 0; own_window = 0;
strcpy(wm_class_name, "conky"); strcpy(window.wm_class_name, "conky");
#endif #endif
stippled_borders = 0; stippled_borders = 0;
border_margin = 3; border_margin = 3;
@ -4943,7 +4942,11 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
} }
CONF("on_bottom") { CONF("on_bottom") {
if(value) if(value)
ERR("on_bottom is deprecated. use own_window_hints below");
on_bottom = string_to_bool(value); on_bottom = string_to_bool(value);
if (on_bottom)
SET_HINT(window.hints,HINT_BELOW);
else else
CONF_ERR; CONF_ERR;
} }
@ -5230,8 +5233,8 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
own_window = string_to_bool(value); own_window = string_to_bool(value);
} }
CONF("wm_class_name") { CONF("wm_class_name") {
strncpy(wm_class_name, value, sizeof(wm_class_name)-1); memset(window.wm_class_name,0,sizeof(window.wm_class_name));
wm_class_name[sizeof(wm_class_name)-1] = 0; strncpy(window.wm_class_name, value, sizeof(window.wm_class_name)-1);
} }
CONF("own_window_transparent") { CONF("own_window_transparent") {
set_transparent = string_to_bool(value); set_transparent = string_to_bool(value);
@ -5243,6 +5246,35 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
ERR("Invalid colour for own_winder_colour (try omitting the '#' for hex colours"); ERR("Invalid colour for own_winder_colour (try omitting the '#' for hex colours");
} }
} }
CONF("own_window_hints") {
if (value) {
char *p_hint, *p_save;
char delim[] = ", ";
/* tokenize the value into individual hints */
if ((p_hint=strtok_r(value, delim, &p_save)) != NULL)
do {
/*fprintf(stderr, "hint [%s] parsed\n", p_hint);*/
if (strncmp(p_hint,"undecorate",10) == 0)
SET_HINT(window.hints,HINT_UNDECORATED);
else if (strncmp(p_hint,"below",5) == 0)
SET_HINT(window.hints,HINT_BELOW);
else if (strncmp(p_hint,"above",5) == 0)
SET_HINT(window.hints,HINT_ABOVE);
else if (strncmp(p_hint,"sticky",6) == 0)
SET_HINT(window.hints,HINT_STICKY);
else if (strncmp(p_hint,"skip_taskbar",12) == 0)
SET_HINT(window.hints,HINT_SKIP_TASKBAR);
else if (strncmp(p_hint,"skip_pager",10) == 0)
SET_HINT(window.hints,HINT_SKIP_PAGER);
else
CONF_ERR;
p_hint=strtok_r(NULL, delim, &p_save);
}
while (p_hint!=NULL);
}
}
#endif #endif
CONF("stippled_borders") { CONF("stippled_borders") {
if (value) if (value)
@ -5603,6 +5635,7 @@ int main(int argc, char **argv)
(stderr, (stderr,
"Conky: forked to background, pid is %d\n", "Conky: forked to background, pid is %d\n",
ret); ret);
fflush(stderr);
return 0; return 0;
} }
} }

View File

@ -299,6 +299,18 @@ char tmpstring2[TEXT_BUFFER_SIZE];
#define ATOM(a) XInternAtom(display, #a, False) #define ATOM(a) XInternAtom(display, #a, False)
#ifdef OWN_WINDOW
enum _window_hints {
HINT_UNDECORATED = 0,
HINT_BELOW,
HINT_ABOVE,
HINT_STICKY,
HINT_SKIP_TASKBAR,
HINT_SKIP_PAGER
};
#define SET_HINT(mask,hint) (mask |= (1<<hint))
#define TEST_HINT(mask,hint) (mask & (1<<hint))
#endif
struct conky_window { struct conky_window {
Window root,window; Window root,window;
Drawable drawable; Drawable drawable;
@ -313,8 +325,10 @@ struct conky_window {
int width; int width;
int height; int height;
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
char wm_class_name[256];
int x; int x;
int y; int y;
unsigned long hints;
#endif #endif
}; };

132
src/x11.c
View File

@ -119,6 +119,7 @@ static Window find_desktop_window()
XFree(children); XFree(children);
fprintf(stderr, fprintf(stderr,
"Conky: desktop window (%lx) found from __SWM_VROOT property\n", win); "Conky: desktop window (%lx) found from __SWM_VROOT property\n", win);
fflush(stderr);
return win; return win;
} }
@ -147,6 +148,7 @@ static Window find_desktop_window()
else else
fprintf(stderr, "Conky: desktop window (%lx) is root window\n",win); fprintf(stderr, "Conky: desktop window (%lx) is root window\n",win);
fflush(stderr);
return win; return win;
} }
@ -199,6 +201,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
XClassHint classHint; XClassHint classHint;
XWMHints wmHint; XWMHints wmHint;
Atom xa;
char window_title[256]; char window_title[256];
window.root = find_desktop_window(); window.root = find_desktop_window();
@ -208,11 +211,13 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
CopyFromParent, CopyFromParent,
InputOutput, InputOutput,
CopyFromParent, CopyFromParent,
CWBackPixel|CWOverrideRedirect, &attrs); CWBackPixel|CWOverrideRedirect,
&attrs);
fprintf(stderr, "Conky: drawing to created window (%lx)\n", window.window); fprintf(stderr, "Conky: drawing to created window (%lx)\n", window.window);
fflush(stderr);
classHint.res_name = "conky"; classHint.res_name = window.wm_class_name;
classHint.res_class = classHint.res_name; classHint.res_class = classHint.res_name;
wmHint.flags = InputHint | StateHint; wmHint.flags = InputHint | StateHint;
@ -228,7 +233,128 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
/* Sets an empty WM_PROTOCOLS property */ /* Sets an empty WM_PROTOCOLS property */
XSetWMProtocols(display,window.window,NULL,0); XSetWMProtocols(display,window.window,NULL,0);
XLowerWindow(display, window.window);
/* Set NORMAL window type for _NET_WM_WINDOW_TYPE. */
xa = ATOM(_NET_WM_WINDOW_TYPE);
if (xa != None) {
Atom prop = ATOM(_NET_WM_WINDOW_TYPE_NORMAL);
XChangeProperty(display, window.window, xa,
XA_ATOM, 32,
PropModeReplace,
(unsigned char *) &prop,
1);
}
/* Set desired hints */
/* Window decorations */
if (TEST_HINT(window.hints,HINT_UNDECORATED)) {
fprintf(stderr, "Conky: hint - undecorated\n"); fflush(stderr);
xa = ATOM(_MOTIF_WM_HINTS);
if (xa != None) {
long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(display, window.window, xa,
xa, 32, PropModeReplace,
(unsigned char *) prop, 5);
}
}
/* Below other windows */
if (TEST_HINT(window.hints,HINT_BELOW)) {
fprintf(stderr, "Conky: hint - below\n"); fflush(stderr);
xa = ATOM(_WIN_LAYER);
if (xa != None) {
long prop = 0;
XChangeProperty(display, window.window, xa,
XA_CARDINAL, 32,
PropModeReplace,
(unsigned char *) &prop, 1);
}
xa = ATOM("_NET_WM_STATE");
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
XChangeProperty(display, window.window, xa,
XA_ATOM, 32,
PropModeAppend,
(unsigned char *) &xa_prop,
1);
}
}
/* Above other windows */
if (TEST_HINT(window.hints,HINT_ABOVE)) {
fprintf(stderr, "Conky: hint - above\n"); fflush(stderr);
xa = ATOM(_WIN_LAYER);
if (xa != None) {
long prop = 6;
XChangeProperty(display, window.window, xa,
XA_CARDINAL, 32,
PropModeReplace,
(unsigned char *) &prop, 1);
}
xa = ATOM("_NET_WM_STATE");
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_ABOVE);
XChangeProperty(display, window.window, xa,
XA_ATOM, 32,
PropModeAppend,
(unsigned char *) &xa_prop,
1);
}
}
/* Sticky */
if (TEST_HINT(window.hints,HINT_STICKY)) {
fprintf(stderr, "Conky: hint - sticky\n"); fflush(stderr);
xa = ATOM("_NET_WM_STATE");
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
XChangeProperty(display, window.window, xa,
XA_ATOM, 32,
PropModeAppend,
(unsigned char *) &xa_prop,
1);
}
}
/* Skip taskbar */
if (TEST_HINT(window.hints,HINT_SKIP_TASKBAR)) {
fprintf(stderr, "Conky: hint - skip_taskbar\n"); fflush(stderr);
xa = ATOM("_NET_WM_STATE");
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
XChangeProperty(display, window.window, xa,
XA_ATOM, 32,
PropModeAppend,
(unsigned char *) &xa_prop,
1);
}
}
/* Skip pager */
if (TEST_HINT(window.hints,HINT_SKIP_PAGER)) {
fprintf(stderr, "Conky: hint - skip_pager\n"); fflush(stderr);
xa = ATOM("_NET_WM_STATE");
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
XChangeProperty(display, window.window, xa,
XA_ATOM, 32,
PropModeAppend,
(unsigned char *) &xa_prop,
1);
}
}
XMapWindow(display, window.window); XMapWindow(display, window.window);
} }