e_input: change calibrations when output is changed 14/168114/3
authorJengHyun Kang <jhyuni.kang@samsung.com>
Wed, 24 Jan 2018 07:49:26 +0000 (16:49 +0900)
committerJeongHyun Kang <jhyuni.kang@samsung.com>
Tue, 30 Jan 2018 04:10:28 +0000 (04:10 +0000)
Change-Id: I88a2f65bc3bb157ceb0c1ceeb864d543a034ffaa

src/bin/e_input.c
src/bin/e_input.h
src/bin/e_input_device.c
src/bin/e_input_evdev.c
src/bin/e_input_private.h

index 2a6ca8a..fe19eef 100644 (file)
@@ -13,6 +13,22 @@ E_API int E_EVENT_INPUT_DISABLED = -1;
 
 E_API E_Input *e_input = NULL;
 
+static Eina_Bool
+_e_input_cb_screen_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
+{
+   Eina_List *l;
+   Eina_List *devices;
+   E_Input_Device *dev_data;
+
+   devices = (Eina_List *)e_input_devices_get();
+
+   EINA_LIST_FOREACH(devices, l, dev_data)
+     {
+        e_input_device_output_changed(dev_data);
+     }
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 EINTERN const char *
 e_input_base_dir_get(void)
 {
@@ -154,6 +170,8 @@ e_input_init(Ecore_Evas *ee)
 
    e_input->dev = dev;
 
+   E_LIST_HANDLER_APPEND(e_input->handlers, E_EVENT_SCREEN_CHANGE, _e_input_cb_screen_change, NULL);
+
    TRACE_INPUT_END();
 
    return _e_input_init_count;
@@ -183,6 +201,8 @@ ecore_event_evas_err:
 EINTERN int
 e_input_shutdown(void)
 {
+   Ecore_Event_Handler *h = NULL;
+
    if (_e_input_init_count < 1) return 0;
    if (--_e_input_init_count != 0) return _e_input_init_count;
 
@@ -194,6 +214,9 @@ e_input_shutdown(void)
    E_EVENT_INPUT_ENABLED = -1;
    E_EVENT_INPUT_DISABLED = -1;
 
+   EINA_LIST_FREE(e_input->handlers, h)
+     ecore_event_handler_del(h);
+
    if (e_input->input_base_dir)
      eina_stringshare_del(e_input->input_base_dir);
    e_input_device_close(e_input->dev);
index c3c57b1..39c0562 100644 (file)
@@ -59,6 +59,7 @@ struct _E_Input
    Ecore_Window window;
    E_Input_Device *dev;
    const char *input_base_dir;
+   Eina_List *handlers;
 
    Eina_Bool use_thread : 1;
 };
index af449d3..a6d645f 100644 (file)
@@ -1121,6 +1121,24 @@ err:
    return EINA_FALSE;
 }
 
+void
+e_input_device_output_changed(E_Input_Device *dev)
+{
+   E_Input_Seat *seat = NULL;
+   E_Input_Evdev *edev = NULL;
+   Eina_List *l = NULL, *l2 = NULL;
+
+   EINA_SAFETY_ON_NULL_RETURN(dev);
+   EINA_SAFETY_ON_NULL_RETURN(dev->seats);
+
+   EINA_LIST_FOREACH(dev->seats, l, seat)
+     {
+        EINA_LIST_FOREACH(e_input_seat_evdev_list_get(seat), l2, edev)
+          {
+             _device_calibration_set(edev);
+          }
+     }
+}
 
 E_API const Eina_List *
 e_input_devices_get(void)
index d94ef9b..f2c2430 100644 (file)
@@ -3,7 +3,7 @@
 
 static void  _device_modifiers_update(E_Input_Evdev *edev);
 
-static void
+void
 _device_calibration_set(E_Input_Evdev *edev)
 {
    E_Output *output;
index 010ed63..2ba2939 100644 (file)
@@ -118,5 +118,8 @@ struct xkb_keymap *_e_input_device_cached_keymap_get(struct xkb_context *ctx, co
 void _e_input_evdev_device_destroy(E_Input_Evdev *evdev);
 void _e_input_pointer_motion_post(E_Input_Evdev *edev);
 
+void _device_calibration_set(E_Input_Evdev *edev);
+void e_input_device_output_changed(E_Input_Device *dev);
+
 #endif
 #endif