summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-05-26 16:34:10 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-05-26 16:27:43 -0400
commited4e54ebe2da6b0c2f04bc118286b1b3251edbd9 (patch)
tree3925e41202b2a3efdaaa1dda976a7a964d522db9 /src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
parent6775b23212305c957f4447c708053585f361bb86 (diff)
wayland/drm: create evas_devices and add device pointer to input events
this is still semi-broken if a seat has many pointer-ish type devices since pointer devices in ecore-evas were never correctly implemented to be 1:1 with seat:cursor relationships @feature
Diffstat (limited to '')
-rw-r--r--src/modules/ecore_evas/engines/drm/ecore_evas_drm.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 82b7d0d1bf..279c5aa289 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -13,6 +13,12 @@
13#include <Ecore_Drm2.h> 13#include <Ecore_Drm2.h>
14#include <Evas_Engine_Drm.h> 14#include <Evas_Engine_Drm.h>
15 15
16#define DRM2_NODEFS
17#include "ecore_drm2_private.h"
18
19#define ELPUT_NODEFS
20#include "elput_private.h"
21
16#ifdef BUILD_ECORE_EVAS_GL_DRM 22#ifdef BUILD_ECORE_EVAS_GL_DRM
17# include <Evas_Engine_GL_Drm.h> 23# include <Evas_Engine_GL_Drm.h>
18# include <dlfcn.h> 24# include <dlfcn.h>
@@ -83,11 +89,80 @@ typedef struct _Ecore_Evas_Engine_Drm_Data
83 Ecore_Fd_Handler *hdlr; 89 Ecore_Fd_Handler *hdlr;
84 Ecore_Drm2_Device *dev; 90 Ecore_Drm2_Device *dev;
85 Ecore_Drm2_Output *output; 91 Ecore_Drm2_Output *output;
92 Evas_Device *seat;
86 Eina_Bool pending : 1; 93 Eina_Bool pending : 1;
87 Eina_Bool ticking : 1; 94 Eina_Bool ticking : 1;
88} Ecore_Evas_Engine_Drm_Data; 95} Ecore_Evas_Engine_Drm_Data;
89 96
90static int _drm_init_count = 0; 97static int _drm_init_count = 0;
98static Eina_List *handlers;
99static Eina_List *canvases;
100
101static Eina_Bool
102_drm_device_change(void *d EINA_UNUSED, int t EINA_UNUSED, void *event)
103{
104 Elput_Event_Device_Change *ev = event;
105 const Eina_List *l;
106 Ecore_Evas *ee;
107 Ecore_Evas_Engine_Drm_Data *edata;
108 Elput_Seat *seat;
109 Elput_Manager *manager;
110 Eina_Bool found = EINA_FALSE;
111 Elput_Device_Caps caps;
112 Evas_Device_Class devclass = EVAS_DEVICE_CLASS_NONE;
113 Eo *dev;
114
115 seat = elput_device_seat_get(ev->device);
116 manager = elput_seat_manager_get(seat);
117 caps = elput_device_caps_get(ev->device);
118
119 EINA_LIST_FOREACH(canvases, l, ee)
120 {
121 edata = ee->engine.data;
122 found = edata->dev->em == manager;
123 if (found) break;
124 }
125
126 if (!found) return ECORE_CALLBACK_RENEW;
127 if (caps & ELPUT_DEVICE_CAPS_TABLET_TOOL)
128 devclass = EVAS_DEVICE_CLASS_PEN; // idk how "pen" is a device class?
129 else if (caps & ELPUT_DEVICE_CAPS_POINTER)
130 devclass = EVAS_DEVICE_CLASS_MOUSE;
131 else if (caps & ELPUT_DEVICE_CAPS_TOUCH)
132 devclass = EVAS_DEVICE_CLASS_TOUCH;
133 else if (caps & ELPUT_DEVICE_CAPS_KEYBOARD)
134 devclass = EVAS_DEVICE_CLASS_KEYBOARD;
135 switch (ev->type)
136 {
137 case ELPUT_DEVICE_ADDED:
138 {
139 if (!edata->seat)
140 {
141 Eina_Stringshare *name = elput_seat_name_get(seat);
142 edata->seat = evas_device_add_full(ee->evas, name,
143 "drm seat", NULL, NULL, EVAS_DEVICE_CLASS_SEAT, EVAS_DEVICE_CLASS_NONE);
144 evas_device_seat_id_set(edata->seat, strtol(name, NULL, 10));
145 }
146
147 dev = evas_device_add_full(ee->evas, elput_device_output_name_get(ev->device),
148 "drm device", edata->seat, NULL, devclass, EVAS_DEVICE_CLASS_NONE);
149 ev->device->evas_device = dev;
150 break;
151 }
152 case ELPUT_DEVICE_REMOVED:
153 {
154 EINA_LIST_FOREACH(evas_device_list(ee->evas, edata->seat), l, dev)
155 {
156 if (dev != ev->device->evas_device) continue;
157 evas_device_del(dev);
158 break;
159 }
160 break;
161 }
162 }
163
164 return ECORE_CALLBACK_RENEW;
165}
91 166
92static int 167static int
93_ecore_evas_drm_init(Ecore_Evas *ee, Ecore_Evas_Engine_Drm_Data *edata, const char *device) 168_ecore_evas_drm_init(Ecore_Evas *ee, Ecore_Evas_Engine_Drm_Data *edata, const char *device)
@@ -130,6 +205,11 @@ _ecore_evas_drm_init(Ecore_Evas *ee, Ecore_Evas_Engine_Drm_Data *edata, const ch
130 else WRN("Could not find output at %d %d", edata->x, edata->y); 205 else WRN("Could not find output at %d %d", edata->x, edata->y);
131 206
132 ecore_event_evas_init(); 207 ecore_event_evas_init();
208 if (!handlers)
209 {
210 handlers = eina_list_append(handlers,
211 ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE, _drm_device_change, NULL));
212 }
133 213
134 return _drm_init_count; 214 return _drm_init_count;
135 215
@@ -146,6 +226,7 @@ init_err:
146static int 226static int
147_ecore_evas_drm_shutdown(Ecore_Evas_Engine_Drm_Data *edata) 227_ecore_evas_drm_shutdown(Ecore_Evas_Engine_Drm_Data *edata)
148{ 228{
229 Ecore_Event_Handler *h;
149 if (--_drm_init_count != 0) return _drm_init_count; 230 if (--_drm_init_count != 0) return _drm_init_count;
150 231
151 ecore_drm2_outputs_destroy(edata->dev); 232 ecore_drm2_outputs_destroy(edata->dev);
@@ -153,6 +234,8 @@ _ecore_evas_drm_shutdown(Ecore_Evas_Engine_Drm_Data *edata)
153 ecore_drm2_device_free(edata->dev); 234 ecore_drm2_device_free(edata->dev);
154 ecore_drm2_shutdown(); 235 ecore_drm2_shutdown();
155 ecore_event_evas_shutdown(); 236 ecore_event_evas_shutdown();
237 EINA_LIST_FREE(handlers, h)
238 ecore_event_handler_del(h);
156 239
157 return _drm_init_count; 240 return _drm_init_count;
158} 241}
@@ -165,6 +248,7 @@ _drm_free(Ecore_Evas *ee)
165 ecore_evas_input_event_unregister(ee); 248 ecore_evas_input_event_unregister(ee);
166 249
167 edata = ee->engine.data; 250 edata = ee->engine.data;
251 canvases = eina_list_remove(canvases, ee);
168 _ecore_evas_drm_shutdown(edata); 252 _ecore_evas_drm_shutdown(edata);
169 free(edata); 253 free(edata);
170} 254}
@@ -843,6 +927,8 @@ _ecore_evas_new_internal(const char *device, int x, int y, int w, int h, Eina_Bo
843 edata->hdlr = 927 edata->hdlr =
844 ecore_main_fd_handler_add(edata->fd, ECORE_FD_READ, _cb_drm_event, ee, 928 ecore_main_fd_handler_add(edata->fd, ECORE_FD_READ, _cb_drm_event, ee,
845 NULL, NULL); 929 NULL, NULL);
930
931 canvases = eina_list_append(canvases, ee);
846 return ee; 932 return ee;
847 933
848eng_err: 934eng_err: