[maemo-commits] [maemo-commits] r8289 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildonwm test
From: www-data at stage.maemo.org www-data at stage.maemo.orgDate: Thu Nov 23 18:11:44 EET 2006
- Previous message: [maemo-commits] r8288 - in projects/haf/trunk/dbus/debian: . patches
- Next message: [maemo-commits] r8290 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . data libhildondesktop src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2006-11-23 18:11:43 +0200 (Thu, 23 Nov 2006) New Revision: 8289 Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm-watched-window.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c Log: * libhildonwm/hd-wm.[ch]: Moved the hd-wm to a new API based on GObject that allows having more than one app switcher. * test/test4.c: Modified test for libhildonwm * ChangeLog updated. Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-11-23 15:54:10 UTC (rev 8288) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-11-23 16:11:43 UTC (rev 8289) @@ -1,3 +1,9 @@ +2006-11-23 Moises Martinez <moises.martinzes at nokia.com> + + * libhildonwm/hd-wm.[ch]: Moved the hd-wm to a new API based on + GObject that allows having more than one app switcher. + * test/test4.c: Modified test for libhildonwm + 2006-11-23 Johan Bilien <johan.bilien at nokia.com> * src/hd-plugin-loader.c: Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm-watched-window.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm-watched-window.c 2006-11-23 15:54:10 UTC (rev 8288) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm-watched-window.c 2006-11-23 16:11:43 UTC (rev 8289) @@ -221,10 +221,8 @@ info = hd_wm_watched_window_peek_info (win); if (info) - g_debug ("Here we notify changes to appswitcher"); - /* - hn_app_switcher_changed (hd_wm_get_app_switcher(), info); - */ + g_debug ("%s: %d, hn_app_switcher_changed (hd_wm_get_app_switcher(), info);",__FILE__,__LINE__); + out: if (data) XFree(data); @@ -283,10 +281,8 @@ info = hd_wm_watched_window_view_get_info (view); hd_wm_watched_window_set_active_view (win, view); - g_debug ("Here we notify stack changes to appswitcher"); - /* - hn_app_switcher_changed_stack (hd_wm_get_app_switcher (), info); - */ + g_debug ("%s: %d, hn_app_switcher_changed_stack (hd_wm_get_app_switcher (), info);",__FILE__,__LINE__); + goto out; } iter = g_list_next(iter); @@ -350,8 +346,7 @@ hd_wm_watched_window_view_set_name (view, win->name); if (win->info) - g_debug ("Here we notify changes to appswitcher 2"); - /*hn_app_switcher_changed (hd_wm_get_app_switcher (), win->info);*/ + g_debug ("%s: %d, hn_app_switcher_changed (hd_wm_get_app_switcher (), win->info);",__FILE__,__LINE__); } static void Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c 2006-11-23 15:54:10 UTC (rev 8288) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c 2006-11-23 16:11:43 UTC (rev 8289) @@ -64,7 +64,28 @@ #define LAUNCH_SUCCESS_TIMEOUT 20 +#define HD_WM_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), HD_TYPE_WM, HDWMPrivate)) +enum +{ + HDWM_ENTRY_INFO_CHANGE_SIGNAL, + HDWM_ENTRY_INFO_ADDED_SIGNAL, + HDWM_ENTRY_INFO_REMOVED_SIGNAL, + HDWM_ENTRY_INFO_STACK_CHANGED_SIGNAL, + HDWM_SIGNALS +}; + +static gint hdwm_signals[HDWM_SIGNALS]; + +G_DEFINE_TYPE (HDWM, hd_wm, G_TYPE_OBJECT); + +static void +hd_wm_class_init (HDWMClass *hdwm_class); + +static void +hd_wm_init (HDWM *hdwm); + static GdkFilterReturn hd_wm_x_event_filter (GdkXEvent *xevent, GdkEvent *event, @@ -91,9 +112,7 @@ gint n_wins; }; -typedef struct HDWM HDWM; - -struct HDWM /* Our main struct */ +struct _HDWMPrivate /* Our main struct */ { Atom atoms[HD_ATOM_COUNT]; @@ -149,12 +168,537 @@ gboolean modal_windows; }; -static HDWM hdwm; /* Singleton instance */ +static HDWMPrivate *hdwmpriv = NULL; /* Singleton instance */ static gboolean hd_wm_add_watched_window (HDWMWatchedWindow *win); +static void +hd_wm_atoms_init() +{ + /* + * The list below *MUST* be kept in the same order as the corresponding + * emun in tm-wm-types.h above or *everything* will break. + * Doing it like this avoids a mass of round trips on startup. + */ + char *atom_names[] = { + + "WM_CLASS", /* ICCCM */ + "WM_NAME", + "WM_STATE", + "WM_TRANSIENT_FOR", + "WM_HINTS", + "WM_WINDOW_ROLE", + + "_NET_WM_WINDOW_TYPE", /* EWMH */ + "_NET_WM_WINDOW_TYPE_MENU", + "_NET_WM_WINDOW_TYPE_NORMAL", + "_NET_WM_WINDOW_TYPE_DIALOG", + "_NET_WM_WINDOW_TYPE_DESKTOP", + "_NET_WM_STATE", + "_NET_WM_STATE_MODAL", + "_NET_SHOWING_DESKTOP", + "_NET_WM_PID", + "_NET_ACTIVE_WINDOW", + "_NET_CLIENT_LIST", + "_NET_WM_ICON", + "_NET_WM_USER_TIME", + "_NET_WM_NAME", + "_NET_CLOSE_WINDOW", + "_NET_WM_STATE_FULLSCREEN", + + "_HILDON_APP_KILLABLE", /* Hildon only props */ + "_HILDON_ABLE_TO_HIBERNATE",/* alias for the above */ + "_NET_CLIENT_LIST", /* NOTE: Hildon uses these values on app wins*/ + "_NET_ACTIVE_WINDOW", /* for views, thus index is named different */ + /* to improve code readablity. */ + /* Ultimatly the props should be renamed with*/ + /* a _HILDON prefix */ + "_HILDON_FROZEN_WINDOW", + "_HILDON_TN_ACTIVATE", + + "_MB_WIN_SUB_NAME", /* MB Only props */ + "_MB_COMMAND", /* FIXME: Unused */ + "_MB_CURRENT_APP_WINDOW", + "_MB_APP_WINDOW_LIST_STACKING", + "_MB_NUM_MODAL_WINDOWS_PRESENT", + + "UTF8_STRING", + }; + + XInternAtoms (GDK_DISPLAY(), + atom_names, + HD_ATOM_COUNT, + False, + hdwmpriv->atoms); +} + +static HDWMWatchableApp* +hd_wm_x_window_is_watchable (Window xid) +{ + HDWMWatchableApp *app; + XClassHint class_hint; + Atom *wm_type_atom; + Status status = 0; + + app = NULL; + + memset(&class_hint, 0, sizeof(XClassHint)); + + gdk_error_trap_push(); + + status = XGetClassHint(GDK_DISPLAY(), xid, &class_hint); + + if (gdk_error_trap_pop() || status == 0 || class_hint.res_name == NULL) + goto out; + + /* Does this window class belong to a 'watched' application ? */ + + app = g_hash_table_lookup(hdwmpriv->watched_apps, + (gconstpointer)class_hint.res_name); + + /* FIXME: below checks are really uneeded assuming we trust new MB list prop + */ + wm_type_atom + = hd_wm_util_get_win_prop_data_and_validate (xid, + hdwmpriv->atoms[HD_ATOM_NET_WM_WINDOW_TYPE], + XA_ATOM, + 32, + 0, + NULL); + if (!wm_type_atom) + { + Window trans_win; + Status result; + + /* Assume anything not setting there type is a TYPE_NORMAL. + * This is to support non EWMH 1980 style wins created by + * SDL, alegro etc. + */ + gdk_error_trap_push(); + + result = XGetTransientForHint(GDK_DISPLAY(), xid, &trans_win); + + /* If its transient for something, assume dialog and ignore. + * This should really never happen. + */ + if (gdk_error_trap_pop() || (result && trans_win != None)) + app = NULL; + goto out; + } + + /* Only care about desktop and app wins */ + if (wm_type_atom[0] != hdwmpriv->atoms[HD_ATOM_NET_WM_WINDOW_TYPE_NORMAL] + && wm_type_atom[0] != hdwmpriv->atoms[HD_ATOM_NET_WM_WINDOW_TYPE_DESKTOP]) + { + app = NULL; + XFree(wm_type_atom); + goto out; + } + + if(!app) + { + /* + * If we got this far and have no app, we are dealing with an application + * that did not provide a .desktop file; we are expected to provide + * rudimentary support, so we create a dummy app object. + * + * We do not add this app to the watchable app hash. + */ + + app = hd_wm_watchable_app_new_dummy (); + + g_debug (" ## Created dummy application for app without .desktop ##"); + } + + + XFree(wm_type_atom); + + out: + + if (class_hint.res_class) + XFree(class_hint.res_class); + + if (class_hint.res_name) + XFree(class_hint.res_name); + + return app; +} + +static DBusHandlerResult +hd_wm_dbus_method_call_handler (DBusConnection *connection, + DBusMessage *message, + void *data ) +{ + const gchar *path; + + /* Catch APP_LAUNCH_BANNER_METHOD */ + if (dbus_message_is_method_call (message, + APP_LAUNCH_BANNER_METHOD_INTERFACE, + APP_LAUNCH_BANNER_METHOD ) ) + { + DBusError error; + gchar *service_name = NULL; + HDWMWatchableApp *app; + + dbus_error_init (&error); + + dbus_message_get_args (message, + &error, + DBUS_TYPE_STRING, + &service_name, + DBUS_TYPE_INVALID ); + + if (dbus_error_is_set (&error)) + { + osso_log(LOG_WARNING, "Error getting message args: %s\n", + error.message); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + + g_return_val_if_fail (service_name, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); + + g_debug ("Checking if service: '%s' is watchable", service_name); + + /* Is this 'service' watchable ? */ + if ((app = hd_wm_lookup_watchable_app_via_service (service_name)) != NULL) + { + if (hd_wm_watchable_app_has_startup_notify (app) + && hdwmpriv->lowmem_banner_timeout > 0 + && !hd_wm_watchable_app_has_windows (app)) + { + g_debug ("Showing Launchbanner..."); + /* + * This function takes care of the distinction between the Loading + * and Resuming banners, hence we no longer test for hibernation + */ + hd_wm_watchable_app_launch_banner_show (app); + } + } + } + + path = dbus_message_get_path(message); + if (path != NULL && g_str_equal(path, TASKNAV_GENERAL_PATH)) + { + const gchar * interface = dbus_message_get_interface(message); + if (g_str_equal(interface, TASKNAV_SENSITIVE_INTERFACE)) + { + g_debug ("%s: %d, set sensitiveness to tn to true",__FILE__,__LINE__); + /* hn_window_set_sensitive (tasknav,TRUE); */ + return DBUS_HANDLER_RESULT_HANDLED; + } + else if (g_str_equal(interface, TASKNAV_INSENSITIVE_INTERFACE)) + { + g_debug ("%s: %d, set sensitiveness to tn to false",__FILE__,__LINE__); + /* hn_window_set_sensitive (tasknav,TRUE); */ + return DBUS_HANDLER_RESULT_HANDLED; + } + } + + + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static DBusHandlerResult +hd_wm_dbus_signal_handler(DBusConnection *conn, DBusMessage *msg, void *data) +{ + if (dbus_message_is_signal(msg, MAEMO_LAUNCHER_SIGNAL_IFACE, + APP_DIED_SIGNAL_NAME)) + { + DBusError err; + gchar *filename; + int pid; + int status; + HDWMWatchableApp *app; + + + dbus_error_init(&err); + + dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &filename, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &status, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) + { + osso_log(LOG_WARNING, "Error getting message args: %s\n", + err.message); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + g_debug ("Checking if filename: '%s' is watchable pid='%i' status='%i'", + filename, pid, status); + + /* Is this 'filename' watchable ? */ + app = hd_wm_lookup_watchable_app_via_exec(filename); + if (app) + { + g_debug ("Showing app died dialog ..."); + hd_wm_watchable_app_died_dialog_show(app); + } + return DBUS_HANDLER_RESULT_HANDLED; + } + + if (dbus_message_is_signal(msg, APPKILLER_SIGNAL_INTERFACE, + APPKILLER_SIGNAL_NAME)) + { + hd_wm_memory_kill_all_watched(FALSE); + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static int +hd_wm_osso_kill_method(GArray *arguments, gpointer data) +{ + gchar *appname = NULL, *operation = NULL; + HDWMWatchedWindow *win = NULL; + HDWMWatchableApp *app; + + if (arguments->len < 1) + return 1; + + operation = (gchar *)g_array_index(arguments, osso_rpc_t, 0).value.s; + + /* In this case, HN will kill every process that has supposedly + * statesaved + */ + + if (operation == NULL) + return 1; + + if (strcmp(operation, "lru") == 0) + { + return hd_wm_memory_kill_lru(); + } + else if (strcmp(operation, "all") == 0) + { + return hd_wm_memory_kill_all_watched(TRUE); + } + else if (strcmp(operation, "app") != 0 || (arguments->len < 2) ) + { + return 1; + } + + /* Kill a certain application */ + + appname = (gchar *)g_array_index(arguments, osso_rpc_t, 1).value.s; + + if (appname == NULL) + return 1; + + win = hd_wm_lookup_watched_window_via_service (appname); + app = hd_wm_watched_window_get_app (win); + + if (win) + { + if (hd_wm_watchable_app_is_able_to_hibernate (app)) + hd_wm_watched_window_attempt_signal_kill (win, SIGTERM, TRUE); + } + + return 0; +} + +static void +hd_wm_class_init (HDWMClass *hdwm_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (hdwm_class); + + g_type_class_add_private (hdwm_class, sizeof (HDWMPrivate)); + + hdwm_signals[HDWM_ENTRY_INFO_CHANGE_SIGNAL] = + g_signal_new("entry_info_changed", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (HDWMClass,entry_info_changed), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + + hdwm_signals[HDWM_ENTRY_INFO_ADDED_SIGNAL] = + g_signal_new("entry_info_added", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (HDWMClass,entry_info_added), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + + hdwm_signals[HDWM_ENTRY_INFO_REMOVED_SIGNAL] = + g_signal_new("entry_info_removed", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (HDWMClass,entry_info_removed), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + + hdwm_signals[HDWM_ENTRY_INFO_STACK_CHANGED_SIGNAL] = + g_signal_new("entry_info_stack_changed", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (HDWMClass,entry_info_stack_changed), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + +} + +static void +hd_wm_init (HDWM *hdwm) +{ + DBusConnection *connection; + DBusError error; + gchar *match_rule = NULL; + GdkKeymap *keymap; + + hdwm->priv = hdwmpriv = HD_WM_GET_PRIVATE (hdwm); + + /*memset(&(hdwm->priv), 0, sizeof(HDWMPrivate));*/ + + osso_manager_t *osso_man = osso_manager_singleton_get_instance(); + + /*hdwmpriv->app_switcher = as;*/ + + /* Check for configurable lowmem values. */ + + hdwm->priv->lowmem_min_distance + = hd_wm_util_getenv_long (LOWMEM_LAUNCH_THRESHOLD_DISTANCE_ENV, + LOWMEM_LAUNCH_THRESHOLD_DISTANCE); + hdwm->priv->lowmem_banner_timeout + = hd_wm_util_getenv_long (LOWMEM_LAUNCH_BANNER_TIMEOUT_ENV, + LOWMEM_LAUNCH_BANNER_TIMEOUT); + + /* Guard about insensibly long values. */ + if (hdwm->priv->lowmem_banner_timeout > LOWMEM_LAUNCH_BANNER_TIMEOUT_MAX) + hdwm->priv->lowmem_banner_timeout = LOWMEM_LAUNCH_BANNER_TIMEOUT_MAX; + + hdwm->priv->lowmem_timeout_multiplier + = hd_wm_util_getenv_long (LOWMEM_TIMEOUT_MULTIPLIER_ENV, + LOWMEM_TIMEOUT_MULTIPLIER); + + /* Various app switcher callbacks */ +#if 0 + application_switcher_set_dnotify_handler (as, &hd_wm_dnotify_func); + application_switcher_set_shutdown_handler (as, &hd_wm_shutdown_func); + application_switcher_set_lowmem_handler (as, &hd_wm_memory_lowmem_func); + application_switcher_set_bgkill_handler (as, &hd_wm_memory_bgkill_func); + + g_signal_connect (as, "lowmem", G_CALLBACK (hd_wm_lowmem_cb), NULL); + g_signal_connect (as, "bgkill", G_CALLBACK (hd_wm_bgkill_cb), NULL); +#endif + /* build our hash of watchable apps via .desktop key/values */ + + hdwm->priv->watched_apps = hd_wm_watchable_apps_init (); + + /* Initialize the common X atoms */ + + hd_wm_atoms_init(); + + /* Hash to track watched windows */ + + hdwm->priv->watched_windows + = g_hash_table_new_full (g_int_hash, + g_int_equal, + (GDestroyNotify)g_free, + (GDestroyNotify)hd_wm_watched_window_destroy); + + /* Hash for windows that dont really still exists but HN makes them appear + * as they do - they are basically backgrounded. + */ + hdwm->priv->watched_windows_hibernating + = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify)g_free, + (GDestroyNotify)hd_wm_watched_window_destroy); + + gdk_error_trap_push(); + + /* select X events */ + + gdk_window_set_events(gdk_get_default_root_window(), + gdk_window_get_events(gdk_get_default_root_window()) + | GDK_PROPERTY_CHANGE_MASK ); + + gdk_window_add_filter(gdk_get_default_root_window(), + hd_wm_x_event_filter, + NULL); + + gdk_error_trap_pop(); + + /* Setup shortcuts */ + + hdwm->priv->keys = hd_keys_init (); + + /* Track changes in the keymap */ + + keymap = gdk_keymap_get_default (); + g_signal_connect (G_OBJECT (keymap), "keys-changed", + G_CALLBACK (hd_keys_reload), hdwm->priv->keys); + + /* Get on the DBus */ + + dbus_error_init (&error); + + connection = dbus_bus_get( DBUS_BUS_SESSION, &error ); + + if (!connection) + { + osso_log(LOG_ERR, "Failed to connect to DBUS: %s!\n", error.message ); + dbus_error_free( &error ); + } + else + { + /* Match rule */ + + match_rule = g_strdup_printf("interface='%s'", + APP_LAUNCH_BANNER_METHOD_INTERFACE ); + + dbus_bus_add_match( connection, match_rule, NULL ); + + g_free (match_rule); + + match_rule = g_strdup_printf( + "type='signal', interface='%s'", + APPKILLER_SIGNAL_INTERFACE); + + dbus_bus_add_match( connection, match_rule, NULL ); + dbus_connection_add_filter(connection, hd_wm_dbus_signal_handler, + NULL, NULL); + g_free(match_rule); + + match_rule = g_strdup_printf("interface='%s'", + TASKNAV_INSENSITIVE_INTERFACE ); + + dbus_bus_add_match( connection, match_rule, NULL ); + + dbus_connection_add_filter( connection, hd_wm_dbus_method_call_handler, + /* model */ NULL, NULL ); + g_free(match_rule); + + /* Setup match rule for Maemo Launcher */ + match_rule = g_strdup_printf("type='signal', interface='%s'", + MAEMO_LAUNCHER_SIGNAL_IFACE); + + dbus_bus_add_match(connection, match_rule, NULL); + dbus_connection_add_filter(connection, hd_wm_dbus_signal_handler, + NULL, NULL); + g_free(match_rule); + + dbus_connection_flush(connection); + + /* Add the com.nokia.tasknav callbacks - FIXME: what are these for ? */ + add_method_cb(osso_man, KILL_APPS_METHOD, + &hd_wm_osso_kill_method, osso_man); + + } +} + void hd_wm_top_item (HDEntryInfo *info) { @@ -194,7 +738,7 @@ hd_wm_util_send_x_message (hd_wm_watched_window_view_get_id (view), hd_wm_watched_window_get_x_win (win), - hdwm.atoms[HD_ATOM_HILDON_VIEW_ACTIVE], + hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE], SubstructureRedirectMask | SubstructureNotifyMask, 0, 0, @@ -240,7 +784,7 @@ ev.xclient.type = ClientMessage; ev.xclient.window = hd_wm_watched_window_get_x_win (win); - ev.xclient.message_type = hdwm.atoms[HD_ATOM_NET_ACTIVE_WINDOW]; + ev.xclient.message_type = hdwmpriv->atoms[HD_ATOM_NET_ACTIVE_WINDOW]; ev.xclient.format = 32; gdk_error_trap_push (); @@ -275,7 +819,7 @@ win = hd_wm_lookup_watched_window_via_service (service_name); if (hd_wm_is_lowmem_situation() || - (pages_available > 0 && pages_available < hdwm.lowmem_min_distance)) + (pages_available > 0 && pages_available < hdwmpriv->lowmem_min_distance)) { gboolean killed = TRUE; if (win == NULL) @@ -305,7 +849,7 @@ * This code is not removed to preserve the configurability as fallback * for non-lowmem situtations */ - if (pages_available > 0 && pages_available < hdwm.lowmem_min_distance) + if (pages_available > 0 && pages_available < hdwmpriv->lowmem_min_distance) { gboolean killed = TRUE; @@ -400,7 +944,7 @@ { hd_wm_util_send_x_message (hd_wm_watched_window_view_get_id (view), hd_wm_watched_window_get_x_win (win), - hdwm.atoms[HD_ATOM_HILDON_VIEW_ACTIVE], + hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE], SubstructureRedirectMask |SubstructureNotifyMask, 0, @@ -422,7 +966,7 @@ ev.xclient.type = ClientMessage; ev.xclient.window = hd_wm_watched_window_get_x_win (active_win ? active_win : win); - ev.xclient.message_type = hdwm.atoms[HD_ATOM_NET_ACTIVE_WINDOW]; + ev.xclient.message_type = hdwmpriv->atoms[HD_ATOM_NET_ACTIVE_WINDOW]; ev.xclient.format = 32; gdk_error_trap_push(); @@ -450,7 +994,7 @@ desktop_state = hd_wm_util_get_win_prop_data_and_validate ( GDK_WINDOW_XID(gdk_get_default_root_window()), - hdwm.atoms[HD_ATOM_NET_SHOWING_DESKTOP], + hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP], XA_CARDINAL, 32, 1, @@ -458,10 +1002,10 @@ if (desktop_state) { - if (desktop_state[0] == 1 && hdwm.last_active_window) + if (desktop_state[0] == 1 && hdwmpriv->last_active_window) { HDWMWatchableApp* app = - hd_wm_watched_window_get_app(hdwm.last_active_window); + hd_wm_watched_window_get_app(hdwmpriv->last_active_window); const gchar * service = hd_wm_watchable_app_get_service (app); hd_wm_top_service (service); @@ -486,7 +1030,7 @@ ev.xclient.type = ClientMessage; ev.xclient.window = GDK_ROOT_WINDOW(); - ev.xclient.message_type = hdwm.atoms[HD_ATOM_NET_SHOWING_DESKTOP]; + ev.xclient.message_type = hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP]; ev.xclient.format = 32; ev.xclient.data.l[0] = 1; @@ -502,164 +1046,11 @@ * created, so that resetting it there means active_window remain NULL and * this breaks the AS menu focus. */ - hdwm.active_window = NULL; + hdwmpriv->active_window = NULL; } -static void -hd_wm_atoms_init() -{ - /* - * The list below *MUST* be kept in the same order as the corresponding - * emun in tm-wm-types.h above or *everything* will break. - * Doing it like this avoids a mass of round trips on startup. - */ - char *atom_names[] = { - - "WM_CLASS", /* ICCCM */ - "WM_NAME", - "WM_STATE", - "WM_TRANSIENT_FOR", - "WM_HINTS", - "WM_WINDOW_ROLE", - - "_NET_WM_WINDOW_TYPE", /* EWMH */ - "_NET_WM_WINDOW_TYPE_MENU", - "_NET_WM_WINDOW_TYPE_NORMAL", - "_NET_WM_WINDOW_TYPE_DIALOG", - "_NET_WM_WINDOW_TYPE_DESKTOP", - "_NET_WM_STATE", - "_NET_WM_STATE_MODAL", - "_NET_SHOWING_DESKTOP", - "_NET_WM_PID", - "_NET_ACTIVE_WINDOW", - "_NET_CLIENT_LIST", - "_NET_WM_ICON", - "_NET_WM_USER_TIME", - "_NET_WM_NAME", - "_NET_CLOSE_WINDOW", - "_NET_WM_STATE_FULLSCREEN", - - "_HILDON_APP_KILLABLE", /* Hildon only props */ - "_HILDON_ABLE_TO_HIBERNATE",/* alias for the above */ - "_NET_CLIENT_LIST", /* NOTE: Hildon uses these values on app wins*/ - "_NET_ACTIVE_WINDOW", /* for views, thus index is named different */ - /* to improve code readablity. */ - /* Ultimatly the props should be renamed with*/ - /* a _HILDON prefix */ - "_HILDON_FROZEN_WINDOW", - "_HILDON_TN_ACTIVATE", - - "_MB_WIN_SUB_NAME", /* MB Only props */ - "_MB_COMMAND", /* FIXME: Unused */ - "_MB_CURRENT_APP_WINDOW", - "_MB_APP_WINDOW_LIST_STACKING", - "_MB_NUM_MODAL_WINDOWS_PRESENT", - - "UTF8_STRING", - }; - - XInternAtoms (GDK_DISPLAY(), - atom_names, - HD_ATOM_COUNT, - False, - hdwm.atoms); -} - - -static HDWMWatchableApp* -hd_wm_x_window_is_watchable (Window xid) -{ - HDWMWatchableApp *app; - XClassHint class_hint; - Atom *wm_type_atom; - Status status = 0; - - app = NULL; - - memset(&class_hint, 0, sizeof(XClassHint)); - - gdk_error_trap_push(); - - status = XGetClassHint(GDK_DISPLAY(), xid, &class_hint); - - if (gdk_error_trap_pop() || status == 0 || class_hint.res_name == NULL) - goto out; - - /* Does this window class belong to a 'watched' application ? */ - - app = g_hash_table_lookup(hdwm.watched_apps, - (gconstpointer)class_hint.res_name); - - /* FIXME: below checks are really uneeded assuming we trust new MB list prop - */ - wm_type_atom - = hd_wm_util_get_win_prop_data_and_validate (xid, - hdwm.atoms[HD_ATOM_NET_WM_WINDOW_TYPE], - XA_ATOM, - 32, - 0, - NULL); - if (!wm_type_atom) - { - Window trans_win; - Status result; - - /* Assume anything not setting there type is a TYPE_NORMAL. - * This is to support non EWMH 1980 style wins created by - * SDL, alegro etc. - */ - gdk_error_trap_push(); - - result = XGetTransientForHint(GDK_DISPLAY(), xid, &trans_win); - - /* If its transient for something, assume dialog and ignore. - * This should really never happen. - */ - if (gdk_error_trap_pop() || (result && trans_win != None)) - app = NULL; - goto out; - } - - /* Only care about desktop and app wins */ - if (wm_type_atom[0] != hdwm.atoms[HD_ATOM_NET_WM_WINDOW_TYPE_NORMAL] - && wm_type_atom[0] != hdwm.atoms[HD_ATOM_NET_WM_WINDOW_TYPE_DESKTOP]) - { - app = NULL; - XFree(wm_type_atom); - goto out; - } - - if(!app) - { - /* - * If we got this far and have no app, we are dealing with an application - * that did not provide a .desktop file; we are expected to provide - * rudimentary support, so we create a dummy app object. - * - * We do not add this app to the watchable app hash. - */ - - app = hd_wm_watchable_app_new_dummy (); - - g_debug (" ## Created dummy application for app without .desktop ##"); - } - - - XFree(wm_type_atom); - - out: - - if (class_hint.res_class) - XFree(class_hint.res_class); - - if (class_hint.res_name) - XFree(class_hint.res_name); - - return app; -} - /* various lookup functions. */ static gboolean @@ -692,7 +1083,7 @@ { HDWMWatchedWindow *win = NULL; - win = g_hash_table_find (hdwm.watched_windows, + win = g_hash_table_find (hdwmpriv->watched_windows, hd_wm_lookup_watched_window_via_service_find_func, (gpointer)service_name); @@ -700,7 +1091,7 @@ { /* Maybe its stored in our hibernating hash */ win - = g_hash_table_find (hdwm.watched_windows_hibernating, + = g_hash_table_find (hdwmpriv->watched_windows_hibernating, hd_wm_lookup_watched_window_via_service_find_func, (gpointer)service_name); } @@ -731,7 +1122,7 @@ HDWMWatchedWindow *win = NULL; win - = g_hash_table_find (hdwm.watched_windows, + = g_hash_table_find (hdwmpriv->watched_windows, hd_wm_lookup_watched_window_via_menu_widget_find_func, (gpointer)menu_widget); @@ -739,7 +1130,7 @@ { /* Maybe its stored in our hibernating hash */ - win = g_hash_table_find (hdwm.watched_windows_hibernating, + win = g_hash_table_find (hdwmpriv->watched_windows_hibernating, hd_wm_lookup_watched_window_via_menu_widget_find_func, (gpointer)menu_widget); } @@ -773,7 +1164,7 @@ HDWMWatchableApp* hd_wm_lookup_watchable_app_via_service (const gchar *service_name) { - return g_hash_table_find ( hdwm.watched_apps, + return g_hash_table_find ( hdwmpriv->watched_apps, hd_wm_lookup_watchable_app_via_service_find_func, (gpointer)service_name); } @@ -800,7 +1191,7 @@ HDWMWatchableApp * hd_wm_lookup_watchable_app_via_exec (const gchar *exec_name) { - return g_hash_table_find(hdwm.watched_apps, + return g_hash_table_find(hdwmpriv->watched_apps, hd_wm_lookup_watchable_app_via_exec_find_func, (gpointer)exec_name); } @@ -855,16 +1246,16 @@ { HDWMWatchedWindow *win; - win = g_hash_table_find ( hdwm.watched_windows, + win = g_hash_table_find ( hdwmpriv->watched_windows, hd_wm_lookup_watched_window_view_find_func, (gpointer)menu_widget); if (!win) { g_debug ("checking WatchedWindowsHibernating hash, has %i items", - g_hash_table_size (hdwm.watched_windows_hibernating)); + g_hash_table_size (hdwmpriv->watched_windows_hibernating)); - win = g_hash_table_find ( hdwm.watched_windows_hibernating, + win = g_hash_table_find ( hdwmpriv->watched_windows_hibernating, hd_wm_lookup_watched_window_view_find_func, (gpointer)menu_widget); } @@ -880,17 +1271,19 @@ { Window previous_app_xwin = 0; + HDWM *hdwm = hd_wm_get_singleton (); + HDWMWatchedWindow *win; Window *app_xwin; GList *views; g_debug ("called"); - if(hdwm.active_window) - previous_app_xwin = hd_wm_watched_window_get_x_win (hdwm.active_window); + if(hdwmpriv->active_window) + previous_app_xwin = hd_wm_watched_window_get_x_win (hdwmpriv->active_window); app_xwin = hd_wm_util_get_win_prop_data_and_validate (GDK_ROOT_WINDOW(), - hdwm.atoms[HD_ATOM_MB_CURRENT_APP_WINDOW], + hdwmpriv->atoms[HD_ATOM_MB_CURRENT_APP_WINDOW], XA_WINDOW, 32, 0, @@ -903,7 +1296,7 @@ previous_app_xwin = *app_xwin; - win = g_hash_table_lookup(hdwm.watched_windows, (gconstpointer)app_xwin); + win = g_hash_table_lookup(hdwmpriv->watched_windows, (gconstpointer)app_xwin); if (win) { @@ -917,7 +1310,7 @@ hd_wm_watchable_app_set_active_window(app, win); hd_wm_watchable_app_set_active_window(app, win); - hdwm.active_window = hdwm.last_active_window = win; + hdwmpriv->active_window = hdwmpriv->last_active_window = win; /* Note: this is whats grouping all views togeather */ views = hd_wm_watched_window_get_views (win); @@ -927,25 +1320,20 @@ for (l = views; l != NULL; l = l->next) { - /*HDWMWatchedWindowView *view = l->data; - HDEntryInfo *info = hd_wm_watched_window_view_get_info (view);*/ + HDWMWatchedWindowView *view = l->data; + HDEntryInfo *info = hd_wm_watched_window_view_get_info (view); - g_debug ("%s: %d, Here we notify changed stack to as",__FILE__,__LINE__); - /* - hn_app_switcher_changed_stack (hdwm.app_switcher, info); - */ - } + g_signal_emit_by_name (hdwm,"entry_info_stack_changed",info); + } } else { /* Window with no views */ g_debug ("Window 0x%x just became active", (int)win); - /*HDEntryInfo *info = hd_wm_watched_window_peek_info (win);*/ - - g_debug ("%s: %d, Here we notify changed stack to as",__FILE__,__LINE__); - /* - hn_app_switcher_changed_stack (hdwm.app_switcher, info); - */ + + HDEntryInfo *info = hd_wm_watched_window_peek_info (win); + + g_signal_emit_by_name (hdwm,"entry_info_stack_changed",info); } } else @@ -956,11 +1344,10 @@ */ HDEntryInfo * info = NULL; - /* = hn_app_switcher_get_home_entry_info (hdwm.app_switcher);*/ + /* = hn_app_switcher_get_home_entry_info (hdwmpriv->app_switcher);*/ if (info) - /*hn_app_switcher_changed_stack (hdwm.app_switcher, info);*/ - g_debug ("%s: %d, Here we try to get home entry and we notify changed stack to as",__FILE__,__LINE__); + g_signal_emit_by_name (hdwm,"entry_info_stack_changed",info); else g_debug ("***************** No Home info yet"); } @@ -974,6 +1361,7 @@ gpointer value, gpointer userdata) { + HDWM *hdwm = hd_wm_get_singleton (); HDWMWatchedWindow *win; struct xwinv *xwins; GdkWindow *gdk_win_wrapper = NULL; @@ -996,8 +1384,8 @@ /* the window is marked as hibernating, we move it to the hibernating * windows hash */ - HDWMWatchableApp * app; - HDEntryInfo * app_info = NULL; + HDWMWatchableApp *app; + HDEntryInfo *app_info = NULL; g_debug ("hibernating window [%s], moving to hibernating hash", hd_wm_watched_window_get_hibernation_key(win)); @@ -1014,10 +1402,9 @@ if (app) app_info = hd_wm_watchable_app_get_info (app); - /* - hn_app_switcher_changed (hdwm.app_switcher, app_info); - */ - g_debug ("%s: %d, Here we notify changes to as",__FILE__,__LINE__); + + + g_signal_emit_by_name (hdwm,"entry_info_changed",app_info); /* free the original hash key, since we are stealing */ g_free (key); @@ -1049,6 +1436,7 @@ { struct xwinv xwins; int i; + HDWM *hdwm = hd_wm_get_singleton (); /* FIXME: We (or MB!) should probably keep a copy of ordered window list * that way we can check against new list for changes before to save @@ -1061,7 +1449,7 @@ xwins.wins = hd_wm_util_get_win_prop_data_and_validate (GDK_ROOT_WINDOW(), - hdwm.atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING], + hdwmpriv->atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING], XA_WINDOW, 32, 0, @@ -1078,14 +1466,14 @@ * fact be hibernating, and we do not want to destroy those, see * client_list_steal_foreach_func () */ - g_hash_table_foreach_steal ( hdwm.watched_windows, + g_hash_table_foreach_steal ( hdwmpriv->watched_windows, client_list_steal_foreach_func, (gpointer)&xwins); /* Now add any new ones */ for (i=0; i < xwins.n_wins; i++) { - if (!g_hash_table_lookup(hdwm.watched_windows, + if (!g_hash_table_lookup(hdwmpriv->watched_windows, (gconstpointer)&xwins.wins[i])) { HDWMWatchedWindow *win; @@ -1137,12 +1525,7 @@ { info = hd_wm_watched_window_create_new_info (win); g_debug ("Adding AS entry for view-less window\n"); - - g_debug ("%s: %d, Here we add entry to as",__FILE__,__LINE__); - - /* - hn_app_switcher_add (hdwm.app_switcher, info); - */ + g_signal_emit_by_name (hdwm,"entry_info_added",info); } } } @@ -1195,10 +1578,10 @@ hd_wm_watched_window_set_gdk_wrapper_win (win, gdk_wrapper_win); - g_hash_table_insert (hdwm.watched_windows, key, (gpointer)win); + g_hash_table_insert (hdwmpriv->watched_windows, key, (gpointer)win); /* we also mark this as the active window */ - hdwm.active_window = hdwm.last_active_window = win; + hdwmpriv->active_window = hdwmpriv->last_active_window = win; hd_wm_watchable_app_set_active_window (hd_wm_watched_window_get_app (win), win); @@ -1219,10 +1602,10 @@ hd_wm_reset_focus () { - if(hdwm.has_focus) + if(hdwmpriv->has_focus) { g_debug ("Making TN unfocusable"); - hdwm.has_focus = FALSE; + hdwmpriv->has_focus = FALSE; g_debug ("%s: %d, set focus to tn to false",__FILE__,__LINE__); /*hn_window_set_focus (tasknav,FALSE);*/ } @@ -1232,9 +1615,9 @@ void hd_wm_focus_active_window () { - if(hdwm.active_window) + if(hdwmpriv->active_window) { - HDWMWatchableApp* app = hd_wm_watched_window_get_app(hdwm.active_window); + HDWMWatchableApp* app = hd_wm_watched_window_get_app(hdwmpriv->active_window); const gchar * service = hd_wm_watchable_app_get_service (app); hd_wm_top_service (service); } @@ -1261,7 +1644,7 @@ { case HD_TN_ACTIVATE_KEY_FOCUS: g_debug ("Making TN focusable"); - hdwm.has_focus = TRUE; + hdwmpriv->has_focus = TRUE; g_debug ("%s: %d, set focus to tn to true",__FILE__,__LINE__); /*hn_window_set_focus (tasknav,TRUE);*/ @@ -1269,7 +1652,7 @@ case HD_TN_DEACTIVATE_KEY_FOCUS: g_debug ("Making TN unfocusable"); - hdwm.has_focus = FALSE; + hdwmpriv->has_focus = FALSE; g_debug ("%s: %d, set focus to tn to false",__FILE__,__LINE__); /*hn_window_set_focus (tasknav,FALSE);*/ @@ -1278,14 +1661,13 @@ case HD_TN_ACTIVATE_MAIN_MENU: g_debug ("activating main menu"); - g_debug ("%s: %d, Here we toggle appswitcher's menu button",__FILE__,__LINE__); + g_debug ("%s: %d, hn_app_switcher_toggle_menu_button (hdwmpriv->app_switcher);",__FILE__,__LINE__); - /*hn_app_switcher_toggle_menu_button (hdwm.app_switcher);*/ return; case HD_TN_ACTIVATE_LAST_APP_WINDOW: g_debug ("passing focus to last active window"); - hdwm.has_focus = FALSE; + hdwmpriv->has_focus = FALSE; hd_wm_focus_active_window (); return; @@ -1307,14 +1689,14 @@ static gboolean hdwm_power_key_timeout (gpointer data) { - if (hdwm.shortcut != NULL && - hdwm.shortcut->action == HD_KEY_ACTION_POWER) + if (hdwmpriv->shortcut != NULL && + hdwmpriv->shortcut->action == HD_KEY_ACTION_POWER) { - hdwm.shortcut->action_func (hdwm.keys, GINT_TO_POINTER(TRUE)); - hdwm.shortcut = NULL; + hdwmpriv->shortcut->action_func (hdwmpriv->keys, GINT_TO_POINTER(TRUE)); + hdwmpriv->shortcut = NULL; } - hdwm.power_key_timeout = 0; + hdwmpriv->power_key_timeout = 0; return FALSE; } @@ -1334,7 +1716,7 @@ { XClientMessageEvent *cev = (XClientMessageEvent *)xevent; - if (cev->message_type == hdwm.atoms[HD_ATOM_HILDON_FROZEN_WINDOW]) + if (cev->message_type == hdwmpriv->atoms[HD_ATOM_HILDON_FROZEN_WINDOW]) { Window xwin_hung; gboolean has_reawoken; @@ -1345,7 +1727,7 @@ g_debug ("@@@@ FROZEN: Window %li status %i @@@@", xwin_hung, has_reawoken); - win = g_hash_table_lookup(hdwm.watched_windows, + win = g_hash_table_lookup(hdwmpriv->watched_windows, &xwin_hung); if ( win ) { @@ -1357,7 +1739,7 @@ } } - else if (cev->message_type == hdwm.atoms[HD_ATOM_HILDON_TN_ACTIVATE]) + else if (cev->message_type == hdwmpriv->atoms[HD_ATOM_HILDON_TN_ACTIVATE]) { g_debug ("_HILDON_TN_ACTIVATE: %d", (int)cev->data.l[0]); hd_wm_activate(cev->data.l[0]); @@ -1368,13 +1750,13 @@ if (((XEvent*)xevent)->type == KeyPress) { XKeyEvent *kev = (XKeyEvent *)xevent; - hdwm.shortcut = hd_keys_handle_keypress (hdwm.keys, kev->keycode, kev->state); + hdwmpriv->shortcut = hd_keys_handle_keypress (hdwmpriv->keys, kev->keycode, kev->state); - if (hdwm.shortcut != NULL && - hdwm.shortcut->action == HD_KEY_ACTION_POWER && - !hdwm.power_key_timeout) + if (hdwmpriv->shortcut != NULL && + hdwmpriv->shortcut->action == HD_KEY_ACTION_POWER && + !hdwmpriv->power_key_timeout) { - hdwm.power_key_timeout = g_timeout_add + hdwmpriv->power_key_timeout = g_timeout_add (HILDON_WINDOW_LONG_PRESS_TIME, hdwm_power_key_timeout, NULL); } @@ -1383,17 +1765,17 @@ } else if (((XEvent*)xevent)->type == KeyRelease) { - if (hdwm.power_key_timeout) + if (hdwmpriv->power_key_timeout) { - g_source_remove (hdwm.power_key_timeout); - hdwm.power_key_timeout = 0; + g_source_remove (hdwmpriv->power_key_timeout); + hdwmpriv->power_key_timeout = 0; } - if (hdwm.shortcut != NULL) + if (hdwmpriv->shortcut != NULL) { if (!hd_wm_modal_windows_present()) - hdwm.shortcut->action_func (hdwm.keys, hdwm.shortcut->action_func_data); - hdwm.shortcut = NULL; + hdwmpriv->shortcut->action_func (hdwmpriv->keys, hdwmpriv->shortcut->action_func_data); + hdwmpriv->shortcut = NULL; } return GDK_FILTER_CONTINUE; } @@ -1408,21 +1790,21 @@ if (G_LIKELY(prop->window == GDK_ROOT_WINDOW())) { - if (prop->atom == hdwm.atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING]) + if (prop->atom == hdwmpriv->atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING]) { hd_wm_process_x_client_list(); } - else if (prop->atom == hdwm.atoms[HD_ATOM_MB_CURRENT_APP_WINDOW]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_MB_CURRENT_APP_WINDOW]) { hd_wm_process_mb_current_app_window (); } - else if (prop->atom == hdwm.atoms[HD_ATOM_NET_SHOWING_DESKTOP]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP]) { int *desktop_state; desktop_state = hd_wm_util_get_win_prop_data_and_validate (GDK_WINDOW_XID(gdk_get_default_root_window()), - hdwm.atoms[HD_ATOM_NET_SHOWING_DESKTOP], + hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP], XA_CARDINAL, 32, 1, @@ -1431,13 +1813,13 @@ { if (desktop_state[0] == 1) { - hdwm.active_window = NULL; + hdwmpriv->active_window = NULL; } XFree(desktop_state); } } - else if (prop->atom == hdwm.atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT]) { g_debug ("Received MODAL WINDOWS notification"); @@ -1446,7 +1828,7 @@ value = hd_wm_util_get_win_prop_data_and_validate ( GDK_WINDOW_XID(gdk_get_default_root_window()), - hdwm.atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT], + hdwmpriv->atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT], XA_CARDINAL, 32, 1, @@ -1454,8 +1836,8 @@ if (value) { - hdwm.modal_windows = *value; - g_debug ("value = %d", hdwm.modal_windows); + hdwmpriv->modal_windows = *value; + g_debug ("value = %d", hdwmpriv->modal_windows); XFree(value); } } @@ -1469,60 +1851,60 @@ * lookup. FIXME: hmmm.. */ - if ( prop->atom == hdwm.atoms[HD_ATOM_WM_NAME] - || prop->atom == hdwm.atoms[HD_ATOM_WM_STATE] - || prop->atom == hdwm.atoms[HD_ATOM_HILDON_VIEW_LIST] - || prop->atom == hdwm.atoms[HD_ATOM_HILDON_VIEW_ACTIVE] - || prop->atom == hdwm.atoms[HD_ATOM_HILDON_APP_KILLABLE] - || prop->atom == hdwm.atoms[HD_ATOM_HILDON_ABLE_TO_HIBERNATE] - || prop->atom == hdwm.atoms[HD_ATOM_NET_WM_STATE] - || prop->atom == hdwm.atoms[HD_ATOM_WM_HINTS] - || prop->atom == hdwm.atoms[HD_ATOM_NET_WM_ICON] - || prop->atom == hdwm.atoms[HD_ATOM_MB_WIN_SUB_NAME] - || prop->atom == hdwm.atoms[HD_ATOM_NET_WM_NAME] - || prop->atom == hdwm.atoms[HD_ATOM_WM_WINDOW_ROLE]) + if ( prop->atom == hdwmpriv->atoms[HD_ATOM_WM_NAME] + || prop->atom == hdwmpriv->atoms[HD_ATOM_WM_STATE] + || prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_LIST] + || prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE] + || prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_APP_KILLABLE] + || prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_ABLE_TO_HIBERNATE] + || prop->atom == hdwmpriv->atoms[HD_ATOM_NET_WM_STATE] + || prop->atom == hdwmpriv->atoms[HD_ATOM_WM_HINTS] + || prop->atom == hdwmpriv->atoms[HD_ATOM_NET_WM_ICON] + || prop->atom == hdwmpriv->atoms[HD_ATOM_MB_WIN_SUB_NAME] + || prop->atom == hdwmpriv->atoms[HD_ATOM_NET_WM_NAME] + || prop->atom == hdwmpriv->atoms[HD_ATOM_WM_WINDOW_ROLE]) { - win = g_hash_table_lookup(hdwm.watched_windows, + win = g_hash_table_lookup(hdwmpriv->watched_windows, (gconstpointer)&prop->window); } if (!win) return GDK_FILTER_CONTINUE; - if (prop->atom == hdwm.atoms[HD_ATOM_WM_NAME] - || prop->atom == hdwm.atoms[HD_ATOM_MB_WIN_SUB_NAME] - || prop->atom == hdwm.atoms[HD_ATOM_NET_WM_NAME]) + if (prop->atom == hdwmpriv->atoms[HD_ATOM_WM_NAME] + || prop->atom == hdwmpriv->atoms[HD_ATOM_MB_WIN_SUB_NAME] + || prop->atom == hdwmpriv->atoms[HD_ATOM_NET_WM_NAME]) { hd_wm_watched_window_props_sync (win, HD_WM_SYNC_NAME); } - else if (prop->atom == hdwm.atoms[HD_ATOM_WM_STATE]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_WM_STATE]) { hd_wm_watched_window_props_sync (win, HD_WM_SYNC_WM_STATE); } - else if (prop->atom == hdwm.atoms[HD_ATOM_NET_WM_ICON]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_NET_WM_ICON]) { hd_wm_watched_window_props_sync (win, HD_WM_SYNC_ICON); } - else if (prop->atom == hdwm.atoms[HD_ATOM_HILDON_VIEW_ACTIVE]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE]) { hd_wm_watched_window_props_sync (win, HD_WM_SYNC_HILDON_VIEW_ACTIVE); } - else if (prop->atom == hdwm.atoms[HD_ATOM_WM_HINTS]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_WM_HINTS]) { hd_wm_watched_window_props_sync (win, HD_WM_SYNC_WMHINTS); } - else if (prop->atom == hdwm.atoms[HD_ATOM_HILDON_VIEW_LIST]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_LIST]) { hd_wm_watched_window_props_sync (win, HD_WM_SYNC_HILDON_VIEW_LIST); } - else if (prop->atom == hdwm.atoms[HD_ATOM_WM_WINDOW_ROLE]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_WM_WINDOW_ROLE]) { /* Windows realy shouldn't do this... */ hd_wm_watched_window_props_sync (win, HD_WM_SYNC_WINDOW_ROLE); } - else if (prop->atom == hdwm.atoms[HD_ATOM_HILDON_APP_KILLABLE] - || prop->atom == hdwm.atoms[HD_ATOM_HILDON_ABLE_TO_HIBERNATE]) + else if (prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_APP_KILLABLE] + || prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_ABLE_TO_HIBERNATE]) { HDWMWatchableApp *app; @@ -1596,133 +1978,8 @@ /* DBus related callbacks */ -static DBusHandlerResult -hd_wm_dbus_method_call_handler (DBusConnection *connection, - DBusMessage *message, - void *data ) -{ - const gchar *path; - /* Catch APP_LAUNCH_BANNER_METHOD */ - if (dbus_message_is_method_call (message, - APP_LAUNCH_BANNER_METHOD_INTERFACE, - APP_LAUNCH_BANNER_METHOD ) ) - { - DBusError error; - gchar *service_name = NULL; - HDWMWatchableApp *app; - - dbus_error_init (&error); - - dbus_message_get_args (message, - &error, - DBUS_TYPE_STRING, - &service_name, - DBUS_TYPE_INVALID ); - if (dbus_error_is_set (&error)) - { - osso_log(LOG_WARNING, "Error getting message args: %s\n", - error.message); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - - g_return_val_if_fail (service_name, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - - g_debug ("Checking if service: '%s' is watchable", service_name); - - /* Is this 'service' watchable ? */ - if ((app = hd_wm_lookup_watchable_app_via_service (service_name)) != NULL) - { - if (hd_wm_watchable_app_has_startup_notify (app) - && hdwm.lowmem_banner_timeout > 0 - && !hd_wm_watchable_app_has_windows (app)) - { - g_debug ("Showing Launchbanner..."); - /* - * This function takes care of the distinction between the Loading - * and Resuming banners, hence we no longer test for hibernation - */ - hd_wm_watchable_app_launch_banner_show (app); - } - } - } - - path = dbus_message_get_path(message); - if (path != NULL && g_str_equal(path, TASKNAV_GENERAL_PATH)) - { - const gchar * interface = dbus_message_get_interface(message); - if (g_str_equal(interface, TASKNAV_SENSITIVE_INTERFACE)) - { - g_debug ("%s: %d, set sensitiveness to tn to true",__FILE__,__LINE__); - /* hn_window_set_sensitive (tasknav,TRUE); */ - return DBUS_HANDLER_RESULT_HANDLED; - } - else if (g_str_equal(interface, TASKNAV_INSENSITIVE_INTERFACE)) - { - g_debug ("%s: %d, set sensitiveness to tn to false",__FILE__,__LINE__); - /* hn_window_set_sensitive (tasknav,TRUE); */ - return DBUS_HANDLER_RESULT_HANDLED; - } - } - - - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static DBusHandlerResult -hd_wm_dbus_signal_handler(DBusConnection *conn, DBusMessage *msg, void *data) -{ - if (dbus_message_is_signal(msg, MAEMO_LAUNCHER_SIGNAL_IFACE, - APP_DIED_SIGNAL_NAME)) - { - DBusError err; - gchar *filename; - int pid; - int status; - HDWMWatchableApp *app; - - - dbus_error_init(&err); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &filename, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &status, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) - { - osso_log(LOG_WARNING, "Error getting message args: %s\n", - err.message); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - g_debug ("Checking if filename: '%s' is watchable pid='%i' status='%i'", - filename, pid, status); - - /* Is this 'filename' watchable ? */ - app = hd_wm_lookup_watchable_app_via_exec(filename); - if (app) - { - g_debug ("Showing app died dialog ..."); - hd_wm_watchable_app_died_dialog_show(app); - } - return DBUS_HANDLER_RESULT_HANDLED; - } - - if (dbus_message_is_signal(msg, APPKILLER_SIGNAL_INTERFACE, - APPKILLER_SIGNAL_NAME)) - { - hd_wm_memory_kill_all_watched(FALSE); - return DBUS_HANDLER_RESULT_HANDLED; - } - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - struct _cb_steal_data { GHashTable *apps; @@ -1798,10 +2055,11 @@ static gboolean hd_wm_dnotify_process () { + HDWM *hdwm = hd_wm_get_singleton (); GHashTable * new_apps; struct _cb_steal_data std; - hdwm.dnotify_timeout_id = 0; + hdwmpriv->dnotify_timeout_id = 0; /* reread all .desktop files and compare each agains existing apps; add any * new ones, updated existing ones @@ -1809,16 +2067,16 @@ * This is quite involved, so we will take a shortcut if we can */ - if(!g_hash_table_size(hdwm.watched_windows) && - !g_hash_table_size(hdwm.watched_windows_hibernating)) + if(!g_hash_table_size(hdwmpriv->watched_windows) && + !g_hash_table_size(hdwmpriv->watched_windows_hibernating)) { /* * we have no watched windows, i.e., no references to the apps, so we can * just replace the old apps with the new ones */ g_debug ("Have no watched windows -- reinitialising watched apps"); - g_hash_table_destroy(hdwm.watched_apps); - hdwm.watched_apps = hd_wm_watchable_apps_init(); + g_hash_table_destroy(hdwmpriv->watched_apps); + hdwmpriv->watched_apps = hd_wm_watchable_apps_init(); return FALSE; } @@ -1830,30 +2088,26 @@ * first we iterate the old hash, looking for any apps that no longer * exist in the new one */ - g_hash_table_foreach_remove(hdwm.watched_apps, + g_hash_table_foreach_remove(hdwmpriv->watched_apps, dnotify_hash_table_foreach_remove_func, new_apps); /* * then we do updates on what is left in the old hash */ - std.apps = hdwm.watched_apps; + std.apps = hdwmpriv->watched_apps; std.update = FALSE; g_hash_table_foreach_steal(new_apps, dnotify_hash_table_foreach_steal_func, &std); - if(std.update) - { - g_debug ("Some apps updated -- notifying AS"); + if (std.update) + { + g_debug ("Some apps updated -- notifying AS"); + g_signal_emit_by_name (hdwm,"entry_info_changed",NULL); + } - g_debug ("%s: %d, Here we notify changes to as",__FILE__,__LINE__); - /* - hn_app_switcher_changed (hdwm.app_switcher, NULL); - */ - } - /* whatever is left in the new_apps hash, we are not interested in */ g_hash_table_destroy(new_apps); @@ -1862,57 +2116,8 @@ -static int -hd_wm_osso_kill_method(GArray *arguments, gpointer data) -{ - gchar *appname = NULL, *operation = NULL; - HDWMWatchedWindow *win = NULL; - HDWMWatchableApp *app; - if (arguments->len < 1) - return 1; - operation = (gchar *)g_array_index(arguments, osso_rpc_t, 0).value.s; - - /* In this case, HN will kill every process that has supposedly - * statesaved - */ - - if (operation == NULL) - return 1; - - if (strcmp(operation, "lru") == 0) - { - return hd_wm_memory_kill_lru(); - } - else if (strcmp(operation, "all") == 0) - { - return hd_wm_memory_kill_all_watched(TRUE); - } - else if (strcmp(operation, "app") != 0 || (arguments->len < 2) ) - { - return 1; - } - - /* Kill a certain application */ - - appname = (gchar *)g_array_index(arguments, osso_rpc_t, 1).value.s; - - if (appname == NULL) - return 1; - - win = hd_wm_lookup_watched_window_via_service (appname); - app = hd_wm_watched_window_get_app (win); - - if (win) - { - if (hd_wm_watchable_app_is_able_to_hibernate (app)) - hd_wm_watched_window_attempt_signal_kill (win, SIGTERM, TRUE); - } - - return 0; -} - /* FIXME -- this function does nothing */ static gboolean hd_wm_relaunch_timeout(gpointer data) @@ -1989,7 +2194,7 @@ gdk_error_trap_push(); role = hd_wm_util_get_win_prop_data_and_validate (xwin, - hdwm.atoms[HD_ATOM_WM_WINDOW_ROLE], + hdwmpriv->atoms[HD_ATOM_WM_WINDOW_ROLE], XA_STRING, 8, 0, @@ -2008,7 +2213,8 @@ return hibernation_key; } - +/* TODO: Move this out!, leftover from appswitcher */ +#if 0 static void hd_wm_lowmem_cb (HDAppSwitcher *app_switcher, gboolean is_on, @@ -2024,197 +2230,60 @@ { hd_wm_memory_bgkill_func (is_on); } +#endif -gboolean -hd_wm_init (HDAppSwitcher *as) +HDWM * +hd_wm_get_singleton (void) { - DBusConnection *connection; - DBusError error; - gchar *match_rule = NULL; - GdkKeymap *keymap; - - memset(&hdwm, 0, sizeof(hdwm)); + static HDWM *hdwm = NULL; - osso_manager_t *osso_man = osso_manager_singleton_get_instance(); + if (!hdwm) + hdwm = g_object_new (HD_TYPE_WM, NULL); - /*hdwm.app_switcher = as;*/ + return hdwm; +} - /* Check for configurable lowmem values. */ - hdwm.lowmem_min_distance - = hd_wm_util_getenv_long (LOWMEM_LAUNCH_THRESHOLD_DISTANCE_ENV, - LOWMEM_LAUNCH_THRESHOLD_DISTANCE); - hdwm.lowmem_banner_timeout - = hd_wm_util_getenv_long (LOWMEM_LAUNCH_BANNER_TIMEOUT_ENV, - LOWMEM_LAUNCH_BANNER_TIMEOUT); - - /* Guard about insensibly long values. */ - if (hdwm.lowmem_banner_timeout > LOWMEM_LAUNCH_BANNER_TIMEOUT_MAX) - hdwm.lowmem_banner_timeout = LOWMEM_LAUNCH_BANNER_TIMEOUT_MAX; - - hdwm.lowmem_timeout_multiplier - = hd_wm_util_getenv_long (LOWMEM_TIMEOUT_MULTIPLIER_ENV, - LOWMEM_TIMEOUT_MULTIPLIER); - - /* Various app switcher callbacks */ -#if 0 - application_switcher_set_dnotify_handler (as, &hd_wm_dnotify_func); - application_switcher_set_shutdown_handler (as, &hd_wm_shutdown_func); - application_switcher_set_lowmem_handler (as, &hd_wm_memory_lowmem_func); - application_switcher_set_bgkill_handler (as, &hd_wm_memory_bgkill_func); -#endif - g_signal_connect (as, "lowmem", G_CALLBACK (hd_wm_lowmem_cb), NULL); - g_signal_connect (as, "bgkill", G_CALLBACK (hd_wm_bgkill_cb), NULL); - - /* build our hash of watchable apps via .desktop key/values */ - - hdwm.watched_apps = hd_wm_watchable_apps_init (); - - /* Initialize the common X atoms */ - - hd_wm_atoms_init(); - - /* Hash to track watched windows */ - - hdwm.watched_windows - = g_hash_table_new_full (g_int_hash, - g_int_equal, - (GDestroyNotify)g_free, - (GDestroyNotify)hd_wm_watched_window_destroy); - - /* Hash for windows that dont really still exists but HN makes them appear - * as they do - they are basically backgrounded. - */ - hdwm.watched_windows_hibernating - = g_hash_table_new_full (g_str_hash, - g_str_equal, - (GDestroyNotify)g_free, - (GDestroyNotify)hd_wm_watched_window_destroy); - - gdk_error_trap_push(); - - /* select X events */ - - gdk_window_set_events(gdk_get_default_root_window(), - gdk_window_get_events(gdk_get_default_root_window()) - | GDK_PROPERTY_CHANGE_MASK ); - - gdk_window_add_filter(gdk_get_default_root_window(), - hd_wm_x_event_filter, - NULL); - - gdk_error_trap_pop(); - - /* Setup shortcuts */ - - hdwm.keys = hd_keys_init (); - - /* Track changes in the keymap */ - - keymap = gdk_keymap_get_default (); - g_signal_connect (G_OBJECT (keymap), "keys-changed", - G_CALLBACK (hd_keys_reload), hdwm.keys); - - /* Get on the DBus */ - - dbus_error_init (&error); - - connection = dbus_bus_get( DBUS_BUS_SESSION, &error ); - - if (!connection ) - { - osso_log(LOG_ERR, "Failed to connect to DBUS: %s!\n", error.message ); - dbus_error_free( &error ); - } - else - { - /* Match rule */ - - match_rule = g_strdup_printf("interface='%s'", - APP_LAUNCH_BANNER_METHOD_INTERFACE ); - - dbus_bus_add_match( connection, match_rule, NULL ); - - g_free (match_rule); - - match_rule = g_strdup_printf( - "type='signal', interface='%s'", - APPKILLER_SIGNAL_INTERFACE); - - dbus_bus_add_match( connection, match_rule, NULL ); - dbus_connection_add_filter(connection, hd_wm_dbus_signal_handler, - NULL, NULL); - g_free(match_rule); - - match_rule = g_strdup_printf("interface='%s'", - TASKNAV_INSENSITIVE_INTERFACE ); - - dbus_bus_add_match( connection, match_rule, NULL ); - - dbus_connection_add_filter( connection, hd_wm_dbus_method_call_handler, - /* model */ NULL, NULL ); - g_free(match_rule); - - /* Setup match rule for Maemo Launcher */ - match_rule = g_strdup_printf("type='signal', interface='%s'", - MAEMO_LAUNCHER_SIGNAL_IFACE); - - dbus_bus_add_match(connection, match_rule, NULL); - dbus_connection_add_filter(connection, hd_wm_dbus_signal_handler, - NULL, NULL); - g_free(match_rule); - - dbus_connection_flush(connection); - - /* Add the com.nokia.tasknav callbacks - FIXME: what are these for ? */ - add_method_cb(osso_man, KILL_APPS_METHOD, - &hd_wm_osso_kill_method, osso_man); - - } - - return TRUE; -} - Atom hd_wm_get_atom(gint indx) { - return hdwm.atoms[indx]; + return hdwmpriv->atoms[indx]; } GHashTable * hd_wm_get_watched_windows(void) { - return hdwm.watched_windows; + return hdwmpriv->watched_windows; } GHashTable * hd_wm_get_hibernating_windows(void) { - return hdwm.watched_windows_hibernating; + return hdwmpriv->watched_windows_hibernating; } gboolean hd_wm_is_lowmem_situation(void) { - return hdwm.lowmem_situation; + return hdwmpriv->lowmem_situation; } void hd_wm_set_lowmem_situation(gboolean b) { - hdwm.lowmem_situation = b; + hdwmpriv->lowmem_situation = b; } gboolean hd_wm_is_bg_kill_situation(void) { - return hdwm.bg_kill_situation; + return hdwmpriv->bg_kill_situation; } void hd_wm_set_bg_kill_situation(gboolean b) { - hdwm.bg_kill_situation = b; + hdwmpriv->bg_kill_situation = b; } HDAppSwitcher * @@ -2226,56 +2295,56 @@ gint hd_wm_get_timer_id(void) { - return hdwm.timer_id; + return hdwmpriv->timer_id; } void hd_wm_set_timer_id(gint id) { - hdwm.timer_id = id; + hdwmpriv->timer_id = id; } void hd_wm_set_about_to_shutdown(gboolean b) { - hdwm.about_to_shutdown = b; + hdwmpriv->about_to_shutdown = b; } gboolean hd_wm_get_about_to_shutdown(void) { - return hdwm.about_to_shutdown; + return hdwmpriv->about_to_shutdown; } GList * hd_wm_get_banner_stack(void) { - return hdwm.banner_stack; + return hdwmpriv->banner_stack; } void hd_wm_set_banner_stack(GList * l) { - hdwm.banner_stack = l; + hdwmpriv->banner_stack = l; } gulong hd_wm_get_lowmem_banner_timeout(void) { - return hdwm.lowmem_banner_timeout; + return hdwmpriv->lowmem_banner_timeout; } gulong hd_wm_get_lowmem_timeout_multiplier(void) { - return hdwm.lowmem_timeout_multiplier; + return hdwmpriv->lowmem_timeout_multiplier; } HDWMWatchedWindow * hd_wm_get_active_window(void) { - return hdwm.active_window; + return hdwmpriv->active_window; } /* @@ -2284,41 +2353,41 @@ void hd_wm_reset_active_window(void) { - hdwm.active_window = NULL; + hdwmpriv->active_window = NULL; } HDWMWatchedWindow * hd_wm_get_last_active_window(void) { - return hdwm.last_active_window; + return hdwmpriv->last_active_window; } gboolean hd_wm_modal_windows_present(void) { - return hdwm.modal_windows; + return hdwmpriv->modal_windows; } void hd_wm_reset_last_active_window(void) { - hdwm.last_active_window = NULL; + hdwmpriv->last_active_window = NULL; } gboolean hd_wm_fullscreen_mode () { - if(hdwm.active_window) + if(hdwmpriv->active_window) { Atom *wm_type_atom; - Window xid = hd_wm_watched_window_get_x_win (hdwm.active_window); + Window xid = hd_wm_watched_window_get_x_win (hdwmpriv->active_window); gdk_error_trap_push(); wm_type_atom = hd_wm_util_get_win_prop_data_and_validate (xid, - hdwm.atoms[HD_ATOM_NET_WM_STATE_FULLSCREEN], + hdwmpriv->atoms[HD_ATOM_NET_WM_STATE_FULLSCREEN], XA_ATOM, 32, 0, @@ -2343,9 +2412,9 @@ static void hd_wm_dnotify_cb ( char *path, void * data) { - if( !hdwm.dnotify_timeout_id ) + if (!hdwmpriv->dnotify_timeout_id) { - hdwm.dnotify_timeout_id = + hdwmpriv->dnotify_timeout_id = g_timeout_add(1000, (GSourceFunc)hd_wm_dnotify_process, NULL); @@ -2358,9 +2427,7 @@ void hd_wm_dnotify_register () { - if(hildon_dnotify_set_cb((hildon_dnotify_cb_f *)hd_wm_dnotify_cb, - DESKTOPENTRYDIR, - NULL) != HILDON_OK) + if (hildon_dnotify_set_cb ((hildon_dnotify_cb_f *)hd_wm_dnotify_cb,DESKTOPENTRYDIR,NULL) != HILDON_OK) { g_warning("unable to register TN callback for %s", DESKTOPENTRYDIR); Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h 2006-11-23 15:54:10 UTC (rev 8288) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h 2006-11-23 16:11:43 UTC (rev 8289) @@ -113,6 +113,35 @@ #define TN_DEFAULT_FOCUS FALSE #endif +#define HD_TYPE_WM (hd_wm_get_type ()) +#define HD_WM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HD_TYPE_WM, HDWM)) +#define HD_WM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HD_TYPE_WM, HDWMClass)) +#define HD_IS_WM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HD_TYPE_WM)) +#define HD_IS_WM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HD_TYPE_WM)) +#define HD_WM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HD_TYPE_WM, HDWMClass)) + +typedef struct _HDWM HDWM; +typedef struct _HDWMClass HDWMClass; +typedef struct _HDWMPrivate HDWMPrivate; + +struct _HDWM +{ + GObject parent; + + HDWMPrivate *priv; +}; + +struct _HDWMClass +{ + GObjectClass parent_class; + + void (*entry_info_added) (HDWM *hdwm,HDEntryInfo *info); + void (*entry_info_removed) (HDWM *hdwm,HDEntryInfo *info); + void (*entry_info_changed) (HDWM *hdwm,HDEntryInfo *info); + void (*entry_info_stack_changed) (HDWM *hdwm,HDEntryInfo *info); + /* */ +}; + typedef struct { gpointer entry_ptr; @@ -131,6 +160,12 @@ HDWMWatchableApp *app; }; +GType +hd_wm_get_type (void); + +HDWM * +hd_wm_get_singleton (void); + /** Send 'top' request for a certain existing window/view * * @param info the window/view to be topped @@ -176,9 +211,6 @@ hd_wm_compute_watched_window_hibernation_key (Window xwin, HDWMWatchableApp *app); -gboolean -hd_wm_init (HDAppSwitcher *as); - void hd_wm_dnotify_register (void); Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c 2006-11-23 15:54:10 UTC (rev 8288) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c 2006-11-23 16:11:43 UTC (rev 8289) @@ -1,12 +1,28 @@ #include <libhildonwm/hd-wm.h> +void +generic_callback (HDWM *hdwm, HDEntryInfo *info, gpointer data) +{ + g_debug ("ACTION: %s app name: %s",hd_entry_info_peek_app_name (info),data); +} + int main (int argc, char **argv) { gtk_init (&argc,&argv); - hd_wm_init (NULL); + HDWM *wm = hd_wm_get_singleton (); + g_signal_connect (G_OBJECT (wm), + "entry_info_changed", + G_CALLBACK (generic_callback), + g_strdup ("info changed")); + + g_signal_connect (G_OBJECT (wm), + "entry_info_added", + G_CALLBACK (generic_callback), + g_strdup ("info added")); + gtk_main (); return 0;
- Previous message: [maemo-commits] r8288 - in projects/haf/trunk/dbus/debian: . patches
- Next message: [maemo-commits] r8290 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . data libhildondesktop src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]