Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert Freudenberg <bert@ubuntu.(none)>2007-05-23 16:33:30 (GMT)
committer Bert Freudenberg <bert@ubuntu.(none)>2007-05-23 16:33:30 (GMT)
commit677c4bc1998dff01a0b36c4c77e58e129351415e (patch)
tree332fc89ba6aacdf8ccd2f2b6be772e1a6df5b3e5
parentf3d9d5e334db1074bc378c751c66c00d2d9261cc (diff)
Reliably detect activity launch (fix for #1560)
-rw-r--r--shell/model/homemodel.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py
index a3afdc4..39885ed 100644
--- a/shell/model/homemodel.py
+++ b/shell/model/homemodel.py
@@ -68,6 +68,12 @@ class HomeModel(gobject.GObject):
screen.connect('window-closed', self._window_closed_cb)
screen.connect('active-window-changed',
self._active_window_changed_cb)
+ bus = dbus.SessionBus()
+ bus.add_signal_receiver(
+ self._dbus_name_owner_changed_cb,
+ 'NameOwnerChanged',
+ 'org.freedesktop.DBus',
+ 'org.freedesktop.DBus')
def get_current_activity(self):
return self._current_activity
@@ -103,9 +109,31 @@ class HomeModel(gobject.GObject):
self.emit('active-activity-changed', None)
self._notify_activity_activation(self._current_activity, None)
+ def _dbus_name_owner_changed_cb(self, name, old, new):
+ """Detect new activity instances on the DBus
+
+ Normally, new activities are detected by
+ the _window_opened_cb callback. However, if the
+ window is opened before the dbus service is up,
+ a RawHomeWindow is created. In here we create
+ a proper HomeActivity replacing the RawHomeWindow.
+ """
+ if name.startswith(_SERVICE_NAME) and new and not old:
+ xid = name[len(_SERVICE_NAME):]
+ if not xid.isdigit():
+ return
+ logging.debug("Activity instance launch detected: %s" % name)
+ xid = int(xid)
+ act = self._get_activity_by_xid(xid)
+ if isinstance(act, HomeRawWindow):
+ logging.debug("Removing bogus raw activity %s for window %i"
+ % (act.get_activity_id(), xid))
+ self._internal_remove_activity(act)
+ self._add_activity(act.get_window())
+
def _get_activity_by_xid(self, xid):
for act in self._activities.values():
- if act.get_xid() == xid:
+ if act.get_launched() and act.get_xid() == xid:
return act
return None