Warning, /plasma/plasma-desktop/design/activities is written in an unsupported language. File is not indexed.

0001 
0002 Overview
0003 --------
0004 
0005 Activities are the "what I'm doing" of context.
0006 They provide a way to organize stuff by project - semantically, not spatially. They have many things
0007 in common with virtual desktops, but are separate; see http://chani.wordpress.com/2010/02/20/the-limits-of-virtual-desktops/ for why.
0008 
0009 An activity has a name and icon, and is always tied to one or more containments; this gives an "anchor" to start with. From there, the user can customize the containment(s), associate windows in kwin, and associate other things (eg. files) in nepomuk. Applications could offer their own activity-specific settings (eg. a "show in this activity" option for dolphin Places) and/or use nepomuk's associations (eg. when a document associated with some activity is opened, notify the activities API so that kwin can automatically associate the window it's in with the activtiy it belongs to).
0010 
0011 While desktop containments are tied to one and only one activity, windows and nepomuk objects can be associated with as many as the user likes.
0012 
0013 an activity can be stopped; this saves out and quits all the activity's containments (and will later save the windows too).
0014 each activity has a containment for each screen; if widgets-per-desktop is enabled, it has a containment for each desktop too. This way, the activity is fully global; after all, humans really aren't good at multitasking. activities are supposed to help you focus on the task at hand.
0015 
0016 
0017 UI
0018 ---
0019 
0020 in 4.5
0021 ------
0022 
0023 KWin's titlebar contextmenu has a submenu for setting which activities a window is on, much like its desktops submenu.
0024 Plasma has an Activity Manager which allows you to create, stop, destroy, and activate activities.
0025 
0026 Future
0027 ------
0028 
0029 * More convenient ways of associating windows with containments would be nice; drag&drop?
0030 * Can the activity manager use compositing to get thumbnails instead of icons?
0031 
0032 Implementation
0033 --------------
0034 
0035 this is a general overview; more detailed and short-term plans are at http://techbase.kde.org/Projects/Plasma/ZUI
0036 
0037 In 4.5
0038 ------
0039 all important code so far has been in kdebase.
0040 
0041 runtime/activitymanager/ is a kded service that manages activities; it controls the list of activities and which one is current. It uses a config file to store the IDs and names, so that this information is available even when nepomuk is down; other data, like the icon, is fetched through nepomuk.
0042 
0043 workspace/libs/kworkspace contains KActivityController, KActivityConsumer, and KActivityInfo - classes that talk to the activity manager over dbus and provide an easy API. Controller inherits Consumer, and is meant only for workspace (kwin and plasma); the other two are meant for use by any application, and will move to kdelibs when they've had a chance to mature.
0044 
0045 workspace/plasma/desktop/shell/ contains Activity, which manages both a KActivityInfo and all the associated containments. some management of activities is done in deskopcorona too. It also contains activitymanager/ - the activity management UI.
0046 
0047 
0048 Future
0049 -------
0050 
0051 * Chani needs to write some examples of activity-aware applications, and put them in kdeexamples/
0052 * we need to decide how plasma-netbook can best use activities (there's not as much multitasking on those devices..)
0053 
0054 * kwin needs to automatically associate a window with the activities for its resources.
0055 * applications need to start advertising what resources they've got in what windows
0056 * it needs to be easy to associate documents with activities (in dolphin?)
0057 
0058 * the taskbar & pager shouldn't show windows from other activities (but perhaps there should be a way to reach them in case you forget where one is)
0059 * I'd like to see a plasmoid that can go in the panel for quick activity switching
0060 * plasma needs a tool for managing which containments belong to which screens/desktops (the most common use case is someone unplugging a monitor and then remembering they need a widget from it)
0061 * stopping an activity should stop all of it, not just plasma; we need to close down the applications in it, like a mini-session, so that they can be restored again when the activity is restored.
0062 * when we have location available, it should be possible to associate activities with locations
0063 * it'd be nice to set other settings based on activity, like IM availability or whether to show (non-critical) notifications
0064 
0065 and I'm sure applications can come up with all sorts of other useful features :)
0066 
0067 
0068 On Sessions
0069 -----------
0070 
0071 closing and restoring windows may be the hardest part of activities. It depends, at least in part, on the application being able to restore itself.
0072 there is already a session protocol for restoring apps when you log in. it's per-process, not per-window. I've heard tell that a lot of applications do not implement it particularly well; iirc, saving and quitting are often done together. I forget whether this means that telling the application to save will make it quit or just do nothing. Each process gets a session key, and on login the application is passed this key and expectted to restore itself from whatever data it has saved for that key.
0073 
0074 There are plenty of warts to that old protocol, and there was an effort to replace it once (by some gnome people iirc?) but it's there and lots of applications use it (at least to *some* extent).
0075 
0076 I think it's worth trying to re-use it. If it works, it gives us some basic support for free, and it's much easier to get applications to be better at using an existing protocol than to try and talk them into supporting a brand new protocol. Remember, we want to save/restore not just kde apps or gtk apps but any other random apps the user needs, even proprietary ones.
0077 
0078 So, how do we re-use it? well, for an application that's on exactly one activity, that's easy: tell it to quit, store its sssion key somewhere along with the activity id, and when it's time to restore that activity you start it again with that key.
0079 If an application is on >1 running activity, merely tell it that one of its activities has quit. if it's activity-aware it should close down stuff that belongs to that activity; if not, oh well, at least nothing is lost. When its last aactivity is closed, we tell it to quit, and save the key with every activity it was associated with, so that as soon as one of them is opened it gets restored.
0080 We will have to be careful that logging out doesn't duplicate any session stuff that activities handle, of course; and once this is in place we may also be able to offer the option of only opening a single activity on login.
0081 
0082 Oh, and we'll have to watch that the windows created as an application is restored get associated with the correct activities. I'm not sure how much work that is; depends how hard it is to go from a WID to a PID to a session key.
0083 
0084 Bonus points if we can get these mini-sessions saving regularly too ;)
0085