winfo: add quickpanel control option 77/274777/1 submit/tizen/20220509.073903
authorDoyoun Kang <doyoun.kang@samsung.com>
Mon, 9 May 2022 05:42:31 +0000 (14:42 +0900)
committerJunseok Kim <juns.kim@samsung.com>
Mon, 9 May 2022 07:29:20 +0000 (16:29 +0900)
winfo -quickpanel [operation(0~3)] {window id}
- operation : 0(hide), 1(show), 2(scroll lock), 3(scroll unlock)
- window id : quickpanel service window id.
              if 0 or invalid id, then use default quickpanel

Change-Id: I8016a2d3d41ea7a8efb2bf4a0ca9acc5ba61a318

src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_info_shared_types.h
src/bin/services/e_service_quickpanel.c
src/bin/services/e_service_quickpanel.h

index acb5a6c6f4f0759dc3e250d679e633949d1da10d..610be534cf0aa83ccda43cf2f8fbbd33168f66db 100644 (file)
@@ -3773,6 +3773,42 @@ _e_info_client_proc_effect_control(int argc, char **argv)
      printf("Error Check Args: enlightenment_info -effect [1: on, 0: off]\n");
 }
 
+static void
+_e_info_client_quickpanel_control(int argc, char **argv)
+{
+   const char *win;
+   int operation;
+   Eldbus_Message *msg;
+   Eldbus_Message_Iter *itr;
+   Eldbus_Pending *p;
+
+   if (argc < 3)
+     {
+        printf("Error Check Args: winfo -quickpanel [operation] {window}\n");
+        return;
+     }
+
+   operation = atoi(argv[2]);
+   if (argc >= 4)
+     win = argv[3];
+   else
+     win = "default";
+
+   msg = eldbus_proxy_method_call_new(e_info_client.proxy, "quickpanel_control");
+   itr = eldbus_message_iter_get(msg);
+   eldbus_message_iter_basic_append(itr, 'i', operation);
+   eldbus_message_iter_basic_append(itr, 's', win);
+
+   p = eldbus_proxy_send(e_info_client.proxy, msg,
+                         _e_info_client_eldbus_message_cb,
+                         NULL, -1);
+   if (!p)
+     {
+        printf("\"aux_msg\" proxy_send error");
+        return;
+     }
+}
+
 static void
 _e_info_client_proc_aux_message(int argc, char **argv)
 {
@@ -6654,6 +6690,12 @@ static ProcInfo procs_to_execute[] =
       "Window effect [on 1, off 0]",
       _e_info_client_proc_effect_control
    },
+   {
+      "quickpanel",
+      USAGE_QUICKPANEL_CONTROL,
+      "Control quickpanel state",
+      _e_info_client_quickpanel_control
+   },
    {
       "aux_msg",
       "[window] [key] [value] [options]",
index 6c551f508bde4cd4d0f858d5117c2758512ef106..b6918f094b6443e1a5fbdcffe09c52feda0c322f 100644 (file)
@@ -12,6 +12,7 @@
 #include "e_info_server_input.h"
 #include <mcheck.h>
 #include "e_policy_wl.h"
+#include "services/e_service_quickpanel.h"
 
 #define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT
 #include <Edje_Edit.h>
@@ -5399,6 +5400,51 @@ e_info_server_cb_effect_control(const Eldbus_Service_Interface *iface EINA_UNUSE
    return reply;
 }
 
+static Eldbus_Message *
+e_info_server_cb_quickpanel_control(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   const char *win_str;
+   int operation = 0;
+   unsigned long tmp = 0;
+   uint64_t win_id = 0;
+   E_Client *ec = NULL;
+   Evas_Object *o;
+   Eina_Bool res = EINA_FALSE;
+
+   if (!eldbus_message_arguments_get(msg, "is", &operation, &win_str))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   if (!e_util_strcmp("default", win_str))
+     ec = NULL;
+   else
+     {
+        res = e_util_string_to_ulong(win_str, &tmp, 16);
+        EINA_SAFETY_ON_FALSE_RETURN_VAL(res, reply);
+
+        win_id = (uint64_t)tmp;
+
+        for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
+          {
+             ec = evas_object_data_get(o, "E_Client");
+             if (!ec) continue;
+
+             Ecore_Window win = e_client_util_win_get(ec);
+
+             if (win == win_id)
+               break;
+          }
+     }
+
+   if ((operation >= 0) && (operation <= 3))
+     e_qp_control_by_command(ec, operation);
+
+   return reply;
+}
+
 static Eldbus_Message *
 e_info_server_cb_magnifier(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
 {
@@ -7407,6 +7453,7 @@ static const Eldbus_Method methods[] = {
    { "get_fps_info", NULL, ELDBUS_ARGS({"a("VALUE_TYPE_FOR_FPS")", "array of fps"}), _e_info_server_cb_fps_info_get, 0},
    { "get_keymap", NULL, ELDBUS_ARGS({"hi", "keymap fd"}), _e_info_server_cb_keymap_info_get, 0},
    { "effect_control", ELDBUS_ARGS({"i", "effect_control"}), NULL, e_info_server_cb_effect_control, 0},
+   { "quickpanel_control", ELDBUS_ARGS({"i", "operation"}, {"s","window id" }), NULL, e_info_server_cb_quickpanel_control, 0},
    { "get_keygrab_status", ELDBUS_ARGS({"s", "get_keygrab_status"}), NULL, _e_info_server_cb_keygrab_status_get, 0},
    { "get_module_info", ELDBUS_ARGS({"ss", "get_module_info"}), NULL, _e_info_server_cb_module_info_get, 0},
    { "aux_msg", ELDBUS_ARGS({"s","window id" }, {"s", "key"}, {"s", "value"}, {"as", "options"}), NULL, e_info_server_cb_aux_message, 0},
index 3884e400301e453c24b74e36fd997735cbb86f57..cbd5bce9b4ec196e101e6632b4e6f9a096b850ac 100644 (file)
@@ -365,4 +365,18 @@ typedef enum
    "Example:\n"                                                               \
    "\twinfo -basic_op_gen basic_op_gen lower\n"
 
+/* -------------------------------------------------------------------------- */
+/* QUICKPANEL CONTROL                                                         */
+/* -------------------------------------------------------------------------- */
+#define USAGE_QUICKPANEL_CONTROL                                                \
+   "-quickpanel (0:hide | 1:show | 2:lock | 3:unlock) {window id}\n"            \
+   "\twindow id : This is an optional value. If you want to control specific\n" \
+   "\t            quickpanel service, then use this parameter.\n,"              \
+   "Example:\n"                                                                 \
+   "\twinfo -quickpanel 0 : hide default quickpanel service\n"                  \
+   "\twinfo -quickpanel 1 : show default quickpanel service\n"                  \
+   "\twinfo -quickpanel 2 : set scroll_lock for quickpanel service\n"           \
+   "\twinfo -quickpanel 3 : unset scoll_lock for quickpanel service\n"          \
+   "\twinfo -quickpanel 1 0x0a710a07 : show the specific quickpanel service\n"
+
 #endif /* end of _E_INFO_SHARED_TYPES_ */
index e8ed867b79e64e64287007b30c9a3402eb92009e..3dbcd536bf131d3447e25d332749eed997d14197 100644 (file)
@@ -1649,6 +1649,25 @@ _quickpanel_contents_region_set(E_Policy_Quickpanel *qp, E_Policy_Angle_Map ridx
    eina_iterator_free(it);
 }
 
+static void
+_e_qp_srv_visible_handle(E_Policy_Quickpanel *qp, Eina_Bool vis)
+{
+   Eina_Bool res = EINA_FALSE;
+
+   // If vis is true, show (with effect) the quickpanel service.
+   // Otherwise, hide (with effect) the quickpanel service.
+
+   res = _e_qp_srv_is_effect_running(qp);
+   if (res)
+     _e_qp_srv_effect_finish(qp, vis);
+   else if ((qp->ec) && ((qp->ec->visible) || (vis)))
+     {
+        _e_qp_srv_effect_start(qp);
+        _e_qp_srv_effect_update(qp, qp->effect.x, qp->effect.y);
+        _e_qp_srv_effect_finish(qp, vis);
+     }
+}
+
 static void
 _e_qp_srv_visible_set(E_Policy_Quickpanel *qp, Eina_Bool vis)
 {
@@ -1663,14 +1682,32 @@ _e_qp_srv_visible_set(E_Policy_Quickpanel *qp, Eina_Bool vis)
         return;
      }
 
-   res = _e_qp_srv_is_effect_running(qp);
-   if (res)
-     _e_qp_srv_effect_finish(qp, vis);
-   else if ((qp->ec) && ((qp->ec->visible) || (vis)))
+   _e_qp_srv_visible_handle(qp, vis);
+}
+
+EINTERN void
+e_qp_control_by_command(E_Client *ec, int operation)
+{
+   E_Policy_Quickpanel *qp = NULL;
+   Eina_List *l;
+
+   qp = _quickpanel_service_get(ec);
+   if (!qp)
      {
-        _e_qp_srv_effect_start(qp);
-        _e_qp_srv_effect_update(qp, qp->effect.x, qp->effect.y);
-        _e_qp_srv_effect_finish(qp, vis);
+        /* look for a first quick panel service */
+        qp = eina_list_nth(qp_services, 0);
+     }
+
+   if (qp)
+     {
+        if (operation == 0)
+          _e_qp_srv_visible_handle(qp, EINA_FALSE);
+        else if (operation == 1)
+          _e_qp_srv_visible_handle(qp, EINA_TRUE);
+        else if (operation == 2)
+          e_service_quickpanel_scroll_lock_set(qp->ec, EINA_TRUE);
+        else
+          e_service_quickpanel_scroll_lock_set(qp->ec, EINA_FALSE);
      }
 }
 
index 02b9143e5538b5bb0ba5325444e431fc2a101f33..477ffe21031247a83ac4fd25bdfaec1c9a34d516 100644 (file)
@@ -72,4 +72,5 @@ EINTERN Eina_Bool e_qp_client_scrollable_get(E_Client *ec, E_Quickpanel_Type typ
 EINTERN Eina_Bool e_qp_client_scrollable_state_set(E_Client *ec, E_Quickpanel_Type type, E_Quickpanel_Client_Scroll_State state);
 EINTERN E_Quickpanel_Client_Scroll_State e_qp_client_scrollable_state_get(E_Client *ec, E_Quickpanel_Type type);
 
+EINTERN void e_qp_control_by_command(E_Client *ec, int operation);
 #endif