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;
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;
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;
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)
{
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
static BOOL
e_rdp_peer_post_connect(freerdp_peer *client)
{
+ e_info_server_input_mouse_accel_set(0);
return TRUE;
}
}
}
- 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)
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)
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
{
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;
}
}
{
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);
}
output->h = E_RDP_HEIGHT;
}
- output->prev_x = output->prev_y = 0;
-
wl_list_init(&output->peers);
return output;
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)
{