From d265a2d05a164c58115eae256e93bb0e3f1021cd Mon Sep 17 00:00:00 2001 From: Philip Kovacs Date: Mon, 6 Mar 2006 05:58:58 +0000 Subject: [PATCH] conky back under WM control for own_window yes git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@541 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 2 ++ src/conky.c | 12 +++++++++++- src/conky.h | 3 ++- src/x11.c | 40 ++++++++++++++++++++++++++++++---------- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55c8b8b2..69477623 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ 2006-03-05 * Added patch to make $cpu stuff work on alpha (thanks Thomas Cort) http://bugs.gentoo.org/show_bug.cgi?id=122637#c3 + * Stop using override_redirect true -- conky back under WM control + when using 'own_window yes'. 2006-02-14 * Drastically simplified own_window=yes window creation code. diff --git a/src/conky.c b/src/conky.c index 80e3c2c2..090b9b23 100644 --- a/src/conky.c +++ b/src/conky.c @@ -4550,6 +4550,16 @@ static void main_loop() set_font(); } break; + + case ButtonPress: + if (own_window) + { + /* forward the click to the root window */ + XUngrabPointer(display, ev.xbutton.time); + ev.xbutton.window = window.root; + XSendEvent(display, ev.xbutton.window, False, ButtonPressMask, &ev); + } + break; #endif default: @@ -5587,7 +5597,7 @@ int main(int argc, char **argv) (own_window, text_width + border_margin * 2 + 1, text_height + border_margin * 2 + 1, - set_transparent, background_colour, info.uname_s.nodename); + set_transparent, background_colour, info.uname_s.nodename, argv, argc); update_text_area(); /* to position text/window on screen */ #endif /* X11 */ diff --git a/src/conky.h b/src/conky.h index 25d35604..ee7990c8 100644 --- a/src/conky.h +++ b/src/conky.h @@ -337,7 +337,8 @@ extern int workarea[4]; extern struct conky_window window; void init_X11(); -void init_window(int use_own_window, int width, int height, int set_trans, int back_colour, char * nodename); +void init_window(int use_own_window, int width, int height, int set_trans, int back_colour, char * nodename, + char **argv, int argc); void create_gc(); void set_transparent_background(Window win); long get_x11_color(const char *); diff --git a/src/x11.c b/src/x11.c index cbfa5091..7305aeda 100644 --- a/src/x11.c +++ b/src/x11.c @@ -173,7 +173,8 @@ inline void set_transparent_background(Window win) //XClearWindow(display, win); not sure why this was here } -void init_window(int own_window, int w, int h, int set_trans, int back_colour, char * nodename) +void init_window(int own_window, int w, int h, int set_trans, int back_colour, char * nodename, + char **argv, int argc) { /* 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 @@ -186,15 +187,19 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c #ifdef OWN_WINDOW if (own_window) { { - /* DRASTICALLY SIMPLIFIED - - * override_redirect=True impedes the WM from manipulating - * the window, adding decorations, etc. we do not register - * for button events so you should have menu clicking over - * the conky window now too. PHK. */ + /* Allow WM control of conky again. Shielding conky from the WM + * via override redirect creates more problems than it's worth and + * makes it impossible to use tools like devilspie to manage the + * conky windows beyond the parametsrs we offer. Also, button + * press events are now explicitly forwarded to the root window. */ XSetWindowAttributes attrs = { ParentRelative,0L,0,0L,0,0,Always,0L,0L,False, - StructureNotifyMask|ExposureMask, - 0L,True,0,0 }; + StructureNotifyMask|ExposureMask|ButtonPressMask, + 0L,False,0,0 }; + + XClassHint classHint; + XWMHints wmHint; + char window_title[256]; window.root = find_desktop_window(); @@ -207,8 +212,23 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c fprintf(stderr, "Conky: drawing to created window (%lx)\n", window.window); - XLowerWindow(display, window.window); + classHint.res_name = "conky"; + classHint.res_class = classHint.res_name; + wmHint.flags = InputHint | StateHint; + wmHint.input = False; + wmHint.initial_state = NormalState; + + sprintf(window_title,WINDOW_NAME_FMT,nodename); + + XmbSetWMProperties (display, window.window, window_title, NULL, + argv, argc, + NULL, &wmHint, &classHint); + + /* Sets an empty WM_PROTOCOLS property */ + XSetWMProtocols(display,window.window,NULL,0); + + XLowerWindow(display, window.window); XMapWindow(display, window.window); } @@ -269,7 +289,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c XSelectInput(display, window.window, ExposureMask #ifdef OWN_WINDOW | (own_window - ? (StructureNotifyMask | PropertyChangeMask) : 0) + ? (StructureNotifyMask | PropertyChangeMask | ButtonPressMask) : 0) #endif ); }