From: jeon Date: Mon, 3 Jun 2019 06:39:26 +0000 (+0900) Subject: headless_debug: implement a keymap print X-Git-Tag: submit/tizen/20190709.095046~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cade3af8b912ad2ec60a901b32fa26ca3fd72836;p=platform%2Fcore%2Fuifw%2Fpepper.git headless_debug: implement a keymap print --- diff --git a/data/scripts/winfo b/data/scripts/winfo index 2e02f35..e320655 100644 --- a/data/scripts/winfo +++ b/data/scripts/winfo @@ -24,6 +24,7 @@ function usage() echo " stdout (redirect STDOUT to a file : /run/pepper/stdout.txt)" echo " stderr (redirect STDERR to a file : /run/pepper/stderr.txt)" echo " keygrab_status" + echo " keymap" echo " topvwins" echo " connected_clients (display connected clients info : pid, uid, gid, socket fd)" echo " reslist (display resources info of the connected clients" @@ -35,11 +36,12 @@ function usage() echo " # winfo protocol_trace_on : enable event trace" echo " # winfo protocol_trace_off : disable event trace" echo " # winfo stdout : redirect STDOUT" - echo " # winfo stderr : redirect STDERR" + echo " # winfo stderr : redirect STDERR" echo " # winfo keygrab_status : display keygrab status" + echo " # winfo keymap : display keymap" echo " # winfo topvwins : display top/visible window stack" echo " # winfo connected_clients : display connected clients information" - echo " # winfo reslist : display each resources information of connected clients" + echo " # winfo reslist : display each resources information of connected clients" echo " # winfo help : display this help message" echo "" } diff --git a/src/bin/headless/debug/debug.c b/src/bin/headless/debug/debug.c index c45ea7c..145e1cc 100644 --- a/src/bin/headless/debug/debug.c +++ b/src/bin/headless/debug/debug.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #define MAX_CMDS 256 @@ -41,6 +43,7 @@ #define TOPVWINS "topvwins" #define CONNECTED_CLIENTS "connected_clients" #define CLIENT_RESOURCES "reslist" +#define KEYMAP "keymap" #define HELP_MSG "help" typedef struct @@ -76,6 +79,7 @@ _headless_debug_usage() fprintf(stdout, "\t %s\n", TOPVWINS); fprintf(stdout, "\t %s\n", CONNECTED_CLIENTS); fprintf(stdout, "\t %s\n", CLIENT_RESOURCES); + fprintf(stdout, "\t %s\n", KEYMAP); fprintf(stdout, "\t %s\n", HELP_MSG); fprintf(stdout, "\nTo execute commands, just create/remove/update a file with the commands above.\n"); @@ -88,6 +92,7 @@ _headless_debug_usage() fprintf(stdout, "\t # winfo topvwins\t\t : display top/visible window stack\n"); fprintf(stdout, "\t # winfo connected_clients\t : display connected clients information\n"); fprintf(stdout, "\t # winfo reslist\t\t : display each resources information of connected clients\n"); + fprintf(stdout, "\t # winfo keymap\t\t : display current xkb keymap\n"); fprintf(stdout, "\t # winfo help\t\t\t : display this help message\n"); } @@ -221,15 +226,6 @@ _headless_debug_redir_stderr(headless_debug_t *hdebug, void *data) } -static void -_headless_debug_NOT_supported(headless_debug_t *hdebug, void *data) -{ - (void) hdebug; - (void) data; - - PEPPER_TRACE("NOT SUPPORTED. WILL BE IMPLEMENTED SOON.\n"); -} - static void _headless_debug_topvwins(headless_debug_t *hdebug, void *data) { @@ -288,6 +284,59 @@ _headless_debug_keygrab_status(headless_debug_t *hdebug, void *data) pepper_keyrouter_debug_keygrab_status_print(keyrouter); } +static void +_headless_debug_keymap(headless_debug_t *hdebug, void *data) +{ + pepper_xkb_t *xkb; + + int i; + int min_keycode, max_keycode, num_mods, num_groups; + struct xkb_context *context = NULL; + struct xkb_keymap *keymap = NULL; + struct xkb_state *state = NULL; + xkb_keysym_t sym = XKB_KEY_NoSymbol; + char keyname[256] = {0, }; + + xkb = headless_input_get_xkb(hdebug->compositor); + PEPPER_CHECK(xkb, return, "xkb is not set\n"); + + context = pepper_xkb_get_context(xkb); + PEPPER_CHECK(context, return, "Current pepper_xkb has no context.\n"); + keymap = pepper_xkb_get_keymap(xkb); + PEPPER_CHECK(keymap, return, "Current pepper_xkb has no keymap.\n"); + state = pepper_xkb_get_state(xkb); + PEPPER_CHECK(state, return, "Current pepper_xkb has no state.\n"); + + min_keycode = xkb_keymap_min_keycode(keymap); + max_keycode = xkb_keymap_max_keycode(keymap); + num_groups = xkb_map_num_groups(keymap); + num_mods = xkb_keymap_num_mods(keymap); + + printf("\n"); + printf(" min keycode: %d\n", min_keycode); + printf(" max keycode: %d\n", max_keycode); + printf(" num_groups : %d\n", num_groups); + printf(" num_mods : %d\n", num_mods); + for (i = 0; i < num_mods; i++) { + printf(" [%2d] mod: %s\n", i, xkb_keymap_mod_get_name(keymap, i)); + } + + printf("\n\n\tkeycode\t\tkeyname\t\t keysym\t repeat\n"); + printf(" ----------------------------------------------------------------------\n"); + + for (i = min_keycode; i < (max_keycode + 1); i++) { + sym = xkb_state_key_get_one_sym(state, i); + + memset(keyname, 0, sizeof(keyname)); + xkb_keysym_get_name(sym, keyname, sizeof(keyname)); + + if (!strncmp(keyname, "NoSymbol", sizeof("NoSymbol")) && sym == 0x0) + continue; + + printf("\t%4d%-5s%-25s%-20x%-5d\n", i, "", keyname, sym, xkb_keymap_key_repeats(keymap, i)); + } +} + static const headless_debug_action_t debug_actions[] = { { STDOUT_REDIR, _headless_debug_redir_stdout, NULL }, @@ -298,6 +347,7 @@ static const headless_debug_action_t debug_actions[] = { TOPVWINS, _headless_debug_topvwins, NULL }, { CONNECTED_CLIENTS, _headless_debug_connected_clients, NULL }, { CLIENT_RESOURCES, _headless_debug_connected_clients, NULL }, + { KEYMAP, _headless_debug_keymap, NULL }, { HELP_MSG, _headless_debug_dummy, NULL }, }; @@ -372,7 +422,7 @@ headless_debug_set_focus_view(pepper_compositor_t *compositor, pepper_view_t *fo } PEPPER_API void -headless_debug_set_top_view(void *compositor, pepper_view_t *top_view) +headless_debug_set_top_view(pepper_compositor_t *compositor, pepper_view_t *top_view) { headless_debug_t *hdebug = NULL; diff --git a/src/bin/headless/headless_server.h b/src/bin/headless/headless_server.h index ae3f59a..3b71fe5 100644 --- a/src/bin/headless/headless_server.h +++ b/src/bin/headless/headless_server.h @@ -44,6 +44,7 @@ PEPPER_API void headless_input_deinit(pepper_compositor_t *compositor); PEPPER_API void headless_input_set_focus_view(pepper_compositor_t *compositor, pepper_view_t *view); PEPPER_API void headless_input_set_top_view(pepper_compositor_t *compositor, pepper_view_t *view); PEPPER_API void *headless_input_get_keyrouter(pepper_compositor_t *compositor); +PEPPER_API void *headless_input_get_xkb(pepper_compositor_t *compositor); /* APIs for headless_debug */ PEPPER_API pepper_bool_t headless_debug_init(pepper_compositor_t *compositor); diff --git a/src/bin/headless/input/input.c b/src/bin/headless/input/input.c index 967a247..45cf874 100644 --- a/src/bin/headless/input/input.c +++ b/src/bin/headless/input/input.c @@ -155,6 +155,16 @@ headless_input_get_keyrouter(pepper_compositor_t *compositor) return hi->keyrouter; } +PEPPER_API void * +headless_input_get_xkb(pepper_compositor_t *compositor) +{ + headless_input_t *hi; + hi = pepper_object_get_user_data((pepper_object_t *)compositor, &KEY_INPUT); + PEPPER_CHECK(hi, return NULL, "input system is not initialized\n"); + + return hi->xkb; +} + void headless_input_set_focus_view(pepper_compositor_t *compositor, pepper_view_t *focus_view) { diff --git a/src/lib/xkb/pepper-xkb.h b/src/lib/xkb/pepper-xkb.h index 81faecc..757663a 100644 --- a/src/lib/xkb/pepper-xkb.h +++ b/src/lib/xkb/pepper-xkb.h @@ -36,6 +36,10 @@ typedef pepper_xkb_rule_names pepper_xkb_rule_names_t; typedef struct pepper_xkb_info pepper_xkb_info_t; typedef struct pepper_xkb pepper_xkb_t; +PEPPER_API struct xkb_keymap *pepper_xkb_get_keymap(pepper_xkb_t *xkb); +PEPPER_API struct xkb_context *pepper_xkb_get_context(pepper_xkb_t *xkb); +PEPPER_API struct xkb_state *pepper_xkb_get_state(pepper_xkb_t *xkb); + PEPPER_API void pepper_xkb_keyboard_set_keymap(pepper_xkb_t *xkb, pepper_keyboard_t *keyboard, diff --git a/src/lib/xkb/xkb.c b/src/lib/xkb/xkb.c index 2ad4090..0e7bdec 100644 --- a/src/lib/xkb/xkb.c +++ b/src/lib/xkb/xkb.c @@ -325,6 +325,33 @@ pepper_xkb_set_keyboard(pepper_xkb_t *xkb, pepper_xkb_info_t *info, return; } +PEPPER_API struct xkb_keymap * +pepper_xkb_get_keymap(pepper_xkb_t *xkb) +{ + PEPPER_CHECK(xkb, return NULL, "invalid xkb!\n"); + PEPPER_CHECK(xkb->info, return NULL, "keymap is not ready\n"); + + return xkb->info->keymap; +} + +PEPPER_API struct xkb_context * +pepper_xkb_get_context(pepper_xkb_t *xkb) +{ + PEPPER_CHECK(xkb, return NULL, "invalid xkb!\n"); + PEPPER_CHECK(xkb->info, return NULL, "keymap is not ready\n"); + + return xkb->info->context; +} + +PEPPER_API struct xkb_state * +pepper_xkb_get_state(pepper_xkb_t *xkb) +{ + PEPPER_CHECK(xkb, return NULL, "invalid xkb!\n"); + PEPPER_CHECK(xkb->info, return NULL, "keymap is not ready\n"); + + return xkb->info->state; +} + PEPPER_API void pepper_xkb_keyboard_set_keymap(pepper_xkb_t *xkb, pepper_keyboard_t *keyboard, @@ -342,6 +369,7 @@ pepper_xkb_keyboard_set_keymap(pepper_xkb_t *xkb, pending_xkb_info = pepper_xkb_info_create_with_names(names); pepper_keyboard_set_pending_xkb_info(keyboard, pending_xkb_info); pepper_xkb_set_keyboard(xkb, pending_xkb_info, keyboard); + xkb->info = pending_xkb_info; } PEPPER_API pepper_xkb_t *