[maemo-commits] [maemo-commits] r8316 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildonwm
From: www-data at stage.maemo.org www-data at stage.maemo.orgDate: Fri Nov 24 18:41:19 EET 2006
- Previous message: [maemo-commits] r8315 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r8317 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildonwm test
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2006-11-24 18:41:18 +0200 (Fri, 24 Nov 2006) New Revision: 8316 Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 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/plugin_manager Log: * libhildonwm/hd-wm.[ch]: Moved to a more consistent GObject behavior. * plugin_manager added notes. * ChangeLog updated. Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-11-24 11:50:46 UTC (rev 8315) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-11-24 16:41:18 UTC (rev 8316) @@ -1,5 +1,9 @@ 2006-11-23 Moises Martinez <moises.martinzes at nokia.com> + * libhildonwm/hd-wm.[ch]: Moved to a more consistent GObject behavior. + +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 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-24 11:50:46 UTC (rev 8315) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c 2006-11-24 16:41:18 UTC (rev 8316) @@ -95,16 +95,16 @@ hd_wm_watchable_apps_init (void); static HDWMWatchableApp* -hd_wm_x_window_is_watchable (Window xid); +hd_wm_x_window_is_watchable (HDWM *hdwm, Window xid); static void -hd_wm_reset_focus (void); +hd_wm_reset_focus (HDWM *hdwm); static void -hd_wm_process_x_client_list (void); +hd_wm_process_x_client_list (HDWM *hdwm); static gboolean -hd_wm_relaunch_timeout(gpointer data); +hd_wm_relaunch_timeout (gpointer data); struct xwinv { @@ -174,7 +174,7 @@ hd_wm_add_watched_window (HDWMWatchedWindow *win); static void -hd_wm_atoms_init() +hd_wm_atoms_init (HDWM *hdwm) { /* * The list below *MUST* be kept in the same order as the corresponding @@ -231,11 +231,11 @@ atom_names, HD_ATOM_COUNT, False, - hdwmpriv->atoms); + hdwm->priv->atoms); } static HDWMWatchableApp* -hd_wm_x_window_is_watchable (Window xid) +hd_wm_x_window_is_watchable (HDWM *hdwm, Window xid) { HDWMWatchableApp *app; XClassHint class_hint; @@ -255,14 +255,14 @@ /* Does this window class belong to a 'watched' application ? */ - app = g_hash_table_lookup(hdwmpriv->watched_apps, + app = g_hash_table_lookup(hdwm->priv->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], + hdwm->priv->atoms[HD_ATOM_NET_WM_WINDOW_TYPE], XA_ATOM, 32, 0, @@ -278,7 +278,7 @@ */ gdk_error_trap_push(); - result = XGetTransientForHint(GDK_DISPLAY(), xid, &trans_win); + result = XGetTransientForHint (GDK_DISPLAY(), xid, &trans_win); /* If its transient for something, assume dialog and ignore. * This should really never happen. @@ -289,33 +289,32 @@ } /* 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 (wm_type_atom[0] != hdwm->priv->atoms[HD_ATOM_NET_WM_WINDOW_TYPE_NORMAL] + && wm_type_atom[0] != hdwm->priv->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. - */ + 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 (); + app = hd_wm_watchable_app_new_dummy (); - g_debug (" ## Created dummy application for app without .desktop ##"); - } + g_debug (" ## Created dummy application for app without .desktop ##"); + } - XFree(wm_type_atom); - out: +out: if (class_hint.res_class) XFree(class_hint.res_class); @@ -332,73 +331,72 @@ void *data ) { const gchar *path; + HDWM *hdwm = HD_WM (data); /* 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; + { + DBusError error; + gchar *service_name = NULL; + HDWMWatchableApp *app; - dbus_error_init (&error); + dbus_error_init (&error); - dbus_message_get_args (message, - &error, - DBUS_TYPE_STRING, - &service_name, - DBUS_TYPE_INVALID ); + 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; - } + 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_return_val_if_fail (service_name, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - g_debug ("Checking if service: '%s' is watchable", service_name); + 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); - } - } + /* 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->priv->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)) { - 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; - } + 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; } @@ -454,7 +452,7 @@ } static int -hd_wm_osso_kill_method(GArray *arguments, gpointer data) +hd_wm_osso_kill_method (GArray *arguments, gpointer data) { gchar *appname = NULL, *operation = NULL; HDWMWatchedWindow *win = NULL; @@ -563,7 +561,7 @@ osso_manager_t *osso_man = osso_manager_singleton_get_instance(); - /*hdwmpriv->app_switcher = as;*/ + /*hdwm->priv->app_switcher = as;*/ /* Check for configurable lowmem values. */ @@ -598,7 +596,7 @@ /* Initialize the common X atoms */ - hd_wm_atoms_init(); + hd_wm_atoms_init (hdwm); /* Hash to track watched windows */ @@ -617,17 +615,17 @@ (GDestroyNotify)g_free, (GDestroyNotify)hd_wm_watched_window_destroy); - gdk_error_trap_push(); + gdk_error_trap_push (); /* select X events */ - gdk_window_set_events(gdk_get_default_root_window(), + 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); + hdwm); gdk_error_trap_pop(); @@ -648,55 +646,47 @@ 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 */ - match_rule = g_strdup_printf("interface='%s'", + match_rule = g_strdup_printf("interface='%s'", APP_LAUNCH_BANNER_METHOD_INTERFACE ); - dbus_bus_add_match( connection, match_rule, NULL ); + dbus_bus_add_match( connection, match_rule, NULL ); + g_free (match_rule); - g_free (match_rule); - - match_rule = g_strdup_printf( - "type='signal', interface='%s'", - APPKILLER_SIGNAL_INTERFACE); + 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); + 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 ); + match_rule = g_strdup_printf("interface='%s'", TASKNAV_INSENSITIVE_INTERFACE ); - dbus_bus_add_match( connection, match_rule, NULL ); + 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); + 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); + 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, + dbus_bus_add_match(connection, match_rule, NULL); + dbus_connection_add_filter(connection, hd_wm_dbus_signal_handler, NULL, NULL); - g_free(match_rule); + g_free(match_rule); - dbus_connection_flush(connection); + 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); + add_method_cb(osso_man, KILL_APPS_METHOD, &hd_wm_osso_kill_method, osso_man); - } + } } void @@ -705,103 +695,106 @@ HDWMWatchedWindow *win = NULL; HDWMWatchableApp *app; gboolean single_view = FALSE; + HDWM *hdwm = hd_wm_get_singleton (); - hd_wm_reset_focus(); + hd_wm_reset_focus (hdwm); if (info->type == HD_ENTRY_WATCHED_APP) - { - app = hd_entry_info_get_app (info); + { + app = hd_entry_info_get_app (info); - g_debug ("Found app: '%s'", - hd_wm_watchable_app_get_name (app)); + g_debug ("Found app: '%s'", hd_wm_watchable_app_get_name (app)); - hd_wm_top_service (hd_wm_watchable_app_get_service (app)); - return; - } + hd_wm_top_service (hd_wm_watchable_app_get_service (app)); + return; + } if (info->type == HD_ENTRY_WATCHED_VIEW) - { - HDWMWatchedWindowView *view = hd_entry_info_get_view (info); - win = hd_wm_watched_window_view_get_parent (view); - app = hd_wm_watched_window_get_app (win); - single_view = (hd_wm_watched_window_get_n_views(win) == 1); + { + HDWMWatchedWindowView *view = hd_entry_info_get_view (info); + win = hd_wm_watched_window_view_get_parent (view); + app = hd_wm_watched_window_get_app (win); + single_view = (hd_wm_watched_window_get_n_views(win) == 1); - if (app && hd_wm_watchable_app_is_hibernating(app)) - { - g_debug ("Window hibernating, calling hd_wm_top_service\n"); - hd_wm_watched_window_set_active_view(win, view); - hd_wm_top_service (hd_wm_watchable_app_get_service (app)); - return; - } + if (app && hd_wm_watchable_app_is_hibernating(app)) + { + g_debug ("Window hibernating, calling hd_wm_top_service\n"); + hd_wm_watched_window_set_active_view(win, view); + hd_wm_top_service (hd_wm_watchable_app_get_service (app)); + return; + } - g_debug ("Sending hildon activate message\n"); + g_debug ("Sending hildon activate message\n"); - hd_wm_util_send_x_message (hd_wm_watched_window_view_get_id (view), - hd_wm_watched_window_get_x_win (win), - hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE], - SubstructureRedirectMask | SubstructureNotifyMask, - 0, - 0, - 0, - 0, - 0); + hd_wm_util_send_x_message (hd_wm_watched_window_view_get_id (view), + hd_wm_watched_window_get_x_win (win), + hdwm->priv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE], + SubstructureRedirectMask | SubstructureNotifyMask, + 0, + 0, + 0, + 0, + 0); - if(!single_view) - return; - } + if (!single_view) + return; + } if (info->type == HD_ENTRY_WATCHED_WINDOW || single_view) - { - XEvent ev; + { + XEvent ev; - win = hd_entry_info_get_window (info); - app = hd_wm_watched_window_get_app (win); + win = hd_entry_info_get_window (info); + app = hd_wm_watched_window_get_app (win); - g_debug ("Found window without views: '%s'\n", - hd_wm_watched_window_get_name (win)); + g_debug ("Found window without views: '%s'\n", hd_wm_watched_window_get_name (win)); - if (app) - { - if (hd_wm_watched_window_is_hibernating (win)) - { - g_debug ("Window hibernating, calling hd_wm_top_service\n"); + if (app) + { + if (hd_wm_watched_window_is_hibernating (win)) + { + g_debug ("Window hibernating, calling hd_wm_top_service\n"); - /* make sure we top the window user requested */ - hd_wm_watchable_app_set_active_window(app, win); - hd_wm_top_service (hd_wm_watchable_app_get_service (app)); + /* make sure we top the window user requested */ + hd_wm_watchable_app_set_active_window(app, win); + hd_wm_top_service (hd_wm_watchable_app_get_service (app)); - return; - } - } + return; + } + } - g_debug ("toping non view window (%li) via _NET_ACTIVE_WINDOW message", + g_debug ("toping non view window (%li) via _NET_ACTIVE_WINDOW message", hd_wm_watched_window_get_x_win (win)); - /* FIXME: hd_wm_util_send_x_message() should be used here but wont - * work! - */ - memset (&ev, 0, sizeof (ev)); + /* FIXME: hd_wm_util_send_x_message() should be used here but wont + * work! + */ + memset (&ev, 0, sizeof (ev)); - ev.xclient.type = ClientMessage; - ev.xclient.window = hd_wm_watched_window_get_x_win (win); - ev.xclient.message_type = hdwmpriv->atoms[HD_ATOM_NET_ACTIVE_WINDOW]; - ev.xclient.format = 32; + ev.xclient.type = ClientMessage; + ev.xclient.window = hd_wm_watched_window_get_x_win (win); + ev.xclient.message_type = hdwm->priv->atoms[HD_ATOM_NET_ACTIVE_WINDOW]; + ev.xclient.format = 32; - gdk_error_trap_push (); - XSendEvent (GDK_DISPLAY(), - GDK_ROOT_WINDOW(), False, - SubstructureRedirectMask, &ev); - XSync (GDK_DISPLAY(),FALSE); - gdk_error_trap_pop(); + gdk_error_trap_push (); + + XSendEvent (GDK_DISPLAY(), + GDK_ROOT_WINDOW(), False, + SubstructureRedirectMask, &ev); + + XSync (GDK_DISPLAY(),FALSE); + + gdk_error_trap_pop(); - } + } else g_debug ("### Invalid window type ###\n"); } gboolean -hd_wm_top_service(const gchar *service_name) +hd_wm_top_service (const gchar *service_name) { + HDWM *hdwm = hd_wm_get_singleton (); osso_manager_t *osso_man; HDWMWatchedWindow *win; guint pages_used = 0, pages_available = 0; @@ -809,33 +802,29 @@ g_debug (" Called with '%s'", service_name); if (service_name == NULL) - { - osso_log(LOG_ERR, "There was no service name!\n"); - return FALSE; - } + { + osso_log(LOG_ERR, "There was no service name!\n"); + return FALSE; + } - hd_wm_reset_focus(); + hd_wm_reset_focus (hdwm); win = hd_wm_lookup_watched_window_via_service (service_name); if (hd_wm_is_lowmem_situation() || - (pages_available > 0 && pages_available < hdwmpriv->lowmem_min_distance)) - { - gboolean killed = TRUE; - if (win == NULL) - { - g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_OPENING);",__FILE__,__LINE__); - } - else if (hd_wm_watched_window_is_hibernating(win)) - { - g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_SWITCHING);",__FILE__,__LINE__); - } + (pages_available > 0 && pages_available < hdwm->priv->lowmem_min_distance)) + { + gboolean killed = TRUE; + + if (win == NULL) + g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_OPENING);",__FILE__,__LINE__); + else + if (hd_wm_watched_window_is_hibernating(win)) + g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_SWITCHING);",__FILE__,__LINE__); - if (!killed) - { - return FALSE; - } - } + if (!killed) + return FALSE; + } /* Check how much memory we do have until the lowmem threshold */ @@ -849,140 +838,126 @@ * This code is not removed to preserve the configurability as fallback * for non-lowmem situtations */ - if (pages_available > 0 && pages_available < hdwmpriv->lowmem_min_distance) - { + if (pages_available > 0 && pages_available < hdwm->priv->lowmem_min_distance) + { - gboolean killed = TRUE; - if (win == NULL) - { - g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_OPENING);",__FILE__,__LINE__); - } - else if (hd_wm_watched_window_is_hibernating(win)) - { - g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_SWITCHING);",__FILE__,__LINE__); - } + gboolean killed = TRUE; - if (!killed) - { - return FALSE; - } - } + if (win == NULL) + g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_OPENING);",__FILE__,__LINE__); + else + if (hd_wm_watched_window_is_hibernating (win)) + g_debug ("%s: %d, killed = tn_close_application_dialog(CAD_ACTION_SWITCHING);",__FILE__,__LINE__); + if (!killed) + return FALSE; + } + if (win == NULL) - { + { /* We dont have a watched window for this service currently * so just launch it. */ - g_debug ("unable to find service name '%s' in running wins", service_name); - g_debug ("Thus launcing via osso_manager_launch()"); - osso_man = osso_manager_singleton_get_instance(); - osso_manager_launch(osso_man, service_name, NULL); - return TRUE; - - } + g_debug ("unable to find service name '%s' in running wins", service_name); + g_debug ("Thus launcing via osso_manager_launch()"); + osso_man = osso_manager_singleton_get_instance(); + osso_manager_launch(osso_man, service_name, NULL); + return TRUE; + } else - { - HDWMWatchableApp *app; - HDWMWatchedWindowView *view = NULL; + { + HDWMWatchableApp *app; + HDWMWatchedWindowView *view = NULL; - app = hd_wm_watched_window_get_app (win); + app = hd_wm_watched_window_get_app (win); - /* set active view before we attempt to waken up hibernating app */ - if (hd_wm_watched_window_get_views (win)) - { - view = hd_wm_watched_window_get_active_view(win); + /* set active view before we attempt to waken up hibernating app */ + if (hd_wm_watched_window_get_views (win)) + { + view = hd_wm_watched_window_get_active_view(win); - if (!view) /* There is no active so just grab the first one */ - { - view = (HDWMWatchedWindowView *)((hd_wm_watched_window_get_views (win))->data); - g_debug ("Window does not have active view !!!"); - hd_wm_watched_window_set_active_view(win, view); - } - else - g_debug ("Active view [%s]", - hd_wm_watched_window_view_get_name(view)); + if (!view) /* There is no active so just grab the first one */ + { + view = (HDWMWatchedWindowView *)((hd_wm_watched_window_get_views (win))->data); + g_debug ("Window does not have active view !!!"); + hd_wm_watched_window_set_active_view(win, view); + } + else + g_debug ("Active view [%s]", hd_wm_watched_window_view_get_name(view)); - } - if (hd_wm_watched_window_is_hibernating(win)) - { - guint interval = LAUNCH_SUCCESS_TIMEOUT * 1000; - HDWMWatchedWindow * active_win - = hd_wm_watchable_app_get_active_window(app); + { + guint interval = LAUNCH_SUCCESS_TIMEOUT * 1000; + HDWMWatchedWindow * active_win = hd_wm_watchable_app_get_active_window(app); - g_debug ("app is hibernating, attempting to reawaken" + g_debug ("app is hibernating, attempting to reawaken" "via osso_manager_launch()"); - if (active_win) - { + if (active_win) hd_wm_watched_window_awake (active_win); - } - else + else { /* we do not know which was the active window, so just launch it */ hd_wm_watchable_app_set_launching (app, TRUE); osso_man = osso_manager_singleton_get_instance(); - osso_manager_launch(osso_man, hd_wm_watchable_app_get_service (app), - RESTORED); - + osso_manager_launch (osso_man, hd_wm_watchable_app_get_service (app),RESTORED); } /* we add a timeout allowing us to check the application started, since we need to display a banner if it did not */ - g_debug ("adding launch_timeout() callback"); - g_timeout_add( interval, - hd_wm_relaunch_timeout, - (gpointer) g_strdup(service_name)); - return TRUE; - } + g_debug ("adding launch_timeout() callback"); + g_timeout_add( interval, hd_wm_relaunch_timeout,(gpointer) g_strdup(service_name)); + return TRUE; + } - g_debug ("sending x message to activate app"); + g_debug ("sending x message to activate app"); if (view) - { - hd_wm_util_send_x_message (hd_wm_watched_window_view_get_id (view), - hd_wm_watched_window_get_x_win (win), - hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE], - SubstructureRedirectMask - |SubstructureNotifyMask, - 0, - 0, - 0, - 0, - 0); - } + { + hd_wm_util_send_x_message (hd_wm_watched_window_view_get_id (view), + hd_wm_watched_window_get_x_win (win), + hdwm->priv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE], + SubstructureRedirectMask | SubstructureNotifyMask, + 0, + 0, + 0, + 0, + 0); + } else - { - /* Regular or grouped win, get MB to top */ - XEvent ev; - HDWMWatchedWindow *active_win = hd_wm_watchable_app_get_active_window(app); + { + /* Regular or grouped win, get MB to top */ + XEvent ev; + HDWMWatchedWindow *active_win = hd_wm_watchable_app_get_active_window(app); - memset(&ev, 0, sizeof(ev)); + memset(&ev, 0, sizeof(ev)); - g_debug ("@@@@ Last active window %s\n", - active_win ? hd_wm_watched_window_get_hibernation_key(active_win) : "none"); + g_debug ("@@@@ Last active window %s\n", + active_win ? hd_wm_watched_window_get_hibernation_key(active_win) : "none"); - ev.xclient.type = ClientMessage; - ev.xclient.window = hd_wm_watched_window_get_x_win (active_win ? active_win : win); - ev.xclient.message_type = hdwmpriv->atoms[HD_ATOM_NET_ACTIVE_WINDOW]; - ev.xclient.format = 32; + ev.xclient.type = ClientMessage; + ev.xclient.window = hd_wm_watched_window_get_x_win (active_win ? active_win : win); + ev.xclient.message_type = hdwm->priv->atoms[HD_ATOM_NET_ACTIVE_WINDOW]; + ev.xclient.format = 32; - gdk_error_trap_push(); - XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), False, - SubstructureRedirectMask, &ev); - XSync(GDK_DISPLAY(),FALSE); - gdk_error_trap_pop(); + gdk_error_trap_push(); - /* - * do not call hd_wm_watchable_app_set_active_window() from here -- this - * is only a request; we set the window only when it becomes active in - * hd_wm_process_mb_current_app_window() - */ - } + XSendEvent (GDK_DISPLAY (), GDK_ROOT_WINDOW(), False, SubstructureRedirectMask, &ev); + + XSync (GDK_DISPLAY (),FALSE); + + gdk_error_trap_pop(); + /* + * do not call hd_wm_watchable_app_set_active_window() from here -- this + * is only a request; we set the window only when it becomes active in + * hd_wm_process_mb_current_app_window() + */ + } } + } return TRUE; } @@ -991,46 +966,45 @@ hd_wm_toggle_desktop (void) { int *desktop_state; + HDWM *hdwm = hd_wm_get_singleton (); - desktop_state = hd_wm_util_get_win_prop_data_and_validate ( - GDK_WINDOW_XID(gdk_get_default_root_window()), - hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP], - XA_CARDINAL, - 32, - 1, - NULL); + desktop_state = + hd_wm_util_get_win_prop_data_and_validate (GDK_WINDOW_XID (gdk_get_default_root_window()), + hdwm->priv->atoms[HD_ATOM_NET_SHOWING_DESKTOP], + XA_CARDINAL, + 32, + 1, + NULL); if (desktop_state) + { + if (desktop_state[0] == 1 && hdwm->priv->last_active_window) { - if (desktop_state[0] == 1 && hdwmpriv->last_active_window) - { - HDWMWatchableApp* app = - 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); - } - else - { - hd_wm_top_desktop(); - } - - XFree(desktop_state); + HDWMWatchableApp* app = hd_wm_watched_window_get_app(hdwm->priv->last_active_window); + const gchar * service = hd_wm_watchable_app_get_service (app); + + hd_wm_top_service (service); } + else + hd_wm_top_desktop (); + + XFree (desktop_state); + } } void hd_wm_top_desktop(void) { XEvent ev; + HDWM *hdwm = hd_wm_get_singleton (); - hd_wm_reset_focus(); + hd_wm_reset_focus (hdwm); memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = GDK_ROOT_WINDOW(); - ev.xclient.message_type = hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP]; + ev.xclient.message_type = hdwm->priv->atoms[HD_ATOM_NET_SHOWING_DESKTOP]; ev.xclient.format = 32; ev.xclient.data.l[0] = 1; @@ -1046,11 +1020,10 @@ * created, so that resetting it there means active_window remain NULL and * this breaks the AS menu focus. */ - hdwmpriv->active_window = NULL; + hdwm->priv->active_window = NULL; } - /* various lookup functions. */ static gboolean @@ -1081,9 +1054,10 @@ HDWMWatchedWindow* hd_wm_lookup_watched_window_via_service (const gchar *service_name) { + HDWM *hdwm = hd_wm_get_singleton (); HDWMWatchedWindow *win = NULL; - win = g_hash_table_find (hdwmpriv->watched_windows, + win = g_hash_table_find (hdwm->priv->watched_windows, hd_wm_lookup_watched_window_via_service_find_func, (gpointer)service_name); @@ -1091,7 +1065,7 @@ { /* Maybe its stored in our hibernating hash */ win - = g_hash_table_find (hdwmpriv->watched_windows_hibernating, + = g_hash_table_find (hdwm->priv->watched_windows_hibernating, hd_wm_lookup_watched_window_via_service_find_func, (gpointer)service_name); } @@ -1122,7 +1096,7 @@ HDWMWatchedWindow *win = NULL; win - = g_hash_table_find (hdwmpriv->watched_windows, + = g_hash_table_find (hdwm->priv->watched_windows, hd_wm_lookup_watched_window_via_menu_widget_find_func, (gpointer)menu_widget); @@ -1130,7 +1104,7 @@ { /* Maybe its stored in our hibernating hash */ - win = g_hash_table_find (hdwmpriv->watched_windows_hibernating, + win = g_hash_table_find (hdwm->priv->watched_windows_hibernating, hd_wm_lookup_watched_window_via_menu_widget_find_func, (gpointer)menu_widget); } @@ -1164,7 +1138,9 @@ HDWMWatchableApp* hd_wm_lookup_watchable_app_via_service (const gchar *service_name) { - return g_hash_table_find ( hdwmpriv->watched_apps, + HDWM *hdwm = hd_wm_get_singleton (); + + return g_hash_table_find ( hdwm->priv->watched_apps, hd_wm_lookup_watchable_app_via_service_find_func, (gpointer)service_name); } @@ -1191,7 +1167,9 @@ HDWMWatchableApp * hd_wm_lookup_watchable_app_via_exec (const gchar *exec_name) { - return g_hash_table_find(hdwmpriv->watched_apps, + HDWM *hdwm = hd_wm_get_singleton (); + + return g_hash_table_find(hdwm->priv->watched_apps, hd_wm_lookup_watchable_app_via_exec_find_func, (gpointer)exec_name); } @@ -1227,16 +1205,16 @@ iter = hd_wm_watched_window_get_views (win); while (iter != NULL) - { - HDWMWatchedWindowView *view; + { + HDWMWatchedWindowView *view; - view = (HDWMWatchedWindowView *)iter->data; + view = (HDWMWatchedWindowView *)iter->data; - if (hd_wm_watched_window_view_get_menu (view) == (GtkWidget*)user_data) - return TRUE; + if (hd_wm_watched_window_view_get_menu (view) == (GtkWidget*)user_data) + return TRUE; - iter = g_list_next(iter); - } + iter = g_list_next (iter); + } return FALSE; } @@ -1245,45 +1223,43 @@ hd_wm_lookup_watched_window_view (GtkWidget *menu_widget) { HDWMWatchedWindow *win; + HDWM *hdwm = hd_wm_get_singleton (); - win = g_hash_table_find ( hdwmpriv->watched_windows, + win = g_hash_table_find ( hdwm->priv->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 (hdwmpriv->watched_windows_hibernating)); + { + g_debug ("checking WatchedWindowsHibernating hash, has %i items", + g_hash_table_size (hdwm->priv->watched_windows_hibernating)); - win = g_hash_table_find ( hdwmpriv->watched_windows_hibernating, - hd_wm_lookup_watched_window_view_find_func, - (gpointer)menu_widget); - } + win = g_hash_table_find (hdwm->priv->watched_windows_hibernating, + hd_wm_lookup_watched_window_view_find_func, + (gpointer)menu_widget); + } return win; } - /* Root win property changes */ static void -hd_wm_process_mb_current_app_window (void) +hd_wm_process_mb_current_app_window (HDWM *hdwm) { Window previous_app_xwin = 0; - HDWM *hdwm = hd_wm_get_singleton (); - HDWMWatchedWindow *win; Window *app_xwin; GList *views; g_debug ("called"); - if(hdwmpriv->active_window) - previous_app_xwin = hd_wm_watched_window_get_x_win (hdwmpriv->active_window); + if(hdwm->priv->active_window) + previous_app_xwin = hd_wm_watched_window_get_x_win (hdwm->priv->active_window); app_xwin = hd_wm_util_get_win_prop_data_and_validate (GDK_ROOT_WINDOW(), - hdwmpriv->atoms[HD_ATOM_MB_CURRENT_APP_WINDOW], + hdwm->priv->atoms[HD_ATOM_MB_CURRENT_APP_WINDOW], XA_WINDOW, 32, 0, @@ -1296,7 +1272,7 @@ previous_app_xwin = *app_xwin; - win = g_hash_table_lookup(hdwmpriv->watched_windows, (gconstpointer)app_xwin); + win = g_hash_table_lookup(hdwm->priv->watched_windows, (gconstpointer)app_xwin); if (win) { @@ -1310,7 +1286,7 @@ hd_wm_watchable_app_set_active_window(app, win); hd_wm_watchable_app_set_active_window(app, win); - hdwmpriv->active_window = hdwmpriv->last_active_window = win; + hdwm->priv->active_window = hdwm->priv->last_active_window = win; /* Note: this is whats grouping all views togeather */ views = hd_wm_watched_window_get_views (win); @@ -1344,7 +1320,7 @@ */ HDEntryInfo * info = NULL; - /* = hn_app_switcher_get_home_entry_info (hdwmpriv->app_switcher);*/ + /* = hn_app_switcher_get_home_entry_info (hdwm->priv->app_switcher);*/ if (info) g_signal_emit_by_name (hdwm,"entry_info_stack_changed",info); @@ -1422,7 +1398,7 @@ if (gdk_win_wrapper) gdk_window_remove_filter (gdk_win_wrapper, hd_wm_x_event_filter, - NULL); + hdwm); hd_wm_watched_window_destroy (win); g_free (key); @@ -1432,11 +1408,10 @@ } static void -hd_wm_process_x_client_list(void) +hd_wm_process_x_client_list (HDWM *hdwm) { 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 @@ -1449,7 +1424,7 @@ xwins.wins = hd_wm_util_get_win_prop_data_and_validate (GDK_ROOT_WINDOW(), - hdwmpriv->atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING], + hdwm->priv->atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING], XA_WINDOW, 32, 0, @@ -1466,14 +1441,14 @@ * fact be hibernating, and we do not want to destroy those, see * client_list_steal_foreach_func () */ - g_hash_table_foreach_steal ( hdwmpriv->watched_windows, + g_hash_table_foreach_steal ( hdwm->priv->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(hdwmpriv->watched_windows, + if (!g_hash_table_lookup(hdwm->priv->watched_windows, (gconstpointer)&xwins.wins[i])) { HDWMWatchedWindow *win; @@ -1482,7 +1457,7 @@ /* We've found a window thats listed but not currently watched. * Check if it is watchable by us */ - app = hd_wm_x_window_is_watchable (xwins.wins[i]); + app = hd_wm_x_window_is_watchable (hdwm, xwins.wins[i]); if (!app) continue; @@ -1540,6 +1515,7 @@ { GdkWindow *gdk_wrapper_win = NULL; gint *key; + HDWM *hdwm = hd_wm_get_singleton (); key = g_new0 (gint, 1); @@ -1553,23 +1529,23 @@ gdk_wrapper_win = gdk_window_foreign_new (*key); if (gdk_wrapper_win != NULL) - { - XWindowAttributes attributes; + { + XWindowAttributes attributes; - XGetWindowAttributes (GDK_DISPLAY (), - GDK_WINDOW_XID (gdk_wrapper_win), - &attributes); + XGetWindowAttributes (GDK_DISPLAY (), + GDK_WINDOW_XID (gdk_wrapper_win), + &attributes); - XSelectInput (GDK_DISPLAY (), - GDK_WINDOW_XID (gdk_wrapper_win), - attributes.your_event_mask - | StructureNotifyMask - | PropertyChangeMask); + XSelectInput (GDK_DISPLAY (), + GDK_WINDOW_XID (gdk_wrapper_win), + attributes.your_event_mask | + StructureNotifyMask | + PropertyChangeMask); - gdk_window_add_filter (gdk_wrapper_win, - hd_wm_x_event_filter, - NULL); - } + gdk_window_add_filter (gdk_wrapper_win, + hd_wm_x_event_filter, + hdwm); + } XSync (GDK_DISPLAY(), False); /* FIXME: Check above does not sync */ @@ -1578,10 +1554,10 @@ hd_wm_watched_window_set_gdk_wrapper_win (win, gdk_wrapper_win); - g_hash_table_insert (hdwmpriv->watched_windows, key, (gpointer)win); + g_hash_table_insert (hdwm->priv->watched_windows, key, (gpointer)win); /* we also mark this as the active window */ - hdwmpriv->active_window = hdwmpriv->last_active_window = win; + hdwm->priv->active_window = hdwm->priv->last_active_window = win; hd_wm_watchable_app_set_active_window (hd_wm_watched_window_get_app (win), win); @@ -1599,38 +1575,38 @@ } static void -hd_wm_reset_focus () +hd_wm_reset_focus (HDWM *hdwm) { - if(hdwmpriv->has_focus) - { - g_debug ("Making TN unfocusable"); - hdwmpriv->has_focus = FALSE; - g_debug ("%s: %d, set focus to tn to false",__FILE__,__LINE__); - /*hn_window_set_focus (tasknav,FALSE);*/ - } -}; + if (hdwm->priv->has_focus) + { + g_debug ("Making TN unfocusable"); + hdwm->priv->has_focus = FALSE; + g_debug ("%s: %d, hn_window_set_focus (tasknav,FALSE);",__FILE__,__LINE__); + } +} - void -hd_wm_focus_active_window () +hd_wm_focus_active_window (HDWM *hdwm) { - if(hdwmpriv->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); - } + + if (hdwm->priv->active_window) + { + HDWMWatchableApp* app = hd_wm_watched_window_get_app(hdwm->priv->active_window); + const gchar * service = hd_wm_watchable_app_get_service (app); + + hd_wm_top_service (service); + } else - { - hd_wm_top_desktop(); - } + hd_wm_top_desktop(); + } void hd_wm_activate(guint32 what) { /*GtkWidget * button = NULL;*/ + HDWM *hdwm = hd_wm_get_singleton (); g_debug ("received request %d", what); @@ -1644,7 +1620,7 @@ { case HD_TN_ACTIVATE_KEY_FOCUS: g_debug ("Making TN focusable"); - hdwmpriv->has_focus = TRUE; + hdwm->priv->has_focus = TRUE; g_debug ("%s: %d, set focus to tn to true",__FILE__,__LINE__); /*hn_window_set_focus (tasknav,TRUE);*/ @@ -1652,7 +1628,7 @@ case HD_TN_DEACTIVATE_KEY_FOCUS: g_debug ("Making TN unfocusable"); - hdwmpriv->has_focus = FALSE; + hdwm->priv->has_focus = FALSE; g_debug ("%s: %d, set focus to tn to false",__FILE__,__LINE__); /*hn_window_set_focus (tasknav,FALSE);*/ @@ -1661,14 +1637,14 @@ case HD_TN_ACTIVATE_MAIN_MENU: g_debug ("activating main menu"); - g_debug ("%s: %d, hn_app_switcher_toggle_menu_button (hdwmpriv->app_switcher);",__FILE__,__LINE__); + g_debug ("%s: %d, hn_app_switcher_toggle_menu_button (hdwm->priv->app_switcher);",__FILE__,__LINE__); return; case HD_TN_ACTIVATE_LAST_APP_WINDOW: g_debug ("passing focus to last active window"); - hdwmpriv->has_focus = FALSE; - hd_wm_focus_active_window (); + hdwm->priv->has_focus = FALSE; + hd_wm_focus_active_window (hdwm); return; default: @@ -1689,14 +1665,16 @@ static gboolean hdwm_power_key_timeout (gpointer data) { - if (hdwmpriv->shortcut != NULL && - hdwmpriv->shortcut->action == HD_KEY_ACTION_POWER) - { - hdwmpriv->shortcut->action_func (hdwmpriv->keys, GINT_TO_POINTER(TRUE)); - hdwmpriv->shortcut = NULL; - } + HDWM *hdwm = HD_WM (data); + + if (hdwm->priv->shortcut != NULL && + hdwm->priv->shortcut->action == HD_KEY_ACTION_POWER) + { + hdwm->priv->shortcut->action_func (hdwm->priv->keys, GINT_TO_POINTER(TRUE)); + hdwm->priv->shortcut = NULL; + } - hdwmpriv->power_key_timeout = 0; + hdwm->priv->power_key_timeout = 0; return FALSE; } @@ -1709,76 +1687,77 @@ { XPropertyEvent *prop; HDWMWatchedWindow *win = NULL; + HDWM *hdwm = HD_WM (data); /* Handle client messages */ if (((XEvent*)xevent)->type == ClientMessage) + { + XClientMessageEvent *cev = (XClientMessageEvent *)xevent; + + if (cev->message_type == hdwm->priv->atoms[HD_ATOM_HILDON_FROZEN_WINDOW]) { - XClientMessageEvent *cev = (XClientMessageEvent *)xevent; + Window xwin_hung; + gboolean has_reawoken; - if (cev->message_type == hdwmpriv->atoms[HD_ATOM_HILDON_FROZEN_WINDOW]) - { - Window xwin_hung; - gboolean has_reawoken; + xwin_hung = (Window)cev->data.l[0]; + has_reawoken = (gboolean)cev->data.l[1]; - xwin_hung = (Window)cev->data.l[0]; - has_reawoken = (gboolean)cev->data.l[1]; + g_debug ("@@@@ FROZEN: Window %li status %i @@@@", xwin_hung, has_reawoken); - g_debug ("@@@@ FROZEN: Window %li status %i @@@@", - xwin_hung, has_reawoken); + win = g_hash_table_lookup (hdwm->priv->watched_windows, &xwin_hung); - win = g_hash_table_lookup(hdwmpriv->watched_windows, - &xwin_hung); - - if ( win ) { - if ( has_reawoken == TRUE ) { - hd_wm_ping_timeout_cancel( win ); - } else { - hd_wm_ping_timeout( win ); - } - } - - } - else if (cev->message_type == hdwmpriv->atoms[HD_ATOM_HILDON_TN_ACTIVATE]) - { + if (win) + { + if ( has_reawoken == TRUE ) + hd_wm_ping_timeout_cancel (win); + else + hd_wm_ping_timeout (win); + } + else + if (cev->message_type == hdwm->priv->atoms[HD_ATOM_HILDON_TN_ACTIVATE]) + { g_debug ("_HILDON_TN_ACTIVATE: %d", (int)cev->data.l[0]); - hd_wm_activate(cev->data.l[0]); - } + hd_wm_activate (cev->data.l[0]); + } + return GDK_FILTER_CONTINUE; } - + } + else if (((XEvent*)xevent)->type == KeyPress) - { - XKeyEvent *kev = (XKeyEvent *)xevent; - hdwmpriv->shortcut = hd_keys_handle_keypress (hdwmpriv->keys, kev->keycode, kev->state); + { + XKeyEvent *kev = (XKeyEvent *)xevent; + hdwm->priv->shortcut = hd_keys_handle_keypress (hdwm->priv->keys, kev->keycode, kev->state); - if (hdwmpriv->shortcut != NULL && - hdwmpriv->shortcut->action == HD_KEY_ACTION_POWER && - !hdwmpriv->power_key_timeout) - { - hdwmpriv->power_key_timeout = g_timeout_add - (HILDON_WINDOW_LONG_PRESS_TIME, - hdwm_power_key_timeout, NULL); - } - - return GDK_FILTER_CONTINUE; + if (hdwm->priv->shortcut != NULL && + hdwm->priv->shortcut->action == HD_KEY_ACTION_POWER && + !hdwm->priv->power_key_timeout) + { + hdwm->priv->power_key_timeout = + g_timeout_add (HILDON_WINDOW_LONG_PRESS_TIME,hdwm_power_key_timeout, hdwm); } - else if (((XEvent*)xevent)->type == KeyRelease) + + return GDK_FILTER_CONTINUE; + } + else + if (((XEvent*)xevent)->type == KeyRelease) + { + if (hdwm->priv->power_key_timeout) { - if (hdwmpriv->power_key_timeout) - { - g_source_remove (hdwmpriv->power_key_timeout); - hdwmpriv->power_key_timeout = 0; - } + g_source_remove (hdwm->priv->power_key_timeout); + hdwm->priv->power_key_timeout = 0; + } - if (hdwmpriv->shortcut != NULL) - { - if (!hd_wm_modal_windows_present()) - hdwmpriv->shortcut->action_func (hdwmpriv->keys, hdwmpriv->shortcut->action_func_data); - hdwmpriv->shortcut = NULL; - } - return GDK_FILTER_CONTINUE; + if (hdwm->priv->shortcut != NULL) + { + if (!hd_wm_modal_windows_present()) + hdwm->priv->shortcut->action_func (hdwm->priv->keys, hdwm->priv->shortcut->action_func_data); + + hdwm->priv->shortcut = NULL; } + return GDK_FILTER_CONTINUE; + } /* If this isn't a property change event ignore ASAP */ if (((XEvent*)xevent)->type != PropertyNotify) @@ -1789,61 +1768,57 @@ /* Root window property change */ if (G_LIKELY(prop->window == GDK_ROOT_WINDOW())) + { + if (prop->atom == hdwm->priv->atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING]) + hd_wm_process_x_client_list (hdwm); + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_MB_CURRENT_APP_WINDOW]) + hd_wm_process_mb_current_app_window (hdwm); + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_NET_SHOWING_DESKTOP]) { - if (prop->atom == hdwmpriv->atoms[HD_ATOM_MB_APP_WINDOW_LIST_STACKING]) - { - hd_wm_process_x_client_list(); - } - else if (prop->atom == hdwmpriv->atoms[HD_ATOM_MB_CURRENT_APP_WINDOW]) - { - hd_wm_process_mb_current_app_window (); - } - else if (prop->atom == hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP]) - { - int *desktop_state; + int *desktop_state; - desktop_state = - hd_wm_util_get_win_prop_data_and_validate (GDK_WINDOW_XID(gdk_get_default_root_window()), - hdwmpriv->atoms[HD_ATOM_NET_SHOWING_DESKTOP], - XA_CARDINAL, - 32, - 1, - NULL); - if (desktop_state) - { - if (desktop_state[0] == 1) - { - hdwmpriv->active_window = NULL; - } + desktop_state = + hd_wm_util_get_win_prop_data_and_validate (GDK_WINDOW_XID (gdk_get_default_root_window()), + hdwm->priv->atoms[HD_ATOM_NET_SHOWING_DESKTOP], + XA_CARDINAL, + 32, + 1, + NULL); + if (desktop_state) + { + if (desktop_state[0] == 1) + hdwm->priv->active_window = NULL; - XFree(desktop_state); - } - } - else if (prop->atom == hdwmpriv->atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT]) - { - g_debug ("Received MODAL WINDOWS notification"); + XFree(desktop_state); + } + } + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT]) + { + g_debug ("Received MODAL WINDOWS notification"); - int * value; + int *value; - value = - hd_wm_util_get_win_prop_data_and_validate ( - GDK_WINDOW_XID(gdk_get_default_root_window()), - hdwmpriv->atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT], - XA_CARDINAL, - 32, - 1, - NULL); + value = + hd_wm_util_get_win_prop_data_and_validate (GDK_WINDOW_XID(gdk_get_default_root_window()), + hdwm->priv->atoms[HD_ATOM_MB_NUM_MODAL_WINDOWS_PRESENT], + XA_CARDINAL, + 32, + 1, + NULL); - if (value) - { - hdwmpriv->modal_windows = *value; - g_debug ("value = %d", hdwmpriv->modal_windows); - XFree(value); - } - } + if (value) + { + hdwm->priv->modal_windows = *value; + g_debug ("value = %d", hdwm->priv->modal_windows); + XFree(value); + } } + } else /* Non root win prop change */ - { + { /* Hopefully one of our watched windows changing a prop.. * * Check if its an atom were actually interested in @@ -1851,77 +1826,66 @@ * lookup. FIXME: hmmm.. */ - 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]) + if (prop->atom == hdwm->priv->atoms[HD_ATOM_WM_NAME] + || prop->atom == hdwm->priv->atoms[HD_ATOM_WM_STATE] + || prop->atom == hdwm->priv->atoms[HD_ATOM_HILDON_VIEW_LIST] + || prop->atom == hdwm->priv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE] + || prop->atom == hdwm->priv->atoms[HD_ATOM_HILDON_APP_KILLABLE] + || prop->atom == hdwm->priv->atoms[HD_ATOM_HILDON_ABLE_TO_HIBERNATE] + || prop->atom == hdwm->priv->atoms[HD_ATOM_NET_WM_STATE] + || prop->atom == hdwm->priv->atoms[HD_ATOM_WM_HINTS] + || prop->atom == hdwm->priv->atoms[HD_ATOM_NET_WM_ICON] + || prop->atom == hdwm->priv->atoms[HD_ATOM_MB_WIN_SUB_NAME] + || prop->atom == hdwm->priv->atoms[HD_ATOM_NET_WM_NAME] + || prop->atom == hdwm->priv->atoms[HD_ATOM_WM_WINDOW_ROLE]) - { - win = g_hash_table_lookup(hdwmpriv->watched_windows, - (gconstpointer)&prop->window); - } + { + win = g_hash_table_lookup(hdwm->priv->watched_windows, (gconstpointer)&prop->window); + } - if (!win) - return GDK_FILTER_CONTINUE; + if (!win) + return GDK_FILTER_CONTINUE; - 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 == hdwmpriv->atoms[HD_ATOM_WM_STATE]) - { - hd_wm_watched_window_props_sync (win, HD_WM_SYNC_WM_STATE); - } - 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 == hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE]) - { - hd_wm_watched_window_props_sync (win, HD_WM_SYNC_HILDON_VIEW_ACTIVE); - } - 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 == hdwmpriv->atoms[HD_ATOM_HILDON_VIEW_LIST]) - { - hd_wm_watched_window_props_sync (win, HD_WM_SYNC_HILDON_VIEW_LIST); - } - 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 == hdwmpriv->atoms[HD_ATOM_HILDON_APP_KILLABLE] - || prop->atom == hdwmpriv->atoms[HD_ATOM_HILDON_ABLE_TO_HIBERNATE]) - { - HDWMWatchableApp *app; + if (prop->atom == hdwm->priv->atoms[HD_ATOM_WM_NAME] || + prop->atom == hdwm->priv->atoms[HD_ATOM_MB_WIN_SUB_NAME] || + prop->atom == hdwm->priv->atoms[HD_ATOM_NET_WM_NAME]) + { + hd_wm_watched_window_props_sync (win, HD_WM_SYNC_NAME); + } + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_WM_STATE]) + hd_wm_watched_window_props_sync (win, HD_WM_SYNC_WM_STATE); + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_NET_WM_ICON]) + hd_wm_watched_window_props_sync (win, HD_WM_SYNC_ICON); + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_HILDON_VIEW_ACTIVE]) + hd_wm_watched_window_props_sync (win, HD_WM_SYNC_HILDON_VIEW_ACTIVE); + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_WM_HINTS]) + hd_wm_watched_window_props_sync (win, HD_WM_SYNC_WMHINTS); + else + if (prop->atom == hdwm->priv->atoms[HD_ATOM_HILDON_VIEW_LIST]) + hd_wm_watched_window_props_sync (win, HD_WM_SYNC_HILDON_VIEW_LIST); + else + if (prop->atom == hdwm->priv->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->priv->atoms[HD_ATOM_HILDON_APP_KILLABLE] || + prop->atom == hdwm->priv->atoms[HD_ATOM_HILDON_ABLE_TO_HIBERNATE]) + { + HDWMWatchableApp *app; - app = hd_wm_watched_window_get_app(win); + app = hd_wm_watched_window_get_app(win); - if (prop->state == PropertyDelete) - { - hd_wm_watchable_app_set_able_to_hibernate (app, FALSE); - } - else - { - hd_wm_watched_window_props_sync (win, - HD_WM_SYNC_HILDON_APP_KILLABLE); - } - } + if (prop->state == PropertyDelete) + hd_wm_watchable_app_set_able_to_hibernate (app, FALSE); + else + hd_wm_watched_window_props_sync (win, HD_WM_SYNC_HILDON_APP_KILLABLE); } - + } + return GDK_FILTER_CONTINUE; } @@ -2053,13 +2017,12 @@ } static gboolean -hd_wm_dnotify_process () +hd_wm_dnotify_process (HDWM *hdwm) { - HDWM *hdwm = hd_wm_get_singleton (); GHashTable * new_apps; struct _cb_steal_data std; - hdwmpriv->dnotify_timeout_id = 0; + hdwm->priv->dnotify_timeout_id = 0; /* reread all .desktop files and compare each agains existing apps; add any * new ones, updated existing ones @@ -2067,40 +2030,39 @@ * This is quite involved, so we will take a shortcut if we can */ - 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(hdwmpriv->watched_apps); - hdwmpriv->watched_apps = hd_wm_watchable_apps_init(); - return FALSE; + if (!g_hash_table_size(hdwm->priv->watched_windows) && + !g_hash_table_size(hdwm->priv->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->priv->watched_apps); + hdwm->priv->watched_apps = hd_wm_watchable_apps_init(); + return FALSE; } g_debug ("Some watched windows -- doing it the hard way"); - new_apps = hd_wm_watchable_apps_init(); + new_apps = hd_wm_watchable_apps_init (); /* * first we iterate the old hash, looking for any apps that no longer * exist in the new one */ - g_hash_table_foreach_remove(hdwmpriv->watched_apps, - dnotify_hash_table_foreach_remove_func, - new_apps); - + g_hash_table_foreach_remove (hdwm->priv->watched_apps, + dnotify_hash_table_foreach_remove_func, + new_apps); /* * then we do updates on what is left in the old hash */ - std.apps = hdwmpriv->watched_apps; + std.apps = hdwm->priv->watched_apps; std.update = FALSE; - g_hash_table_foreach_steal(new_apps, - dnotify_hash_table_foreach_steal_func, - &std); + g_hash_table_foreach_steal (new_apps, + dnotify_hash_table_foreach_steal_func, + &std); if (std.update) { @@ -2109,18 +2071,14 @@ } /* whatever is left in the new_apps hash, we are not interested in */ - g_hash_table_destroy(new_apps); + g_hash_table_destroy (new_apps); return FALSE; } - - - - /* FIXME -- this function does nothing */ static gboolean -hd_wm_relaunch_timeout(gpointer data) +hd_wm_relaunch_timeout (gpointer data) { gchar *service_name = (gchar *)data; HDWMWatchedWindow *win = NULL; @@ -2143,10 +2101,10 @@ g_debug ("Attempting to open directory [%s]", DESKTOPENTRYDIR); if ((directory = opendir(DESKTOPENTRYDIR)) == NULL) - { - g_debug (" ##### Failed in opening " DESKTOPENTRYDIR " ##### "); - return NULL; - } + { + g_debug (" ##### Failed in opening " DESKTOPENTRYDIR " ##### "); + return NULL; + } watchable_apps = g_hash_table_new_full (g_str_hash, g_str_equal, @@ -2154,53 +2112,54 @@ (GDestroyNotify)hd_wm_watchable_app_destroy); while ((entry = readdir(directory)) != NULL) - { - gchar *path; + { + gchar *path; - if (!g_str_has_suffix(entry->d_name, DESKTOP_SUFFIX)) + if (!g_str_has_suffix(entry->d_name, DESKTOP_SUFFIX)) continue; - path = g_build_filename(DESKTOPENTRYDIR, entry->d_name, NULL); + path = g_build_filename(DESKTOPENTRYDIR, entry->d_name, NULL); - g_debug ("Attempting to open desktop file [%s] ...", path); + g_debug ("Attempting to open desktop file [%s] ...", path); - app = hd_wm_watchable_app_new (path); + app = hd_wm_watchable_app_new (path); - if (app) - { - g_hash_table_insert (watchable_apps, - g_strdup(hd_wm_watchable_app_get_class_name (app)), - (gpointer)app); - } - - g_free(path); + if (app) + { + g_hash_table_insert (watchable_apps, + g_strdup(hd_wm_watchable_app_get_class_name (app)), + (gpointer)app); } - closedir(directory); + g_free(path); + } + closedir (directory); + return watchable_apps; } -gchar* +gchar * hd_wm_compute_watched_window_hibernation_key (Window xwin, HDWMWatchableApp *app) { gchar *role, *hibernation_key = NULL; + HDWM *hdwm = hd_wm_get_singleton (); g_debug ("#### computing hibernation key ####"); - g_return_val_if_fail(app, NULL); + g_return_val_if_fail (app, NULL); - gdk_error_trap_push(); + gdk_error_trap_push (); role = hd_wm_util_get_win_prop_data_and_validate (xwin, - hdwmpriv->atoms[HD_ATOM_WM_WINDOW_ROLE], + hdwm->priv->atoms[HD_ATOM_WM_WINDOW_ROLE], XA_STRING, 8, 0, NULL); - if (gdk_error_trap_pop()||!role || !*role) + if (gdk_error_trap_pop() || !role || !*role) hibernation_key = g_strdup(hd_wm_watchable_app_get_class_name (app)); else hibernation_key = g_strdup_printf("%s%s", @@ -2378,30 +2337,31 @@ gboolean hd_wm_fullscreen_mode () { - if(hdwmpriv->active_window) - { - Atom *wm_type_atom; - Window xid = hd_wm_watched_window_get_x_win (hdwmpriv->active_window); + HDWM *hdwm = hd_wm_get_singleton (); + + if (hdwm->priv->active_window) + { + Atom *wm_type_atom; + Window xid = hd_wm_watched_window_get_x_win (hdwm->priv->active_window); - gdk_error_trap_push(); + gdk_error_trap_push(); - wm_type_atom - = hd_wm_util_get_win_prop_data_and_validate (xid, - hdwmpriv->atoms[HD_ATOM_NET_WM_STATE_FULLSCREEN], - XA_ATOM, - 32, - 0, - NULL); + wm_type_atom = + hd_wm_util_get_win_prop_data_and_validate (xid, + hdwm->priv->atoms[HD_ATOM_NET_WM_STATE_FULLSCREEN], + XA_ATOM, + 32, + 0, + NULL); - gdk_error_trap_pop(); + gdk_error_trap_pop(); - if(!wm_type_atom) - return FALSE; + if (!wm_type_atom) + return FALSE; - XFree(wm_type_atom); - return TRUE; - } - + XFree(wm_type_atom); + return TRUE; + } /* destktop cannot run in fullscreen mode */ return FALSE; } @@ -2410,11 +2370,13 @@ * comments on hd_wm_dnotify_process () */ static void -hd_wm_dnotify_cb ( char *path, void * data) +hd_wm_dnotify_cb (char *path, void * data) { - if (!hdwmpriv->dnotify_timeout_id) + HDWM *hdwm = HD_WM (data); + + if (!hdwm->priv->dnotify_timeout_id) { - hdwmpriv->dnotify_timeout_id = + hdwm->priv->dnotify_timeout_id = g_timeout_add(1000, (GSourceFunc)hd_wm_dnotify_process, NULL); @@ -2428,9 +2390,8 @@ hd_wm_dnotify_register () { 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); - } + { + 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-24 11:50:46 UTC (rev 8315) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h 2006-11-24 16:41:18 UTC (rev 8316) @@ -220,7 +220,7 @@ hd_wm_activate(guint32 what); void -hd_wm_focus_active_window (void); +hd_wm_focus_active_window (HDWM *hdwm); gboolean hd_wm_fullscreen_mode (void); Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/plugin_manager =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/plugin_manager 2006-11-24 11:50:46 UTC (rev 8315) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/plugin_manager 2006-11-24 16:41:18 UTC (rev 8316) @@ -1,4 +1,15 @@ +Notes +------ +We have at the moment plugins that we cannot unload (SB:presence,connection) and +plugins in tasknavigator that the user is not meant to unload them (TN:appswitcher,others menu) + +Because of performance reasons we should have built-in plugins in libhildondesktop (appswitcher,others menu) +and we should find a way for the user not being able to remove them. + +We need a mandatory key for every plugin that is not meant to be unloaded and a new type of plugin: builtin + + Desktop Configuration (A) ---------------------
- Previous message: [maemo-commits] r8315 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r8317 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildonwm test
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]