2017-02-03 12:13:48 -08:00
|
|
|
#define E_COMP_WL
|
2012-03-28 18:43:17 -07:00
|
|
|
#include "e.h"
|
2016-05-11 07:02:22 -07:00
|
|
|
#include <drm_mode.h>
|
|
|
|
|
2017-01-18 06:03:20 -08:00
|
|
|
#include <Ecore_Drm2.h>
|
|
|
|
#include <Elput.h>
|
2017-08-08 15:59:39 -07:00
|
|
|
|
2016-12-09 05:33:56 -08:00
|
|
|
static Ecore_Event_Handler *seat_handler;
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Drm" };
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2015-01-05 06:09:59 -08:00
|
|
|
static Ecore_Event_Handler *activate_handler;
|
2015-02-19 11:49:21 -08:00
|
|
|
static Ecore_Event_Handler *output_handler;
|
2017-02-03 12:13:48 -08:00
|
|
|
static Ecore_Event_Handler *input_handler;
|
2015-01-05 06:09:59 -08:00
|
|
|
static Eina_Bool session_state = EINA_FALSE;
|
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
static const char *conn_types[] =
|
|
|
|
{
|
|
|
|
"None", "VGA", "DVI-I", "DVI-D", "DVI-A",
|
|
|
|
"Composite", "S-Video", "LVDS", "Component", "DIN",
|
|
|
|
"DisplayPort", "HDMI-A", "HDMI-B", "TV", "eDP", "Virtual",
|
|
|
|
"DSI", "UNKNOWN"
|
|
|
|
};
|
|
|
|
|
|
|
|
static E_Randr2_Connector rtype[] =
|
|
|
|
{
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_DVI,
|
|
|
|
E_RANDR2_CONNECTOR_DVI,
|
|
|
|
E_RANDR2_CONNECTOR_DVI,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_DISPLAY_PORT,
|
|
|
|
E_RANDR2_CONNECTOR_HDMI_A,
|
|
|
|
E_RANDR2_CONNECTOR_HDMI_B,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_DISPLAY_PORT,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
E_RANDR2_CONNECTOR_UNDEFINED,
|
|
|
|
};
|
|
|
|
|
2015-01-05 06:09:59 -08:00
|
|
|
static Eina_Bool
|
2015-04-06 12:57:09 -07:00
|
|
|
_e_mod_drm_cb_activate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
2015-01-05 06:09:59 -08:00
|
|
|
{
|
2016-05-11 07:02:22 -07:00
|
|
|
Ecore_Drm2_Event_Activate *ev;
|
2015-01-05 06:09:59 -08:00
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
if (!(ev = event)) goto end;
|
2015-01-05 06:09:59 -08:00
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
if (ev->active)
|
2015-01-05 06:09:59 -08:00
|
|
|
{
|
|
|
|
if (session_state) goto end;
|
|
|
|
session_state = EINA_TRUE;
|
2020-12-01 18:29:27 -08:00
|
|
|
e_backlight_suspend_set(EINA_FALSE);
|
2015-01-05 06:09:59 -08:00
|
|
|
|
2015-04-06 12:57:09 -07:00
|
|
|
ecore_evas_show(e_comp->ee);
|
2017-06-02 11:49:06 -07:00
|
|
|
evas_damage_rectangle_add(e_comp->evas, 0, 0, e_comp->w, e_comp->h);
|
2015-01-05 06:09:59 -08:00
|
|
|
ecore_event_add(E_EVENT_COMPOSITOR_ENABLE, NULL, NULL, NULL);
|
2017-06-09 17:18:20 -07:00
|
|
|
ecore_evas_pointer_warp(e_comp->ee, e_comp_wl->ptr.x, e_comp_wl->ptr.y);
|
|
|
|
if (e_comp->pointer->client.ec)
|
|
|
|
{
|
|
|
|
ecore_evas_object_cursor_set(e_comp->ee, e_comp->pointer->client.ec->frame,
|
|
|
|
E_LAYER_MAX - 1, e_comp->pointer->client.x, e_comp->pointer->client.y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ecore_evas_object_cursor_set(e_comp->pointer->ee, e_comp->pointer->o_ptr,
|
|
|
|
E_LAYER_MAX - 1, e_comp->pointer->hot.x, e_comp->pointer->hot.y);
|
2015-01-05 06:09:59 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
session_state = EINA_FALSE;
|
2020-12-01 18:29:27 -08:00
|
|
|
e_backlight_suspend_set(EINA_TRUE);
|
|
|
|
|
2015-04-06 12:57:09 -07:00
|
|
|
ecore_evas_hide(e_comp->ee);
|
2015-01-05 06:09:59 -08:00
|
|
|
edje_file_cache_flush();
|
|
|
|
edje_collection_cache_flush();
|
2015-04-06 12:57:09 -07:00
|
|
|
evas_image_cache_flush(e_comp->evas);
|
|
|
|
evas_font_cache_flush(e_comp->evas);
|
|
|
|
evas_render_dump(e_comp->evas);
|
2015-01-05 06:09:59 -08:00
|
|
|
|
|
|
|
ecore_event_add(E_EVENT_COMPOSITOR_DISABLE, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2015-02-19 11:49:21 -08:00
|
|
|
static Eina_Bool
|
2017-06-16 11:59:42 -07:00
|
|
|
_e_mod_drm_cb_output(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
2015-02-19 11:49:21 -08:00
|
|
|
{
|
2015-04-22 18:15:12 -07:00
|
|
|
if (!e_randr2_cfg->ignore_hotplug_events)
|
2017-06-16 11:59:42 -07:00
|
|
|
e_randr2_screen_refresh_queue(1);
|
2015-05-13 11:44:51 -07:00
|
|
|
|
2015-02-19 11:49:21 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:44:51 -07:00
|
|
|
static E_Randr2_Screen *
|
|
|
|
_info_unconf_primary_find(E_Randr2 *r)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
E_Randr2_Screen *s, *s_primary = NULL;
|
|
|
|
int priority = 0;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(r->screens, l, s)
|
|
|
|
{
|
2020-05-13 12:36:06 -07:00
|
|
|
if (!((s->config.enabled) &&
|
2015-05-13 11:44:51 -07:00
|
|
|
(s->config.mode.w > 0) && (s->config.mode.h > 0) &&
|
|
|
|
(s->config.geom.w > 0) && (s->config.geom.h > 0)))
|
|
|
|
continue;
|
|
|
|
if (s->config.priority > priority)
|
|
|
|
{
|
|
|
|
s_primary = s;
|
|
|
|
priority = s->config.priority;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return s_primary;
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_Randr2_Screen *
|
|
|
|
_info_unconf_left_find(E_Randr2 *r)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
E_Randr2_Screen *s, *s_left = NULL;
|
|
|
|
int left_x = 0x7fffffff;
|
|
|
|
int left_size = 0;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(r->screens, l, s)
|
|
|
|
{
|
|
|
|
if (!((s->config.enabled) &&
|
|
|
|
(s->config.mode.w > 0) && (s->config.mode.h > 0) &&
|
|
|
|
(s->config.geom.w > 0) && (s->config.geom.h > 0)))
|
|
|
|
continue;
|
|
|
|
if ((s->config.geom.x <= left_x) &&
|
|
|
|
((s->config.geom.w * s->config.geom.h) > left_size))
|
|
|
|
{
|
|
|
|
left_size = s->config.geom.w * s->config.geom.h;
|
|
|
|
left_x = s->config.geom.x;
|
|
|
|
s_left = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s_left;
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_Randr2_Screen *
|
|
|
|
_info_unconf_closest_find(E_Randr2 *r, E_Randr2_Screen *s2, Eina_Bool configured)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
E_Randr2_Screen *s, *s_sel = NULL;
|
|
|
|
int dist = 0x7fffffff;
|
|
|
|
int dx, dy;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(r->screens, l, s)
|
|
|
|
{
|
|
|
|
if (s == s2) continue;
|
|
|
|
if (!((s->config.enabled) &&
|
|
|
|
(s->config.mode.w > 0) && (s->config.mode.h > 0) &&
|
|
|
|
(s->config.geom.w > 0) && (s->config.geom.h > 0)))
|
|
|
|
continue;
|
|
|
|
if ((!configured) &&
|
|
|
|
(s->config.relative.mode != E_RANDR2_RELATIVE_UNKNOWN))
|
|
|
|
continue;
|
|
|
|
else if ((configured) &&
|
|
|
|
(s->config.relative.mode == E_RANDR2_RELATIVE_UNKNOWN))
|
|
|
|
continue;
|
|
|
|
dx = (s->config.geom.x + (s->config.geom.w / 2)) -
|
|
|
|
(s2->config.geom.x + (s2->config.geom.w / 2));
|
|
|
|
dy = (s->config.geom.y + (s->config.geom.h / 2)) -
|
|
|
|
(s2->config.geom.y + (s2->config.geom.h / 2));
|
|
|
|
dx = sqrt((dx * dx) + (dy * dy));
|
|
|
|
if (dx < dist)
|
|
|
|
{
|
|
|
|
s_sel = s;
|
|
|
|
dist = dx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s_sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_mod_drm_relative_fixup(E_Randr2 *r)
|
|
|
|
{
|
|
|
|
E_Randr2_Screen *s, *s2;
|
|
|
|
int d, dx, dy;
|
|
|
|
|
|
|
|
s = _info_unconf_primary_find(r);
|
|
|
|
if (s)
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_NONE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s = _info_unconf_left_find(r);
|
|
|
|
if (!s) return;
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
// find the next screen that is closest to the last one we configured
|
|
|
|
/// that is still not configured yet
|
|
|
|
s = _info_unconf_closest_find(r, s, EINA_FALSE);
|
|
|
|
if (!s) break;
|
|
|
|
s2 = _info_unconf_closest_find(r, s, EINA_TRUE);
|
|
|
|
// fix up s->config.relative.mode, s->config.relative.to and
|
|
|
|
// s->config.relative.align to match (as closely as possible)
|
|
|
|
// the geometry given - config s relative to s2
|
|
|
|
if (!s2) s->config.relative.mode = E_RANDR2_RELATIVE_NONE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s->config.relative.to = strdup(s2->id);
|
|
|
|
s->config.relative.align = 0.0;
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_NONE;
|
|
|
|
if ((s->config.geom.x + s->config.geom.w) <=
|
|
|
|
s2->config.geom.x)
|
|
|
|
{
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_TO_LEFT;
|
|
|
|
d = s->config.geom.h - s2->config.geom.h;
|
|
|
|
dy = s2->config.geom.y - s->config.geom.y;
|
|
|
|
if (d != 0)
|
|
|
|
s->config.relative.align = ((double)dy) / ((double)d);
|
|
|
|
}
|
|
|
|
else if (s->config.geom.x >=
|
|
|
|
(s2->config.geom.x + s2->config.geom.w))
|
|
|
|
{
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_TO_RIGHT;
|
|
|
|
d = s->config.geom.h - s2->config.geom.h;
|
|
|
|
dy = s2->config.geom.y - s->config.geom.y;
|
|
|
|
if (d != 0)
|
|
|
|
s->config.relative.align = ((double)dy) / ((double)d);
|
|
|
|
}
|
|
|
|
else if ((s->config.geom.y + s->config.geom.h) <=
|
|
|
|
s2->config.geom.y)
|
|
|
|
{
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_TO_ABOVE;
|
|
|
|
d = s->config.geom.w - s2->config.geom.w;
|
|
|
|
dx = s2->config.geom.x - s->config.geom.x;
|
|
|
|
if (d != 0)
|
|
|
|
s->config.relative.align = ((double)dx) / ((double)d);
|
|
|
|
}
|
|
|
|
else if (s->config.geom.y >=
|
|
|
|
(s2->config.geom.y + s2->config.geom.h))
|
|
|
|
{
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_TO_BELOW;
|
|
|
|
d = s->config.geom.w - s2->config.geom.w;
|
|
|
|
dx = s2->config.geom.x - s->config.geom.x;
|
|
|
|
if (d != 0)
|
|
|
|
s->config.relative.align = ((double)dx) / ((double)d);
|
|
|
|
}
|
|
|
|
else if ((s->config.geom.x == s2->config.geom.x) &&
|
|
|
|
(s->config.geom.y == s2->config.geom.y) &&
|
|
|
|
(s->config.geom.w == s2->config.geom.w) &&
|
|
|
|
(s->config.geom.h == s2->config.geom.h))
|
|
|
|
{
|
|
|
|
s->config.relative.mode = E_RANDR2_RELATIVE_CLONE;
|
|
|
|
}
|
|
|
|
if (s->config.relative.align < 0.0)
|
|
|
|
s->config.relative.align = 0.0;
|
|
|
|
else if (s->config.relative.align > 1.0)
|
|
|
|
s->config.relative.align = 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
static E_Randr2 *
|
|
|
|
_drm2_randr_create(void)
|
|
|
|
{
|
|
|
|
const Eina_List *l;
|
|
|
|
E_Randr2 *r = NULL;
|
|
|
|
Ecore_Drm2_Device *dev;
|
|
|
|
const Eina_List *outputs;
|
|
|
|
Ecore_Drm2_Output *output;
|
|
|
|
unsigned int type;
|
2017-12-15 08:09:56 -08:00
|
|
|
E_Zone *zone;
|
2016-05-11 07:02:22 -07:00
|
|
|
|
|
|
|
dev = ecore_evas_data_get(e_comp->ee, "device");
|
|
|
|
if (!dev) return NULL;
|
|
|
|
|
|
|
|
outputs = ecore_drm2_outputs_get(dev);
|
|
|
|
if (!outputs) return NULL;
|
|
|
|
|
|
|
|
printf("DRM2 RRR: ................. info get!\n");
|
|
|
|
|
|
|
|
r = E_NEW(E_Randr2, 1);
|
|
|
|
if (!r) return NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(outputs, l, output)
|
|
|
|
{
|
|
|
|
E_Randr2_Screen *s;
|
|
|
|
const Eina_List *m;
|
|
|
|
Ecore_Drm2_Output_Mode *omode;
|
|
|
|
E_Config_Randr2_Screen *cs = NULL;
|
|
|
|
unsigned int *crtcs;
|
|
|
|
int priority = 0, num = 0, j = 0;
|
|
|
|
Eina_Bool ok = EINA_FALSE;
|
|
|
|
Eina_Bool possible = EINA_FALSE;
|
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
if (!ecore_drm2_output_connected_get(output))
|
|
|
|
continue;
|
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
s = E_NEW(E_Randr2_Screen, 1);
|
|
|
|
if (!s) continue;
|
|
|
|
|
|
|
|
s->info.name = ecore_drm2_output_name_get(output);
|
|
|
|
printf("DRM2 RRR: .... out %s\n", s->info.name);
|
|
|
|
|
|
|
|
s->info.connected = ecore_drm2_output_connected_get(output);
|
|
|
|
printf("DRM2 RRR: ...... connected %i\n", s->info.connected);
|
|
|
|
|
|
|
|
s->info.screen = ecore_drm2_output_model_get(output);
|
|
|
|
|
|
|
|
s->info.edid = ecore_drm2_output_edid_get(output);
|
|
|
|
if (s->info.edid)
|
|
|
|
s->id = malloc(strlen(s->info.name) + 1 + strlen(s->info.edid) + 1);
|
|
|
|
else
|
|
|
|
s->id = malloc(strlen(s->info.name) + 1 + 1);
|
|
|
|
if (!s->id)
|
|
|
|
{
|
2019-03-22 09:42:10 -07:00
|
|
|
free(s->info.name);
|
2016-05-11 07:02:22 -07:00
|
|
|
free(s->info.screen);
|
|
|
|
free(s->info.edid);
|
|
|
|
free(s);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
strcpy(s->id, s->info.name);
|
|
|
|
strcat(s->id, "/");
|
|
|
|
if (s->info.edid) strcat(s->id, s->info.edid);
|
|
|
|
|
|
|
|
printf("DRM2 RRR: Created Screen: %s\n", s->id);
|
|
|
|
|
|
|
|
type = MIN(ecore_drm2_output_connector_type_get(output),
|
|
|
|
EINA_C_ARRAY_LENGTH(conn_types) - 1);
|
|
|
|
s->info.connector = rtype[type];
|
2020-05-13 12:36:06 -07:00
|
|
|
s->info.is_lid = ((type == DRM_MODE_CONNECTOR_LVDS) ||
|
2016-05-11 07:02:22 -07:00
|
|
|
(type == DRM_MODE_CONNECTOR_eDP));
|
|
|
|
s->info.lid_closed = (s->info.is_lid && e_acpi_lid_is_closed());
|
|
|
|
printf("DRM2 RRR: ...... lid_closed = %i (%i && %i)\n",
|
|
|
|
s->info.lid_closed, s->info.is_lid, e_acpi_lid_is_closed());
|
|
|
|
|
|
|
|
s->info.backlight = ecore_drm2_output_backlight_get(output);
|
2017-06-16 11:59:42 -07:00
|
|
|
s->info.subpixel = ecore_drm2_output_subpixel_get(output);
|
2016-05-11 07:02:22 -07:00
|
|
|
|
|
|
|
ecore_drm2_output_physical_size_get(output, &s->info.size.w,
|
|
|
|
&s->info.size.h);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ecore_drm2_output_modes_get(output), m, omode)
|
|
|
|
{
|
|
|
|
E_Randr2_Mode *rmode;
|
|
|
|
unsigned int flags, refresh;
|
|
|
|
|
|
|
|
rmode = malloc(sizeof(E_Randr2_Mode));
|
|
|
|
if (!rmode) continue;
|
|
|
|
|
|
|
|
ecore_drm2_output_mode_info_get(omode, &rmode->w, &rmode->h,
|
|
|
|
&refresh, &flags);
|
|
|
|
|
|
|
|
rmode->refresh = refresh;
|
|
|
|
rmode->preferred = (flags & DRM_MODE_TYPE_PREFERRED);
|
|
|
|
|
|
|
|
s->info.modes = eina_list_append(s->info.modes, rmode);
|
|
|
|
}
|
|
|
|
|
2017-12-15 08:09:56 -08:00
|
|
|
e_randr2_screen_modes_sort(s);
|
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
if (e_randr2_cfg)
|
|
|
|
cs = e_randr2_config_screen_find(s, e_randr2_cfg);
|
|
|
|
if (cs)
|
|
|
|
priority = cs->priority;
|
|
|
|
else if (ecore_drm2_output_primary_get(output))
|
|
|
|
priority = 100;
|
|
|
|
s->config.priority = priority;
|
|
|
|
|
|
|
|
crtcs = ecore_drm2_device_crtcs_get(dev, &num);
|
|
|
|
for (j = 0; j < num; j++)
|
|
|
|
{
|
|
|
|
if (crtcs[j] == ecore_drm2_output_crtc_get(output))
|
|
|
|
{
|
|
|
|
ok = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
/* get possible crtcs, compare to output_crtc_get */
|
|
|
|
for (j = 0; j < num; j++)
|
|
|
|
{
|
|
|
|
if (ecore_drm2_output_possible_crtc_get(output, crtcs[j]))
|
|
|
|
{
|
|
|
|
ok = EINA_TRUE;
|
|
|
|
possible = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
2019-07-14 14:20:49 -07:00
|
|
|
int rotations, outrot;
|
2019-03-22 09:42:10 -07:00
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
if (!possible)
|
|
|
|
{
|
|
|
|
unsigned int refresh;
|
|
|
|
|
2020-12-01 13:21:17 -08:00
|
|
|
ecore_drm2_output_info_get(output,
|
|
|
|
&s->config.geom.x,
|
|
|
|
&s->config.geom.y,
|
|
|
|
&s->config.geom.w,
|
|
|
|
&s->config.geom.h,
|
|
|
|
&refresh);
|
2017-07-21 14:00:26 -07:00
|
|
|
s->config.mode.w = s->config.geom.w;
|
|
|
|
s->config.mode.h = s->config.geom.h;
|
2016-05-11 07:02:22 -07:00
|
|
|
s->config.mode.refresh = refresh;
|
2020-05-13 12:36:06 -07:00
|
|
|
s->config.enabled =
|
2016-05-11 07:02:22 -07:00
|
|
|
((s->config.mode.w != 0) && (s->config.mode.h != 0));
|
|
|
|
|
|
|
|
printf("DRM2 RRR: '%s' %i %i %ix%i\n", s->info.name,
|
|
|
|
s->config.geom.x, s->config.geom.y,
|
|
|
|
s->config.geom.w, s->config.geom.h);
|
|
|
|
}
|
|
|
|
|
2020-12-01 13:21:17 -08:00
|
|
|
outrot = ecore_drm2_output_rotation_get(output);
|
2019-07-14 14:20:49 -07:00
|
|
|
if (outrot & ECORE_DRM2_ROTATION_NORMAL)
|
|
|
|
s->config.rotation = 0;
|
|
|
|
else if (outrot & ECORE_DRM2_ROTATION_90)
|
|
|
|
s->config.rotation = 90;
|
|
|
|
else if (outrot & ECORE_DRM2_ROTATION_180)
|
|
|
|
s->config.rotation = 180;
|
|
|
|
else if (outrot & ECORE_DRM2_ROTATION_270)
|
|
|
|
s->config.rotation = 270;
|
|
|
|
else
|
|
|
|
{
|
2020-05-13 12:03:23 -07:00
|
|
|
printf("DRM2 RRR: caution - rotation flags empty - assume 0\n");
|
2019-07-14 14:20:49 -07:00
|
|
|
s->config.rotation = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("DRM2 RRR: drm output rotation=%i\n", s->config.rotation);
|
2019-03-22 09:42:10 -07:00
|
|
|
|
2017-12-15 08:41:14 -08:00
|
|
|
s->info.can_rot_0 = EINA_FALSE;
|
|
|
|
s->info.can_rot_90 = EINA_FALSE;
|
|
|
|
s->info.can_rot_180 = EINA_FALSE;
|
|
|
|
s->info.can_rot_270 = EINA_FALSE;
|
|
|
|
|
|
|
|
rotations =
|
|
|
|
ecore_drm2_output_supported_rotations_get(output);
|
2019-07-14 14:20:49 -07:00
|
|
|
if (!(rotations &
|
|
|
|
(ECORE_DRM2_ROTATION_NORMAL | ECORE_DRM2_ROTATION_90 |
|
|
|
|
ECORE_DRM2_ROTATION_180 | ECORE_DRM2_ROTATION_270)))
|
|
|
|
rotations |= ECORE_DRM2_ROTATION_NORMAL;
|
2017-12-15 08:41:14 -08:00
|
|
|
|
|
|
|
if (rotations & ECORE_DRM2_ROTATION_NORMAL)
|
|
|
|
s->info.can_rot_0 = EINA_TRUE;
|
|
|
|
if (rotations & ECORE_DRM2_ROTATION_90)
|
|
|
|
s->info.can_rot_90 = EINA_TRUE;
|
|
|
|
if (rotations & ECORE_DRM2_ROTATION_180)
|
|
|
|
s->info.can_rot_180 = EINA_TRUE;
|
|
|
|
if (rotations & ECORE_DRM2_ROTATION_270)
|
|
|
|
s->info.can_rot_270 = EINA_TRUE;
|
2016-05-11 07:02:22 -07:00
|
|
|
|
|
|
|
if (cs)
|
|
|
|
{
|
|
|
|
if (cs->profile)
|
|
|
|
s->config.profile = strdup(cs->profile);
|
|
|
|
else
|
|
|
|
s->config.profile = NULL;
|
|
|
|
s->config.scale_multiplier = cs->scale_multiplier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-15 08:09:56 -08:00
|
|
|
zone = e_zone_for_id_get(s->id);
|
|
|
|
if ((zone) && (!zone->output)) zone->output = s;
|
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
r->screens = eina_list_append(r->screens, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
_e_mod_drm_relative_fixup(r);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Ecore_Drm2_Output *
|
|
|
|
_drm2_output_find(const Eina_List *outputs, const char *oname)
|
|
|
|
{
|
|
|
|
const Eina_List *l;
|
|
|
|
Ecore_Drm2_Output *output = NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(outputs, l, output)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
name = ecore_drm2_output_name_get(output);
|
|
|
|
if (!name) continue;
|
|
|
|
|
|
|
|
if (!strcmp(name, oname))
|
|
|
|
{
|
|
|
|
free(name);
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Ecore_Drm2_Output_Mode *
|
|
|
|
_drm2_mode_screen_find(E_Randr2_Screen *s, Ecore_Drm2_Output *output)
|
|
|
|
{
|
|
|
|
Ecore_Drm2_Output_Mode *mode, *m = NULL;
|
|
|
|
const Eina_List *l;
|
|
|
|
int diff, distance = 0x7fffffff;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ecore_drm2_output_modes_get(output), l, mode)
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
unsigned int refresh;
|
|
|
|
|
|
|
|
ecore_drm2_output_mode_info_get(mode, &width, &height, &refresh, NULL);
|
|
|
|
|
|
|
|
diff = (100 * abs(s->config.mode.w - width)) +
|
|
|
|
(100 * abs(s->config.mode.h - height)) +
|
|
|
|
fabs((100 * s->config.mode.refresh) - (100 * refresh));
|
|
|
|
if (diff < distance)
|
|
|
|
{
|
|
|
|
m = mode;
|
|
|
|
distance = diff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_drm2_output_primary_set(const Eina_List *outputs, Ecore_Drm2_Output *output)
|
|
|
|
{
|
|
|
|
const Eina_List *l;
|
|
|
|
Ecore_Drm2_Output *o;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(outputs, l, o)
|
|
|
|
{
|
|
|
|
if (o == output)
|
|
|
|
ecore_drm2_output_primary_set(output, EINA_TRUE);
|
|
|
|
else
|
|
|
|
ecore_drm2_output_primary_set(output, EINA_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_drm2_rotation_exists(Ecore_Drm2_Output *output, int rot)
|
|
|
|
{
|
|
|
|
int rots;
|
|
|
|
|
|
|
|
rots = ecore_drm2_output_supported_rotations_get(output);
|
2019-07-14 14:20:49 -07:00
|
|
|
printf("RRR: DRM2 ..... rots for %p rots=%x input=%x\n", output, rots, rot);
|
|
|
|
// hack for ... broken drivers that don't say anything about rotations
|
|
|
|
if (!(rots &
|
|
|
|
(ECORE_DRM2_ROTATION_NORMAL | ECORE_DRM2_ROTATION_90 |
|
|
|
|
ECORE_DRM2_ROTATION_180 | ECORE_DRM2_ROTATION_270)))
|
|
|
|
rots |= ECORE_DRM2_ROTATION_NORMAL;
|
2019-03-22 09:42:10 -07:00
|
|
|
if (rots >= 0)
|
|
|
|
{
|
|
|
|
if ((rot == 0) && (rots & ECORE_DRM2_ROTATION_NORMAL))
|
|
|
|
return EINA_TRUE;
|
|
|
|
if ((rot == 90) && (rots & ECORE_DRM2_ROTATION_90))
|
|
|
|
return EINA_TRUE;
|
|
|
|
if ((rot == 180) && (rots & ECORE_DRM2_ROTATION_180))
|
|
|
|
return EINA_TRUE;
|
|
|
|
if ((rot == 270) && (rots & ECORE_DRM2_ROTATION_270))
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2019-07-14 14:20:49 -07:00
|
|
|
printf("RRR: DRM2 ..... no rot matches!\n");
|
2019-03-22 09:42:10 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
static void
|
2020-06-13 12:49:16 -07:00
|
|
|
_drm2_randr_apply(void)
|
2016-05-11 07:02:22 -07:00
|
|
|
{
|
|
|
|
Ecore_Drm2_Device *dev;
|
2019-03-22 09:42:10 -07:00
|
|
|
Ecore_Drm2_Output **outconf, *out;
|
2016-05-11 07:02:22 -07:00
|
|
|
int nw = 0, nh = 0;
|
2019-03-22 09:42:10 -07:00
|
|
|
int minw, minh, maxw, maxh;
|
2019-07-15 02:03:15 -07:00
|
|
|
int rot;
|
2019-03-22 09:42:10 -07:00
|
|
|
unsigned int *crtcs = NULL;
|
|
|
|
int num_crtcs = 0, numout = 0;
|
|
|
|
const Eina_List *outputs = NULL;
|
|
|
|
E_Randr2_Screen **screenconf;
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
/* get drm device */
|
2016-05-11 07:02:22 -07:00
|
|
|
dev = ecore_evas_data_get(e_comp->ee, "device");
|
|
|
|
if (!dev) return;
|
|
|
|
|
|
|
|
nw = e_randr2->w;
|
|
|
|
nh = e_randr2->h;
|
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
/* get screen size range */
|
|
|
|
ecore_drm2_device_screen_size_range_get(dev, &minw, &minh, &maxw, &maxh);
|
|
|
|
printf("RRR: size range: %ix%i -> %ix%i\n", minw, minh, maxw, maxh);
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
crtcs = ecore_drm2_device_crtcs_get(dev, &num_crtcs);
|
|
|
|
outputs = ecore_drm2_outputs_get(dev);
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
if ((crtcs) && (outputs))
|
2016-05-11 07:02:22 -07:00
|
|
|
{
|
2019-03-22 09:42:10 -07:00
|
|
|
E_Randr2_Screen *s;
|
|
|
|
Eina_List *l;
|
|
|
|
int top_priority = 0, i;
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
outconf = alloca(num_crtcs * sizeof(Ecore_Drm2_Output *));
|
|
|
|
screenconf = alloca(num_crtcs * sizeof(E_Randr2_Screen *));
|
|
|
|
memset(outconf, 0, num_crtcs * sizeof(Ecore_Drm2_Output *));
|
|
|
|
memset(screenconf, 0, num_crtcs * sizeof(E_Randr2_Screen *));
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
/* decide which outputs gets which crtcs */
|
|
|
|
EINA_LIST_FOREACH(e_randr2->screens, l, s)
|
|
|
|
{
|
|
|
|
printf("RRR: find output for '%s'\n", s->info.name);
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
if (!s->config.configured)
|
|
|
|
{
|
|
|
|
printf("RRR: unconfigured screen: %s\n", s->info.name);
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
out = _drm2_output_find(outputs, s->info.name);
|
|
|
|
if (out)
|
|
|
|
{
|
|
|
|
printf("RRR: enabled: %i\n", s->config.enabled);
|
|
|
|
if (s->config.enabled)
|
|
|
|
{
|
|
|
|
if (s->config.priority > top_priority)
|
|
|
|
top_priority = s->config.priority;
|
|
|
|
|
|
|
|
for (i = 0; i < num_crtcs; i++)
|
|
|
|
{
|
|
|
|
if (!outconf[i])
|
|
|
|
{
|
|
|
|
printf("RRR: crtc slot empty: %i\n", i);
|
|
|
|
if (ecore_drm2_output_possible_crtc_get(out, crtcs[i]))
|
|
|
|
{
|
2019-07-14 14:20:49 -07:00
|
|
|
printf("RRR: output is possible...\n");
|
2019-03-22 09:42:10 -07:00
|
|
|
if (_drm2_rotation_exists(out, s->config.rotation))
|
|
|
|
{
|
2019-07-14 14:20:49 -07:00
|
|
|
printf("RRR: assign slot out: %p\n", out);
|
2019-03-22 09:42:10 -07:00
|
|
|
outconf[i] = out;
|
|
|
|
screenconf[i] = s;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-15 08:41:14 -08:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
numout = 0;
|
|
|
|
for (i = 0; i < num_crtcs; i++)
|
|
|
|
if (outconf[i]) numout++;
|
2017-12-15 08:41:14 -08:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
if (numout)
|
|
|
|
{
|
|
|
|
for (i = 0; i < num_crtcs; i++)
|
|
|
|
{
|
|
|
|
if (outconf[i])
|
|
|
|
{
|
|
|
|
Ecore_Drm2_Output_Mode *mode;
|
|
|
|
Ecore_Drm2_Rotation orient = ECORE_DRM2_ROTATION_NORMAL;
|
2020-07-08 09:39:43 -07:00
|
|
|
Ecore_Drm2_Relative_Mode relmode;
|
2019-03-22 09:42:10 -07:00
|
|
|
|
|
|
|
mode = _drm2_mode_screen_find(screenconf[i], outconf[i]);
|
|
|
|
if (screenconf[i]->config.rotation == 0)
|
|
|
|
orient = ECORE_DRM2_ROTATION_NORMAL;
|
|
|
|
else if (screenconf[i]->config.rotation == 90)
|
|
|
|
orient = ECORE_DRM2_ROTATION_90;
|
|
|
|
else if (screenconf[i]->config.rotation == 180)
|
|
|
|
orient = ECORE_DRM2_ROTATION_180;
|
|
|
|
else if (screenconf[i]->config.rotation == 270)
|
|
|
|
orient = ECORE_DRM2_ROTATION_270;
|
|
|
|
|
|
|
|
printf("RRR: crtc on: %i = '%s' @ %i %i - %ix%i orient %i mode %p out %p\n",
|
|
|
|
i, screenconf[i]->info.name,
|
|
|
|
screenconf[i]->config.geom.x,
|
|
|
|
screenconf[i]->config.geom.y,
|
|
|
|
screenconf[i]->config.geom.w,
|
|
|
|
screenconf[i]->config.geom.h,
|
|
|
|
orient, mode, outconf[i]);
|
|
|
|
|
|
|
|
ecore_drm2_output_mode_set(outconf[i], mode,
|
|
|
|
screenconf[i]->config.geom.x,
|
|
|
|
screenconf[i]->config.geom.y);
|
|
|
|
|
|
|
|
ecore_drm2_output_relative_to_set(outconf[i],
|
|
|
|
screenconf[i]->config.relative.to);
|
2020-07-08 09:39:43 -07:00
|
|
|
relmode = ECORE_DRM2_RELATIVE_MODE_NONE;
|
|
|
|
switch (screenconf[i]->config.relative.mode)
|
|
|
|
{
|
|
|
|
case E_RANDR2_RELATIVE_UNKNOWN: relmode = ECORE_DRM2_RELATIVE_MODE_UNKNOWN; break;
|
|
|
|
case E_RANDR2_RELATIVE_NONE: relmode = ECORE_DRM2_RELATIVE_MODE_NONE; break;
|
|
|
|
case E_RANDR2_RELATIVE_CLONE: relmode = ECORE_DRM2_RELATIVE_MODE_CLONE; break;
|
|
|
|
case E_RANDR2_RELATIVE_TO_LEFT: relmode = ECORE_DRM2_RELATIVE_MODE_TO_LEFT; break;
|
|
|
|
case E_RANDR2_RELATIVE_TO_RIGHT: relmode = ECORE_DRM2_RELATIVE_MODE_TO_RIGHT; break;
|
|
|
|
case E_RANDR2_RELATIVE_TO_ABOVE: relmode = ECORE_DRM2_RELATIVE_MODE_TO_ABOVE; break;
|
|
|
|
case E_RANDR2_RELATIVE_TO_BELOW: relmode = ECORE_DRM2_RELATIVE_MODE_TO_BELOW; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
ecore_drm2_output_relative_mode_set(outconf[i], relmode);
|
2019-03-22 09:42:10 -07:00
|
|
|
|
|
|
|
if (screenconf[i]->config.priority == top_priority)
|
|
|
|
{
|
|
|
|
_drm2_output_primary_set(outputs, outconf[i]);
|
|
|
|
top_priority = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_drm2_output_enabled_set(outconf[i],
|
|
|
|
screenconf[i]->config.enabled);
|
|
|
|
|
2020-12-01 13:21:17 -08:00
|
|
|
ecore_drm2_output_rotation_set(outconf[i], orient);
|
2019-03-22 09:42:10 -07:00
|
|
|
|
|
|
|
ecore_evas_rotation_with_resize_set(e_comp->ee,
|
|
|
|
screenconf[i]->config.rotation);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("RRR: crtc off: %i\n", i);
|
|
|
|
/* FIXME: Need new drm2 API to disable crtc...
|
|
|
|
* one which Does Not Take an Output as param */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
/* free(outputs); */
|
|
|
|
/* free(crtcs); */
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
if (nw > maxw) nw = maxw;
|
|
|
|
if (nh > maxh) nh = maxh;
|
|
|
|
if (nw < minw) nw = minw;
|
|
|
|
if (nh < minh) nh = minh;
|
2019-07-14 14:20:49 -07:00
|
|
|
printf("RRR: set vsize: %ix%i, rot=%i\n", nw, nh, ecore_evas_rotation_get(e_comp->ee));
|
2019-03-22 09:42:10 -07:00
|
|
|
ecore_drm2_device_calibrate(dev, nw, nh);
|
2019-07-15 02:03:15 -07:00
|
|
|
rot = ecore_evas_rotation_get(e_comp->ee);
|
|
|
|
if ((rot == 90) || (rot == 270))
|
|
|
|
ecore_drm2_device_pointer_max_set(dev, nh, nw);
|
|
|
|
else
|
|
|
|
ecore_drm2_device_pointer_max_set(dev, nw, nh);
|
|
|
|
ecore_drm2_device_pointer_rotation_set(dev, rot);
|
2016-05-11 07:02:22 -07:00
|
|
|
|
2019-03-22 09:42:10 -07:00
|
|
|
if (!e_randr2_cfg->ignore_hotplug_events)
|
|
|
|
e_randr2_screen_refresh_queue(EINA_FALSE);
|
2016-05-11 07:02:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_drm2_dpms(int set)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
E_Randr2_Screen *s;
|
|
|
|
Ecore_Drm2_Device *dev;
|
|
|
|
const Eina_List *outputs, *ll;
|
|
|
|
Ecore_Drm2_Output *output;
|
|
|
|
|
|
|
|
dev = ecore_evas_data_get(e_comp->ee, "device");
|
|
|
|
if (!dev) return;
|
|
|
|
|
|
|
|
outputs = ecore_drm2_outputs_get(dev);
|
|
|
|
if (!outputs) return;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(e_randr2->screens, l, s)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(outputs, ll, output)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
name = ecore_drm2_output_name_get(output);
|
|
|
|
if (!name) continue;
|
|
|
|
|
|
|
|
if (!strcmp(name, s->info.name))
|
|
|
|
{
|
|
|
|
if ((!s->config.configured) || s->config.enabled)
|
2017-09-05 12:35:07 -07:00
|
|
|
if (ecore_drm2_output_dpms_get(output) != set)
|
|
|
|
ecore_drm2_output_dpms_set(output, set);
|
2016-05-11 07:02:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
free(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-27 10:31:13 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_drm2_key_down(Ecore_Event_Key *ev)
|
|
|
|
{
|
|
|
|
int code;
|
|
|
|
|
|
|
|
code = (ev->keycode - 8);
|
|
|
|
|
|
|
|
if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
|
|
|
|
((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) ||
|
|
|
|
(ev->modifiers & ECORE_EVENT_MODIFIER_ALTGR)) &&
|
|
|
|
(code >= KEY_F1) && (code <= KEY_F8))
|
|
|
|
{
|
|
|
|
Ecore_Drm2_Device *dev;
|
|
|
|
int vt;
|
|
|
|
|
|
|
|
vt = (code - KEY_F1 + 1);
|
|
|
|
|
|
|
|
dev = ecore_evas_data_get(e_comp->ee, "device");
|
|
|
|
if (dev)
|
|
|
|
{
|
|
|
|
ecore_drm2_device_vt_set(dev, vt);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_drm2_key_up(Ecore_Event_Key *ev)
|
|
|
|
{
|
|
|
|
(void)ev;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_drm_randr_available(void)
|
|
|
|
{
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2016-12-09 05:33:56 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_drm2_cb_seat_caps(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
|
|
|
{
|
|
|
|
Elput_Event_Seat_Caps *ev;
|
|
|
|
|
|
|
|
ev = event;
|
|
|
|
|
|
|
|
if (ev->pointer_count <= 0)
|
|
|
|
{
|
|
|
|
e_pointer_hide(e_comp->pointer);
|
|
|
|
e_comp_wl_input_pointer_enabled_set(EINA_FALSE);
|
|
|
|
}
|
|
|
|
else if (ev->pointer_count > 0)
|
|
|
|
{
|
2019-01-31 06:10:57 -08:00
|
|
|
e_mouse_update();
|
2016-12-09 05:33:56 -08:00
|
|
|
e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
|
2017-02-03 12:13:48 -08:00
|
|
|
e_pointer_show(e_comp->pointer);
|
2016-12-09 05:33:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ev->keyboard_count <= 0)
|
|
|
|
e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
|
|
|
|
else if (ev->keyboard_count > 0)
|
|
|
|
e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
|
|
|
|
|
2017-01-17 05:42:53 -08:00
|
|
|
if (ev->touch_count <= 0)
|
|
|
|
e_comp_wl_input_touch_enabled_set(EINA_FALSE);
|
|
|
|
else if (ev->touch_count > 0)
|
|
|
|
e_comp_wl_input_touch_enabled_set(EINA_TRUE);
|
|
|
|
|
2016-12-09 05:33:56 -08:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_drm2_init(void)
|
|
|
|
{
|
|
|
|
seat_handler =
|
|
|
|
ecore_event_handler_add(ELPUT_EVENT_SEAT_CAPS, _drm2_cb_seat_caps, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_drm2_shutdown(void)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(seat_handler);
|
|
|
|
}
|
2016-05-11 07:02:22 -07:00
|
|
|
|
|
|
|
static E_Comp_Screen_Iface drmiface =
|
|
|
|
{
|
|
|
|
.available = _drm_randr_available,
|
2016-12-09 05:33:56 -08:00
|
|
|
.init = _drm2_init,
|
|
|
|
.shutdown = _drm2_shutdown,
|
2016-05-11 07:02:22 -07:00
|
|
|
.create = _drm2_randr_create,
|
|
|
|
.apply = _drm2_randr_apply,
|
|
|
|
.dpms = _drm2_dpms,
|
2016-07-27 10:31:13 -07:00
|
|
|
.key_down = _drm2_key_down,
|
|
|
|
.key_up = _drm2_key_up,
|
2017-02-03 12:13:48 -08:00
|
|
|
.relative_motion = EINA_TRUE,
|
2017-02-24 11:15:42 -08:00
|
|
|
.backlight_enabled = EINA_TRUE,
|
2016-05-11 07:02:22 -07:00
|
|
|
};
|
2015-07-08 12:06:09 -07:00
|
|
|
|
2017-02-03 12:13:48 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_pointer_motion(void *d EINA_UNUSED, int t EINA_UNUSED, Elput_Event_Pointer_Motion *ev)
|
|
|
|
{
|
2017-02-07 07:35:47 -08:00
|
|
|
e_comp_wl_extension_relative_motion_event(ev->time_usec, ev->dx, ev->dy,
|
|
|
|
ev->dx_unaccel, ev->dy_unaccel);
|
2017-02-03 12:13:48 -08:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2017-06-09 17:18:20 -07:00
|
|
|
static void
|
|
|
|
_drm_device_del(void *data EINA_UNUSED, const Efl_Event *event)
|
|
|
|
{
|
|
|
|
Eo *seat = event->info;
|
|
|
|
|
2017-06-12 02:48:32 -07:00
|
|
|
if (efl_input_device_type_get(event->info) == EFL_INPUT_DEVICE_TYPE_SEAT) return;
|
2017-06-09 17:18:20 -07:00
|
|
|
seat = efl_input_device_seat_get(event->info);
|
|
|
|
|
2020-07-08 09:39:43 -07:00
|
|
|
if (seat != evas_default_device_get(e_comp->evas, EVAS_DEVICE_CLASS_SEAT)) return;
|
2019-06-26 06:07:46 -07:00
|
|
|
if (!efl_input_device_is_pointer_type_get(event->info)) return;
|
|
|
|
if (efl_input_device_pointer_device_count_get(seat) == 1)
|
|
|
|
ecore_evas_cursor_device_unset(e_comp->ee, event->info);
|
2017-06-09 17:18:20 -07:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void *
|
2012-03-28 18:43:17 -07:00
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
2014-09-04 07:05:59 -07:00
|
|
|
int w = 0, h = 0;
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2018-04-25 09:06:12 -07:00
|
|
|
static Efl_Callback_Array_Item arr[2] = { { 0, _drm_device_del } };
|
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
printf("LOAD WL_DRM MODULE\n");
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
/* try to init ecore_drm */
|
|
|
|
/* if (!ecore_drm_init()) */
|
|
|
|
/* { */
|
|
|
|
/* fprintf(stderr, "Could not initialize ecore_drm"); */
|
|
|
|
/* return NULL; */
|
|
|
|
/* } */
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2015-03-12 10:44:34 -07:00
|
|
|
if (e_comp_config_get()->engine == E_COMP_ENGINE_GL)
|
2014-07-16 12:38:40 -07:00
|
|
|
{
|
2015-04-20 08:44:33 -07:00
|
|
|
e_comp->ee = ecore_evas_new("gl_drm", 0, 0, 1, 1, NULL);
|
2015-04-06 12:57:09 -07:00
|
|
|
e_comp_gl_set(!!e_comp->ee);
|
2014-07-16 12:38:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fallback to framebuffer drm (non-accel) */
|
2015-04-06 12:57:09 -07:00
|
|
|
if (!e_comp->ee)
|
2012-03-28 18:43:17 -07:00
|
|
|
{
|
2015-04-20 08:44:33 -07:00
|
|
|
if ((e_comp->ee = ecore_evas_new("drm", 0, 0, 1, 1, NULL)))
|
2015-04-06 13:01:39 -07:00
|
|
|
{
|
|
|
|
e_comp_gl_set(EINA_FALSE);
|
|
|
|
elm_config_accel_preference_set("none");
|
|
|
|
elm_config_accel_preference_override_set(EINA_TRUE);
|
|
|
|
elm_config_all_flush();
|
|
|
|
elm_config_save();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-18 07:15:12 -07:00
|
|
|
fprintf(stderr, "Could not create ecore_evas_drm canvas\n");
|
2015-04-06 13:01:39 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-03-28 18:43:17 -07:00
|
|
|
}
|
|
|
|
|
2015-04-06 12:59:59 -07:00
|
|
|
ecore_evas_data_set(e_comp->ee, "comp", e_comp);
|
|
|
|
|
2015-04-22 18:15:12 -07:00
|
|
|
e_comp->screen = &drmiface;
|
2014-05-09 02:53:53 -07:00
|
|
|
|
|
|
|
if (!e_comp_wl_init()) return NULL;
|
2017-12-15 08:04:20 -08:00
|
|
|
|
|
|
|
/* get the current screen geometry */
|
|
|
|
ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
|
2015-04-22 16:27:36 -07:00
|
|
|
if (!e_comp_canvas_init(w, h)) return NULL;
|
2014-05-09 02:53:53 -07:00
|
|
|
|
2018-04-25 09:06:12 -07:00
|
|
|
arr[0].desc = EFL_CANVAS_SCENE_EVENT_DEVICE_REMOVED;
|
2015-08-13 13:05:57 -07:00
|
|
|
ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x,
|
|
|
|
&e_comp_wl->ptr.y);
|
2015-07-07 11:33:14 -07:00
|
|
|
evas_event_feed_mouse_in(e_comp->evas, 0, NULL);
|
2015-04-22 07:42:33 -07:00
|
|
|
|
2015-05-13 09:05:57 -07:00
|
|
|
e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
|
|
|
|
e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
|
|
|
|
e_comp_wl_input_touch_enabled_set(EINA_TRUE);
|
2014-05-09 02:53:53 -07:00
|
|
|
|
2015-04-06 12:57:09 -07:00
|
|
|
e_comp->pointer = e_pointer_canvas_new(e_comp->ee, EINA_TRUE);
|
|
|
|
e_comp->pointer->color = EINA_TRUE;
|
2014-03-17 06:57:56 -07:00
|
|
|
|
2016-05-11 07:02:22 -07:00
|
|
|
activate_handler =
|
|
|
|
ecore_event_handler_add(ECORE_DRM2_EVENT_ACTIVATE,
|
|
|
|
_e_mod_drm_cb_activate, NULL);
|
|
|
|
|
|
|
|
output_handler =
|
|
|
|
ecore_event_handler_add(ECORE_DRM2_EVENT_OUTPUT_CHANGED,
|
|
|
|
_e_mod_drm_cb_output, NULL);
|
2015-02-24 10:27:56 -08:00
|
|
|
|
2017-02-07 07:35:47 -08:00
|
|
|
input_handler =
|
|
|
|
ecore_event_handler_add(ELPUT_EVENT_POINTER_MOTION,
|
|
|
|
(Ecore_Event_Handler_Cb)_pointer_motion, NULL);
|
2017-02-03 12:13:48 -08:00
|
|
|
|
2018-04-25 09:06:12 -07:00
|
|
|
efl_event_callback_array_priority_add(e_comp->evas, arr,
|
2017-06-09 17:18:20 -07:00
|
|
|
EFL_CALLBACK_PRIORITY_BEFORE, NULL);
|
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
return m;
|
2012-03-28 18:43:17 -07:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API int
|
2014-03-11 02:01:01 -07:00
|
|
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
2012-03-28 18:43:17 -07:00
|
|
|
{
|
2015-04-06 12:57:55 -07:00
|
|
|
if (output_handler) ecore_event_handler_del(output_handler);
|
|
|
|
output_handler = NULL;
|
|
|
|
|
2015-01-05 06:09:59 -08:00
|
|
|
if (activate_handler) ecore_event_handler_del(activate_handler);
|
|
|
|
activate_handler = NULL;
|
|
|
|
|
2017-02-03 12:13:48 -08:00
|
|
|
E_FREE_FUNC(input_handler, ecore_event_handler_del);
|
2012-03-28 18:43:17 -07:00
|
|
|
return 1;
|
|
|
|
}
|