1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

find_desktop_window() api changes. window parent s/b root, not desktop,

otherwise the window manager may not control the window.


git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@558 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2006-03-07 19:46:51 +00:00
parent 347ea1ba16
commit d7b85bbf02
3 changed files with 24 additions and 9 deletions

View File

@ -4573,9 +4573,9 @@ static void main_loop()
case ButtonPress: case ButtonPress:
if (own_window) if (own_window)
{ {
/* forward the click to the root window */ /* forward the click to the desktop window */
XUngrabPointer(display, ev.xbutton.time); XUngrabPointer(display, ev.xbutton.time);
ev.xbutton.window = window.root; ev.xbutton.window = window.desktop;
XSendEvent(display, ev.xbutton.window, False, ButtonPressMask, &ev); XSendEvent(display, ev.xbutton.window, False, ButtonPressMask, &ev);
} }
break; break;

View File

@ -312,7 +312,7 @@ enum _window_hints {
#define TEST_HINT(mask,hint) (mask & (1<<hint)) #define TEST_HINT(mask,hint) (mask & (1<<hint))
#endif #endif
struct conky_window { struct conky_window {
Window root,window; Window root,window,desktop;
Drawable drawable; Drawable drawable;
GC gc; GC gc;
#ifdef XDBE #ifdef XDBE

View File

@ -45,7 +45,7 @@ struct conky_window window;
/* local prototypes */ /* local prototypes */
static void update_workarea(); static void update_workarea();
static Window find_desktop_window(); static Window find_desktop_window(Window *p_root, Window *p_desktop);
static Window find_subwindow(Window win, int w, int h); static Window find_subwindow(Window win, int w, int h);
/* X11 initializer */ /* X11 initializer */
@ -95,7 +95,9 @@ static void update_workarea()
} }
} }
static Window find_desktop_window() /* Find root window and desktop window. Return desktop window on success,
* and set root and desktop byref return values. Return 0 on failure. */
static Window find_desktop_window(Window *p_root, Window *p_desktop)
{ {
Atom type; Atom type;
int format, i; int format, i;
@ -106,6 +108,9 @@ static Window find_desktop_window()
Window troot, parent, *children; Window troot, parent, *children;
unsigned char *buf = NULL; unsigned char *buf = NULL;
if (!p_root || !p_desktop)
return(0);
/* some window managers set __SWM_VROOT to some child of root window */ /* some window managers set __SWM_VROOT to some child of root window */
XQueryTree(display, root, &troot, &parent, &children, &n); XQueryTree(display, root, &troot, &parent, &children, &n);
@ -120,6 +125,8 @@ static Window find_desktop_window()
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); fflush(stderr);
*p_root=win;
*p_desktop=win;
return win; return win;
} }
@ -144,11 +151,15 @@ static Window find_desktop_window()
if (win != root) if (win != root)
fprintf(stderr, fprintf(stderr,
"Conky: desktop window (%lx) is subwindow of root window (%lx)\n",win,root); "\nConky: desktop window (%lx) is subwindow of root window (%lx)\n",win,root);
else else
fprintf(stderr, "Conky: desktop window (%lx) is root window\n",win); fprintf(stderr, "\nConky: desktop window (%lx) is root window\n",win);
fflush(stderr); fflush(stderr);
*p_root=root;
*p_desktop=win;
return win; return win;
} }
@ -204,7 +215,11 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
Atom xa; Atom xa;
char window_title[256]; char window_title[256];
window.root = find_desktop_window(); /* We want to parent the window to the root so it's under WM control,
* but we want to forward button clicks to the desktop window for menus.
* On some desktop systems, the desktop window != root window. */
if ( !find_desktop_window( &window.root, &window.desktop ) )
return;
window.window = XCreateWindow(display, window.root, window.window = XCreateWindow(display, window.root,
window.x, window.y, w, h, 0, window.x, window.y, w, h, 0,
@ -373,7 +388,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
XWindowAttributes attrs; XWindowAttributes attrs;
if (!window.window) if (!window.window)
window.window = find_desktop_window(); window.window = find_desktop_window( &window.root, &window.desktop );
if (XGetWindowAttributes(display, window.window, &attrs)) { if (XGetWindowAttributes(display, window.window, &attrs)) {
window.width = attrs.width; window.width = attrs.width;