hn-wm.h

Go to the documentation of this file.
00001 /* -*- mode:C; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
00002 
00003 /*
00004  * This file is part of maemo-af-desktop
00005  *
00006  * Copyright (C) 2005 Nokia Corporation.
00007  *
00008  * Contact: Karoliina Salminen <karoliina.t.salminen@nokia.com>
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public License
00012  * as published by the Free Software Foundation; either version 2.1 of
00013  * the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00023  * 02110-1301 USA
00024  *
00025  */
00026 
00031 #ifndef HILDON_NAVIGATOR_WM_H
00032 #define HILDON_NAVIGATOR_WM_H
00033 
00034 #include <X11/Xlib.h>
00035 #include <X11/Xatom.h>
00036 
00037 #include <gdk/gdk.h>
00038 #include <gdk/gdkx.h>
00039 #include <gdk/gdkevents.h>
00040 
00041 #include <gtk/gtk.h>
00042 
00043 #include <hildon-navigator.h>
00044 #include <hildon-widgets/hildon-defines.h>
00045 #include <hildon-widgets/hildon-banner.h>
00046 #include <hildon-widgets/hildon-note.h>
00047 
00048 #include <libosso.h>
00049 #include <log-functions.h>
00050 
00051 #include <libmb/mbdotdesktop.h>
00052 #include <libmb/mbutil.h>
00053 
00054 #define DBUS_API_SUBJECT_TO_CHANGE
00055 #include <dbus/dbus.h>
00056 
00057 #include <stdlib.h>
00058 #include <string.h>
00059 #include <dirent.h>
00060 #include <signal.h>
00061 #include <sys/types.h>
00062 #include <sys/stat.h>
00063 #include <sys/time.h>
00064 #include <pwd.h>
00065 
00066 #include "hn-wm-types.h"
00067 #include "application-switcher.h"
00068 #include "osso-manager.h"
00069 #include "others-menu.h"
00070 #include "hildon-navigator-interface.h"
00071 
00072 #define HN_WANT_DEBUG 1 /* Set to 1 for more verbose hn */
00073 
00074 #if (HN_WANT_DEBUG)
00075 #define HN_DBG(x, a...) \
00076  fprintf(stderr, __FILE__ ":%d,%s() " x "\n", __LINE__, __func__, ##a)
00077 #else
00078 #define HN_DBG(x, a...) do {} while (0)
00079 #endif
00080 #define HN_MARK() HN_DBG("--mark--");
00081 
00082 /* .desktop file related defines, mainly for keys
00083  */
00084 #define DESKTOP_EXEC_FIELD    "Exec"
00085 #define DESKTOP_LAUNCH_FIELD  "X-Osso-Service"
00086 #define DESKTOP_VISIBLE_FIELD "Name"
00087 #define DESKTOP_ICON_FIELD    "Icon"
00088 #define DESKTOP_SUP_WMCLASS   "StartupWMClass"
00089 #define DESKTOP_STARTUPNOTIFY "StartupNotify"
00090 #define DESKTOP_SUFFIX        ".desktop"
00091 #define UNKNOWN_TITLE         "Unknown"
00092 
00093 /* DBus/Banner etc related defines
00094  */
00095 #define APP_LAUNCH_BANNER_METHOD_INTERFACE   "com.nokia.tasknav.app_launch_banner"
00096 #define APP_LAUNCH_BANNER_METHOD_PATH        "/com/nokia/tasknav/app_launch_banner"
00097 #define APP_LAUNCH_BANNER_METHOD             "app_launch_banner"
00098 #define APP_LAUNCH_BANNER_MSG_LOADING        "ckct_ib_application_loading"
00099 #define APP_LAUNCH_BANNER_MSG_LOADING_FAILED "ckct_ib_application_loading_failed"
00100 /* Timeout of the launch banner, in secons */
00101 #define APP_LAUNCH_BANNER_TIMEOUT            20
00102 /* Timeout of the launch banner in lowmem situation */
00103 #define APP_LAUNCH_BANNER_TIMEOUT_LOWMEM     40
00104 /* Interval for checking for new window or timeout, in seconds */
00105 #define APP_LAUNCH_BANNER_CHECK_INTERVAL     0.5
00106 
00107 /* Maemo Launcher DBus interface
00108  */
00109 #define MAEMO_LAUNCHER_SIGNAL_IFACE "org.maemo.launcher"
00110 #define MAEMO_LAUNCHER_SIGNAL_PATH "/org/maemo/launcher"
00111 #define APP_DIED_SIGNAL_NAME "ApplicationDied"
00112 
00113 /* Application killer DBus interface
00114  */
00115 #define APPKILLER_SIGNAL_INTERFACE "com.nokia.osso_app_killer"
00116 #define APPKILLER_SIGNAL_PATH      "/com/nokia/osso_app_killer"
00117 #define APPKILLER_SIGNAL_NAME      "exit"
00118 
00119 /* Low memory settings
00120  */
00121 #define LAUNCH_SUCCESS_TIMEOUT 20
00122 
00123 /* For gathering available memory information */
00124 #define LOWMEM_PROC_ALLOWED              "/proc/sys/vm/lowmem_allowed_pages"
00125 #define LOWMEM_PROC_USED                 "/proc/sys/vm/lowmem_used_pages"
00126 
00127 #define LOWMEM_LAUNCH_BANNER_TIMEOUT     0
00128 #define LOWMEM_LAUNCH_BANNER_TIMEOUT_MAX 60000
00129 #define LOWMEM_LAUNCH_BANNER_TIMEOUT_ENV "NAVIGATOR_LOWMEM_LAUNCH_BANNER_TIMEOUT"
00130 /* Added by Karoliina 26092005 */
00131 #define LOWMEM_TIMEOUT_MULTIPLIER_ENV    "NAVIGATOR_LOWMEM_TIMEOUT_MULTIPLIER"
00132 #define LOWMEM_TIMEOUT_MULTIPLIER        2
00133 /* */
00134 #define LOWMEM_LAUNCH_THRESHOLD_DISTANCE 2500
00135 #define LOWMEM_LAUNCH_THRESHOLD_DISTANCE_ENV "NAVIGATOR_LOWMEM_LAUNCH_THRESHOLD_DISTANCE"
00136 
00137 #define KILL_DELAY 2000        /* 2 seconds */
00138 #define KILL_DELAY_LOWMEM 4000 /* 4 seconds */
00139 
00140 struct HNWMLaunchBannerInfo
00141 {
00142   GtkWidget         *parent;
00143   GtkWidget         *banner;
00144   struct timeval     launch_time;
00145   gchar             *msg;
00146   HNWMWatchableApp  *app;
00147 };
00148 
00149 struct HNWM   /* Our main struct, used globally unfortunatly.. */
00150 {
00151 
00152   Atom          atoms[HN_ATOM_COUNT];
00153 
00154   /* WatchedWindows is a hash of watched windows hashed via in X window ID.
00155    * As most lookups happen via window ID's makes sense to hash on this,
00156    */
00157   GHashTable   *watched_windows;
00158 
00159   /* watched windows that are 'hibernating' - i.e there actually not
00160    * running any more but still appear in HN as if they are ( for memory ).
00161    * Split into seperate hash for efficiency reasons.
00162    */
00163   GHashTable   *watched_windows_hibernating;
00164 
00165   /* A hash of valid watchable apps ( hashed on class name ). This is built
00166    * on startup by slurping in /usr/share/applications/hildon .desktop's
00167    * NOTE: previous code used service/exec/class to refer to class name so
00168    *       quite confusing.
00169    */
00170   GHashTable   *watched_apps;
00171 
00172   ApplicationSwitcher_t *app_switcher;
00173 
00174   /* FIXME: Below memory management related not 100% sure what they do */
00175 
00176   gulong        lowmem_banner_timeout;
00177   gulong        lowmem_min_distance;
00178   gulong        lowmem_timeout_multiplier;
00179   gboolean      lowmem_situation;
00180 
00181   gboolean      bg_kill_situation;
00182   gint          timer_id;
00183   gboolean      about_to_shutdown;
00184 };
00185 
00186 /* Return the singleton HNWM instance */
00187 HNWM *hn_wm_get_singleton(void);
00188 
00194 void hn_wm_top_view(GtkMenuItem *menuitem);
00195 
00196 
00200 gboolean hn_wm_top_service(const gchar *service_name);
00201 
00205 void hn_wm_top_desktop(void);
00206 
00207 
00208 HNWMWatchedWindow*
00209 hn_wm_lookup_watched_window_via_service (const gchar *service_name);
00210 
00211 HNWMWatchedWindow*
00212 hn_wm_lookup_watched_window_via_menu_widget (GtkWidget *menu_widget);
00213 
00214 HNWMWatchableApp*
00215 hn_wm_lookup_watchable_app_via_service (const gchar *service_name);
00216 
00217 HNWMWatchableApp*
00218 hn_wm_lookup_watchable_app_via_exec (const gchar *exec_name);
00219 
00220 HNWMWatchableApp*
00221 hn_wm_lookup_watchable_app_via_menu (GtkWidget *menu);
00222 
00223 HNWMWatchedWindow*
00224 hn_wm_lookup_watched_window_view (GtkWidget *menu_widget);
00225 
00226 gchar *
00227 hn_wm_compute_watched_window_hibernation_key (Window xwin,
00228                           HNWMWatchableApp *app);
00229 
00230 gboolean
00231 hn_wm_init (ApplicationSwitcher_t *as);
00232 
00233 /**** Likely deprecated stuff *****/
00234 
00235 typedef struct
00236 {
00237   Window window_id;
00238   union win_value *viewlist;
00239   gulong num_views;
00240 } view_clean_t;
00241 
00242 typedef struct
00243 {
00244   gpointer menu_ptr;
00245   gulong view_id;
00246   gchar *service;
00247   gchar *wm_class;
00248   gulong window_id;
00249 } menuitem_comp_t;
00250 
00251 
00252 #include "hn-wm-util.h"
00253 #include "hn-wm-memory.h"
00254 #include "hn-wm-watchable-app.h"
00255 #include "hn-wm-watched-window.h"
00256 #include "hn-wm-watched-window-view.h"
00257 
00258 #endif /* HILDON_NAVIGATOR_WM_H */
00259 

Generated on Fri Jun 9 16:23:09 2006 for maemo-af-desktop-documentation by  doxygen 1.4.6