e_devicemgr_input: realloc memory for multi touch when max touch count is updated 08/250508/4
authorjeon <jhyuni.kang@samsung.com>
Mon, 28 Dec 2020 12:42:50 +0000 (21:42 +0900)
committerjeon <jhyuni.kang@samsung.com>
Tue, 29 Dec 2020 05:52:30 +0000 (14:52 +0900)
Change-Id: I9fddb59ae1c187e2de0de18edd5374537fca771d

src/bin/e_devicemgr.h
src/bin/e_devicemgr_input.c

index 9c83a29416b82ea9dc201587fa4db8d1b9b6a9bf..641c660741370660f394dfc2205b3a34e223a120 100644 (file)
@@ -83,6 +83,8 @@ struct _E_Devicemgr
    } detent;
 
    Eina_List *watched_clients;
+
+   int max_touch_count;
 };
 
 struct _E_Devicemgr_Intercept_Hook
index a5f40e20d39ae53691c2a4ff58f6f388dfea4170..eb55f75b9423f814c73f3b865cb93d8ecf531551 100644 (file)
@@ -186,6 +186,7 @@ _e_devicemgr_input_device_add(const char *name, const char *identifier, const ch
 {
    E_Devicemgr_Input_Device *dev;
    Eina_List *l;
+   int current_touch_count = -1;
 
    EINA_LIST_FOREACH(e_devicemgr->device_list, l, dev)
      {
@@ -210,20 +211,26 @@ _e_devicemgr_input_device_add(const char *name, const char *identifier, const ch
    if (dev->clas == ECORE_DEVICE_CLASS_MOUSE)
      e_devicemgr->last_device_ptr = dev;
 
-   if (!e_devicemgr->last_device_touch && dev->clas == ECORE_DEVICE_CLASS_TOUCH)
+   if (dev->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
-        e_devicemgr->last_device_touch = dev;
+        if (!e_devicemgr->last_device_touch)
+          e_devicemgr->last_device_touch = dev;
 
-        if (e_devicemgr->multi)
+        current_touch_count = e_input_touch_max_count_get();
+        if (e_devicemgr->max_touch_count < current_touch_count)
           {
-             ELOGF("DEVMGR_TOUCH", "Multi pointer is NOT NULL. It'll be updated.\n", NULL);
-             free (e_devicemgr->multi);
-          }
+             e_devicemgr->max_touch_count = current_touch_count;
+             if (e_devicemgr->multi)
+               {
+                  ELOGF("DEVMGR_TOUCH", "Multi pointer is NOT NULL. It'll be updated to %d finger of touch.\n", NULL, current_touch_count);
+                  free (e_devicemgr->multi);
+               }
 
-        e_devicemgr->multi = calloc(1, sizeof(E_Devicemgr_Input_Device_Multi)*e_input_touch_max_count_get());
+             e_devicemgr->multi = calloc(1, sizeof(E_Devicemgr_Input_Device_Multi)*current_touch_count);
 
-        if (!e_devicemgr->multi)
-          ELOGF("DEVMGR_TOUCH", "Failed to allocate memory for multi ptr. (finger=%d)\n", NULL, e_input_touch_max_count_get());
+             if (!e_devicemgr->multi)
+               ELOGF("DEVMGR_TOUCH", "Failed to allocate memory for multi ptr. (finger=%d)\n", NULL, current_touch_count);
+          }
      }
 
    if (!e_devicemgr->last_device_kbd && dev->clas == ECORE_DEVICE_CLASS_KEYBOARD)
@@ -453,6 +460,8 @@ e_devicemgr_input_init(void)
           DMWRN("input.virtual_mouse_device_enable: but failed to create device !\n");
      }
 
+   e_devicemgr->max_touch_count = 0;
+
    return EINA_TRUE;
 }