forked from enlightenment/enlightenment
E (RandR): Use output->monitor first to get resolutions (if it exists), then
fallback to output->crtc common modes if needed. No need to drop duplicate resolutions anymore, in fact we should list them due to different refresh rates. Add functions to smart monitor object for getting position, orientation, and mode info. When searching for a resolution within snapping fuzziness, also try to find one which matches the current refresh rate. Signed-off-by: Christopher Michael <cp.michael@samsung.com> SVN revision: 77690
This commit is contained in:
parent
6de05d3dee
commit
47977be1ca
|
@ -200,7 +200,7 @@ e_smart_monitor_crtc_set(Evas_Object *obj, E_Randr_Crtc_Info *crtc)
|
||||||
sd->rotation = _e_smart_monitor_rotation_get(sd->orientation);
|
sd->rotation = _e_smart_monitor_rotation_get(sd->orientation);
|
||||||
sd->mode = crtc->current_mode;
|
sd->mode = crtc->current_mode;
|
||||||
|
|
||||||
sd->rate = ((float)sd->mode->dotClock /
|
sd->rate = (int)((float)sd->mode->dotClock /
|
||||||
((float)sd->mode->hTotal * (float)sd->mode->vTotal));
|
((float)sd->mode->hTotal * (float)sd->mode->vTotal));
|
||||||
|
|
||||||
EINA_LIST_FOREACH(crtc->outputs, l, output)
|
EINA_LIST_FOREACH(crtc->outputs, l, output)
|
||||||
|
@ -213,32 +213,22 @@ e_smart_monitor_crtc_set(Evas_Object *obj, E_Randr_Crtc_Info *crtc)
|
||||||
|
|
||||||
printf("Output: %d %s\n", output->xid, output->name);
|
printf("Output: %d %s\n", output->xid, output->name);
|
||||||
|
|
||||||
if (output->crtc)
|
if (sd->mode)
|
||||||
modes = output->crtc->outputs_common_modes;
|
{
|
||||||
else if (output->monitor)
|
printf("\tCurrent Mode\n");
|
||||||
|
printf("\t\tID: %d\n", sd->mode->xid);
|
||||||
|
printf("\t\tSize: %d x %d\n", sd->mode->width, sd->mode->height);
|
||||||
|
printf("\t\tRate: %dHz\n", sd->rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output->monitor)
|
||||||
modes = output->monitor->modes;
|
modes = output->monitor->modes;
|
||||||
|
else if (output->crtc)
|
||||||
/* grab a copy of this monitor's modes,
|
modes = output->crtc->outputs_common_modes;
|
||||||
* filtering out duplicate resolutions */
|
|
||||||
EINA_LIST_FOREACH(modes, m, mode)
|
|
||||||
{
|
|
||||||
Ecore_X_Randr_Mode_Info *nmode = NULL;
|
|
||||||
|
|
||||||
if ((nmode = eina_list_data_get(m->next)))
|
|
||||||
{
|
|
||||||
if (!strcmp(mode->name, nmode->name))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sd->modes = eina_list_append(sd->modes, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sort the mode list */
|
|
||||||
sd->modes = eina_list_sort(sd->modes, 0, _e_smart_cb_modes_sort);
|
|
||||||
|
|
||||||
/* NB: This is just a development printf to list modes.
|
/* NB: This is just a development printf to list modes.
|
||||||
* Remove when dialog is complete */
|
* Remove when dialog is complete */
|
||||||
EINA_LIST_FOREACH(sd->modes, m, mode)
|
EINA_LIST_FOREACH(modes, m, mode)
|
||||||
{
|
{
|
||||||
double rate = 0.0;
|
double rate = 0.0;
|
||||||
|
|
||||||
|
@ -246,10 +236,15 @@ e_smart_monitor_crtc_set(Evas_Object *obj, E_Randr_Crtc_Info *crtc)
|
||||||
rate = ((float)mode->dotClock /
|
rate = ((float)mode->dotClock /
|
||||||
((float)mode->hTotal * (float)mode->vTotal));
|
((float)mode->hTotal * (float)mode->vTotal));
|
||||||
|
|
||||||
printf("\tMode: %d %dx%d @ %.1fHz\n", mode->xid,
|
printf("\t\tMode: %d %dx%d @ %.1fHz\n", mode->xid,
|
||||||
mode->width, mode->height, rate);
|
mode->width, mode->height, rate);
|
||||||
|
|
||||||
|
sd->modes = eina_list_append(sd->modes, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* sort the mode list */
|
||||||
|
sd->modes = eina_list_sort(sd->modes, 0, _e_smart_cb_modes_sort);
|
||||||
|
|
||||||
/* get the min resolution for this monitor */
|
/* get the min resolution for this monitor */
|
||||||
mode = eina_list_nth(sd->modes, 0);
|
mode = eina_list_nth(sd->modes, 0);
|
||||||
sd->min.w = mode->width;
|
sd->min.w = mode->width;
|
||||||
|
@ -393,6 +388,38 @@ e_smart_monitor_moving_get(Evas_Object *obj)
|
||||||
return sd->moving;
|
return sd->moving;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
e_smart_monitor_position_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
|
||||||
|
{
|
||||||
|
Evas_Coord mx, my;
|
||||||
|
|
||||||
|
e_layout_child_geometry_get(obj, &mx, &my, NULL, NULL);
|
||||||
|
if (x) *x = mx;
|
||||||
|
if (y) *y = my;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ecore_X_Randr_Orientation
|
||||||
|
e_smart_monitor_orientation_get(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd;
|
||||||
|
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj)))
|
||||||
|
return ECORE_X_RANDR_ORIENTATION_ROT_0;
|
||||||
|
|
||||||
|
return sd->orientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ecore_X_Randr_Mode_Info *
|
||||||
|
e_smart_monitor_mode_get(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Smart_Data *sd;
|
||||||
|
|
||||||
|
if (!(sd = evas_object_smart_data_get(obj)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return sd->mode;
|
||||||
|
}
|
||||||
|
|
||||||
/* local functions */
|
/* local functions */
|
||||||
static void
|
static void
|
||||||
_e_smart_add(Evas_Object *obj)
|
_e_smart_add(Evas_Object *obj)
|
||||||
|
@ -1255,10 +1282,10 @@ _e_smart_monitor_refresh_rates_refill(Evas_Object *obj)
|
||||||
Eina_List *modes = NULL, *m = NULL;
|
Eina_List *modes = NULL, *m = NULL;
|
||||||
Ecore_X_Randr_Mode_Info *mode = NULL;
|
Ecore_X_Randr_Mode_Info *mode = NULL;
|
||||||
|
|
||||||
if (output->crtc)
|
if (output->monitor)
|
||||||
modes = output->crtc->outputs_common_modes;
|
|
||||||
else if (output->monitor)
|
|
||||||
modes = output->monitor->modes;
|
modes = output->monitor->modes;
|
||||||
|
else if (output->crtc)
|
||||||
|
modes = output->crtc->outputs_common_modes;
|
||||||
|
|
||||||
/* grab a copy of this monitor's modes,
|
/* grab a copy of this monitor's modes,
|
||||||
* filtering out duplicate resolutions */
|
* filtering out duplicate resolutions */
|
||||||
|
@ -1276,7 +1303,7 @@ _e_smart_monitor_refresh_rates_refill(Evas_Object *obj)
|
||||||
|
|
||||||
snprintf(buff, sizeof(buff), "%.1fHz", rate);
|
snprintf(buff, sizeof(buff), "%.1fHz", rate);
|
||||||
|
|
||||||
ow = e_widget_radio_add(evas, buff, abs((int)rate), rg);
|
ow = e_widget_radio_add(evas, buff, (int)rate, rg);
|
||||||
e_widget_list_object_append(sd->o_refresh, ow, 1, 0, 0.5);
|
e_widget_list_object_append(sd->o_refresh, ow, 1, 0, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1304,9 +1331,18 @@ _e_smart_monitor_resolution_get(E_Smart_Data *sd, Evas_Coord width, Evas_Coord h
|
||||||
{
|
{
|
||||||
if ((((int)mode->height - RESIZE_SNAP_FUZZINESS) <= height) ||
|
if ((((int)mode->height - RESIZE_SNAP_FUZZINESS) <= height) ||
|
||||||
(((int)mode->height + RESIZE_SNAP_FUZZINESS) <= height))
|
(((int)mode->height + RESIZE_SNAP_FUZZINESS) <= height))
|
||||||
|
{
|
||||||
|
double rate = 0.0;
|
||||||
|
|
||||||
|
if ((mode->hTotal) && (mode->vTotal))
|
||||||
|
rate = (((float)mode->dotClock /
|
||||||
|
((float)mode->hTotal * (float)mode->vTotal)));
|
||||||
|
|
||||||
|
if (((int)rate == sd->rate))
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue