From: Junkyeong, Kim Date: Fri, 3 Jun 2022 06:44:53 +0000 (+0900) Subject: Change mouse event treat method X-Git-Tag: submit/tizen/20220609.045520~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc422d551bb6448bfb4308df3a559b72bced0851;p=platform%2Fcore%2Fuifw%2Fe-mod-tizen-rdp.git Change mouse event treat method - use client side default cursor. - change move value calculation prev : diff current client mouse event and previous client mouse event. next : diff current client mouse event and e_pointer current coordinate. - set to do not use pointer acceleration. Change-Id: I4e33bd4bc21527726e3591ecf0dfc2a1f2744a58 Signed-off-by: Junkyeong, Kim --- diff --git a/src/e_mod_rdp.c b/src/e_mod_rdp.c index cd0eb52..e73cead 100644 --- a/src/e_mod_rdp.c +++ b/src/e_mod_rdp.c @@ -67,7 +67,6 @@ typedef struct _E_Rdp_Output E_Rdp_Output; typedef struct _E_Rdp_Backend E_Rdp_Backend; typedef struct _E_Rdp_Peer_Context E_Rdp_Peer_Context; typedef struct _E_Rdp_Peer_Item E_Rdp_Peer_Item; -typedef struct _E_Rdp_Peer_Context E_Rdp_Peer_Context; static E_Rdp_Config_Data *g_rdp_config; static E_Rdp_Backend *g_rdp_backend; @@ -88,15 +87,6 @@ struct _E_Rdp_Output uint32_t primary_w; uint32_t primary_h; - float mouse_scale_w; - float mouse_scale_h; - - uint32_t prev_x; - uint32_t prev_y; - Ecore_Timer *mouse_cal_timer; - Eina_Bool calibration; - - Eina_Bool cursor_changed; double refresh_time; int refresh_count; @@ -108,6 +98,10 @@ struct _E_Rdp_Output Eina_Rectangle cursor_crop_dst; Eina_Rectangle cursor_damage_rect; + Eina_Rectangle input_region; + float mouse_scale_w; + float mouse_scale_h; + int mouse_x; int mouse_y; @@ -1331,21 +1325,6 @@ _e_rdp_frame_timer(void *data) return ECORE_CALLBACK_RENEW; } -static Eina_Bool -_e_rdp_recal_timer(void *data) -{ - E_Rdp_Output *output; - - EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL); - - output = (E_Rdp_Output *)data; - - output->calibration = EINA_TRUE; - output->mouse_cal_timer = NULL; - - return ECORE_CALLBACK_CANCEL; -} - static void _e_rdp_free_keyfile(E_Rdp_Backend *b, rdpSettings *settings) { @@ -1547,32 +1526,64 @@ _e_rdp_refresh_time_set(uint32_t w, uint32_t h) return VGA_TIME; } -static Eina_Bool -_e_rdp_mouse_cal(E_Rdp_Output *output, int x, int y) +static void +_e_rdp_get_input_region(E_Rdp_Output *output) { - int diff_x = 0; - int diff_y = 0; - Eina_Bool cal = EINA_FALSE; + double server_ratio, client_ratio; - if (!output->calibration) + server_ratio = (double)output->primary_w / (double)output->primary_h; + client_ratio = (double)output->w / (double)output->h; + if (server_ratio > client_ratio) { - if (output->mouse_cal_timer) - ecore_timer_del(output->mouse_cal_timer); - output->mouse_cal_timer = ecore_timer_add(2.0, _e_rdp_recal_timer, output); - return cal; + output->input_region.x = 0; + output->input_region.w = output->w; + output->input_region.h = output->primary_h * output->w / output->primary_w; + output->input_region.y = (output->h - output->input_region.h) / 2; } + else if (server_ratio < client_ratio) + { + output->input_region.y = 0; + output->input_region.h = output->h; + output->input_region.w = output->primary_w * output->h / output->primary_h; + output->input_region.x = (output->w - output->input_region.w) / 2; + } + else // server_ratio == client_ratio + { + output->input_region.x = 0; + output->input_region.y = 0; + output->input_region.w = output->w; + output->input_region.h = output->h; + } +} + +static Eina_Bool +_e_rdp_check_input_region(E_Rdp_Output *output, int x, int y) +{ + if (output->input_region.x > x || + output->input_region.x + output->input_region.w < x) + return EINA_FALSE; - diff_x = (x * output->mouse_scale_w) - e_comp->pointer->x; - if (diff_x <= (-1 * ((int)output->primary_w / 2 - 10)) || diff_x >= (int)output->primary_w / 2 - 10) - cal = EINA_TRUE; + if (output->input_region.y > y || + output->input_region.y + output->input_region.h < y) + return EINA_FALSE; - diff_y = (y * output->mouse_scale_h) - e_comp->pointer->y; - if (diff_y <= (-1 * ((int)output->primary_h / 2 - 10)) || diff_y >= (int)output->primary_h / 2 - 10) - cal = EINA_TRUE; + return EINA_TRUE; +} - output->calibration = EINA_FALSE; +static int +_e_rdp_get_pointer_x(E_Rdp_Output *output, int x) +{ + float temp_x; + temp_x = x - output->input_region.x; + return temp_x * output->mouse_scale_w; +} - return cal; +static int +_e_rdp_get_pointer_y(E_Rdp_Output *output, int y) +{ + float temp_y; + temp_y = y - output->input_region.y; + return temp_y * output->mouse_scale_h; } static BOOL @@ -1584,6 +1595,7 @@ e_rdp_peer_capabilities(freerdp_peer *client) static BOOL e_rdp_peer_post_connect(freerdp_peer *client) { + e_info_server_input_mouse_accel_set(0); return TRUE; } @@ -1655,9 +1667,6 @@ e_rdp_peer_activate(freerdp_peer *client) } } - output->mouse_scale_w = (float)output->primary_w / output->w; - output->mouse_scale_h = (float)output->primary_h / output->h; - rfx_context_reset(peerCtx->rfx_context, output->w, output->h); nsc_context_reset(peerCtx->nsc_context, output->w, output->h); if (peersItem->flags & RDP_PEER_ACTIVATED) @@ -1670,9 +1679,9 @@ e_rdp_peer_activate(freerdp_peer *client) peersItem->flags |= RDP_PEER_ACTIVATED; b->client_count++; - /* disable pointer on the client side */ + /* enable pointer on the client side */ pointer = client->update->pointer; - pointer_system.type = SYSPTR_NULL; + pointer_system.type = SYSPTR_DEFAULT; pointer->PointerSystem(client->context, &pointer_system); if (b->client_count == 1) @@ -1715,8 +1724,10 @@ e_rdp_peer_activate(freerdp_peer *client) e_video_debug_display_primary_plane_set(EINA_TRUE); - output->prev_x = e_comp->pointer->x; - output->prev_y = e_comp->pointer->y; + _e_rdp_get_input_region(output); + + output->mouse_scale_w = (float)output->primary_w / (float)output->input_region.w; + output->mouse_scale_h = (float)output->primary_h / (float)output->input_region.h; } else { @@ -1770,41 +1781,26 @@ e_rdp_input_synchronize_event(rdpInput *input, UINT32 flags) static BOOL e_rdp_mouse_event(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) { - int e_output_w, e_output_h; int move_x = 0, move_y = 0; int motionless = 0; uint32_t button = 0; uint32_t state = 0; - Eina_Bool mouse_cal = EINA_FALSE; - + int cal_x = 0, cal_y = 0; E_Rdp_Peer_Context *peerContext = (E_Rdp_Peer_Context *)input->context; E_Rdp_Output *output = peerContext->rdpBackend->output; - E_Output *e_output = output->primary_output; - e_output_w = e_output->config.mode.w; - e_output_h = e_output->config.mode.h; + motionless = peerContext->rdpBackend->motionless; if (flags & PTR_FLAGS_MOVE && !motionless) { - if (x < e_output_w && y < e_output_h) + if (_e_rdp_check_input_region(output, x, y)) { state = E_INFO_EVENT_STATE_MOTION; - move_x = (int)((int)(x - output->prev_x) * output->mouse_scale_w); - move_y = (int)((int)(y - output->prev_y) * output->mouse_scale_h); - mouse_cal = _e_rdp_mouse_cal(output, x, y); - if (mouse_cal) - { - move_x = (int)((x * output->mouse_scale_w) - e_comp->pointer->x); - move_y = (int)((y * output->mouse_scale_h) - e_comp->pointer->y); - } - else - { - move_x = (int)((int)(x - output->prev_x) * output->mouse_scale_w); - move_y = (int)((int)(y - output->prev_y) * output->mouse_scale_h); - } - output->prev_x = x; - output->prev_y = y; + cal_x = _e_rdp_get_pointer_x(output, x); + cal_y = _e_rdp_get_pointer_y(output, y); + move_x = cal_x - e_comp->pointer->x; + move_y = cal_y - e_comp->pointer->y; } } @@ -1838,14 +1834,13 @@ e_rdp_mouse_event(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) { if (!(flags & PTR_FLAGS_MOVE)) { - if (x < e_output_w && y < e_output_h) + if (_e_rdp_check_input_region(output, x, y)) { - move_x = (int)((int)(x - output->prev_x) * output->mouse_scale_w); - move_y = (int)((int)(y - output->prev_y) * output->mouse_scale_h); - output->prev_x = x; - output->prev_y = y; + cal_x = _e_rdp_get_pointer_x(output, x); + cal_y = _e_rdp_get_pointer_y(output, y); + move_x = cal_x - e_comp->pointer->x; + move_y = cal_y - e_comp->pointer->y; } - e_info_server_input_mousegen(0, move_x, move_y, E_INFO_EVENT_STATE_MOTION); e_info_server_input_mousegen(button, move_x, move_y, state); } @@ -2240,8 +2235,6 @@ e_rdp_output_create(void) output->h = E_RDP_HEIGHT; } - output->prev_x = output->prev_y = 0; - wl_list_init(&output->peers); return output; @@ -2271,11 +2264,6 @@ e_rdp_backend_destroy(void) ecore_event_handler_del(h); b->handlers = NULL; } - if (b->output->mouse_cal_timer) - { - ecore_timer_del(b->output->mouse_cal_timer); - b->output->mouse_cal_timer = NULL; - } if (b->output->frame_timer) {