Mercurial > MadButterfly
diff src/X_supp.c @ 756:cceac4ba259e
Support drawing at root window for X Window
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 26 Aug 2010 14:54:50 +0800 |
parents | 82836f1290b6 |
children | f43224bf3524 |
line wrap: on
line diff
--- a/src/X_supp.c Thu Aug 26 13:54:53 2010 +0800 +++ b/src/X_supp.c Thu Aug 26 14:54:50 2010 +0800 @@ -428,12 +428,13 @@ handle_x_event(rt); } else { for(i=0;i<rt->n_monitor;i++) { - if (rt->monitors[i].type == MONITOR_READ) + if (rt->monitors[i].type == MONITOR_READ) { if (FD_ISSET(rt->monitors[i].fd, &rfds)) rt->monitors[i].f(rt->monitors[i].fd,rt->monitors[i].arg); - else if (rt->monitors[i].type == MONITOR_WRITE) + } else if (rt->monitors[i].type == MONITOR_WRITE) { if (FD_ISSET(rt->monitors[i].fd, &wfds)) - rt->monitors[i].f(rt->monitors[i].fd,rt->monitors[i].arg); + rt->monitors[i].f(rt->monitors[i].fd,rt->monitors[i].arg); + } } } } @@ -454,9 +455,27 @@ XSetWindowAttributes wattr; int depth; int x, y; + int draw_root = 0; + const char *disp_name; + char disp_buf[32]; + int cp; int r; - display = XOpenDisplay(display_name); + /* + * Support drawing on the root window. + */ + disp_name = display_name; + if(strstr(display_name, ":root") != NULL) { + draw_root = 1; + cp = strlen(display_name) - 5; + if(cp >= 32) + cp = 31; + memcpy(disp_buf, display_name, cp); + disp_buf[cp] = 0; + disp_name = disp_buf; + } + + display = XOpenDisplay(disp_name); if(display == NULL) return ERR; @@ -467,15 +486,19 @@ wattr.override_redirect = False; x = 10; y = 10; - win = XCreateWindow(display, root, - x, y, - w, h, - 1, depth, InputOutput, visual, - CWOverrideRedirect, &wattr); - r = XMapWindow(display, win); - if(r == -1) { - XCloseDisplay(display); - return ERR; + if(draw_root) + win = RootWindowOfScreen(ScreenOfDisplay(display, screen)); + else { + win = XCreateWindow(display, root, + x, y, + w, h, + 1, depth, InputOutput, visual, + CWOverrideRedirect, &wattr); + r = XMapWindow(display, win); + if(r == -1) { + XCloseDisplay(display); + return ERR; + } } XSelectInput(display, win, PointerMotionMask | ExposureMask |