def make_hole(self, border_width): """ Uses shape extension to create hole in window... Area needs only border, rest should be transparent. """ width, height = self.size dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay()) ) # I have no idea why this works... wid = X.XID(self.get_window().get_xid()) mask = X.create_pixmap(dpy, wid, width, height, 1) xgcv = X.c_void_p() gc = X.create_gc(dpy, mask, 0, xgcv) X.set_foreground(dpy, gc, 1) X.fill_rectangle(dpy, mask, gc, 0, 0, width, height) X.set_foreground(dpy, gc, 0) X.fill_rectangle(dpy, mask, gc, border_width, border_width, width - 2 * border_width, height - 2 * border_width) SHAPE_BOUNDING = 0 SHAPE_SET = 0 X.shape_combine_mask(dpy, wid, SHAPE_BOUNDING, 0, 0, mask, SHAPE_SET) X.free_gc(dpy, gc) X.free_pixmap(dpy, mask)
def make_hole(self, border_width): """ Uses shape extension to create hole in window... Area needs only border, rest should be transparent. """ width, height = self.size dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay())) # I have no idea why this works... wid = X.XID(self.get_window().get_xid()) mask = X.create_pixmap(dpy, wid, width, height, 1) xgcv = X.c_void_p() gc = X.create_gc(dpy, mask, 0, xgcv) X.set_foreground(dpy, gc, 1) X.fill_rectangle(dpy, mask, gc, 0, 0, width, height) X.set_foreground(dpy, gc, 0) X.fill_rectangle(dpy, mask, gc, border_width, border_width, width - 2 * border_width, height - 2 * border_width) SHAPE_BOUNDING = 0 SHAPE_SET = 0 X.shape_combine_mask(dpy, wid, SHAPE_BOUNDING, 0, 0, mask, SHAPE_SET) X.free_gc(dpy, gc) X.free_pixmap(dpy, mask)
def show(self): OSDWindow.show(self) from ctypes import byref pb = self.b.get_pixbuf() win = X.XID(self.get_window().get_xid()) pixmap = X.create_pixmap(self.xdisplay, win, pb.get_width(), pb.get_height(), 1) width = pb.get_width() height = pb.get_height() self.f.move(self.cursor, int(width / 2), int(height / 2)) gc = X.create_gc(self.xdisplay, pixmap, 0, None) X.set_foreground(self.xdisplay, gc, 0) X.fill_rectangle(self.xdisplay, pixmap, gc, 0, 0, pb.get_width(), pb.get_height()) X.set_foreground(self.xdisplay, gc, 1) X.set_background(self.xdisplay, gc, 1) r = int(pb.get_width() * 0.985) x = (pb.get_width() - r) / 2 X.fill_arc(self.xdisplay, pixmap, gc, x, x, r, r, 0, 360*64) X.flush_gc(self.xdisplay, gc) X.flush(self.xdisplay) X.shape_combine_mask(self.xdisplay, win, X.SHAPE_BOUNDING, 0, 0, pixmap, X.SHAPE_SET) X.flush(self.xdisplay)