summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-01-13 10:33:22 -0500
committerChris Michael <cp.michael@samsung.com>2015-01-13 10:35:52 -0500
commit90ffc57f0c6d7c56047288dbdf78bdde4042e9bd (patch)
tree4dbe39aa8e7cf28b84e00e159ba7b39f81e6ae16 /src/lib/ecore_drm
parent30506f0d6d295dea2f1d905e655123874b3e1a11 (diff)
ecore-drm: Limit mouse movement to within the output size
Summary: This patch adds support to limit the mouse from moving outside the output dimensions, and fixes coordinate transformation calls to use the Output from the Input device @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/ecore_drm_evdev.c66
1 files changed, 58 insertions, 8 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_evdev.c b/src/lib/ecore_drm/ecore_drm_evdev.c
index 333977172c..c52b25b7d8 100644
--- a/src/lib/ecore_drm/ecore_drm_evdev.c
+++ b/src/lib/ecore_drm/ecore_drm_evdev.c
@@ -32,8 +32,8 @@ _device_calibration_set(Ecore_Drm_Evdev *edev)
32 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6)) 32 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
33 goto cont; 33 goto cont;
34 34
35 cal[2] /= edev->output.w; 35 cal[2] /= edev->output->current_mode->width;
36 cal[5] /= edev->output.h; 36 cal[5] /= edev->output->current_mode->height;
37 37
38 status = 38 status =
39 libinput_device_config_calibration_set_matrix(edev->device, cal); 39 libinput_device_config_calibration_set_matrix(edev->device, cal);
@@ -48,6 +48,39 @@ cont:
48} 48}
49 49
50static void 50static void
51_device_output_set(Ecore_Drm_Evdev *edev)
52{
53 Ecore_Drm_Input *input;
54 Ecore_Drm_Output *output;
55 const char *oname;
56
57 if (!edev->seat) return;
58 if (!(input = edev->seat->input)) return;
59
60 oname = libinput_device_get_output_name(edev->device);
61 if (oname)
62 {
63 Eina_List *l;
64
65 DBG("Device Has Output Name: %s", oname);
66
67 EINA_LIST_FOREACH(input->dev->outputs, l, output)
68 {
69 if ((output->name) && (!strcmp(output->name, oname)))
70 {
71 edev->output = output;
72 break;
73 }
74 }
75 }
76 else
77 {
78 if (!(output = eina_list_nth(input->dev->outputs, 0))) return;
79 edev->output = output;
80 }
81}
82
83static void
51_device_configure(Ecore_Drm_Evdev *edev) 84_device_configure(Ecore_Drm_Evdev *edev)
52{ 85{
53 if (libinput_device_config_tap_get_finger_count(edev->device) > 0) 86 if (libinput_device_config_tap_get_finger_count(edev->device) > 0)
@@ -58,6 +91,7 @@ _device_configure(Ecore_Drm_Evdev *edev)
58 libinput_device_config_tap_set_enabled(edev->device, tap); 91 libinput_device_config_tap_set_enabled(edev->device, tap);
59 } 92 }
60 93
94 _device_output_set(edev);
61 _device_calibration_set(edev); 95 _device_calibration_set(edev);
62} 96}
63 97
@@ -286,11 +320,25 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve
286{ 320{
287 Ecore_Drm_Input *input; 321 Ecore_Drm_Input *input;
288 Ecore_Event_Mouse_Move *ev; 322 Ecore_Event_Mouse_Move *ev;
323 Ecore_Drm_Output *output;
289 324
290 if (!(input = edev->seat->input)) return; 325 if (!(input = edev->seat->input)) return;
291 326
292 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return; 327 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
293 328
329 if ((output = edev->output))
330 {
331 if (edev->mouse.x < output->x)
332 edev->mouse.x = output->x;
333 else if (edev->mouse.x >= (output->x + output->current_mode->width))
334 edev->mouse.x = (output->x + output->current_mode->width - 1);
335
336 if (edev->mouse.y < output->y)
337 edev->mouse.y = output->y;
338 else if (edev->mouse.y >= (output->y + output->current_mode->height))
339 edev->mouse.y = (output->y + output->current_mode->height - 1);
340 }
341
294 ev->window = (Ecore_Window)input->dev->window; 342 ev->window = (Ecore_Window)input->dev->window;
295 ev->event_window = (Ecore_Window)input->dev->window; 343 ev->event_window = (Ecore_Window)input->dev->window;
296 ev->root_window = (Ecore_Window)input->dev->window; 344 ev->root_window = (Ecore_Window)input->dev->window;
@@ -342,9 +390,11 @@ _device_handle_pointer_motion_absolute(struct libinput_device *device, struct li
342 if (!(edev = libinput_device_get_user_data(device))) return; 390 if (!(edev = libinput_device_get_user_data(device))) return;
343 391
344 edev->mouse.x = 392 edev->mouse.x =
345 libinput_event_pointer_get_absolute_x_transformed(event, edev->output.w); 393 libinput_event_pointer_get_absolute_x_transformed(event,
394 edev->output->current_mode->width);
346 edev->mouse.y = 395 edev->mouse.y =
347 libinput_event_pointer_get_absolute_y_transformed(event, edev->output.h); 396 libinput_event_pointer_get_absolute_y_transformed(event,
397 edev->output->current_mode->height);
348 398
349 _device_pointer_motion(edev, event); 399 _device_pointer_motion(edev, event);
350} 400}
@@ -607,9 +657,9 @@ _device_handle_touch_down(struct libinput_device *device, struct libinput_event_
607 if (!(edev = libinput_device_get_user_data(device))) return; 657 if (!(edev = libinput_device_get_user_data(device))) return;
608 658
609 edev->mouse.x = 659 edev->mouse.x =
610 libinput_event_touch_get_x_transformed(event, edev->output.w); 660 libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width);
611 edev->mouse.y = 661 edev->mouse.y =
612 libinput_event_touch_get_y_transformed(event, edev->output.h); 662 libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height);
613 663
614 edev->mt_slot = libinput_event_touch_get_seat_slot(event); 664 edev->mt_slot = libinput_event_touch_get_seat_slot(event);
615 665
@@ -629,9 +679,9 @@ _device_handle_touch_motion(struct libinput_device *device, struct libinput_even
629 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return; 679 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
630 680
631 edev->mouse.x = 681 edev->mouse.x =
632 libinput_event_touch_get_x_transformed(event, edev->output.w); 682 libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width);
633 edev->mouse.y = 683 edev->mouse.y =
634 libinput_event_touch_get_y_transformed(event, edev->output.h); 684 libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height);
635 685
636 edev->mt_slot = libinput_event_touch_get_seat_slot(event); 686 edev->mt_slot = libinput_event_touch_get_seat_slot(event);
637 687