Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use slide state dbus message instead of the gconf key #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 49 additions & 48 deletions src/launcher/hd-app-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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. */
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/launcher/hd-app-mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 43 additions & 3 deletions src/util/hd-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <glib.h>
#include <mce/dbus-names.h>
Expand Down Expand Up @@ -147,9 +148,6 @@ hd_dbus_signal_handler (DBusConnection *conn, DBusMessage *msg, void *data)
}
}




return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/util/hd-dbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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