ecore_drm2: Add API to find a display at given coordinates

NB: This also makes a small modification for calibrating displays
which should now properly work based on display rotation
This commit is contained in:
Christopher Michael 2024-01-17 08:14:01 -05:00
parent c7d2f9960d
commit db666e93e9
4 changed files with 35 additions and 3 deletions

View File

@ -115,6 +115,7 @@ EAPI int ecore_drm2_display_supported_rotations_get(Ecore_Drm2_Display *disp);
EAPI void ecore_drm2_display_relative_mode_set(Ecore_Drm2_Display *disp, Ecore_Drm2_Relative_Mode mode);
EAPI void ecore_drm2_display_relative_to_set(Ecore_Drm2_Display *disp, const char *relative);
EAPI void ecore_drm2_display_dpi_get(Ecore_Drm2_Display *disp, int *xdpi, int *ydpi);
EAPI Ecore_Drm2_Display *ecore_drm2_display_find(Ecore_Drm2_Device *dev, int x, int y);
# endif

View File

@ -41,6 +41,7 @@ _ecore_drm2_device_cb_device_change(void *data, int type EINA_UNUSED, void *even
{
Elput_Event_Device_Change *ev;
Ecore_Drm2_Device *dev;
int dw, dh;
ev = event;
dev = data;
@ -55,7 +56,10 @@ _ecore_drm2_device_cb_device_change(void *data, int type EINA_UNUSED, void *even
{
disp = eina_list_data_get(dev->displays);
if (disp)
ecore_drm2_device_calibrate(dev, disp->w, disp->h);
{
ecore_drm2_display_info_get(disp, NULL, NULL, &dw, &dh, NULL);
ecore_drm2_device_calibrate(dev, dw, dh);
}
}
else
{
@ -65,7 +69,8 @@ _ecore_drm2_device_cb_device_change(void *data, int type EINA_UNUSED, void *even
{
if (eina_streq(disp->name, name))
{
ecore_drm2_device_calibrate(dev, disp->w, disp->h);
ecore_drm2_display_info_get(disp, NULL, NULL, &dw, &dh, NULL);
ecore_drm2_device_calibrate(dev, dw, dh);
break;
}
}

View File

@ -1,5 +1,9 @@
#include "ecore_drm2_private.h"
#define INSIDE(x, y, xx, yy, ww, hh) \
(((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && \
((x) >= (xx)) && ((y) >= (yy)))
#define EDID_DESCRIPTOR_ALPHANUMERIC_DATA_STRING 0xfe
#define EDID_DESCRIPTOR_DISPLAY_PRODUCT_NAME 0xfc
#define EDID_DESCRIPTOR_DISPLAY_PRODUCT_SERIAL_NUMBER 0xff
@ -963,3 +967,25 @@ ecore_drm2_display_dpi_get(Ecore_Drm2_Display *disp, int *xdpi, int *ydpi)
if (ydpi)
*ydpi = ((25.4 * (disp->state.current->mode->height)) / disp->ph);
}
EAPI Ecore_Drm2_Display *
ecore_drm2_display_find(Ecore_Drm2_Device *dev, int x, int y)
{
Eina_List *l;
Ecore_Drm2_Display *disp;
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL);
EINA_LIST_FOREACH(dev->displays, l, disp)
{
int ox, oy, ow, oh;
if (!disp->state.current->enabled) continue;
ecore_drm2_display_info_get(disp, &ox, &oy, &ow, &oh, NULL);
if (INSIDE(x, y, ox, oy, ow, oh))
return disp;
}
return NULL;
}

View File

@ -240,7 +240,7 @@ struct _Ecore_Drm2_Display_Mode
struct _Ecore_Drm2_Display
{
/* int fd; */
int x, y, w, h;
int x, y;
int pw, ph; // physical dimensions
Eina_Stringshare *name, *make, *model, *serial;