From: Inhong Han Date: Thu, 9 May 2024 02:30:12 +0000 (+0900) Subject: Support for aligning the floating IME X-Git-Tag: accepted/tizen/8.0/unified/20240516.162447~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f6e40c31eaa7748cdad0cf30a53ea8883dd966b4;p=platform%2Fcore%2Fuifw%2Fe-mod-tizen-wl-textinput.git Support for aligning the floating IME Change-Id: I3defffa8de4f6305f9852600424e5b3cdf992482 --- diff --git a/src/e_mod_input_panel.c b/src/e_mod_input_panel.c index 81bd69f..b7ddc97 100644 --- a/src/e_mod_input_panel.c +++ b/src/e_mod_input_panel.c @@ -34,6 +34,19 @@ typedef enum E_INPUT_PANEL_COORDINATE_TYPE_LOGICAL, } E_Input_Panel_Coordinate_Type; +typedef enum +{ + E_INPUT_PANEL_ALIGN_TOP_LEFT, + E_INPUT_PANEL_ALIGN_TOP_CENTER, + E_INPUT_PANEL_ALIGN_TOP_RIGHT, + E_INPUT_PANEL_ALIGN_MIDDLE_LEFT, + E_INPUT_PANEL_ALIGN_MIDDLE_CENTER, + E_INPUT_PANEL_ALIGN_MIDDLE_RIGHT, + E_INPUT_PANEL_ALIGN_BOTTOM_LEFT, + E_INPUT_PANEL_ALIGN_BOTTOM_CENTER, + E_INPUT_PANEL_ALIGN_BOTTOM_RIGHT, +} E_Input_Panel_Align; + struct _E_Input_Panel { struct wl_global *global; @@ -82,6 +95,9 @@ struct _E_Input_Panel_Floating_Info Eina_Bool init_landscape_position; int before_canvas_x; int before_canvas_y; + int new_width; + int new_height; + E_Input_Panel_Align align; struct { @@ -96,6 +112,12 @@ struct _E_Input_Panel_Floating_Info int x; int y; } pending_position; + + struct + { + int x; + int y; + } align_position; }; static E_Input_Panel *g_input_panel = NULL; @@ -584,8 +606,72 @@ _e_input_panel_position_set(E_Client *ec, int w, int h) _e_input_panel_convert_floating_position(ec, sx, sy, &nx, &ny, E_INPUT_PANEL_COORDINATE_TYPE_LOGICAL); } - LOGI("nx : %d, ny : %d", nx, ny); - e_client_util_move_without_frame(ec, nx, ny); + if (ec->vkbd.floating && g_floating_info->new_width > 0 && g_floating_info->new_height > 0) + { + LOGI("x : %d, y : %d, w : %d, h : %d", nx, ny, g_floating_info->new_width, g_floating_info->new_height); + e_client_util_move_resize_without_frame(ec, nx, ny, g_floating_info->new_width, g_floating_info->new_height); + g_floating_info->new_width = -1; + g_floating_info->new_height = -1; + } + else + { + LOGI("x : %d, y : %d", nx, ny); + e_client_util_move_without_frame(ec, nx, ny); + } +} + +static void +_e_input_panel_floating_position_align_set(E_Client *ec) +{ + int x, y; + + if (!ec || !g_floating_info) return; + + x = g_floating_info->align_position.x; + y = g_floating_info->align_position.y; + + switch (g_floating_info->align) + { + case E_INPUT_PANEL_ALIGN_TOP_CENTER: + x -= (ec->w / 2); + break; + case E_INPUT_PANEL_ALIGN_TOP_RIGHT: + x -= ec->w; + break; + case E_INPUT_PANEL_ALIGN_MIDDLE_LEFT: + y -= (ec->h / 2); + break; + case E_INPUT_PANEL_ALIGN_MIDDLE_CENTER: + x -= (ec->w / 2); + y -= (ec->h / 2); + break; + case E_INPUT_PANEL_ALIGN_MIDDLE_RIGHT: + x -= ec->w; + y -= (ec->h / 2); + break; + case E_INPUT_PANEL_ALIGN_BOTTOM_LEFT: + y -= ec->h; + break; + case E_INPUT_PANEL_ALIGN_BOTTOM_CENTER: + x -= (ec->w / 2); + y -= ec->h; + break; + case E_INPUT_PANEL_ALIGN_BOTTOM_RIGHT: + x -= ec->w; + y -= ec->h; + break; + case E_INPUT_PANEL_ALIGN_TOP_LEFT: + default: + x = g_floating_info->align_position.x; + y = g_floating_info->align_position.y; + break; + } + + LOGI("x : %d, y : %d, w : %d, h : %d", x, y, ec->w, ec->h); + e_input_panel_floating_position_set(x, y); + + g_floating_info->align_position.x = -1; + g_floating_info->align_position.y = -1; } static void @@ -596,6 +682,9 @@ _ips_show(E_Client *ec) LOGI("IPS::SHOW\n"); + if (ec->vkbd.floating && g_floating_info->align_position.x >= 0 && g_floating_info->align_position.y >= 0) + _e_input_panel_floating_position_align_set(ec); + _e_input_panel_position_set(ec, ec->client.w, ec->client.h); ec->visible = EINA_TRUE; @@ -1724,4 +1813,41 @@ void e_input_panel_pending_position_reset(void) g_floating_info->pending_position.x = -1; g_floating_info->pending_position.y = -1; } +} + +void e_input_panel_floating_position_align_set(int x, int y, int align) +{ + E_Input_Panel_Surface *floating_ips = NULL; + E_Input_Panel_Surface *ips = NULL; + Eina_List *l; + Eina_List *l_next; + + if (g_floating_info) + { + LOGI("x : %d, y : %d, align : %d", x, y, align); + g_floating_info->align_position.x = x; + g_floating_info->align_position.y = y; + g_floating_info->align = (E_Input_Panel_Align)align; + } + + EINA_LIST_FOREACH_SAFE(g_input_panel->surfaces, l, l_next, ips) + { + if (!ips || !ips->ec) continue; + if (ips->ec->frame && ips->ec->vkbd.floating) + { + floating_ips = ips; + break; + } + } + + if (floating_ips && floating_ips->showing) + _e_input_panel_floating_position_align_set(floating_ips->ec); +} + +void e_input_panel_floating_panel_move_resize(int x, int y, int w, int h) +{ + LOGI("x : %d, y : %d, w : %d, h : %d", x, y, w, h); + g_floating_info->new_width = w; + g_floating_info->new_height = h; + e_input_panel_floating_position_set(x, y); } \ No newline at end of file diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 130d61f..7770237 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -1049,6 +1049,17 @@ _e_text_input_method_context_cb_set_floating_drag_enabled(struct wl_client *clie e_input_panel_floating_drag_enabled(enabled ? EINA_TRUE : EINA_FALSE); } +static void +_e_text_input_method_context_cb_move_resize_floating_panel(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, + uint32_t x, uint32_t y, uint32_t width, uint32_t height) +{ + E_Text_Input *text_input = wl_resource_get_user_data(resource); + + CHECK_TEXT_INPUT(resource, text_input); + LOGI("x : %u, y : %u, w : %u, h : %u", x, y, width, height); + e_input_panel_floating_panel_move_resize(x, y, width, height); +} + static const struct zwp_input_method_context_v1_interface _e_text_input_method_context_implementation = { _e_text_input_method_context_cb_destroy, _e_text_input_method_context_cb_string_commit, @@ -1079,6 +1090,7 @@ static const struct zwp_input_method_context_v1_interface _e_text_input_method_c _e_text_input_method_context_cb_reshow_input_panel, _e_text_input_method_context_cb_set_floating_panel, _e_text_input_method_context_cb_set_floating_drag_enabled, + _e_text_input_method_context_cb_move_resize_floating_panel, }; static void @@ -1924,6 +1936,7 @@ _e_text_input_cb_input_panel_position_set(struct wl_client *client EINA_UNUSED, E_Text_Input *text_input = wl_resource_get_user_data(resource); CHECK_TEXT_INPUT(resource, text_input); + LOGI("x : %u, y : %u", x, y); e_input_panel_floating_position_set(x, y); } @@ -1963,6 +1976,25 @@ _e_text_input_cb_surrounding_text_ex_set(struct wl_client *client EINA_UNUSED, s } } +static void +_e_text_input_cb_input_panel_position_align_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t x, uint32_t y, uint32_t align) +{ + E_Text_Input *text_input = wl_resource_get_user_data(resource); + E_Input_Method *input_method = NULL; + Eina_List *l = NULL; + + CHECK_TEXT_INPUT(resource, text_input); + e_input_panel_floating_position_align_set(x, y, align); + + EINA_LIST_FOREACH(text_input->input_methods, l, input_method) + { + if (!input_method || !input_method->context) continue; + + if (input_method->context->resource) + zwp_input_method_context_v1_send_input_panel_position_align(input_method->context->resource, x, y, align); + } +} + static void _e_text_input_cb_resource_destroy(struct wl_resource *resource) { @@ -2062,7 +2094,8 @@ static const struct wl_text_input_interface _e_text_input_implementation = { _e_text_input_cb_finalize_content, _e_text_input_cb_prediction_hint_data_set, _e_text_input_cb_input_panel_enabled_set, - _e_text_input_cb_surrounding_text_ex_set + _e_text_input_cb_surrounding_text_ex_set, + _e_text_input_cb_input_panel_position_align_set }; static void diff --git a/src/e_mod_main.h b/src/e_mod_main.h index fe651e8..87f71ce 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -30,6 +30,8 @@ void e_input_panel_floating_drag_enabled(Eina_Bool enabled); Eina_Bool e_input_panel_floating_mode_get(void); Eina_Bool e_text_input_activation_state_get(void); void e_input_panel_pending_position_reset(void); +void e_input_panel_floating_position_align_set(int x, int y, int align); +void e_input_panel_floating_panel_move_resize(int x, int y, int w, int h); typedef enum { TIZEN_PROFILE_UNKNOWN = 0,