randr: add match for refresh rate

Store output config with refresh rate, so we don't just get correct
geometry for outputs.
This commit is contained in:
Sebastian Dransfeld 2014-03-06 10:11:52 +01:00
parent f32426878c
commit ff750b2bb9
2 changed files with 43 additions and 5 deletions

View File

@ -131,6 +131,22 @@ e_randr_config_save(void)
return e_config_domain_save("e_randr", _e_randr_edd, e_randr_cfg); return e_config_domain_save("e_randr", _e_randr_edd, e_randr_cfg);
} }
EAPI double
e_randr_mode_refresh_rate_get(Ecore_X_Randr_Mode_Info *mode)
{
double rate = 0.0;
if (mode)
{
if ((mode->hTotal) && (mode->vTotal))
rate = ((double)mode->dotClock /
((double)mode->hTotal * (double)mode->vTotal));
rate = round(rate);
}
return rate;
}
/* local functions */ /* local functions */
static Eina_Bool static Eina_Bool
_e_randr_config_load(void) _e_randr_config_load(void)
@ -151,6 +167,7 @@ _e_randr_config_load(void)
E_CONFIG_VAL(D, T, geo.y, INT); E_CONFIG_VAL(D, T, geo.y, INT);
E_CONFIG_VAL(D, T, geo.w, INT); E_CONFIG_VAL(D, T, geo.w, INT);
E_CONFIG_VAL(D, T, geo.h, INT); E_CONFIG_VAL(D, T, geo.h, INT);
E_CONFIG_VAL(D, T, refresh_rate, DOUBLE);
E_CONFIG_VAL(D, T, connect, UCHAR); E_CONFIG_VAL(D, T, connect, UCHAR);
/* define edd for randr config */ /* define edd for randr config */
@ -205,6 +222,21 @@ _e_randr_config_load(void)
_e_randr_config_new(); _e_randr_config_new();
do_restore = EINA_FALSE; do_restore = EINA_FALSE;
} }
else
{
#define CONFIG_VERSION_CHECK(VERSION) \
if (e_randr_cfg->version - (E_RANDR_CONFIG_FILE_EPOCH * 1000000) < (VERSION))
CONFIG_VERSION_CHECK(4)
{
E_Config_Randr_Output *output;
Eina_List *l;
/* Set refresh_rate to 60 */
EINA_LIST_FOREACH(e_randr_cfg->outputs, l, output)
if (output->refresh_rate == 0) output->refresh_rate = 60.0;
}
}
if (!e_randr_cfg) return EINA_FALSE; if (!e_randr_cfg) return EINA_FALSE;
_e_randr_load(); _e_randr_load();
@ -759,16 +791,18 @@ _e_randr_output_mode_update(E_Randr_Output *output)
{ {
for (i = 0; i < nmode_infos; i++) for (i = 0; i < nmode_infos; i++)
{ {
double rate = 0.0;
rate = e_randr_mode_refresh_rate_get(mode_infos[i]);
if ((mode_infos[i]->width == (unsigned int)output->cfg->geo.w) && if ((mode_infos[i]->width == (unsigned int)output->cfg->geo.w) &&
(mode_infos[i]->height == (unsigned int)output->cfg->geo.h)) (mode_infos[i]->height == (unsigned int)output->cfg->geo.h) &&
(rate == output->cfg->refresh_rate) &&
(_e_randr_output_mode_valid(mode_infos[i]->xid, modes, nmodes)))
{ {
output->mode = mode_infos[i]->xid; output->mode = mode_infos[i]->xid;
break; break;
} }
} }
/* check if mode is available */
if (!_e_randr_output_mode_valid(output->mode, modes, nmodes))
output->mode = 0;
} }
/* see if we can use the mode of the crtc */ /* see if we can use the mode of the crtc */
@ -801,6 +835,7 @@ _e_randr_output_mode_update(E_Randr_Output *output)
{ {
output->cfg->geo.w = mode_infos[i]->width; output->cfg->geo.w = mode_infos[i]->width;
output->cfg->geo.h = mode_infos[i]->height; output->cfg->geo.h = mode_infos[i]->height;
output->cfg->refresh_rate = e_randr_mode_refresh_rate_get(mode_infos[i]);
break; break;
} }
} }
@ -826,6 +861,7 @@ error:
output->cfg->geo.w, output->cfg->geo.h, output->cfg->geo.w, output->cfg->geo.h,
output->cfg->geo.x, output->cfg->geo.y); output->cfg->geo.x, output->cfg->geo.y);
output->cfg->geo.x = output->cfg->geo.y = output->cfg->geo.w = output->cfg->geo.h = 0; output->cfg->geo.x = output->cfg->geo.y = output->cfg->geo.w = output->cfg->geo.h = 0;
output->cfg->refresh_rate = 0.0;
output->mode = 0; output->mode = 0;
return; return;
} }

View File

@ -17,7 +17,7 @@ typedef struct _E_Randr E_Randr;
#define E_RANDR_VERSION_1_4 ((1 << 16) | 4) #define E_RANDR_VERSION_1_4 ((1 << 16) | 4)
#define E_RANDR_CONFIG_FILE_EPOCH 4 #define E_RANDR_CONFIG_FILE_EPOCH 4
#define E_RANDR_CONFIG_FILE_GENERATION 3 #define E_RANDR_CONFIG_FILE_GENERATION 4
#define E_RANDR_CONFIG_FILE_VERSION \ #define E_RANDR_CONFIG_FILE_VERSION \
((E_RANDR_CONFIG_FILE_EPOCH * 1000000) + E_RANDR_CONFIG_FILE_GENERATION) ((E_RANDR_CONFIG_FILE_EPOCH * 1000000) + E_RANDR_CONFIG_FILE_GENERATION)
@ -28,6 +28,7 @@ struct _E_Config_Randr_Output
unsigned int orient; // value of the ecore_x_randr_orientation unsigned int orient; // value of the ecore_x_randr_orientation
Eina_Rectangle geo; // geometry Eina_Rectangle geo; // geometry
double refresh_rate; // calculated refresh rate
Eina_Bool connect; // does the user want this output connected Eina_Bool connect; // does the user want this output connected
}; };
@ -74,6 +75,7 @@ EINTERN Eina_Bool e_randr_init(void);
EINTERN int e_randr_shutdown(void); EINTERN int e_randr_shutdown(void);
EAPI Eina_Bool e_randr_config_save(void); EAPI Eina_Bool e_randr_config_save(void);
EAPI double e_randr_mode_refresh_rate_get(Ecore_X_Randr_Mode_Info *mode);
extern EAPI E_Config_Randr *e_randr_cfg; extern EAPI E_Config_Randr *e_randr_cfg;