#define VALUE_TYPE_FOR_PENDING_COMMIT "uiuu"
#define VALUE_TYPE_REQUEST_FOR_KILL "uts"
#define VALUE_TYPE_REPLY_KILL "s"
+#define VALUE_TYPE_REQUEST_FOR_WININFO "t"
+#define VALUE_TYPE_REPLY_WININFO "uiiiiiibbiibbbiitsiiib"
+#define VALUE_TYPE_REQUEST_FOR_WININFO_TREE "ti"
+#define VALUE_TYPE_REPLY_WININFO_TREE "tsia(tsiiiiiiii)"
static E_Info_Client e_info_client;
return -1;
}
+static void
+_e_message_get_window_name(void *data, const Eldbus_Message *msg, Eldbus_Pending *p EINA_UNUSED)
+{
+ char **win = data;
+
+ const char *name = NULL, *text = NULL;
+ Eina_Bool res;
+ const char *w;
+
+ res = eldbus_message_error_get(msg, &name, &text);
+ EINA_SAFETY_ON_TRUE_GOTO(res, finish);
+
+ res = eldbus_message_arguments_get(msg, "s", &w);
+ EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+ EINA_SAFETY_ON_NULL_GOTO(w, finish);
+
+ *win = strdup(w);
+
+ ecore_main_loop_quit();
+
+ return;
+
+finish:
+ if ((name) || (text))
+ {
+ printf("errname:%s errmsg:%s\n", name, text);
+ }
+
+ ecore_main_loop_quit();
+}
+
+static char *
+_e_get_window_name(uint64_t win)
+{
+ Eldbus_Pending *p;
+ char *win_name = NULL;
+
+ p = eldbus_proxy_call(e_info_client.proxy, "get_window_name",
+ _e_message_get_window_name,
+ &win_name, -1, "t", win);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
+
+ ecore_main_loop_begin();
+
+ return win_name;
+}
+
+static void
+_e_message_get_windows(void *data, const Eldbus_Message *msg, Eldbus_Pending *p EINA_UNUSED)
+{
+ const char *name = NULL, *text = NULL;
+ Eina_Bool res;
+ Eldbus_Message_Iter *array_of_windows;
+ uint64_t win;
+ Eina_List **win_list = data;
+
+ res = eldbus_message_error_get(msg, &name, &text);
+ EINA_SAFETY_ON_TRUE_GOTO(res, finish);
+
+ res = eldbus_message_arguments_get(msg, "at", &array_of_windows);
+ EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+
+ while (eldbus_message_iter_get_and_next(array_of_windows, 't', &win))
+ {
+ *win_list = eina_list_append(*win_list, (void *)((Ecore_Window)win));
+ }
+
+ ecore_main_loop_quit();
+
+ return;
+
+finish:
+ if ((name) || (text))
+ {
+ printf("errname:%s errmsg:%s\n", name, text);
+ }
+
+ ecore_main_loop_quit();
+}
+
+const static int _E_GET_WINDOWS_NAME_MODE = 1;
+const static int _E_GET_WINDOWS_PID_MODE = 2;
+
+static Eina_List *
+_e_get_windows(int mode, char *value)
+{
+ Eldbus_Pending *p;
+ Eina_List *win_list = NULL;
+
+ p = eldbus_proxy_call(e_info_client.proxy, "get_windows",
+ _e_message_get_windows,
+ &win_list, -1, "is", mode, value);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
+
+ ecore_main_loop_begin();
+
+ return win_list;
+}
+
static E_Win_Info *
_e_win_info_new(Ecore_Window id, uint32_t res_id, int pid, Eina_Bool alpha, int opaque, const char *name, int x, int y, int w, int h, int layer, int visible, int visibility, int iconic, int frame_visible, int focused, int hwc, int pl_zpos, Ecore_Window parent_id, const char *layer_name)
{
printf("Usage: enlightenment_info %s", KILL_USAGE);
}
+static int window_id_format_dec;
+
+static void
+_e_info_client_cb_wininfo(const Eldbus_Message *msg)
+{
+ const char *name = NULL, *text = NULL;
+ Eina_Bool res;
+ const char *layer_name;
+ int x, y, w, h, layer, obscured, opaque, hwc, pl_zpos;
+ Eina_Bool visible, alpha, iconic, focused, frame_visible, redirected;
+ uint64_t parent_id;
+ uint32_t res_id;
+ int pid, xright, ybelow, border_size;
+
+ res = eldbus_message_error_get(msg, &name, &text);
+ EINA_SAFETY_ON_TRUE_GOTO(res, finish);
+
+ res = eldbus_message_arguments_get(msg,
+ VALUE_TYPE_REPLY_WININFO,
+ &res_id,
+ &pid,
+ &x,
+ &y,
+ &w,
+ &h,
+ &layer,
+ &visible,
+ &alpha,
+ &opaque,
+ &obscured,
+ &iconic,
+ &frame_visible,
+ &focused,
+ &hwc,
+ &pl_zpos,
+ &parent_id,
+ &layer_name,
+ &xright,
+ &ybelow,
+ &border_size,
+ &redirected);
+ EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+
+ if (window_id_format_dec)
+ printf("\n Parent id: %lu\n", (unsigned long)parent_id);
+ else
+ printf("\n Parent id: 0x%lx\n", (unsigned long)parent_id);
+
+ printf(" Resource id: %u\n"
+ " PID: %d\n"
+ " X: %d\n"
+ " Y: %d\n"
+ " Width: %d\n"
+ " Height: %d\n"
+ " Border size: %d\n"
+ " Depth: %d\n"
+ " Focused: %d\n"
+ " Opaque: %d\n"
+ " Obscured: %d\n"
+ " Iconic: %d\n"
+ " Map State: %s\n"
+ " Frame visible: %d\n"
+ " Redirect State: %s\n"
+ " Layer name: %s\n",
+ res_id, pid, x, y, w, h, border_size, alpha ? 32 : 24,
+ focused, opaque, obscured, iconic, visible ? "Visible" : "Not visible",
+ frame_visible, redirected ? "yes" : "no", layer_name);
+ printf(" PL@ZPos:");
+ if (hwc >= 0)
+ {
+ if ((!iconic) && (!obscured) && (frame_visible))
+ {
+ if (hwc) printf(" hwc@%i\n", pl_zpos);
+ else printf(" comp@%i\n", pl_zpos);
+ }
+ else
+ printf(" - \n");
+ }
+ else
+ {
+ printf(" - \n");
+ }
+ printf (" Corners: +%d+%d -%d+%d -%d-%d +%d-%d\n",
+ x, y, xright, y, xright, ybelow, x, ybelow);
+
+ return;
+
+finish:
+ if ((name) || (text))
+ {
+ printf("errname:%s errmsg:%s\n", name, text);
+ }
+}
+
+static void
+_e_info_client_cb_wininfo_tree(const Eldbus_Message *msg)
+{
+ const char *error_name = NULL, *error_text = NULL;
+ Eina_Bool res;
+ const char *pname;
+ uint64_t pwin;
+ Eldbus_Message_Iter *array_of_children, *child;
+ int num_children;
+
+ res = eldbus_message_error_get(msg, &error_name, &error_text);
+ EINA_SAFETY_ON_TRUE_GOTO(res, finish);
+
+ res = eldbus_message_arguments_get(msg, VALUE_TYPE_REPLY_WININFO_TREE,
+ &pwin, &pname, &num_children, &array_of_children);
+ EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+
+ if (window_id_format_dec)
+ printf("\n Parent window id: %lu \"%s\"\n", (unsigned long)pwin, pname);
+ else
+ printf("\n Parent window id: 0x%lx \"%s\"\n", (unsigned long)pwin, pname);
+
+ printf (" %d child%s%s\n", num_children, num_children == 1 ? "" : "ren",
+ num_children ? ":" : ".");
+
+ while (eldbus_message_iter_get_and_next(array_of_children, 'r', &child))
+ {
+ uint64_t child_win;
+ const char *child_name;
+ int x, y, w, h, hwc, pl_zpos, level, j;
+
+ res = eldbus_message_iter_arguments_get(child,
+ "tsiiiiiiii",
+ &child_win,
+ &child_name,
+ &num_children, &level,
+ &x, &y, &w, &h, &hwc, &pl_zpos);
+ EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+
+ for (j = 0; j <= level; j++) printf (" ");
+ if (window_id_format_dec)
+ printf("%lu \"%s\":", (unsigned long)child_win, child_name);
+ else
+ printf("0x%lx \"%s\":", (unsigned long)child_win, child_name);
+ printf (" %dx%d+%d+%d", w, h, x, y);
+ if (hwc > 0) printf(" hwc@%i", pl_zpos);
+ else if (!hwc) printf(" comp@%i", pl_zpos);
+ printf("\n");
+ if (num_children > 0)
+ {
+ for (j = 0; j <= level + 1; j++) printf (" ");
+ printf ("%d child%s:\n", num_children, num_children == 1 ? "" : "ren");
+ }
+ }
+
+
+ return;
+
+finish:
+ if ((error_name) || (error_text))
+ {
+ printf("errname:%s errmsg:%s\n", error_name, error_text);
+ }
+}
+
+static void
+_e_info_client_cb_wininfo_print_hints(const Eldbus_Message *msg)
+{
+ const char *name = NULL, *text = NULL;
+ Eina_Bool res;
+ Eldbus_Message_Iter *array_of_hints;
+ int count = 0;
+ char *hint;
+
+ res = eldbus_message_error_get(msg, &name, &text);
+ EINA_SAFETY_ON_TRUE_GOTO(res, finish);
+
+ res = eldbus_message_arguments_get(msg, "as", &array_of_hints);
+ EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+
+ while (eldbus_message_iter_get_and_next(array_of_hints, 's', &hint))
+ {
+ printf(" %s\n", hint);
+ count++;
+ }
+
+ if (!count)
+ printf(" No window hints\n");
+
+ ecore_main_loop_quit();
+
+ return;
+
+finish:
+ if ((name) || (text))
+ {
+ printf("errname:%s errmsg:%s\n", name, text);
+ }
+
+ 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 shape)
+{
+ Eina_Bool res;
+ char *win_name;
+
+ win_name = _e_get_window_name(win);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(win_name, EINA_FALSE);
+
+ if (window_id_format_dec)
+ printf("\nwininfo: Window id: %lu \"%s\"\n", (unsigned long)win, win_name);
+ else
+ printf("\nwininfo: Window id: 0x%lx \"%s\"\n", (unsigned long)win, win_name);
+
+ free(win_name);
+
+ if (!children && !tree && !wm && !size && !shape)
+ stats = 1;
+
+ if ((children || tree))
+ {
+ res = _e_info_client_eldbus_message_with_args("wininfo_tree",
+ _e_info_client_cb_wininfo_tree,
+ VALUE_TYPE_REQUEST_FOR_WININFO_TREE,
+ win, tree);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EINA_FALSE);
+ }
+
+ if (stats)
+ {
+ res = _e_info_client_eldbus_message_with_args("wininfo",
+ _e_info_client_cb_wininfo,
+ VALUE_TYPE_REQUEST_FOR_WININFO,
+ win);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EINA_FALSE);
+ }
+
+ if (wm)
+ {
+ printf("\nAux_Hint:\n");
+ res = _e_info_client_eldbus_message_with_args("wininfo_hints",
+ _e_info_client_cb_wininfo_print_hints,
+ "it",
+ 1, win);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EINA_FALSE);
+ }
+
+ if (size)
+ {
+ printf("\nSize hints:\n");
+ res = _e_info_client_eldbus_message_with_args("wininfo_hints",
+ _e_info_client_cb_wininfo_print_hints,
+ "it",
+ 0, win);
+ 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;
+}
+
+#define WININFO_USAGE \
+ "[-options ...]\n\n" \
+ "where options include:\n" \
+ "\t-help : print this message.\n" \
+ "\t-children : print parent and child identifiers.\n" \
+ "\t-tree : print children identifiers recursively.\n" \
+ "\t-stats : print window geometry [DEFAULT]\n" \
+ "\t-id windowid : use the window with the specified id\n" \
+ "\t-name windowname : use the window with the specified name\n" \
+ "\t-pid windowpid : use the window with the specified id\n" \
+ "\t-int : print window id in decimal\n" \
+ "\t-size : print size hints\n" \
+ "\t-wm : print window manager hints\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, shape = 0;
+ char *name = NULL, *pid = NULL;
+ Eina_List *win_list = NULL, *l;
+
+ /* Handle our command line arguments */
+ for (i = 2; i < argc; i++)
+ {
+ if (eina_streq(argv[i], "-help"))
+ goto usage;
+
+ if (eina_streq (argv[i], "-children"))
+ {
+ children = 1;
+ continue;
+ }
+
+ if (eina_streq(argv[i], "-tree"))
+ {
+ tree = 1;
+ continue;
+ }
+
+ if (eina_streq(argv[i], "-stats"))
+ {
+ stats = 1;
+ continue;
+ }
+
+ if (eina_streq(argv[i], "-id"))
+ {
+ if (++i >= argc || (argv[i][0] < '0' || argv[i][0] > '9'))
+ {
+ printf("Error: -id requires argument\n");
+ goto usage;
+ }
+
+ if (strlen(argv[i]) >= 2 && argv[i][0] == '0' && argv[i][1] == 'x')
+ res = _util_string_to_ulong(argv[i], (unsigned long *)&win, 16);
+ else
+ res = _util_string_to_ulong(argv[i], (unsigned long *)&win, 10);
+
+ EINA_SAFETY_ON_FALSE_GOTO(res, usage);
+
+ continue;
+ }
+
+ if (eina_streq(argv[i], "-name"))
+ {
+ if (++i >= argc)
+ {
+ printf("Error: -name requires argument\n");
+ goto usage;
+ }
+
+ name = argv[i];
+ continue;
+ }
+
+ if (eina_streq(argv[i], "-pid"))
+ {
+ if (++i >= argc || (argv[i][0] < '0' || argv[i][0] > '9'))
+ {
+ printf("Error: -name requires argument\n");
+ goto usage;
+ }
+
+ pid = argv[i];
+ continue;
+ }
+ if (eina_streq (argv[i], "-int"))
+ {
+ window_id_format_dec = 1;
+ continue;
+ }
+ if (eina_streq (argv[i], "-wm"))
+ {
+ wm = 1;
+ continue;
+ }
+ if (eina_streq (argv[i], "-size"))
+ {
+ 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;
+ }
+
+ goto usage;
+ }
+
+ if (!win && (name || pid))
+ {
+ if (name)
+ win_list = _e_get_windows(_E_GET_WINDOWS_NAME_MODE, name);
+ else
+ win_list = _e_get_windows(_E_GET_WINDOWS_PID_MODE, pid);
+
+ if (!win_list)
+ {
+ printf("Error: cannot get windows\n");
+ return;
+ }
+ }
+
+ if (!win && !win_list)
+ {
+ printf("Please select the window about which you\n"
+ "would like information by clicking the\n"
+ "mouse in that window.\n");
+ if (_e_get_window_under_touch((Ecore_Window *)&win))
+ {
+ printf("Error: cannot get window under touch\n");
+ return;
+ }
+ }
+
+ if (win)
+ {
+ res = _e_info_client_display_wininfo(win, children, tree, stats, wm, size, shape);
+ EINA_SAFETY_ON_FALSE_RETURN(res);
+ }
+ else
+ {
+ for(l = win_list; l; l = eina_list_next(l))
+ {
+ 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, shape);
+ EINA_SAFETY_ON_FALSE_GOTO(res, finish);
+ }
+ }
+
+finish:
+ if (win_list)
+ eina_list_free(win_list);
+
+ return;
+
+usage:
+ printf("Usage: enlightenment_info -wininfo %s", WININFO_USAGE);
+}
+
static struct
{
const char *option;
KILL_USAGE,
"kill a client",
_e_info_client_proc_kill_client
+ },
+ {
+ "wininfo",
+ WININFO_USAGE,
+ "displaying information about windows",
+ _e_info_client_proc_wininfo
}
};
#define PATH "/org/enlightenment/wm"
#define IFACE "org.enlightenment.wm.info"
+#define ERR_BASE "org.enlightenment.wm.Error."
+#define INVALID_ARGS ERR_BASE"InvalidArguments"
+#define GET_CALL_MSG_ARG_ERR ERR_BASE"GetCallMsgArgFailed"
+#define WIN_NOT_EXIST ERR_BASE"WindowNotExist"
+
E_API int E_EVENT_INFO_ROTATION_MESSAGE = -1;
typedef struct _E_Info_Server
#define VALUE_TYPE_FOR_PENDING_COMMIT "uiuu"
#define VALUE_TYPE_REQUEST_FOR_KILL "uts"
#define VALUE_TYPE_REPLY_KILL "s"
+#define VALUE_TYPE_REQUEST_FOR_WININFO "t"
+#define VALUE_TYPE_REPLY_WININFO "uiiiiiibbiibbbiitsiiib"
+#define VALUE_TYPE_REQUEST_FOR_WININFO_TREE "ti"
+#define VALUE_TYPE_REPLY_WININFO_TREE "tsia(tsiiiiiiii)"
enum
{
_e_info_server_hook_call(hookpoint, NULL);
}
+#ifdef ENABLE_HWC_MULTI
+static void
+_e_info_server_ec_hwc_info_get(E_Client *ec, int *hwc, int *pl_zpos)
+{
+ Eina_List *l;
+ E_Output *eout;
+ E_Plane *ep;
+
+ *hwc = -1;
+ *pl_zpos = -999;
+
+ if ((!e_comp->hwc) || (e_comp->hwc_deactive))
+ return;
+
+ *hwc = 0;
+
+ eout = e_output_find(ec->zone->output_id);
+ EINA_LIST_FOREACH(eout->planes, l, ep)
+ {
+ if (e_plane_is_fb_target(ep))
+ *pl_zpos = ep->zpos;
+
+ if (ep->ec == ec)
+ {
+ *hwc = 1;
+ *pl_zpos = ep->zpos;
+ break;
+ }
+ }
+}
+#endif
+
static void
_msg_clients_append(Eldbus_Message_Iter *iter)
{
#ifdef ENABLE_HWC_MULTI
- if ((e_comp->hwc) && (!e_comp->hwc_deactive))
- {
- Eina_List *l;
- E_Plane *ep;
-
- hwc = 0;
-
- E_Output *eout = e_output_find(ec->zone->output_id);
- EINA_LIST_FOREACH(eout->planes, l, ep)
- {
- if (e_plane_is_fb_target(ep))
- pl_zpos = ep->zpos;
-
- if (ep->ec == ec)
- {
- hwc = 1;
- pl_zpos = ep->zpos;
- break;
- }
- }
- }
+ _e_info_server_ec_hwc_info_get(ec, &hwc, &pl_zpos);
#endif
eldbus_message_iter_arguments_append(array_of_ec, "("VALUE_TYPE_FOR_TOPVWINS")", &struct_of_ec);
ec = evas_object_data_get(o, "E_Client");
if (!ec) continue;
- if (e_client_util_ignored_get(ec)) continue;
w = e_client_util_win_get(ec);
if (w == win)
return reply;
}
+static Eldbus_Message *
+_e_info_server_cb_get_windows(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ const static int _E_GET_WINDOWS_NAME_MODE = 1;
+ const static int _E_GET_WINDOWS_PID_MODE = 2;
+ Eldbus_Message *reply;
+ Eldbus_Message_Iter *iter;
+ Eina_Bool res;
+ E_Client *ec;
+ char *value;
+ uint32_t mode;
+ int count = 0;
+ Eldbus_Message_Iter *array_of_windows;
+ Evas_Object *o;
+ pid_t pid;
+
+ res = eldbus_message_arguments_get(msg, "is", &mode, &value);
+ if (res != EINA_TRUE)
+ {
+ return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+ "get_windows: an attempt to get arguments from method call message failed");
+ }
+
+ if (mode == _E_GET_WINDOWS_PID_MODE)
+ {
+ if (strlen(value) >= 2 && value[0] == '0' && value[1] == 'x')
+ res = e_util_string_to_int(value, &pid, 16);
+ else
+ res = e_util_string_to_int(value, &pid, 10);
+
+ if (res == EINA_FALSE)
+ return eldbus_message_error_new(msg, INVALID_ARGS,
+ "get_windows: invalid input arguments");
+ }
+
+ reply = eldbus_message_method_return_new(msg);
+ iter = eldbus_message_iter_get(reply);
+
+ eldbus_message_iter_arguments_append(iter, "at", &array_of_windows);
+
+ for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
+ {
+ const char *ec_name, *find;
+ Ecore_Window win;
+
+ ec = evas_object_data_get(o, "E_Client");
+ if (!ec) continue;
+
+ ec_name = e_client_util_name_get(ec) ?: "NO NAME";
+
+ if (mode == _E_GET_WINDOWS_NAME_MODE)
+ {
+ find = strstr(ec_name, (const char *)value);
+
+ if (!find)
+ continue;
+ }
+ else if (mode == _E_GET_WINDOWS_PID_MODE)
+ {
+ pid_t ec_pid = -1;
+
+ ec_pid = ec->netwm.pid;
+ if (ec_pid <= 0)
+ {
+ if (ec->comp_data)
+ {
+ E_Comp_Wl_Client_Data *cdata = (E_Comp_Wl_Client_Data*)ec->comp_data;
+ if (cdata->surface)
+ wl_client_get_credentials(wl_resource_get_client(cdata->surface), &ec_pid, NULL, NULL);
+ }
+ }
+ if (ec_pid != pid)
+ continue;
+ }
+
+ win = e_client_util_win_get(ec);
+
+ count++;
+
+ eldbus_message_iter_arguments_append(array_of_windows, "t", win);
+ }
+
+ eldbus_message_iter_container_close(iter, array_of_windows);
+
+ if (count)
+ return reply;
+
+ eldbus_message_unref(reply);
+
+ return eldbus_message_error_new(msg, WIN_NOT_EXIST,
+ "get_windows: specified window(s) doesn't exist");
+}
+
+static Eldbus_Message *
+_e_info_server_cb_get_window_name(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply;
+ Eina_Bool res;
+ E_Client *ec;
+ uint64_t win;
+
+ res = eldbus_message_arguments_get(msg, VALUE_TYPE_REQUEST_FOR_WININFO,
+ &win);
+ if (res != EINA_TRUE)
+ {
+ return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+ "get_window_name: 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, "get_window_name: specified window doesn't exist");
+ }
+
+ reply = eldbus_message_method_return_new(msg);
+
+ eldbus_message_arguments_append(reply, "s",
+ e_client_util_name_get(ec) ?: "NO NAME");
+
+ return reply;
+}
+
+static void
+_e_info_server_wininfo_tree_info_add(E_Client *ec, Eldbus_Message_Iter *iter,
+ int recurse, int level)
+{
+ Eldbus_Message_Iter *struct_of_child;
+
+ if (ec->transients)
+ {
+ E_Client *child;
+ const Eina_List *l;
+
+ EINA_LIST_FOREACH(ec->transients, l, child)
+ {
+ uint64_t win;
+ int num_child = -1;
+ int hwc = -1, pl_zpos;
+
+ if (recurse)
+ num_child = eina_list_count(child->transients);
+
+#ifdef ENABLE_HWC_MULTI
+
+ if ((!child->iconic) && (!child->visibility.obscured) &&
+ evas_object_visible_get(ec->frame))
+ _e_info_server_ec_hwc_info_get(child, &hwc, &pl_zpos);
+#endif
+
+ win = e_client_util_win_get(child);
+ eldbus_message_iter_arguments_append(iter, "(tsiiiiiiii)", &struct_of_child);
+ eldbus_message_iter_arguments_append
+ (struct_of_child, "tsiiiiiiii", win, e_client_util_name_get(child) ?: "NO NAME",
+ num_child, level, child->x, child->y, child->w, child->h, hwc, pl_zpos);
+ eldbus_message_iter_container_close(iter, struct_of_child);
+
+ if (recurse)
+ _e_info_server_wininfo_tree_info_add(child, iter, 1, level + 1);
+ }
+ }
+}
+
+static Eldbus_Message *
+_e_info_server_cb_wininfo_tree(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply;
+ Eldbus_Message_Iter *iter, *array_of_child;
+ Eina_Bool res;
+ E_Client *ec;
+ uint64_t win;
+ int recurse;
+
+ res = eldbus_message_arguments_get(msg, VALUE_TYPE_REQUEST_FOR_WININFO_TREE,
+ &win, &recurse);
+ if (res != EINA_TRUE)
+ {
+ return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+ "wininfo: 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: 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, 't', (uint64_t)e_client_util_win_get(ec->parent));
+ eldbus_message_iter_basic_append(iter, 's', e_client_util_name_get(ec->parent) ?: "NO NAME");
+ eldbus_message_iter_basic_append(iter, 'i', eina_list_count(ec->transients));
+
+ array_of_child = eldbus_message_iter_container_new(iter, 'a', "(tsiiiiiiii)");
+ _e_info_server_wininfo_tree_info_add(ec, array_of_child, recurse, 1);
+ eldbus_message_iter_container_close(iter, array_of_child);
+
+ return reply;
+}
+
+static Eldbus_Message *
+_e_info_server_cb_wininfo(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply;
+ Eina_Bool res;
+ E_Client *ec;
+ uint64_t win;
+ Ecore_Window pwin;
+ uint32_t res_id = 0;
+ pid_t pid = -1;
+ char layer_name[64];
+ int hwc = -1, pl_zpos = -999, dw, dh, xright, ybelow;;
+
+ res = eldbus_message_arguments_get(msg, VALUE_TYPE_REQUEST_FOR_WININFO,
+ &win);
+ if (res != EINA_TRUE)
+ {
+ return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+ "wininfo: 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: specified window(s) doesn't exist");
+ }
+
+ e_comp_layer_name_get(ec->layer, layer_name, sizeof(layer_name));
+
+ pwin = e_client_util_win_get(ec->parent);
+
+ if (ec->pixmap)
+ res_id = e_pixmap_res_id_get(ec->pixmap);
+
+ pid = ec->netwm.pid;
+ if (pid <= 0)
+ {
+ if (ec->comp_data)
+ {
+ E_Comp_Wl_Client_Data *cdata = (E_Comp_Wl_Client_Data*)ec->comp_data;
+ if (cdata->surface)
+ wl_client_get_credentials(wl_resource_get_client(cdata->surface), &pid, NULL, NULL);
+ }
+ }
+
+#ifdef ENABLE_HWC_MULTI
+ _e_info_server_ec_hwc_info_get(ec, &hwc, &pl_zpos);
+#endif
+
+ ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &dw, &dh);
+
+ xright = dw - ec->x - ec->border_size * 2 - ec->w;
+ ybelow = dh - ec->y - ec->border_size * 2 - ec->h;
+
+ reply = eldbus_message_method_return_new(msg);
+
+ eldbus_message_arguments_append(reply, VALUE_TYPE_REPLY_WININFO, res_id, pid,
+ ec->x, ec->y, ec->w, ec->h, ec->layer, ec->visible,
+ ec->argb, ec->visibility.opaque, ec->visibility.obscured,
+ ec->iconic, evas_object_visible_get(ec->frame),
+ ec->focused, hwc, pl_zpos, (uint64_t)pwin,
+ layer_name, xright, ybelow, ec->border_size,
+ ec->redirected);
+
+ return reply;
+}
+
+static void
+_e_info_server_cb_wininfo_size_hints_append(E_Client *ec, Eldbus_Message_Iter *array_of_hints)
+{
+ char temp[512] = {0};
+ Evas_Coord w, h, l, r, t, b;
+ double x, y;
+
+ evas_object_size_hint_min_get(ec->frame, &w, &h);
+ snprintf(temp, sizeof(temp), " min: h(%d), v(%d)", w, h);
+ eldbus_message_iter_arguments_append(array_of_hints, "s", temp);
+
+ evas_object_size_hint_max_get(ec->frame, &w, &h);
+ snprintf(temp, sizeof(temp), " max: h(%d), v(%d)", w, h);
+ eldbus_message_iter_arguments_append(array_of_hints, "s", temp);
+
+ evas_object_size_hint_request_get(ec->frame, &w, &h);
+ snprintf(temp, sizeof(temp), " request: h(%d), v(%d)", w, h);
+ eldbus_message_iter_arguments_append(array_of_hints, "s", temp);
+
+ evas_object_size_hint_align_get(ec->frame, &x, &y);
+ snprintf(temp, sizeof(temp), " align: x(%f), y(%f)", x, y);
+ eldbus_message_iter_arguments_append(array_of_hints, "s", temp);
+
+ evas_object_size_hint_weight_get(ec->frame, &x, &y);
+ snprintf(temp, sizeof(temp), " weight: x(%f), y(%f)", x, y);
+ eldbus_message_iter_arguments_append(array_of_hints, "s", temp);
+
+ evas_object_size_hint_padding_get(ec->frame, &l, &r, &t, &b);
+ snprintf(temp, sizeof(temp), " padding: l(%d), r(%d), t(%d), b(%d)",
+ l, r, t, b);
+ eldbus_message_iter_arguments_append(array_of_hints, "s", temp);
+}
+
+static void
+_e_info_server_cb_wininfo_wm_hints_append(E_Client *ec, Eldbus_Message_Iter *array_of_hints)
+{
+ Eina_List *l;
+ E_Comp_Wl_Aux_Hint *hint;
+ char temp[512] = {0};
+
+ if (!ec->comp_data)
+ return;
+
+ EINA_LIST_FOREACH(ec->comp_data->aux_hint.hints, l, hint)
+ {
+ snprintf(temp, sizeof(temp), "%s: %s", hint->hint, hint->val);
+ eldbus_message_iter_arguments_append(array_of_hints, "s", temp);
+ }
+}
+
+static Eldbus_Message *
+_e_info_server_cb_wininfo_hints(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply;
+ Eldbus_Message_Iter *iter, *array_of_hints;
+ Eina_Bool res;
+ E_Client *ec;
+ uint64_t win;
+ int wm_mode;
+
+ res = eldbus_message_arguments_get(msg, "it", &wm_mode, &win);
+ if (res != EINA_TRUE)
+ {
+ return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+ "wininfo_hints: 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_hints: specified window(s) doesn't exist");
+ }
+
+ reply = eldbus_message_method_return_new(msg);
+ iter = eldbus_message_iter_get(reply);
+
+ eldbus_message_iter_arguments_append(iter, "as", &array_of_hints);
+ if (wm_mode)
+ _e_info_server_cb_wininfo_wm_hints_append(ec, array_of_hints);
+ else
+ _e_info_server_cb_wininfo_size_hints_append(ec, array_of_hints);
+ eldbus_message_iter_container_close(iter, array_of_hints);
+
+ 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;
+}
+
//{ "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({"a("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
{ "remote_surface", ELDBUS_ARGS({"ii", "remote surface query"}), ELDBUS_ARGS({"as", "remote surfac information"}), _e_info_server_cb_remote_surface, 0},
{ "get_win_under_touch", NULL, ELDBUS_ARGS({"i", "result"}), _e_info_server_cb_get_win_under_touch, 0 },
{ "kill_client", ELDBUS_ARGS({VALUE_TYPE_REQUEST_FOR_KILL, "window"}), ELDBUS_ARGS({"a"VALUE_TYPE_REPLY_KILL, "kill result"}), _e_info_server_cb_kill_client, 0 },
+ { "get_window_name", ELDBUS_ARGS({"t", "window"}), ELDBUS_ARGS({"s", "window name"}), _e_info_server_cb_get_window_name, 0 },
+ { "get_windows", ELDBUS_ARGS({"is", "mode, value"}), ELDBUS_ARGS({"at", "array_of_windows"}), _e_info_server_cb_get_windows, 0 },
+ { "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 }
};