[e_info] add "-shape" option for the wininfo
authorKonstantin Drabeniuk <k.drabeniuk@samsung.com>
Thu, 18 May 2017 14:02:02 +0000 (17:02 +0300)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 25 May 2017 23:26:07 +0000 (08:26 +0900)
Change-Id: Ie722f782a9a3b29390e71a1c5a53f4be58deaf2f
Signed-off-by: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
src/bin/e_info_client.c
src/bin/e_info_server.c

index e056820f5e8ff57d5ca2487f23f9ba4461b1209f..be5ba9d52c2c107920bc9a9d4cba73c8ea5da071 100644 (file)
@@ -3076,9 +3076,73 @@ finish:
    ecore_main_loop_quit();
 }
 
+static void
+_e_info_client_cb_wininfo_print_shape(const Eldbus_Message *msg)
+{
+   const char *name = NULL, *text = NULL;
+   Eina_Bool res;
+   Eldbus_Message_Iter *array_of_shape, *array_of_shape_input;
+   Eldbus_Message_Iter *struct_of_shape;
+   int count = 0;
+   int shape_rects_num, shape_input_rects_num;
+
+   res = eldbus_message_error_get(msg, &name, &text);
+   EINA_SAFETY_ON_TRUE_GOTO(res, finish);
+
+   res = eldbus_message_arguments_get(msg, "ia(iiii)ia(iiii)",
+                                      &shape_rects_num, &array_of_shape,
+                                      &shape_input_rects_num, &array_of_shape_input);
+   EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+
+   printf("   Number of shape rectangles: %d\n", shape_rects_num);
+   if (shape_rects_num)
+     {
+        while (eldbus_message_iter_get_and_next(array_of_shape, 'r', &struct_of_shape))
+          {
+             int x, y, w, h;
+             res = eldbus_message_iter_arguments_get(struct_of_shape,
+                                                     "iiii",
+                                                     &x, &y, &w, &h);
+             EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+             count++;
+             printf("      %d) x(%d), y(%d), w(%d), h(%d)\n", count, x, y, w, h);
+
+          }
+     }
+
+   count = 0;
+   printf("   Number of shape input rectangles: %d\n", shape_input_rects_num);
+   if (shape_input_rects_num)
+     {
+        while (eldbus_message_iter_get_and_next(array_of_shape_input, 'r', &struct_of_shape))
+          {
+             int x, y, w, h;
+             res = eldbus_message_iter_arguments_get(struct_of_shape,
+                                                     "iiii",
+                                                     &x, &y, &w, &h);
+             EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+             count++;
+             printf("      %d) x(%d), y(%d), w(%d), h(%d)\n", count, x, y, w, h);
+
+          }
+     }
+
+   ecore_main_loop_quit();
+
+   return;
+
+finish:
+   if ((name) || (text))
+     {
+        printf("errname:%s errmsg:%s\n", name, text);
+     }
+
+   ecore_main_loop_quit();
+}
+
 static Eina_Bool
 _e_info_client_display_wininfo(uint64_t win, int children, int tree, int stats,
-                               int wm, int size)
+                               int wm, int size, int shape)
 {
    Eina_Bool res;
    char *win_name;
@@ -3093,7 +3157,7 @@ _e_info_client_display_wininfo(uint64_t win, int children, int tree, int stats,
 
    free(win_name);
 
-   if (!children && !tree && !wm && !size)
+   if (!children && !tree && !wm && !size && !shape)
      stats = 1;
 
    if ((children || tree))
@@ -3134,6 +3198,15 @@ _e_info_client_display_wininfo(uint64_t win, int children, int tree, int stats,
         EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EINA_FALSE);
      }
 
+   if (shape)
+     {
+        res = _e_info_client_eldbus_message_with_args("wininfo_shape",
+                                                      _e_info_client_cb_wininfo_print_shape,
+                                                      "t",
+                                                      win);
+        EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EINA_FALSE);
+     }
+
    return EINA_TRUE;
 }
 
@@ -3150,14 +3223,21 @@ _e_info_client_display_wininfo(uint64_t win, int children, int tree, int stats,
   "\t-int              : print window id in decimal\n" \
   "\t-size             : print size hints\n" \
   "\t-wm               : print window manager hints\n" \
-  "\t-all              : -tree, -stats, -wm, -size\n" \
+  "\t-shape            : print shape rectangles\n" \
+  "\t-all              : -tree, -stats, -wm, -size, -shape\n" \
+  "Example:\n" \
+  "\tenlightenment_info -wininfo\n" \
+  "\tenlightenment_info -wininfo -id [win_id] -all\n" \
+  "\tenlightenment_info -wininfo -children -stats -size\n" \
+  "\tenlightenment_info -wininfo -name [win_name] -tree -wm\n" \
+  "\tenlightenment_info -wininfo -pid [win_pid] -size -shape -int\n" \
 
 static void
 _e_info_client_proc_wininfo(int argc, char **argv)
 {
    Eina_Bool res;
    uint64_t win = 0;
-   int i, children = 0, tree = 0, stats = 0, wm = 0, size = 0;
+   int i, children = 0, tree = 0, stats = 0, wm = 0, size = 0, shape = 0;
    char *name = NULL, *pid = NULL;
    Eina_List *win_list = NULL, *l;
 
@@ -3241,12 +3321,18 @@ _e_info_client_proc_wininfo(int argc, char **argv)
              size = 1;
              continue;
           }
+        if (eina_streq (argv[i], "-shape"))
+          {
+             shape = 1;
+             continue;
+          }
         if (eina_streq (argv[i], "-all"))
           {
              tree = 1;
              stats = 1;
              wm = 1;
              size = 1;
+             shape = 1;
              continue;
           }
 
@@ -3281,7 +3367,7 @@ _e_info_client_proc_wininfo(int argc, char **argv)
 
    if (win)
      {
-        res = _e_info_client_display_wininfo(win, children, tree, stats, wm, size);
+        res = _e_info_client_display_wininfo(win, children, tree, stats, wm, size, shape);
         EINA_SAFETY_ON_FALSE_RETURN(res);
      }
    else
@@ -3291,7 +3377,7 @@ _e_info_client_proc_wininfo(int argc, char **argv)
              uint64_t win;
 
              win = (uint64_t)((Ecore_Window)eina_list_data_get(l));
-             res = _e_info_client_display_wininfo(win, children, tree, stats, wm, size);
+             res = _e_info_client_display_wininfo(win, children, tree, stats, wm, size, shape);
              EINA_SAFETY_ON_FALSE_GOTO(res, finish);
           }
      }
index 480fb21327715deb26c0d1cc946b389a1aab8f6b..131084cf20924f05f62a7bd841b9cd71e5d19885 100755 (executable)
@@ -3351,7 +3351,7 @@ _e_info_server_wininfo_tree_info_add(E_Client *ec, Eldbus_Message_Iter *iter,
         EINA_LIST_FOREACH(ec->transients, l, child)
           {
              uint64_t win;
-             unsigned int num_child = -1;
+             int num_child = -1;
              int hwc = -1, pl_zpos;
 
              if (recurse)
@@ -3569,6 +3569,61 @@ _e_info_server_cb_wininfo_hints(const Eldbus_Service_Interface *iface EINA_UNUSE
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_wininfo_shape(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply;
+   Eldbus_Message_Iter *iter, *array_of_shape, *struct_of_shape;
+   Eina_Bool res;
+   E_Client *ec;
+   uint64_t win;
+   int i;
+
+   res = eldbus_message_arguments_get(msg, "t", &win);
+   if (res != EINA_TRUE)
+     {
+        return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+                      "wininfo_shape: an attempt to get arguments from method call message failed");
+     }
+
+   ec = _e_info_server_ec_find_by_win(win);
+   if (!ec)
+     {
+        return eldbus_message_error_new(msg, WIN_NOT_EXIST, "wininfo_shape: specified window(s) doesn't exist");
+     }
+
+   reply = eldbus_message_method_return_new(msg);
+   iter = eldbus_message_iter_get(reply);
+
+   eldbus_message_iter_basic_append(iter, 'i', ec->shape_rects_num);
+   array_of_shape = eldbus_message_iter_container_new(iter, 'a', "(iiii)");
+   for(i = 0; i < ec->shape_rects_num; ++i)
+     {
+        eldbus_message_iter_arguments_append(iter, "(iiii)", &struct_of_shape);
+        eldbus_message_iter_arguments_append
+           (struct_of_shape, "iiii",
+            ec->shape_rects[i].x, ec->shape_rects[i].y,
+            ec->shape_rects[i].w, ec->shape_rects[i].h);
+        eldbus_message_iter_container_close(iter, struct_of_shape);
+     }
+   eldbus_message_iter_container_close(iter, array_of_shape);
+
+   eldbus_message_iter_basic_append(iter, 'i', ec->shape_input_rects_num);
+   array_of_shape = eldbus_message_iter_container_new(iter, 'a', "(iiii)");
+   for(i = 0; i < ec->shape_input_rects_num; ++i)
+     {
+        eldbus_message_iter_arguments_append(iter, "(iiii)", &struct_of_shape);
+        eldbus_message_iter_arguments_append
+           (struct_of_shape, "iiii",
+            ec->shape_input_rects[i].x, ec->shape_input_rects[i].y,
+            ec->shape_input_rects[i].w, ec->shape_input_rects[i].h);
+        eldbus_message_iter_container_close(iter, struct_of_shape);
+     }
+   eldbus_message_iter_container_close(iter, array_of_shape);
+
+   return reply;
+}
+
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"a("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
    { "compobjs", NULL, ELDBUS_ARGS({"a("SIGNATURE_COMPOBJS_CLIENT")", "array of comp objs"}), _e_info_server_cb_compobjs, 0 },
@@ -3616,6 +3671,7 @@ static const Eldbus_Method methods[] = {
    { "wininfo", ELDBUS_ARGS({VALUE_TYPE_REQUEST_FOR_WININFO, "window"}), ELDBUS_ARGS({VALUE_TYPE_REPLY_WININFO, "window info"}), _e_info_server_cb_wininfo, 0 },
    { "wininfo_tree", ELDBUS_ARGS({VALUE_TYPE_REQUEST_FOR_WININFO_TREE, "wininfo_tree"}), ELDBUS_ARGS({VALUE_TYPE_REPLY_WININFO_TREE, "window tree info"}), _e_info_server_cb_wininfo_tree, 0 },
    { "wininfo_hints", ELDBUS_ARGS({"it", "mode, window"}), ELDBUS_ARGS({"as", "window hints"}), _e_info_server_cb_wininfo_hints, 0 },
+   { "wininfo_shape", ELDBUS_ARGS({"t", "window"}), ELDBUS_ARGS({"ia(iiii)ia(iiii)", "window shape"}), _e_info_server_cb_wininfo_shape, 0 },
    { NULL, NULL, NULL, NULL, 0 }
 };