summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Ecore_Evas.am1
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_private.h3
-rw-r--r--src/lib/elput/elput_evdev.c6
-rw-r--r--src/lib/elput/elput_private.h4
-rw-r--r--src/lib/evas/canvas/evas_main.c6
-rw-r--r--src/modules/ecore_evas/engines/drm/ecore_evas_drm.c86
6 files changed, 102 insertions, 4 deletions
diff --git a/src/Makefile_Ecore_Evas.am b/src/Makefile_Ecore_Evas.am
index 7907a67..dbdf5f6 100644
--- a/src/Makefile_Ecore_Evas.am
+++ b/src/Makefile_Ecore_Evas.am
@@ -271,6 +271,7 @@ modules_ecore_evas_engines_drm_module_la_SOURCES = $(DRMSOURCES)
271modules_ecore_evas_engines_drm_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ 271modules_ecore_evas_engines_drm_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
272@ECORE_EVAS_CFLAGS@ \ 272@ECORE_EVAS_CFLAGS@ \
273@ECORE_DRM2_CFLAGS@ \ 273@ECORE_DRM2_CFLAGS@ \
274@ELPUT_CFLAGS@ \
274-I$(top_srcdir)/src/modules/evas/engines/drm \ 275-I$(top_srcdir)/src/modules/evas/engines/drm \
275-I$(top_srcdir)/src/modules/evas/engines/gl_drm 276-I$(top_srcdir)/src/modules/evas/engines/gl_drm
276modules_ecore_evas_engines_drm_module_la_LIBADD = \ 277modules_ecore_evas_engines_drm_module_la_LIBADD = \
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index 2be6069..a7e3766 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -20,6 +20,7 @@
20# include <sys/ioctl.h> 20# include <sys/ioctl.h>
21# include <dlfcn.h> 21# include <dlfcn.h>
22 22
23#ifndef DRM2_NODEFS
23extern int _ecore_drm2_log_dom; 24extern int _ecore_drm2_log_dom;
24extern Eina_Bool _ecore_drm2_use_atomic; 25extern Eina_Bool _ecore_drm2_use_atomic;
25 26
@@ -52,7 +53,7 @@ extern Eina_Bool _ecore_drm2_use_atomic;
52# undef CRIT 53# undef CRIT
53# endif 54# endif
54# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm2_log_dom, __VA_ARGS__) 55# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm2_log_dom, __VA_ARGS__)
55 56#endif
56/* The following defines and structures were borrowed from drm.h */ 57/* The following defines and structures were borrowed from drm.h */
57 58
58/** 59/**
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index a212691..741d1fd 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -300,6 +300,7 @@ _keyboard_key_send(Elput_Device *dev, enum libinput_key_state state, const char
300 ev->modifiers = dev->seat->modifiers; 300 ev->modifiers = dev->seat->modifiers;
301 ev->timestamp = timestamp; 301 ev->timestamp = timestamp;
302 ev->same_screen = 1; 302 ev->same_screen = 1;
303 ev->dev = dev->evas_device;
303 304
304 ev->window = dev->seat->manager->window; 305 ev->window = dev->seat->manager->window;
305 ev->event_window = dev->seat->manager->window; 306 ev->event_window = dev->seat->manager->window;
@@ -803,6 +804,7 @@ _pointer_motion_send(Elput_Device *edev)
803 ev->root_window = edev->seat->manager->window; 804 ev->root_window = edev->seat->manager->window;
804 ev->timestamp = ptr->timestamp; 805 ev->timestamp = ptr->timestamp;
805 ev->same_screen = 1; 806 ev->same_screen = 1;
807 ev->dev = edev->evas_device;
806 808
807 ev->x = ptr->x; 809 ev->x = ptr->x;
808 ev->y = ptr->y; 810 ev->y = ptr->y;
@@ -912,6 +914,7 @@ _pointer_button_send(Elput_Device *edev, enum libinput_button_state state)
912 ev->root_window = edev->seat->manager->window; 914 ev->root_window = edev->seat->manager->window;
913 ev->timestamp = ptr->timestamp; 915 ev->timestamp = ptr->timestamp;
914 ev->same_screen = 1; 916 ev->same_screen = 1;
917 ev->dev = edev->evas_device;
915 918
916 ev->x = ptr->x; 919 ev->x = ptr->x;
917 ev->y = ptr->y; 920 ev->y = ptr->y;
@@ -1033,6 +1036,7 @@ _pointer_axis_send(Elput_Device *dev, int direction, int value)
1033 ev->root_window = dev->seat->manager->window; 1036 ev->root_window = dev->seat->manager->window;
1034 ev->timestamp = ptr->timestamp; 1037 ev->timestamp = ptr->timestamp;
1035 ev->same_screen = 1; 1038 ev->same_screen = 1;
1039 ev->dev = dev->evas_device;
1036 1040
1037 ev->x = ptr->x; 1041 ev->x = ptr->x;
1038 ev->y = ptr->y; 1042 ev->y = ptr->y;
@@ -1189,6 +1193,7 @@ _touch_motion_send(Elput_Device *dev)
1189 ev->root_window = dev->seat->manager->window; 1193 ev->root_window = dev->seat->manager->window;
1190 ev->timestamp = touch->timestamp; 1194 ev->timestamp = touch->timestamp;
1191 ev->same_screen = 1; 1195 ev->same_screen = 1;
1196 ev->dev = dev->evas_device;
1192 1197
1193 ev->x = lround(touch->x); 1198 ev->x = lround(touch->x);
1194 ev->y = lround(touch->y); 1199 ev->y = lround(touch->y);
@@ -1447,6 +1452,7 @@ _tablet_tool_axis(struct libinput_device *idev, struct libinput_event_tablet_too
1447 ev->root_window = dev->seat->manager->window; 1452 ev->root_window = dev->seat->manager->window;
1448 ev->timestamp = ptr->timestamp; 1453 ev->timestamp = ptr->timestamp;
1449 ev->naxis = num; 1454 ev->naxis = num;
1455 ev->dev = dev->evas_device;
1450 ev->axis = axis = calloc(num, sizeof(Ecore_Axis)); 1456 ev->axis = axis = calloc(num, sizeof(Ecore_Axis));
1451 for (i = 0; i < num; i++) 1457 for (i = 0; i < num; i++)
1452 { 1458 {
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 982d3f5..202c52b 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -28,6 +28,7 @@
28# include <systemd/sd-login.h> 28# include <systemd/sd-login.h>
29# endif 29# endif
30 30
31#ifndef ELPUT_NODEFS
31# ifdef ELPUT_DEFAULT_LOG_COLOR 32# ifdef ELPUT_DEFAULT_LOG_COLOR
32# undef ELPUT_DEFAULT_LOG_COLOR 33# undef ELPUT_DEFAULT_LOG_COLOR
33# endif 34# endif
@@ -59,7 +60,7 @@ extern int _elput_log_dom;
59# undef CRIT 60# undef CRIT
60# endif 61# endif
61# define CRIT(...) EINA_LOG_DOM_CRIT(_elput_log_dom, __VA_ARGS__) 62# define CRIT(...) EINA_LOG_DOM_CRIT(_elput_log_dom, __VA_ARGS__)
62 63#endif
63typedef struct _Elput_Interface 64typedef struct _Elput_Interface
64{ 65{
65 Eina_Bool (*connect)(Elput_Manager **manager, const char *seat, unsigned int tty); 66 Eina_Bool (*connect)(Elput_Manager **manager, const char *seat, unsigned int tty);
@@ -218,6 +219,7 @@ struct _Elput_Device
218 Elput_Device_Caps caps; 219 Elput_Device_Caps caps;
219 220
220 Eina_Hash *key_remap_hash; 221 Eina_Hash *key_remap_hash;
222 Eo *evas_device;
221 223
222 Eina_Bool left_handed : 1; 224 Eina_Bool left_handed : 1;
223 Eina_Bool key_remap : 1; 225 Eina_Bool key_remap : 1;
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index e03af07..0229e0d 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -1006,9 +1006,11 @@ evas_output_method_set(Evas *eo_e, int render_method)
1006 output->info = e->engine.func->info(eo_e); 1006 output->info = e->engine.func->info(eo_e);
1007 } 1007 }
1008 1008
1009 // Wayland already handles seats. 1009 // Wayland/drm already handles seats.
1010 if (em->definition && (eina_streq(em->definition->name, "wayland_shm") || 1010 if (em->definition && (eina_streq(em->definition->name, "wayland_shm") ||
1011 eina_streq(em->definition->name, "wayland_egl"))) 1011 eina_streq(em->definition->name, "wayland_egl") ||
1012 eina_streq(em->definition->name, "drm") ||
1013 eina_streq(em->definition->name, "gl_drm")))
1012 return; 1014 return;
1013 1015
1014 e->default_seat = evas_device_add_full(eo_e, "default", "The default seat", 1016 e->default_seat = evas_device_add_full(eo_e, "default", "The default seat",
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 82b7d0d..279c5aa 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: