e_info_client/server: add -prop_set option in winfo (enlightenment_info) 61/289161/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Thu, 2 Mar 2023 06:23:10 +0000 (15:23 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Thu, 2 Mar 2023 07:08:58 +0000 (07:08 +0000)
We add new option "prop_set" to test some property in winfo (enlightenment_info)
ex) winfo -prop_set [window] [property] [value]

First we support test for pinning window.
- winfo -prop_set 0x12345678 pin 1

Change-Id: I114b4b020870fcf8d1892f507b699303f4f67443

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

index 6e94a8e7ac2e3e06e235f9139420ce4ff86ef3e7..1dc9b5aa03bab179bbbe4fc21816b3995067ebc1 100644 (file)
@@ -6680,6 +6680,29 @@ _e_info_client_proc_resize_ppu_set(int argc, char **argv)
      }
 }
 
+static void
+_e_info_client_property_set(int argc, char **argv)
+{
+   const char *win, *property;
+   int set;
+
+   if (argc < 5)
+     {
+        printf("Error Check Args: winfo -prop_set [window] [property] [value]\n");
+        return;
+     }
+
+   win = argv[2];
+   property = argv[3];
+   set = atoi(argv[4]);
+
+   if (!_e_info_client_eldbus_message_with_args("prop_set", NULL, "ssi", win, property, set))
+     {
+        printf("_e_info_client_eldbus_message_with_args error");
+        return;
+     }
+}
+
 typedef struct _ProcInfo
 {
    const char *option;
@@ -7089,6 +7112,12 @@ static ProcInfo procs_to_execute[] =
       "Set resize ppu value",
       _e_info_client_proc_resize_ppu_set
    },
+   {
+      "prop_set",
+      USAGE_PROPERTY_SET,
+      "Set/Unset specify property",
+      _e_info_client_property_set
+   },
 };
 
 ProcInfo procs_to_input[] =
index 5529a6900761d42bba8d115d8d0f79281257b3e7..353409d4dfacfbaa118691fefc79988f410d7974 100644 (file)
@@ -7642,6 +7642,62 @@ e_info_server_cb_resize_ppu_set(const Eldbus_Service_Interface *iface EINA_UNUSE
    return reply;
 }
 
+static void
+_e_info_server_prop_set(E_Client *ec, const char *property, int set)
+{
+   if (!ec) return;
+   if (!property) return;
+
+   if (!e_util_strcmp("pin", property))
+     {
+        e_client_pinned_set(ec, set);
+     }
+   else
+     {
+        ERR("Not supported operation (%s)", property);
+     }
+}
+
+static Eldbus_Message *
+_e_info_server_cb_prop_set(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   const char *win_str, *property;
+   int value;
+   unsigned long tmp = 0;
+   uint64_t win_id = 0;
+   E_Client *ec;
+   Evas_Object *o;
+   Eina_Bool res = EINA_FALSE;
+
+   if (!eldbus_message_arguments_get(msg, "ssi", &win_str, &property, &value))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   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)
+          {
+             _e_info_server_prop_set(ec, property, value);
+             break;
+          }
+     }
+
+   return reply;
+}
+
 //{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"iiiiisiiia("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
@@ -7745,6 +7801,7 @@ static const Eldbus_Method methods[] = {
    { "input_output_set", ELDBUS_ARGS({"ss", "set input device's output name"}), NULL, _e_info_server_cb_input_output_set, 0 },
    { "input_seat_set", ELDBUS_ARGS({"ss", "set input device's seat"}), NULL, _e_info_server_cb_input_seat_set, 0 },
    { "resize_ppu_set", ELDBUS_ARGS({"si", "set resize ppu"}), NULL, e_info_server_cb_resize_ppu_set, 0},
+   { "prop_set", ELDBUS_ARGS({"s","window id" }, {"s", "property"}, {"i", "set value"}), NULL, _e_info_server_cb_prop_set, 0},
    { NULL, NULL, NULL, NULL, 0 }
 };
 
index cbd5bce9b4ec196e101e6632b4e6f9a096b850ac..9f75619cb33d143273ae4abb09a5405d483e8cf4 100644 (file)
@@ -365,6 +365,14 @@ typedef enum
    "Example:\n"                                                               \
    "\twinfo -basic_op_gen basic_op_gen lower\n"
 
+/* -------------------------------------------------------------------------- */
+/* PROPERTY_SET                                                               */
+/* -------------------------------------------------------------------------- */
+#define USAGE_PROPERTY_SET                                                    \
+   "-prop_set {window id} ( pin ) ( 1 | 0) \n"                                \
+   "Example:\n"                                                               \
+   "\twinfo -prop_set 0x12345678 pin 1\n"
+
 /* -------------------------------------------------------------------------- */
 /* QUICKPANEL CONTROL                                                         */
 /* -------------------------------------------------------------------------- */