From 72562502b9e28eebe7884eb8f4f911a9e842ebea Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 29 Sep 2006 13:35:48 -0400 Subject: [PATCH] Add composited overlay window underneath chat --- shell/view/ActivityHost.py | 15 ++++++++++++++- shell/view/OverlayWindow.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 shell/view/OverlayWindow.py diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index a9d55ea7..259f3fb1 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -8,12 +8,14 @@ from sugar.canvas.IconColor import IconColor from sugar.p2p import Stream from sugar.p2p import network from sugar.chat import ActivityChat +import OverlayWindow class ActivityChatWindow(gtk.Window): def __init__(self, gdk_window, chat_widget): gtk.Window.__init__(self) self.realize() + self.set_decorated(False) self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.window.set_accept_focus(True) self.window.set_transient_for(gdk_window) @@ -43,8 +45,15 @@ class ActivityHost: info = registry.get_activity(self._type) self._icon_name = info.get_icon() + try: + self._overlay_window = OverlayWindow.OverlayWindow(self._gdk_window) + win = self._overlay_window.window + except RuntimeError: + self._overlay_window = None + win = self._gdk_window + self._chat_widget = ActivityChat.ActivityChat(self) - self._chat_window = ActivityChatWindow(self._gdk_window, self._chat_widget) + self._chat_window = ActivityChatWindow(win, self._chat_widget) self._frame_was_visible = False self._shell.connect('activity-changed', self._activity_changed_cb) @@ -101,11 +110,15 @@ class ActivityHost: dialog.window.set_transient_for(self._gdk_window) def chat_show(self, frame_was_visible): + if self._overlay_window: + self._overlay_window.show_all() 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() wasvis = self._frame_was_visible self._frame_was_visible = False return wasvis diff --git a/shell/view/OverlayWindow.py b/shell/view/OverlayWindow.py new file mode 100644 index 00000000..13353606 --- /dev/null +++ b/shell/view/OverlayWindow.py @@ -0,0 +1,34 @@ +import gtk +import cairo + + +class OverlayWindow(gtk.Window): + def __init__(self, lower_window): + gtk.Window.__init__(self) + + 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.realize() + + self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) + self.window.set_accept_focus(False) + self.window.set_transient_for(lower_window) + + self.set_decorated(False) + self.set_position(gtk.WIN_POS_CENTER_ALWAYS) + self.set_default_size(gtk.gdk.screen_width(), gtk.gdk.screen_height()) + self.set_app_paintable(True) + + self.connect('expose-event', self._expose_cb) + + def _expose_cb(self, widget, event): + cr = widget.window.cairo_create() + cr.set_source_rgba(0.0, 0.0, 0.0, 0.4) # Transparent + cr.set_operator(cairo.OPERATOR_SOURCE) + cr.paint() + return False +