2 #include "e_info_shared_types.h"
7 typedef void (*E_Info_Message_Cb)(const Eldbus_Message *msg);
9 typedef struct _E_Info_Client
14 Eldbus_Connection *conn;
23 typedef struct _E_Win_Info
25 Ecore_Window id; // native window id
28 const char *name; // name of client window
29 int x, y, w, h; // geometry
30 int layer; // value of E_Layer
31 int vis; // visibility
32 int alpha; // alpha window
38 const char *layer_name; // layer name
41 #define VALUE_TYPE_FOR_TOPVWINS "uuisiiiiibbiibbis"
42 #define VALUE_TYPE_REQUEST_RESLIST "ui"
43 #define VALUE_TYPE_REPLY_RESLIST "ssi"
44 #define VALUE_TYPE_FOR_INPUTDEV "ssi"
46 static E_Info_Client e_info_client;
48 static int keepRunning = 1;
49 static void end_program(int sig);
50 static Eina_Bool _e_info_client_eldbus_message(const char *method, E_Info_Message_Cb cb);
51 static Eina_Bool _e_info_client_eldbus_message_with_args(const char *method, E_Info_Message_Cb cb, const char *signature, ...);
54 _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 focused, int hwc, const char *layer_name)
56 E_Win_Info *win = NULL;
58 win = E_NEW(E_Win_Info, 1);
59 EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
64 win->name = eina_stringshare_add(name);
73 win->visibility = visibility;
75 win->focused = focused;
77 win->layer_name = eina_stringshare_add(layer_name);
83 _e_win_info_free(E_Win_Info *win)
85 EINA_SAFETY_ON_NULL_RETURN(win);
88 eina_stringshare_del(win->name);
91 eina_stringshare_del(win->layer_name);
97 _cb_window_info_get(const Eldbus_Message *msg)
99 const char *name = NULL, *text = NULL;
100 Eldbus_Message_Iter *array, *ec;
103 res = eldbus_message_error_get(msg, &name, &text);
104 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
106 res = eldbus_message_arguments_get(msg, "a("VALUE_TYPE_FOR_TOPVWINS")", &array);
107 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
109 while (eldbus_message_iter_get_and_next(array, 'r', &ec))
111 const char *win_name;
112 const char *layer_name;
113 int x, y, w, h, layer, visibility, opaque, hwc;
114 Eina_Bool visible, alpha, iconic, focused;
118 E_Win_Info *win = NULL;
119 res = eldbus_message_iter_arguments_get(ec,
120 VALUE_TYPE_FOR_TOPVWINS,
140 printf("Failed to get win info\n");
144 win = _e_win_info_new(id, res_id, pid, alpha, opaque, win_name, x, y, w, h, layer, visible, visibility, iconic, focused, hwc, layer_name);
145 e_info_client.win_list = eina_list_append(e_info_client.win_list, win);
149 if ((name) || (text))
151 printf("errname:%s errmsg:%s\n", name, text);
156 _cb_input_device_info_get(const Eldbus_Message *msg)
158 const char *name = NULL, *text = NULL;
159 Eldbus_Message_Iter *array, *eldbus_msg;
161 E_Comp_Wl_Input_Device *dev;
163 res = eldbus_message_error_get(msg, &name, &text);
164 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
166 res = eldbus_message_arguments_get(msg, "a("VALUE_TYPE_FOR_INPUTDEV")", &array);
167 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
169 while (eldbus_message_iter_get_and_next(array, 'r', &eldbus_msg))
174 res = eldbus_message_iter_arguments_get(eldbus_msg,
175 VALUE_TYPE_FOR_INPUTDEV,
181 printf("Failed to get device info\n");
185 dev = E_NEW(E_Comp_Wl_Input_Device, 1);
186 dev->name = strdup(dev_name);
187 dev->identifier = strdup(identifier);
188 dev->capability = capability;
190 e_info_client.input_dev = eina_list_append(e_info_client.input_dev, dev);
194 if ((name) || (text))
196 printf("errname:%s errmsg:%s\n", name, text);
201 _cb_input_keymap_info_get(const Eldbus_Message *msg)
203 const char *name = NULL, *text = NULL;
206 int min_keycode=0, max_keycode=0, fd=0, size=0, num_mods=0, num_groups = 0;
207 struct xkb_context *context = NULL;
208 struct xkb_keymap *keymap = NULL;
209 struct xkb_state *state = NULL;
210 xkb_keysym_t sym = XKB_KEY_NoSymbol;
211 char keyname[256] = {0, };
214 res = eldbus_message_error_get(msg, &name, &text);
215 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
217 res = eldbus_message_arguments_get(msg, "hi", &fd, &size);
218 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
220 context = xkb_context_new(0);
221 EINA_SAFETY_ON_NULL_GOTO(context, finish);
223 map = mmap(NULL, size, 0x01, 0x0001, fd, 0);
224 if (map == ((void *)-1))
230 keymap = xkb_map_new_from_string(context, map, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
235 EINA_SAFETY_ON_NULL_GOTO(keymap, finish);
236 state = xkb_state_new(keymap);
237 EINA_SAFETY_ON_NULL_GOTO(state, finish);
239 min_keycode = xkb_keymap_min_keycode(keymap);
240 max_keycode = xkb_keymap_max_keycode(keymap);
241 num_groups = xkb_map_num_groups(keymap);
242 num_mods = xkb_keymap_num_mods(keymap);
245 printf(" min keycode: %d\n", min_keycode);
246 printf(" max keycode: %d\n", max_keycode);
247 printf(" num_groups : %d\n", num_groups);
248 printf(" num_mods : %d\n", num_mods);
249 for (i = 0; i < num_mods; i++)
251 printf(" [%2d] mod: %s\n", i, xkb_keymap_mod_get_name(keymap, i));
254 printf("\n\n\tkeycode\t\tkeyname\t\t keysym\t repeat\n");
255 printf(" ----------------------------------------------------------------------\n");
257 for (i = min_keycode; i < (max_keycode + 1); i++)
259 sym = xkb_state_key_get_one_sym(state, i);
261 memset(keyname, 0, sizeof(keyname));
262 xkb_keysym_get_name(sym, keyname, sizeof(keyname));
264 printf("\t%4d%-5s%-25s%-20p%-5d\n", i, "", keyname, (void *)sym, xkb_keymap_key_repeats(keymap, i));
267 if ((name) || (text ))
269 printf("errname:%s errmsg:%s\n", name, text);
271 if (state) xkb_state_unref(state);
272 if (keymap) xkb_map_unref(keymap);
273 if (context) xkb_context_unref(context);
277 _e_info_client_proc_protocol_trace(int argc, char **argv)
279 char fd_name[PATH_MAX];
281 Eina_Bool disable = EINA_FALSE;
284 if (argc != 3 || !argv[2])
286 printf("protocol-trace: Usage> enlightenment_info -protocol_trace [console | file path | disable]\n");
293 if (!getcwd(cwd, sizeof(cwd)))
294 snprintf(cwd, sizeof(cwd), "/tmp");
296 if (!strncmp(argv[2], "console", 7))
297 snprintf(fd_name, PATH_MAX, "/proc/%d/fd/1", pid);
298 else if (!strncmp(argv[2], "disable", 7))
302 if (argv[2][0] == '/')
303 snprintf(fd_name, PATH_MAX, "%s", argv[2]);
307 snprintf(fd_name, PATH_MAX, "%s/%s", cwd, argv[2]);
309 snprintf(fd_name, PATH_MAX, "%s", argv[2]);
313 printf("protocol-trace: %s\n", disable ? "disable" : fd_name);
315 if (!_e_info_client_eldbus_message_with_args("protocol_trace", NULL, "s", disable ? "disable" : fd_name))
320 _e_info_client_proc_topvwins_info(int argc, char **argv)
326 const char *prev_layer_name = NULL;
327 E_Win_Info *nocomp_win = NULL;
329 if (!_e_info_client_eldbus_message("get_window_info", _cb_window_info_get))
332 printf("%d Top level windows\n", eina_list_count(e_info_client.win_list));
333 printf("--------------------------------------[ topvwins ]----------------------------------------------------------\n");
334 printf(" No Win_ID RcsID PID w h x y Focus Depth Opaq Visi Icon Map_State Title \n");
335 printf("------------------------------------------------------------------------------------------------------------\n");
337 if (!e_info_client.win_list)
339 printf("no window\n");
343 EINA_LIST_FOREACH(e_info_client.win_list, l, win)
347 if (win->layer != prev_layer)
349 if (prev_layer != -1)
350 printf("------------------------------------------------------------------------------------------------------------[%s]\n",
351 prev_layer_name ? prev_layer_name : " ");
352 prev_layer = win->layer;
353 prev_layer_name = win->layer_name;
355 printf("%3d 0x%08x %5d %5d %5d %5d %6d %6d %c %5d %d ", i, win->id, win->res_id, win->pid, win->w, win->h, win->x, win->y, win->focused ? 'O':' ', win->alpha? 32:24, win->opaque);
356 printf("%2d %d %-11s %s\n", win->visibility, win->iconic, win->vis? "Viewable":"NotViewable", win->name?:"No Name");
357 if(win->hwc == 2) nocomp_win = win;
361 printf("------------------------------------------------------------------------------------------------------------[%s]\n",
362 prev_layer_name ? prev_layer_name : " ");
365 printf("\nNocomp : %s(0x%08x)\n\n", nocomp_win->name?:"No Name", nocomp_win->id);
367 E_FREE_LIST(e_info_client.win_list, _e_win_info_free);
371 _e_info_client_proc_input_device_info(int argc, char **argv)
373 E_Comp_Wl_Input_Device *dev;
377 if (!_e_info_client_eldbus_message("get_input_devices", _cb_input_device_info_get))
380 printf("--------------------------------------[ input devices ]----------------------------------------------------------\n");
381 printf(" No Name identifier Cap\n");
382 printf("-----------------------------------------------------------------------------------------------------------------\n");
384 if (!e_info_client.input_dev)
386 printf("no devices\n");
390 EINA_LIST_FOREACH(e_info_client.input_dev, l, dev)
393 printf("%3d %50s %20s ", i, dev->name, dev->identifier);
394 if (dev->capability & ECORE_DEVICE_POINTER) printf("Pointer | ");
395 if (dev->capability & ECORE_DEVICE_KEYBOARD) printf("Keyboard | ");
396 if (dev->capability & ECORE_DEVICE_TOUCH) printf("Touch | ");
397 printf("(0x%x)\n", dev->capability);
400 E_FREE_LIST(e_info_client.input_dev, free);
404 _e_info_client_proc_keymap_info(int argc, char **argv)
406 if (!_e_info_client_eldbus_message("get_keymap", _cb_input_keymap_info_get))
411 _directory_make(char *path)
413 char dir[PATH_MAX], curdir[PATH_MAX], stamp[PATH_MAX];
421 buf = calloc (1, sizeof (struct tm));
422 EINA_SAFETY_ON_NULL_RETURN_VAL(buf, NULL);
424 t = localtime_r(&timer, buf);
428 printf("fail to get local time\n");
432 fullpath = (char*) calloc(1, PATH_MAX*sizeof(char));
436 printf("fail to alloc pathname memory\n");
440 if (path && path[0] == '/')
441 snprintf(dir, PATH_MAX, "%s", path);
444 char *temp = getcwd(curdir, PATH_MAX);
453 if (strlen(curdir) == 1 && curdir[0] == '/')
454 snprintf(dir, PATH_MAX, "/%s", path);
456 snprintf(dir, PATH_MAX, "%s/%s", curdir, path);
459 snprintf(dir, PATH_MAX, "%s", curdir);
462 if (!(dp = opendir (dir)))
466 printf("not exist: %s\n", dir);
472 /* make the folder for the result of xwd files */
473 snprintf(stamp, PATH_MAX, "%04d%02d%02d.%02d%02d%02d", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
475 if (strlen(dir) == 1 && dir[0] == '/')
476 snprintf(fullpath, PATH_MAX, "/topvwins-%s", stamp);
478 snprintf(fullpath, PATH_MAX, "%s/topvwins-%s", dir, stamp);
482 if ((mkdir(fullpath, 0755)) < 0)
484 printf("fail: mkdir '%s'\n", fullpath);
489 printf("directory: %s\n", fullpath);
495 _e_info_client_proc_topvwins_shot(int argc, char **argv)
497 char *directory = _directory_make(argv[2]);
498 EINA_SAFETY_ON_NULL_RETURN(directory);
500 if (!_e_info_client_eldbus_message_with_args("dump_topvwins", NULL, "s", directory))
510 _e_info_client_proc_eina_log_levels(int argc, char **argv)
512 EINA_SAFETY_ON_FALSE_RETURN(argc == 3);
513 EINA_SAFETY_ON_NULL_RETURN(argv[2]);
515 if (!_e_info_client_eldbus_message_with_args("eina_log_levels", NULL, "s", argv[2]))
522 _e_info_client_proc_eina_log_path(int argc, char **argv)
524 char fd_name[PATH_MAX];
528 EINA_SAFETY_ON_FALSE_RETURN(argc == 3);
529 EINA_SAFETY_ON_NULL_RETURN(argv[2]);
534 if (!getcwd(cwd, sizeof(cwd)))
535 snprintf(cwd, sizeof(cwd), "/tmp");
537 if (!strncmp(argv[2], "console", 7))
538 snprintf(fd_name, PATH_MAX, "/proc/%d/fd/1", pid);
541 if (argv[2][0] == '/')
542 snprintf(fd_name, PATH_MAX, "%s", argv[2]);
546 snprintf(fd_name, PATH_MAX, "%s/%s", cwd, argv[2]);
548 snprintf(fd_name, PATH_MAX, "%s", argv[2]);
552 printf("eina-log-path: %s\n", fd_name);
554 if (!_e_info_client_eldbus_message_with_args("eina_log_path", NULL, "s", fd_name))
561 _cb_window_prop_get(const Eldbus_Message *msg)
563 const char *name = NULL, *text = NULL;
564 Eldbus_Message_Iter *array, *ec;
567 res = eldbus_message_error_get(msg, &name, &text);
568 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
570 res = eldbus_message_arguments_get(msg, "a(ss)", &array);
571 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
573 printf("--------------------------------------[ window prop ]-----------------------------------------------------\n");
574 while (eldbus_message_iter_get_and_next(array, 'r', &ec))
578 res = eldbus_message_iter_arguments_get(ec,
584 printf("Failed to get win prop info\n");
588 if (!strcmp(title, "[WINDOW PROP]"))
589 printf("---------------------------------------------------------------------------------------------------------\n");
591 printf("%20s : %s\n", title, value);
593 printf("----------------------------------------------------------------------------------------------------------\n");
596 if ((name) || (text))
598 printf("errname:%s errmsg:%s\n", name, text);
603 _e_info_client_prop_prop_info(int argc, char **argv)
605 const static int WINDOW_ID_MODE = 0;
606 const static int WINDOW_PID_MODE = 1;
607 const static int WINDOW_NAME_MODE = 2;
611 if (argc < 3 || argv[2] == NULL)
613 printf("Error Check Args: enlightenment_info -prop [windowID]\n"
614 " enlightenment_info -prop -id [windowID]\n"
615 " enlightenment_info -prop -pid [PID]\n"
616 " enlightenment_info -prop -name [name]\n");
620 if (strlen(argv[2]) > 2 && argv[2][0] == '-')
622 if (!strcmp(argv[2], "-id")) mode = WINDOW_ID_MODE;
623 if (!strcmp(argv[2], "-pid")) mode = WINDOW_PID_MODE;
624 if (!strcmp(argv[2], "-name")) mode = WINDOW_NAME_MODE;
625 value = (argc >= 4 ? argv[3] : NULL);
629 mode = WINDOW_ID_MODE;
633 if (!_e_info_client_eldbus_message_with_args("get_window_prop", _cb_window_prop_get, "us", mode, value))
635 printf("_e_info_client_eldbus_message_with_args error");
641 _cb_window_proc_connected_clients_get(const Eldbus_Message *msg)
643 const char *name = NULL, *text = NULL;
644 Eldbus_Message_Iter *array, *ec;
647 res = eldbus_message_error_get(msg, &name, &text);
648 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
650 res = eldbus_message_arguments_get(msg, "a(ss)", &array);
651 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
653 printf("--------------------------------------[ connected clients ]-----------------------------------------------------\n");
655 while (eldbus_message_iter_get_and_next(array, 'r', &ec))
659 res = eldbus_message_iter_arguments_get(ec,
665 printf("Failed to get connected clients info\n");
669 if (!strcmp(title, "[Connected Clients]"))
671 printf("\n[%2d] %s\n", ++cnt, value);
673 else if (!strcmp(title, "[E_Client Info]"))
675 printf(" |----- %s :: %s\n", title, value);
680 if ((name) || (text))
682 printf("errname:%s errmsg:%s\n", name, text);
687 _e_info_client_proc_connected_clients(int argc, char **argv)
689 if (!_e_info_client_eldbus_message("get_connected_clients", _cb_window_proc_connected_clients_get))
691 printf("_e_info_client_eldbus_message error");
696 #define ROTATION_USAGE \
697 "[COMMAND] [ARG]...\n" \
698 "\tset : Set the orientation of zone (Usage: set [zone-no] [rval(0|90|180|270)]\n" \
699 "\tinfo : Get the information of zone's rotation (Usage: info [zone-no]) (Not Implemented)\n" \
700 "\tenable : Enable the rotation of zone (Usage: enable [zone-no]\n" \
701 "\tdisable : Disable the rotation of zone (Usage: disable [zone-no]\n"
704 _cb_rotation_query(const Eldbus_Message *msg)
707 /* TODO: need implementation */
711 _e_info_client_proc_rotation(int argc, char **argv)
713 E_Info_Rotation_Message req;
714 int32_t zone_num = -1;
716 const int off_len = 2, cmd_len = 1;
717 Eina_Bool res = EINA_FALSE;
719 if (argc < off_len + cmd_len)
722 if (eina_streq(argv[off_len], "info"))
724 if (argc > off_len + cmd_len)
725 zone_num = atoi(argv[off_len + 1]);
727 res = _e_info_client_eldbus_message_with_args("rotation_query",
733 if (eina_streq(argv[off_len], "set"))
735 if (argc < off_len + cmd_len + 1)
737 else if (argc > off_len + cmd_len + 1)
739 zone_num = atoi(argv[off_len + 1]);
740 rval = atoi(argv[off_len + 2]);
743 rval = atoi(argv[off_len + 1]);
745 if ((rval < 0) || (rval > 270) || (rval % 90 != 0))
748 req = E_INFO_ROTATION_MESSAGE_SET;
752 if (argc > off_len + cmd_len)
753 zone_num = atoi(argv[off_len + 1]);
755 if (eina_streq(argv[off_len], "enable"))
756 req = E_INFO_ROTATION_MESSAGE_ENABLE;
757 else if (eina_streq(argv[off_len], "disable"))
758 req = E_INFO_ROTATION_MESSAGE_DISABLE;
763 res = _e_info_client_eldbus_message_with_args("rotation_message",
765 req, zone_num, rval);
769 printf("_e_info_client_eldbus_message_with_args error");
773 printf("Usage: enlightenment_info -rotation %s", ROTATION_USAGE);
776 #define RESLIST_USAGE \
778 "\t-tree : All resources\n" \
779 "\t-p {pid} : Specify client pid\n"
789 _pname_get(pid_t pid, char *name, int size)
794 char proc[512], pname[512];
797 snprintf(proc, 512,"/proc/%d/cmdline", pid);
799 h = fopen(proc, "r");
802 len = fread(pname, sizeof(char), 512, h);
805 if ('\n' == pname[len - 1])
806 pname[len - 1] = '\0';
811 strncpy(name, pname, size);
816 _cb_disp_res_lists_get(const Eldbus_Message *msg)
818 const char *name = NULL, *text = NULL;
819 Eldbus_Message_Iter *array, *resource;
821 int nClient = 0, nResource = 0;
825 res = eldbus_message_error_get(msg, &name, &text);
826 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
828 res = eldbus_message_arguments_get(msg, "a("VALUE_TYPE_REPLY_RESLIST")", &array);
829 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
831 snprintf(temp, PATH_MAX,"%6s %6s %s %s\n", "NO", "PID", "N_of_Res", "NAME");
834 while (eldbus_message_iter_get_and_next(array, 'r', &resource))
836 char cmd[512] = {0, };
840 res = eldbus_message_iter_arguments_get(resource,
841 VALUE_TYPE_REPLY_RESLIST,
847 printf("Failed to get connected clients info\n");
850 if (!strcmp(type, "[client]"))
856 else if (!strcmp(type, "[count]"))
859 _pname_get(pid, cmd, sizeof(cmd));
861 printf("%6d %6d %4d %9s\n", nClient, pid, nResource, cmd);
867 if ((name) || (text))
869 printf("errname:%s errmsg:%s\n", name, text);
874 _cb_disp_res_lists_get_detail(const Eldbus_Message *msg)
876 const char *name = NULL, *text = NULL;
877 Eldbus_Message_Iter *array, *resource;
879 int nClient = 0, nResource = 0;
881 res = eldbus_message_error_get(msg, &name, &text);
882 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
884 res = eldbus_message_arguments_get(msg, "a("VALUE_TYPE_REPLY_RESLIST")", &array);
885 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
887 while (eldbus_message_iter_get_and_next(array, 'r', &resource))
891 char cmd[512] = {0, };
894 res = eldbus_message_iter_arguments_get(resource,
895 VALUE_TYPE_REPLY_RESLIST,
902 printf("Failed to get connected clients info\n");
905 if (!strcmp(type, "[client]"))
910 _pname_get(pid, cmd, sizeof(cmd));
911 printf("[%2d] pid %d (%s)\n", nClient, pid, cmd);
914 else if (!strcmp(type, "[resource]"))
917 printf(" |----- %s obj@%d\n", item, id);
923 if ((name) || (text))
925 printf("errname:%s errmsg:%s\n", name, text);
930 _e_info_client_proc_res_lists(int argc, char **argv)
937 mode = DEFAULT_SUMMARY;
938 if (!_e_info_client_eldbus_message_with_args("get_res_lists", _cb_disp_res_lists_get, VALUE_TYPE_REQUEST_RESLIST, mode, pid))
940 printf("%s error\n", __FUNCTION__);
946 if (eina_streq(argv[2], "-tree")) mode = TREE;
949 if (!_e_info_client_eldbus_message_with_args("get_res_lists", _cb_disp_res_lists_get_detail, VALUE_TYPE_REQUEST_RESLIST, mode, pid))
951 printf("%s error\n", __FUNCTION__);
957 if (eina_streq(argv[2], "-p"))
961 if (pid <= 0) goto arg_err;
965 if (!_e_info_client_eldbus_message_with_args("get_res_lists", _cb_disp_res_lists_get_detail, VALUE_TYPE_REQUEST_RESLIST, mode, pid))
967 printf("%s error\n", __FUNCTION__);
975 printf("Usage: enlightenment_info -reslist\n%s", RESLIST_USAGE);
980 _cb_fps_info_get(const Eldbus_Message *msg)
982 const char *name = NULL, *text = NULL;
986 res = eldbus_message_error_get(msg, &name, &text);
987 EINA_SAFETY_ON_TRUE_GOTO(res, finish);
989 res = eldbus_message_arguments_get(msg, "s", &fps);
990 EINA_SAFETY_ON_FALSE_GOTO(res, finish);
991 if (strcmp(fps, "no_update"))
995 if ((name) || (text ))
997 printf("errname:%s errmsg:%s\n", name, text);
1002 _e_info_client_proc_fps_info(int argc, char **argv)
1008 if (!_e_info_client_eldbus_message("get_fps_info", _cb_fps_info_get))
1012 while (keepRunning);
1016 _e_info_client_proc_transform_set(int argc, char **argv)
1018 int32_t id_enable_xy_sxsy_angle[8];
1023 printf("Error Check Args: enlightenment_info -transform [windowID] [transform id] [enable] [x] [y] [scale_x(percent)] [scale_y(percent)] [degree] [keep_ratio]\n");
1027 id_enable_xy_sxsy_angle[0] = 0; // transform id
1028 id_enable_xy_sxsy_angle[1] = 1; // enable
1029 id_enable_xy_sxsy_angle[2] = 0; // move x
1030 id_enable_xy_sxsy_angle[3] = 0; // move y
1031 id_enable_xy_sxsy_angle[4] = 100; // scale x percent
1032 id_enable_xy_sxsy_angle[5] = 100; // scale y percent
1033 id_enable_xy_sxsy_angle[6] = 0; // rotation degree
1034 id_enable_xy_sxsy_angle[7] = 0; // keep ratio
1036 for (i = 0 ; i < 8 && i+3 < argc; ++i)
1037 id_enable_xy_sxsy_angle[i] = atoi(argv[i+3]);
1039 if (!_e_info_client_eldbus_message_with_args("transform_message", NULL, "siiiiiiii",
1040 argv[2], id_enable_xy_sxsy_angle[0] , id_enable_xy_sxsy_angle[1], id_enable_xy_sxsy_angle[2],
1041 id_enable_xy_sxsy_angle[3], id_enable_xy_sxsy_angle[4], id_enable_xy_sxsy_angle[5],
1042 id_enable_xy_sxsy_angle[6], id_enable_xy_sxsy_angle[7]))
1044 printf("_e_info_client_eldbus_message_with_args error");
1050 _e_info_client_proc_buffer_shot(int argc, char **argv)
1054 int dumprun = atoi(argv[2]);
1056 if (dumprun < 0 || dumprun > 1)
1058 printf("Error Check Args : enlightenment_info -dump_buffers [1: start, 0: stop]\n");
1062 if (!_e_info_client_eldbus_message_with_args("dump_buffers", NULL, "i", dumprun))
1064 printf("_e_info_client_proc_buffer_shot fail (%d)\n", dumprun);
1067 printf("_e_info_client_proc_buffer_shot %s\n", (dumprun == 1 ? "start" : "stop"));
1071 printf("Error Check Args : enlightenment_info -dump_buffers [1: start, 0: stop]\n");
1077 _e_info_client_proc_hwc_trace(int argc, char **argv)
1083 printf("Error Check Args: enlightenment_info -hwc_trace [0/1]\n");
1087 onoff = atoi(argv[2]);
1089 if (onoff == 1 || onoff == 0)
1091 if (!_e_info_client_eldbus_message_with_args("hwc_trace_message", NULL, "i", onoff))
1093 printf("_e_info_client_eldbus_message_with_args error");
1098 printf("Error Check Args: enlightenment_info -hwc_trace [0/1]\n");
1106 const char *description;
1107 void (*func)(int argc, char **argv);
1111 "protocol_trace", "[console|file_path|disable]",
1112 "Enable/disable wayland protocol trace",
1113 _e_info_client_proc_protocol_trace
1117 "Print top visible windows",
1118 _e_info_client_proc_topvwins_info
1121 "dump_topvwins", "[directory_path]",
1122 "Dump top-level visible windows (default directory_path : current working directory)",
1123 _e_info_client_proc_topvwins_shot
1126 "eina_log_levels", "[mymodule1:5,mymodule2:2]",
1127 "Set EINA_LOG_LEVELS in runtime",
1128 _e_info_client_proc_eina_log_levels
1131 "eina_log_path", "[console|file_path]",
1132 "Set eina-log path in runtime",
1133 _e_info_client_proc_eina_log_path
1137 "Print window infomation",
1138 _e_info_client_prop_prop_info
1141 "connected_clients", NULL,
1142 "Print connected clients on Enlightenment",
1143 _e_info_client_proc_connected_clients
1148 "Send a message about rotation",
1149 _e_info_client_proc_rotation
1154 "Print connected client's resources",
1155 _e_info_client_proc_res_lists
1158 "input_devices", NULL,
1159 "Print connected input devices",
1160 _e_info_client_proc_input_device_info
1164 "Print FPS in every sec",
1165 _e_info_client_proc_fps_info
1169 "[id enable x y w h angle keep_ratio]",
1170 "Set transform in runtime",
1171 _e_info_client_proc_transform_set
1174 "dump_buffers", "[start:1,stop:0]",
1175 "Dump attach buffers (start:1,stop:0, path:/tmp/dump_xxx/)",
1176 _e_info_client_proc_buffer_shot
1182 "Show the hwc trace log",
1183 _e_info_client_proc_hwc_trace
1188 "Print a current keymap",
1189 _e_info_client_proc_keymap_info
1194 _e_info_client_eldbus_message_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *p EINA_UNUSED)
1196 E_Info_Message_Cb cb = (E_Info_Message_Cb)data;
1200 ecore_main_loop_quit();
1204 _e_info_client_eldbus_message(const char *method, E_Info_Message_Cb cb)
1208 p = eldbus_proxy_call(e_info_client.proxy, method,
1209 _e_info_client_eldbus_message_cb,
1211 EINA_SAFETY_ON_NULL_RETURN_VAL(p, EINA_FALSE);
1213 ecore_main_loop_begin();
1218 _e_info_client_eldbus_message_with_args(const char *method, E_Info_Message_Cb cb, const char *signature, ...)
1223 va_start(ap, signature);
1224 p = eldbus_proxy_vcall(e_info_client.proxy, method,
1225 _e_info_client_eldbus_message_cb,
1226 cb, -1, signature, ap);
1228 EINA_SAFETY_ON_NULL_RETURN_VAL(p, EINA_FALSE);
1230 ecore_main_loop_begin();
1235 _e_info_client_eldbus_disconnect(void)
1237 if (e_info_client.proxy)
1239 eldbus_proxy_unref(e_info_client.proxy);
1240 e_info_client.proxy = NULL;
1243 if (e_info_client.obj)
1245 eldbus_object_unref(e_info_client.obj);
1246 e_info_client.obj = NULL;
1249 if (e_info_client.conn)
1251 eldbus_connection_unref(e_info_client.conn);
1252 e_info_client.conn = NULL;
1255 if (e_info_client.eldbus_init)
1258 e_info_client.eldbus_init = 0;
1263 _e_info_client_eldbus_connect(void)
1265 e_info_client.eldbus_init = eldbus_init();
1266 EINA_SAFETY_ON_FALSE_GOTO(e_info_client.eldbus_init > 0, err);
1268 e_info_client.conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
1269 EINA_SAFETY_ON_NULL_GOTO(e_info_client.conn, err);
1271 e_info_client.obj = eldbus_object_get(e_info_client.conn,
1272 "org.enlightenment.wm",
1273 "/org/enlightenment/wm");
1274 EINA_SAFETY_ON_NULL_GOTO(e_info_client.obj, err);
1276 e_info_client.proxy = eldbus_proxy_get(e_info_client.obj, "org.enlightenment.wm.info");
1277 EINA_SAFETY_ON_NULL_GOTO(e_info_client.proxy, err);
1282 _e_info_client_eldbus_disconnect();
1287 _e_info_client_process(int argc, char **argv)
1289 int nproc = sizeof(procs) / sizeof(procs[0]);
1292 signal(SIGINT, end_program);
1293 signal(SIGALRM, end_program);
1294 signal(SIGHUP, end_program);
1295 signal(SIGPIPE, end_program);
1296 signal(SIGQUIT, end_program);
1297 signal(SIGTERM, end_program);
1299 for (i = 0; i < nproc; i++)
1301 if (!strncmp(argv[1]+1, procs[i].option, strlen(procs[i].option)))
1304 procs[i].func(argc, argv);
1314 _e_info_client_print_usage(const char *exec)
1316 int nproc = sizeof(procs) / sizeof(procs[0]);
1319 printf("\nUsage:\n");
1321 for (i = 0; i < nproc; i++)
1322 printf(" %s -%s %s\n", exec, procs[i].option, (procs[i].params)?procs[i].params:"");
1324 printf("\nOptions:\n");
1326 for (i = 0; i < nproc; i++)
1328 printf(" -%s\n", procs[i].option);
1329 printf(" %s\n", (procs[i].description)?procs[i].description:"");
1336 end_program(int sig)
1342 main(int argc, char **argv)
1344 if (argc < 2 || argv[1][0] != '-')
1346 _e_info_client_print_usage(argv[0]);
1350 /* connecting dbus */
1351 if (!_e_info_client_eldbus_connect())
1354 if (!strcmp(argv[1], "-h") ||
1355 !strcmp(argv[1], "-help") ||
1356 !strcmp(argv[1], "--help"))
1358 _e_info_client_print_usage(argv[0]);
1362 /* handling a client request */
1363 if (!_e_info_client_process(argc, argv))
1365 printf("unknown option: %s\n", argv[1]);
1366 _e_info_client_print_usage(argv[0]);
1370 /* disconnecting dbus */
1371 _e_info_client_eldbus_disconnect();
1376 _e_info_client_eldbus_disconnect();