From: Junkyeong, Kim Date: Fri, 22 Apr 2022 08:27:22 +0000 (+0900) Subject: Adjust cursor position X-Git-Tag: submit/tizen/20220427.130003~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd08a4f0ffb60c294a5c862612c202315c04e6c9;p=platform%2Fcore%2Fuifw%2Fe-mod-tizen-rdp.git Adjust cursor position if there is a big difference between pointer position and rdp client cursor position, adjust move value. - no big difference : move = previous rdp client cursor position - current rdp client cursor position - big difference : move = previous pointer position - current rdp client cursor position Change-Id: I48d7a282fbe12d0a947cf2574bc463b79d65a77e Signed-off-by: Junkyeong, Kim --- diff --git a/src/e_mod_rdp.c b/src/e_mod_rdp.c index ee194c5..cd0eb52 100644 --- a/src/e_mod_rdp.c +++ b/src/e_mod_rdp.c @@ -93,6 +93,8 @@ struct _E_Rdp_Output uint32_t prev_x; uint32_t prev_y; + Ecore_Timer *mouse_cal_timer; + Eina_Bool calibration; Eina_Bool cursor_changed; double refresh_time; @@ -1329,6 +1331,21 @@ _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) { @@ -1530,6 +1547,34 @@ _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) +{ + int diff_x = 0; + int diff_y = 0; + Eina_Bool cal = EINA_FALSE; + + if (!output->calibration) + { + 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; + } + + 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; + + 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; + + output->calibration = EINA_FALSE; + + return cal; +} + static BOOL e_rdp_peer_capabilities(freerdp_peer *client) { @@ -1669,6 +1714,9 @@ e_rdp_peer_activate(freerdp_peer *client) output->buffer_changed = EINA_TRUE; e_video_debug_display_primary_plane_set(EINA_TRUE); + + output->prev_x = e_comp->pointer->x; + output->prev_y = e_comp->pointer->y; } else { @@ -1727,6 +1775,7 @@ e_rdp_mouse_event(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) int motionless = 0; uint32_t button = 0; uint32_t state = 0; + Eina_Bool mouse_cal = EINA_FALSE; E_Rdp_Peer_Context *peerContext = (E_Rdp_Peer_Context *)input->context; E_Rdp_Output *output = peerContext->rdpBackend->output; @@ -1742,6 +1791,18 @@ e_rdp_mouse_event(rdpInput *input, UINT16 flags, UINT16 x, UINT16 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; } @@ -2210,6 +2271,11 @@ 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) {