Use screenshot for overlay window background
Instead of requiring a compositing manager for the transparent background of the OverlayWindow, take a screenshot and use that instead.
This commit is contained in:
parent
f196eb264e
commit
de2cfecf92
@ -96,14 +96,14 @@ class ActivityHost:
|
||||
|
||||
def chat_show(self, frame_was_visible):
|
||||
if self._overlay_window:
|
||||
self._overlay_window.show_all()
|
||||
self._overlay_window.appear()
|
||||
self._chat_window.show_all()
|
||||
self._frame_was_visible = frame_was_visible
|
||||
|
||||
def chat_hide(self):
|
||||
self._chat_window.hide()
|
||||
if self._overlay_window:
|
||||
self._overlay_window.hide()
|
||||
self._overlay_window.disappear()
|
||||
wasvis = self._frame_was_visible
|
||||
self._frame_was_visible = False
|
||||
return wasvis
|
||||
|
@ -17,16 +17,21 @@
|
||||
import gtk
|
||||
import cairo
|
||||
|
||||
def _grab_pixbuf(window=None):
|
||||
if not window:
|
||||
screen = gtk.gdk.screen_get_default()
|
||||
window = screen.get_root_window()
|
||||
color_map = gtk.gdk.colormap_get_system()
|
||||
(x, y, w, h, bpp) = window.get_geometry()
|
||||
return gtk.gdk.pixbuf_get_from_drawable(None, window, color_map, x, y, 0, 0, w, h)
|
||||
|
||||
class OverlayWindow(gtk.Window):
|
||||
def __init__(self, lower_window):
|
||||
gtk.Window.__init__(self)
|
||||
self._lower_window = lower_window
|
||||
|
||||
colormap = self.get_screen().get_rgba_colormap()
|
||||
colormap=None
|
||||
if not colormap:
|
||||
raise RuntimeError("The window manager doesn't support compositing.")
|
||||
self.set_colormap(colormap)
|
||||
self._img = gtk.Image()
|
||||
self.add(self._img)
|
||||
|
||||
self.realize()
|
||||
|
||||
@ -39,7 +44,20 @@ class OverlayWindow(gtk.Window):
|
||||
self.set_default_size(gtk.gdk.screen_width(), gtk.gdk.screen_height())
|
||||
self.set_app_paintable(True)
|
||||
|
||||
self.connect('expose-event', self._expose_cb)
|
||||
# self.connect('expose-event', self._expose_cb)
|
||||
|
||||
def appear(self):
|
||||
pbuf = _grab_pixbuf(self._lower_window)
|
||||
#pbuf.saturate_and_pixelate(pbuf, 0.5, False)
|
||||
w = pbuf.get_width()
|
||||
h = pbuf.get_height()
|
||||
pbuf2 = pbuf.composite_color_simple(w, h, gtk.gdk.INTERP_NEAREST, 100, 1024, 0, 0)
|
||||
self._img.set_from_pixbuf(pbuf2)
|
||||
self.show_all()
|
||||
|
||||
def disappear(self):
|
||||
self._img.set_from_pixbuf(None)
|
||||
self.hide()
|
||||
|
||||
def _expose_cb(self, widget, event):
|
||||
cr = widget.window.cairo_create()
|
||||
|
Loading…
Reference in New Issue
Block a user