From ddc7ec3bfeebfa1e85dd6920766874b102b97302 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 12 Mar 2010 21:34:30 +0000 Subject: [PATCH] Show and ShowByName dbus calls for org.enlightenment.wm.Desktop SVN revision: 47168 --- data/tools/enlightenment_remote | 39 ++++++++++++-- src/modules/msgbus/msgbus_desktop.c | 80 +++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 5 deletions(-) diff --git a/data/tools/enlightenment_remote b/data/tools/enlightenment_remote index c7227d12e..daf504a3f 100644 --- a/data/tools/enlightenment_remote +++ b/data/tools/enlightenment_remote @@ -30,7 +30,9 @@ OPTIONS: -default-profile-get Get the default configuration profile -default-profile-set OPT1 Set the default configuration profile to OPT1 - -desks-get Get the number of virtual desktops + -desktops-get Get the number of virtual desktops + -desktop-show OPT1 OPT2 Show the desk at position OPT1 (x) and OPT2 (y), see -desktops-get for current count. + -desktop-show-by-name OPT1 Show the desk named OPT1 -desktop-bg-add OPT1 OPT2 OPT3 OPT4 OPT5 Add a desktop bg definition. OPT1 = container no. OPT2 = zone no. OPT3 = desk_x. OPT4 = desk_y. OPT5 = bg file path -desktop-bg-del OPT1 OPT2 OPT3 OPT4 Delete a desktop bg definition. OPT1 = container no. OPT2 = zone no. OPT3 = desk_x. OPT4 = desk_y. -desktop-bg-list List all current desktop bg definitions @@ -168,7 +170,7 @@ ERCIIIIS(){ } #=== FUNCTION ================================================================ -# NAME: ERCIIIIS +# NAME: ERCIIII # DESCRIPTION: eremote call with int, int, int, int parameter # PARAMETERS: interface/method call, int, int, int, int # RETURNS: @@ -177,6 +179,16 @@ ERCIIII(){ dbus-send --print-reply=literal --dest=org.enlightenment.wm.service /org/enlightenment/wm/RemoteObject "$1" int32:"$2" int32:"$3" int32:"$4" int32:"$5" } +#=== FUNCTION ================================================================ +# NAME: ERCII +# DESCRIPTION: eremote call with int, int parameter +# PARAMETERS: interface/method call, int, int +# RETURNS: +#=============================================================================== +ERCII(){ + dbus-send --print-reply=literal --dest=org.enlightenment.wm.service /org/enlightenment/wm/RemoteObject "$1" int32:"$2" int32:"$3" +} + #------------------------------------------------------------------------------- @@ -266,6 +278,19 @@ er_desktop_get(){ ERGMI org.enlightenment.wm.Desktop.GetVirtualCount } +#------------------------------------------------------------------------------- +# E Virtual show +#------------------------------------------------------------------------------- +er_desktop_show(){ + ERCII org.enlightenment.wm.Desktop.Show "$2" "$3" +} + +#------------------------------------------------------------------------------- +# E Virtual show by name +#------------------------------------------------------------------------------- +er_desktop_show_by_name(){ + ERCS org.enlightenment.wm.Desktop.ShowByName "$2" +} #------------------------------------------------------------------------------- # E Desktop background add @@ -291,8 +316,6 @@ er_desktop_bg_list(){ - - #=== FUNCTION ================================================================ # NAME: Main # DESCRIPTION: We start there and go to the desired option @@ -342,9 +365,15 @@ case "$1" in -default-profile-set) er_default_profile_set "$@" ;; - -desks-get) + -desks-get|-desktops-get) er_desktop_get ;; + -desktop-show) + er_desktop_show "$@" + ;; + -desktop-show-by-name) + er_desktop_show_by_name "$@" + ;; -desktop-bg-add) er_desktop_bg_add "$@" ;; diff --git a/src/modules/msgbus/msgbus_desktop.c b/src/modules/msgbus/msgbus_desktop.c index 810e43f6a..5d6154657 100644 --- a/src/modules/msgbus/msgbus_desktop.c +++ b/src/modules/msgbus/msgbus_desktop.c @@ -5,6 +5,12 @@ #include "e.h" #include "msgbus_desktop.h" +static int _log_dom = -1; +#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) +#define WARN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) + static DBusMessage * cb_virtual_desktops(E_DBus_Object *obj, DBusMessage *msg) { @@ -21,6 +27,69 @@ cb_virtual_desktops(E_DBus_Object *obj, DBusMessage *msg) return reply; } +static DBusMessage * +cb_desktop_show(E_DBus_Object *obj, DBusMessage *msg) +{ + DBusError err; + int x, y; + + dbus_error_init(&err); + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &x, + DBUS_TYPE_INT32, &y, + DBUS_TYPE_INVALID)) + { + ERR("could not get Show arguments: %s: %s", err.name, err.message); + dbus_error_free(&err); + } + else + { + E_Zone *zone = e_util_zone_current_get(e_manager_current_get()); + fprintf(stderr, "show desktop %d,%d from zone %p.\n", x, y, zone); + DBG("show desktop %d,%d from zone %p.", x, y, zone); + e_zone_desk_flip_to(zone, x, y); + } + + return dbus_message_new_method_return(msg); +} + +static DBusMessage * +cb_desktop_show_by_name(E_DBus_Object *obj, DBusMessage *msg) +{ + DBusError err; + const char *name; + + dbus_error_init(&err); + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID)) + { + ERR("could not get Show arguments: %s: %s", err.name, err.message); + dbus_error_free(&err); + } + else if (name) + { + E_Zone *zone = e_util_zone_current_get(e_manager_current_get()); + unsigned int i, count; + + DBG("show desktop %s from zone %p.", name, zone); + count = zone->desk_x_count * zone->desk_y_count; + for (i = 0; i < count; i++) + { + E_Desk *desk = zone->desks[i]; + if ((desk->name) && (strcmp(desk->name, name) == 0)) + { + DBG("show desktop %s (%d,%d) from zone %p.", + name, desk->x, desk->y, zone); + e_zone_desk_flip_to(zone, desk->x, desk->y); + break; + } + } + } + + return dbus_message_new_method_return(msg); +} + static DBusMessage* cb_desktop_bgadd(E_DBus_Object *obj, DBusMessage *msg) { @@ -107,11 +176,22 @@ void msgbus_desktop_init(Eina_Array *ifaces) { E_DBus_Interface *iface; + if (_log_dom == -1) + { + _log_dom = eina_log_domain_register("msgbus_desktop", EINA_COLOR_BLUE); + if (_log_dom < 0) + EINA_LOG_ERR("could not register msgbus_desktop log domain!"); + } + iface = e_dbus_interface_new("org.enlightenment.wm.Desktop"); if (iface) { e_dbus_interface_method_add(iface, "GetVirtualCount", "", "ii", cb_virtual_desktops); + e_dbus_interface_method_add(iface, "Show", "ii", "", + cb_desktop_show); + e_dbus_interface_method_add(iface, "ShowByName", "s", "", + cb_desktop_show_by_name); e_msgbus_interface_attach(iface); eina_array_push(ifaces, iface); }