From 6832a9d663ef1a9d5b3b164e92b1eca59ba42212 Mon Sep 17 00:00:00 2001 From: uvos Date: Sat, 2 Apr 2022 18:14:27 +0200 Subject: [PATCH] Use slide state dbus message instead of the gconf key --- src/launcher/hd-app-mgr.c | 97 ++++++++++++++++++++------------------- src/launcher/hd-app-mgr.h | 1 + src/util/hd-dbus.c | 46 +++++++++++++++++-- src/util/hd-dbus.h | 1 + 4 files changed, 94 insertions(+), 51 deletions(-) diff --git a/src/launcher/hd-app-mgr.c b/src/launcher/hd-app-mgr.c index 2db2c70f..8e39fdaf 100644 --- a/src/launcher/hd-app-mgr.c +++ b/src/launcher/hd-app-mgr.c @@ -51,6 +51,7 @@ #include "hd-transition.h" #include "hd-wm.h" #include "hd-orientation-lock.h" +#include "../util/hd-dbus.h" #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "hd-app-mgr" @@ -284,6 +285,7 @@ static void hd_app_mgr_gconf_value_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data); + static gboolean hd_app_mgr_show_callui_cb (gpointer data); //gboolean hd_app_mgr_check_show_callui (void); @@ -406,6 +408,7 @@ static void hd_app_mgr_init (HdAppMgr *self) { HdAppMgrPrivate *priv; + gboolean slide_open = FALSE; self->priv = priv = HD_APP_MGR_GET_PRIVATE (self); @@ -419,22 +422,16 @@ hd_app_mgr_init (HdAppMgr *self) G_CALLBACK (hd_app_mgr_populate_tree_finished), self); hd_launcher_tree_populate (priv->tree); + + hd_dbus_get_slide_state (&slide_open); + priv->slide_closed = !slide_open; /* NOTE: Can we assume this when we start up? */ priv->unlocked = TRUE; priv->gconf_client = gconf_client_get_default (); + if (priv->gconf_client) { - priv->slide_closed = !gconf_client_get_bool (priv->gconf_client, - GCONF_SLIDE_OPEN_KEY, - NULL); - gconf_client_add_dir (priv->gconf_client, GCONF_SLIDE_OPEN_DIR, - GCONF_CLIENT_PRELOAD_NONE, NULL); - gconf_client_notify_add (priv->gconf_client, GCONF_SLIDE_OPEN_KEY, - hd_app_mgr_gconf_value_changed, - (gpointer) self, - NULL, NULL); - /* We don't call hd_app_mgr_mce_activate_accel_if_needed (); here because hdrm is not ready yet. */ @@ -2236,6 +2233,48 @@ hd_app_mgr_mce_activate_accel_if_needed (gboolean update_portraitness) priv->portrait && priv->slide_closed); } +void hd_app_mgr_inform_slide_state_changed(gboolean slide_state) +{ + if(!the_app_mgr) + return; + + HdAppMgrPrivate *priv = HD_APP_MGR_GET_PRIVATE (the_app_mgr); + + priv->slide_closed = !slide_state; + + /* Should UI be able to rotate? + * Related to the orientation lock (locking to portrait mode). */ + gboolean allow_ui_to_rotate; + + if (!priv->ui_can_rotate && hd_orientation_lock_is_locked_to_portrait ()) + allow_ui_to_rotate = TRUE; + else + allow_ui_to_rotate = priv->ui_can_rotate; + + /* If in LAUNCHER_PORTRAIT with the slide/hkb open, turn it into + * landscape mode + * If in LAUNCHER with closed slide and device's oriented portrait go to + * LAUNCHER_PORTRAIT. + * Under any other case just update the portraitness */ + if (!priv->slide_closed && + STATE_ONE_OF(hd_render_manager_get_state (), HDRM_STATE_LAUNCHER_PORTRAIT | HDRM_STATE_TASK_NAV_PORTRAIT)) + { + /* manually setting the HDAppMgr is a bit of kludge, since it's + * supposed to reflect the accellerometer status, but it's needed or + * the status change won't work since HDRM will rely on the HdAppMgr + * declared orientation to actually change state */ + gboolean portrait = priv->portrait; + priv->portrait = FALSE; + hd_render_manager_set_state (hd_render_manager_get_state () == HDRM_STATE_LAUNCHER_PORTRAIT?HDRM_STATE_LAUNCHER:HDRM_STATE_TASK_NAV); + priv->portrait = portrait; + } + else if (priv->slide_closed && priv->portrait && allow_ui_to_rotate && + STATE_ONE_OF(hd_render_manager_get_state () , HDRM_STATE_LAUNCHER | HDRM_STATE_TASK_NAV)) + hd_render_manager_set_state (hd_render_manager_get_state () == HDRM_STATE_LAUNCHER?HDRM_STATE_LAUNCHER_PORTRAIT:HDRM_STATE_TASK_NAV_PORTRAIT); + else + hd_app_mgr_update_portraitness(the_app_mgr); +} + static void hd_app_mgr_gconf_value_changed (GConfClient *client, guint cnxn_id, @@ -2261,44 +2300,6 @@ hd_app_mgr_gconf_value_changed (GConfClient *client, if(hd_home_view_container_get_current_view(hd_home_get_view_container(home)) != gconf_value_get_int(gvalue)-1) hd_home_view_container_set_current_view(hd_home_get_view_container(home), gconf_value_get_int(gvalue)-1); } - - if (!g_strcmp0 (gconf_entry_get_key (entry), - GCONF_SLIDE_OPEN_KEY)) - { - priv->slide_closed = !value; - - /* Should UI be able to rotate? - * Related to the orientation lock (locking to portrait mode). */ - gboolean allow_ui_to_rotate; - - if (!priv->ui_can_rotate && hd_orientation_lock_is_locked_to_portrait ()) - allow_ui_to_rotate = TRUE; - else - allow_ui_to_rotate = priv->ui_can_rotate; - - /* If in LAUNCHER_PORTRAIT with the slide/hkb open, turn it into - * landscape mode - * If in LAUNCHER with closed slide and device's oriented portrait go to - * LAUNCHER_PORTRAIT. - * Under any other case just update the portraitness */ - if (!priv->slide_closed && - STATE_ONE_OF(hd_render_manager_get_state (), HDRM_STATE_LAUNCHER_PORTRAIT | HDRM_STATE_TASK_NAV_PORTRAIT)) - { - /* manually setting the HDAppMgr is a bit of kludge, since it's - * supposed to reflect the accellerometer status, but it's needed or - * the status change won't work since HDRM will rely on the HdAppMgr - * declared orientation to actually change state */ - gboolean portrait = priv->portrait; - priv->portrait = FALSE; - hd_render_manager_set_state (hd_render_manager_get_state () == HDRM_STATE_LAUNCHER_PORTRAIT?HDRM_STATE_LAUNCHER:HDRM_STATE_TASK_NAV); - priv->portrait = portrait; - } - else if (priv->slide_closed && priv->portrait && allow_ui_to_rotate && - STATE_ONE_OF(hd_render_manager_get_state () , HDRM_STATE_LAUNCHER | HDRM_STATE_TASK_NAV)) - hd_render_manager_set_state (hd_render_manager_get_state () == HDRM_STATE_LAUNCHER?HDRM_STATE_LAUNCHER_PORTRAIT:HDRM_STATE_TASK_NAV_PORTRAIT); - else - hd_app_mgr_update_portraitness(self); - } if(gconf_client_dir_exists(priv->gconf_client, GCONF_KEY_ACTIONS_DIR, NULL)) { conf_enable_home_contacts_phone = gconf_client_get_bool(priv->gconf_client, GCONF_KEY_ACTIONS_DIR "/home_contacts_phone", NULL); diff --git a/src/launcher/hd-app-mgr.h b/src/launcher/hd-app-mgr.h index 0c314613..d2d3dea8 100644 --- a/src/launcher/hd-app-mgr.h +++ b/src/launcher/hd-app-mgr.h @@ -113,6 +113,7 @@ gboolean hd_app_mgr_is_portrait(void); gboolean hd_app_mgr_slide_is_open (void); gboolean hd_app_mgr_ui_can_rotate (void); void hd_app_mgr_update_orientation(void); +void hd_app_mgr_inform_slide_state_changed(gboolean slide_state); G_END_DECLS diff --git a/src/util/hd-dbus.c b/src/util/hd-dbus.c index 39e71ecb..5e651050 100644 --- a/src/util/hd-dbus.c +++ b/src/util/hd-dbus.c @@ -6,6 +6,7 @@ #include "hd-volume-profile.h" #include "hd-task-navigator.h" #include "hd-dbus.h" +#include "../launcher/hd-app-mgr.h" #include #include @@ -147,9 +148,6 @@ hd_dbus_signal_handler (DBusConnection *conn, DBusMessage *msg, void *data) } } - - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -177,6 +175,36 @@ void hd_dbus_open_vkb (void) dbus_message_unref(msg); } +gboolean hd_dbus_get_slide_state (gboolean *slide_state) +{ + DBusMessage *msg; + DBusMessage *reply; + DBusError error; + gboolean ret = FALSE; + + dbus_error_init (&error); + + msg = dbus_message_new_method_call(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_KEYBOARD_SLIDE_GET); + + reply = dbus_connection_send_with_reply_and_block(sysbus_conn, msg, DBUS_TIMEOUT_USE_DEFAULT, &error); + if (!reply) { + g_warning ("%s: dbus_connection_send_with_reply_and_block() failed %s", __func__, error.message); + } else { + dbus_bool_t state; + if(dbus_message_get_args(reply, &error, DBUS_TYPE_BOOLEAN, &state, DBUS_TYPE_INVALID)) { + ret = TRUE; + *slide_state = state; + } else { + g_warning ("%s: unable to get arguments from dbus reply %s", __func__, error.message); + } + dbus_message_unref(reply); + } + + dbus_error_free(&error); + dbus_message_unref(msg); + return ret; +} + static DBusHandlerResult hd_dbus_system_bus_signal_handler (DBusConnection *conn, @@ -313,6 +341,13 @@ hd_dbus_system_bus_signal_handler (DBusConnection *conn, && (hd_render_manager_get_state() & (HDRM_STATE_HOME|HDRM_STATE_HOME_PORTRAIT)); } + else if (dbus_message_is_signal (msg, MCE_SIGNAL_IF, MCE_KEYBOARD_SLIDE_GET)) + { + dbus_bool_t state = FALSE; + dbus_message_get_args (msg, NULL, DBUS_TYPE_BOOLEAN, &state, + DBUS_TYPE_INVALID); + hd_app_mgr_inform_slide_state_changed(state); + } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -493,6 +528,11 @@ hd_dbus_init (HdCompMgr * hmgr) "type='signal',path='" MCE_SIGNAL_PATH "'," "interface='" MCE_SIGNAL_IF "'," "member='" MCE_CALL_STATE_SIG "'", NULL); + + dbus_bus_add_match (sysbus_conn, + "type='signal',path='" MCE_SIGNAL_PATH "'," + "interface='" MCE_SIGNAL_IF "'," + "member='" MCE_KEYBOARD_SLIDE_GET "'", NULL); dbus_connection_add_filter (sysbus_conn, hd_dbus_system_bus_signal_handler, diff --git a/src/util/hd-dbus.h b/src/util/hd-dbus.h index b8d98351..d396f365 100644 --- a/src/util/hd-dbus.h +++ b/src/util/hd-dbus.h @@ -19,5 +19,6 @@ gboolean hd_dbus_launch_service (DBusConnection *connection, void hd_dbus_send_event (char *value); void hd_dbus_send_desktop_orientation_changed (gboolean to_portrait); void hd_dbus_open_vkb (void); +gboolean hd_dbus_get_slide_state (gboolean *slide_state); #endif