Compare commits

...

2 Commits

4 changed files with 73 additions and 12 deletions

View File

@ -58,6 +58,15 @@ typedef struct _Ecore_Drm2_Plane Ecore_Drm2_Plane;
/* opaque structure to represent a drm device */
typedef struct _Ecore_Drm2_Device Ecore_Drm2_Device;
/* public structure to represent an event for session state changes */
typedef struct _Ecore_Drm2_Event_Activate
{
Eina_Bool active : 1;
} Ecore_Drm2_Event_Activate;
/* API events */
EAPI extern int ECORE_DRM2_EVENT_ACTIVATE;
/* API functions */
EAPI int ecore_drm2_init(void);
EAPI int ecore_drm2_shutdown(void);

View File

@ -36,6 +36,8 @@ int (*sym_drmModeAtomicAddProperty)(drmModeAtomicReqPtr req, uint32_t object_id,
int (*sym_drmModeAtomicCommit)(int fd, drmModeAtomicReqPtr req, uint32_t flags, void *user_data) = NULL;
void (*sym_drmModeAtomicSetCursor)(drmModeAtomicReqPtr req, int cursor) = NULL;
EAPI int ECORE_DRM2_EVENT_ACTIVATE = -1;
/* local static functions */
static Eina_Bool
_ecore_drm2_link(void)
@ -144,6 +146,8 @@ ecore_drm2_init(void)
goto log_err;
}
ECORE_DRM2_EVENT_ACTIVATE = ecore_event_type_new();
if (!_ecore_drm2_link()) goto link_err;
return _ecore_drm2_init_count;
@ -176,6 +180,8 @@ ecore_drm2_shutdown(void)
if (_drm_lib) dlclose(_drm_lib);
ECORE_DRM2_EVENT_ACTIVATE = -1;
eina_log_domain_unregister(_ecore_drm2_log_dom);
_ecore_drm2_log_dom = -1;

View File

@ -9,26 +9,68 @@
/* local functions */
static Eina_Bool
_ecore_drm2_device_cb_session_active(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
_ecore_drm2_device_cb_session_active(void *data, int type EINA_UNUSED, void *event)
{
/* Ecore_Drm2_Device *dev; */
Ecore_Drm2_Device *dev;
Elput_Event_Session_Active *ev;
Ecore_Drm2_Event_Activate *eevent;
/* dev = data; */
dev = data;
ev = event;
if (ev->active)
{
/* TODO: wake compositor, compositor damage all, set state_invalid = true */
/* NB: Input enable is already done inside elput */
}
else
{
/* TODO: compositor offscreen, output->repaint_needed = false */
/* NB: Input disable is already done inside elput */
Eina_List *l;
Ecore_Drm2_Display *disp;
EINA_LIST_FOREACH(dev->displays, l, disp)
ecore_drm2_display_dpms_set(disp, DRM_MODE_DPMS_ON);
}
/* TODO: raise ecore_drm2_event_active ?? */
eevent = calloc(1, sizeof(Ecore_Drm2_Event_Activate));
if (!eevent) return ECORE_CALLBACK_RENEW;
eevent->active = ev->active;
ecore_event_add(ECORE_DRM2_EVENT_ACTIVATE, eevent, NULL, NULL);
return ECORE_CALLBACK_RENEW;
}
static Eina_Bool
_ecore_drm2_device_cb_device_change(void *data, int type EINA_UNUSED, void *event)
{
Elput_Event_Device_Change *ev;
Ecore_Drm2_Device *dev;
ev = event;
dev = data;
if (ev->type == ELPUT_DEVICE_ADDED)
{
Eina_Stringshare *name;
Ecore_Drm2_Display *disp;
name = elput_device_output_name_get(ev->device);
if (!name)
{
disp = eina_list_data_get(dev->displays);
if (disp)
ecore_drm2_device_calibrate(dev, disp->w, disp->h);
}
else
{
Eina_List *l;
EINA_LIST_FOREACH(dev->displays, l, disp)
{
if (eina_streq(disp->name, name))
{
ecore_drm2_device_calibrate(dev, disp->w, disp->h);
break;
}
}
}
}
return ECORE_CALLBACK_RENEW;
}
@ -278,7 +320,9 @@ ecore_drm2_device_open(const char *seat, unsigned int tty)
ecore_event_handler_add(ELPUT_EVENT_SESSION_ACTIVE,
_ecore_drm2_device_cb_session_active, dev);
/* TODO: event handler for device_change */
dev->device_hdlr =
ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE,
_ecore_drm2_device_cb_device_change, dev);
/* cleanup path variable */
eina_stringshare_del(path);
@ -314,6 +358,7 @@ ecore_drm2_device_close(Ecore_Drm2_Device *dev)
_ecore_drm2_planes_destroy(dev);
_ecore_drm2_crtcs_destroy(dev);
ecore_event_handler_del(dev->device_hdlr);
ecore_event_handler_del(dev->session_hdlr);
elput_input_shutdown(dev->em);

View File

@ -337,6 +337,7 @@ struct _Ecore_Drm2_Device
} cursor;
Ecore_Event_Handler *session_hdlr;
Ecore_Event_Handler *device_hdlr;
Eina_List *crtcs;
Eina_List *conns;