+Window BC_Capture::bar(int x, int y, int w, int h, int color)
+{
+ unsigned long mask = CWEventMask | CWBackPixel |
+ CWOverrideRedirect | CWSaveUnder;
+ XSetWindowAttributes attr;
+ memset(&attr, 0, sizeof(attr));
+ Screen *scr = XDefaultScreenOfDisplay(display);
+ Window root = RootWindowOfScreen(scr);
+ Visual *vis = DefaultVisualOfScreen(scr);
+ int depth = DefaultDepthOfScreen(scr);
+ attr.background_pixel = color;
+ attr.override_redirect = True;
+ attr.save_under = True;
+ Window win = XCreateWindow(display, root, x,y,w,h, 0,depth,
+ InputOutput, vis, mask, &attr);
+ XMapWindow(display, win);
+ return win;
+}
+
+void BC_Capture::bars_on(int bw, int color, int x, int y, int w, int h)
+{
+ this->bar_w = bw;
+ this->bar_color = color;
+ border[0] = bar(x-bw, y-bw, w+2*bw, bw, color);
+ border[1] = bar(x-bw, y, bw, h, color);
+ border[2] = bar(x-bw, y+h, w+2*bw, bw, color);
+ border[3] = bar(x+w, y, bw, h, color);
+ XFlush(display);
+}
+
+void BC_Capture::bars_off()
+{
+ for( int i=0; i<4; ++i ) {
+ if( !border[i] ) continue;
+ XUnmapWindow(display, border[i]);
+ }
+ for( int i=0; i<4; ++i ) {
+ if( !border[i] ) continue;
+ XDestroyWindow(display, border[i]);
+ border[i] = 0;
+ }
+ XFlush(display);
+}
+
+void BC_Capture::bars_reposition(int x, int y, int w, int h)
+{
+ int bw = this->bar_w;
+ if( border[0] )
+ XMoveResizeWindow(display, border[0], x-bw, y-bw, w+2*bw, bw);
+ if( border[1] )
+ XMoveResizeWindow(display, border[1], x-bw, y, bw, h );
+ if( border[2] )
+ XMoveResizeWindow(display, border[2], x-bw, y+h, w+2*bw, bw);
+ if( border[3] )
+ XMoveResizeWindow(display, border[3], x+w, y, bw, h );
+}