Make conf_display work again (primary output resolution st/ld).

SVN revision: 69547
This commit is contained in:
Leif Middelschulte 2012-03-21 23:39:11 +00:00
parent b1d31afdb8
commit 95f33ad549
6 changed files with 100 additions and 80 deletions

View File

@ -50,7 +50,6 @@ static E_Config_DD *_e_config_mime_icon_edd = NULL;
static E_Config_DD *_e_config_syscon_action_edd = NULL; static E_Config_DD *_e_config_syscon_action_edd = NULL;
static E_Config_DD *_e_config_env_var_edd = NULL; static E_Config_DD *_e_config_env_var_edd = NULL;
static E_Config_DD *_e_config_randr_size_edd = NULL; static E_Config_DD *_e_config_randr_size_edd = NULL;
static E_Config_DD *_e_config_randr_size_mm_edd = NULL;
static E_Config_DD *_e_config_randr_edid_hash_edd = NULL; static E_Config_DD *_e_config_randr_edid_hash_edd = NULL;
static E_Config_DD *_e_config_randr_serialized_setup_edd = NULL; static E_Config_DD *_e_config_randr_serialized_setup_edd = NULL;
static E_Config_DD *_e_config_randr_serialized_setup_11_edd = NULL; static E_Config_DD *_e_config_randr_serialized_setup_11_edd = NULL;
@ -520,18 +519,6 @@ e_config_init(void)
#define D _e_config_randr_size_edd #define D _e_config_randr_size_edd
E_CONFIG_VAL(D, T, width, INT); E_CONFIG_VAL(D, T, width, INT);
E_CONFIG_VAL(D, T, height, INT); E_CONFIG_VAL(D, T, height, INT);
E_CONFIG_VAL(D, T, width, INT);
E_CONFIG_VAL(D, T, height, INT);
_e_config_randr_size_mm_edd = E_CONFIG_DD_NEW("Ecore_X_Randr_Screen_Size_MM", Ecore_X_Randr_Screen_Size_MM);
#undef T
#undef D
#define T Ecore_X_Randr_Screen_Size_MM
#define D _e_config_randr_size_mm_edd
E_CONFIG_VAL(D, T, width, INT);
E_CONFIG_VAL(D, T, height, INT);
E_CONFIG_VAL(D, T, width_mm, INT);
E_CONFIG_VAL(D, T, height_mm, INT);
_e_config_randr_edid_hash_edd = E_CONFIG_DD_NEW("E_Randr_Edid_Hash", E_Randr_Edid_Hash); _e_config_randr_edid_hash_edd = E_CONFIG_DD_NEW("E_Randr_Edid_Hash", E_Randr_Edid_Hash);
#undef T #undef T
@ -545,7 +532,10 @@ e_config_init(void)
#undef D #undef D
#define T E_Randr_Serialized_Setup_11 #define T E_Randr_Serialized_Setup_11
#define D _e_config_randr_serialized_setup_11_edd #define D _e_config_randr_serialized_setup_11_edd
E_CONFIG_SUB(D, T, size, _e_config_randr_size_edd); E_CONFIG_VAL(D, T, size.width, INT);
E_CONFIG_VAL(D, T, size.height, INT);
E_CONFIG_VAL(D, T, size.width_mm, INT);
E_CONFIG_VAL(D, T, size.height_mm, INT);
E_CONFIG_VAL(D, T, orientation, INT); E_CONFIG_VAL(D, T, orientation, INT);
E_CONFIG_VAL(D, T, refresh_rate, SHORT); E_CONFIG_VAL(D, T, refresh_rate, SHORT);

View File

@ -27,7 +27,6 @@ static Eina_Bool _init(void);
static void _shutdown(void); static void _shutdown(void);
static Eina_Bool _screen_info_refresh(void); static Eina_Bool _screen_info_refresh(void);
static Eina_Bool _e_event_config_loaded_cb(void *data, int type, void *e); static Eina_Bool _e_event_config_loaded_cb(void *data, int type, void *e);
static void _try_restore_configuration(void);
static void _event_listeners_add(void); static void _event_listeners_add(void);
static void _event_listeners_remove(void); static void _event_listeners_remove(void);
@ -60,13 +59,15 @@ _init(void)
return EINA_FALSE; return EINA_FALSE;
_event_listeners_add(); _event_listeners_add();
_try_restore_configuration(); if (e_config->randr_serialized_setup)
if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
{ {
if ((e_config->randr_serialized_setup) && e_randr_try_restore_configuration();
(e_config->randr_serialized_setup->outputs_policies))
_12_policies_restore(); if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
{
if (e_config->randr_serialized_setup->outputs_policies)
_12_policies_restore();
}
} }
return EINA_TRUE; return EINA_TRUE;
@ -144,22 +145,6 @@ _event_listeners_add(void)
} }
} }
static void
_try_restore_configuration(void)
{
if (e_config->randr_serialized_setup)
{
if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
{
_11_try_restore_configuration();
}
else if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
{
_12_try_restore_configuration();
}
}
}
// "Free" helper functions // "Free" helper functions
static void static void
_event_listeners_remove(void) _event_listeners_remove(void)

View File

@ -29,6 +29,7 @@ typedef enum _E_Randr_Configuration_Store_Modifier
} E_Randr_Configuration_Store_Modifier; } E_Randr_Configuration_Store_Modifier;
EAPI void e_randr_store_configuration(E_Randr_Configuration_Store_Modifier modifier); EAPI void e_randr_store_configuration(E_Randr_Configuration_Store_Modifier modifier);
EAPI void e_randr_11_store_configuration(E_Randr_Configuration_Store_Modifier modifier);
#else #else
#ifndef E_RANDR_H #ifndef E_RANDR_H
@ -183,6 +184,8 @@ struct _E_Randr_Serialized_Setup
EINTERN Eina_Bool e_randr_init(void); EINTERN Eina_Bool e_randr_init(void);
EAPI Eina_Bool e_randr_screen_info_refresh(void); EAPI Eina_Bool e_randr_screen_info_refresh(void);
EINTERN int e_randr_shutdown(void); EINTERN int e_randr_shutdown(void);
EINTERN void e_randr_try_restore_configuration(void);
EINTERN E_Randr_Serialized_Setup *e_randr_serialized_setup_new(void);
EINTERN void e_randr_serialized_setup_free(E_Randr_Serialized_Setup *ss); EINTERN void e_randr_serialized_setup_free(E_Randr_Serialized_Setup *ss);
EINTERN void e_randr_11_serialized_setup_free(E_Randr_Serialized_Setup_11 *ss_11); EINTERN void e_randr_11_serialized_setup_free(E_Randr_Serialized_Setup_11 *ss_11);
EINTERN void e_randr_12_serialized_setup_free(E_Randr_Serialized_Setup_12 *ss_12); EINTERN void e_randr_12_serialized_setup_free(E_Randr_Serialized_Setup_12 *ss_12);

View File

@ -15,14 +15,30 @@ _serialized_setup_11_new(void)
{ {
E_Randr_Serialized_Setup_11 *ss; E_Randr_Serialized_Setup_11 *ss;
Ecore_X_Randr_Screen_Size_MM *size; Ecore_X_Randr_Screen_Size_MM *size;
Ecore_X_Randr_Orientation ori;
Ecore_X_Randr_Refresh_Rate rate;
ss = malloc(sizeof(*ss)); ss = malloc(sizeof(*ss));
if (!(size = (Ecore_X_Randr_Screen_Size_MM *)eina_list_data_get(eina_list_nth(e_randr_screen_info.rrvd_info.randr_info_11->sizes, e_randr_screen_info.rrvd_info.randr_info_11->csize_index)))) goto _serialized_setup_11_new_failed_free_ss; if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
ss->size.width = size->width; {
ss->size.height = size->height; if (!(size = (Ecore_X_Randr_Screen_Size_MM *)eina_list_data_get(eina_list_nth(e_randr_screen_info.rrvd_info.randr_info_11->sizes, e_randr_screen_info.rrvd_info.randr_info_11->csize_index)))) goto _serialized_setup_11_new_failed_free_ss;
ss->refresh_rate = e_randr_screen_info.rrvd_info.randr_info_11->current_rate; rate = e_randr_screen_info.rrvd_info.randr_info_11->current_rate;
ss->orientation = e_randr_screen_info.rrvd_info.randr_info_11->corientation; ori = e_randr_screen_info.rrvd_info.randr_info_11->corientation;
ss->size.width = size->width;
ss->size.width_mm = size->width_mm;
ss->size.height = size->height;
ss->size.height_mm = size->height_mm;
}
else if (e_randr_screen_info.randr_version > ECORE_X_RANDR_1_1)
{
ecore_x_randr_screen_primary_output_current_size_get(e_randr_screen_info.root, &ss->size.width, &ss->size.height, &ss->size.width_mm, &ss->size.height_mm, NULL);
rate = ecore_x_randr_screen_primary_output_current_refresh_rate_get(e_randr_screen_info.root);
ori = ecore_x_randr_screen_primary_output_orientation_get(e_randr_screen_info.root);
}
ss->refresh_rate = rate;
ss->orientation = ori;
return ss; return ss;
@ -35,24 +51,31 @@ _serialized_setup_11_new_failed_free_ss:
E_Randr_Serialized_Setup_11 * E_Randr_Serialized_Setup_11 *
_serialized_setup_11_update(E_Randr_Serialized_Setup_11 *ss_11) _serialized_setup_11_update(E_Randr_Serialized_Setup_11 *ss_11)
{ {
Ecore_X_Randr_Screen_Size_MM *size;
if (ss_11) if (ss_11)
{ e_randr_11_serialized_setup_free(ss_11);
if (!(size = (Ecore_X_Randr_Screen_Size_MM *)eina_list_data_get(eina_list_nth(e_randr_screen_info.rrvd_info.randr_info_11->sizes, e_randr_screen_info.rrvd_info.randr_info_11->csize_index)))) return NULL;
if (!memcpy(&ss_11->size, size, sizeof(Ecore_X_Randr_Screen_Size_MM))) ss_11 = _serialized_setup_11_new();
goto _update_serialized_setup_11_failed_free_ss;
ss_11->refresh_rate = e_randr_screen_info.rrvd_info.randr_info_11->current_rate;
ss_11->orientation = e_randr_screen_info.rrvd_info.randr_info_11->corientation;
}
else
ss_11 = _serialized_setup_11_new();
return ss_11; return ss_11;
}
_update_serialized_setup_11_failed_free_ss: void
free(ss_11); _11_store_configuration(E_Randr_Configuration_Store_Modifier modifier __UNUSED__)
return NULL; {
if (!e_config->randr_serialized_setup)
e_config->randr_serialized_setup = e_randr_serialized_setup_new();
if (e_config->randr_serialized_setup->serialized_setup_11)
e_config->randr_serialized_setup->serialized_setup_11 = _serialized_setup_11_update(e_config->randr_serialized_setup->serialized_setup_11);
else
e_config->randr_serialized_setup->serialized_setup_11 = _serialized_setup_11_new();
}
EAPI void e_randr_11_store_configuration(E_Randr_Configuration_Store_Modifier modifier __UNUSED__)
{
_11_store_configuration(modifier);
e_config_save_queue();
} }
//Free helper functions //Free helper functions
@ -71,32 +94,42 @@ e_randr_11_serialized_setup_free(E_Randr_Serialized_Setup_11 *ss_11)
Eina_Bool Eina_Bool
_11_try_restore_configuration(void) _11_try_restore_configuration(void)
{ {
Ecore_X_Randr_Screen_Size_MM *stored_size, *size; Ecore_X_Randr_Screen_Size_MM *stored_size, *size, *sizes;
Eina_List *iter; Eina_List *iter;
int i = 0; int i = 0, nsizes;
#define SIZE_EQUAL(size) \
((stored_size->width == (size).width) \
&& (stored_size->height == (size).height) \
&& (stored_size->width_mm == (size).width_mm) \
&& (stored_size->height_mm == (size).height_mm))
if (!e_config->randr_serialized_setup->serialized_setup_11) return EINA_FALSE; if (!e_config->randr_serialized_setup->serialized_setup_11) return EINA_FALSE;
stored_size = &e_config->randr_serialized_setup->serialized_setup_11->size; stored_size = &e_config->randr_serialized_setup->serialized_setup_11->size;
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_11->sizes, iter, size) if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
{ {
if ((stored_size->width == size->width) EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_11->sizes, iter, size)
&& (stored_size->height == size->height)
&& (stored_size->width_mm == size->width_mm)
&& (stored_size->height_mm == size->height_mm))
{ {
return ecore_x_randr_screen_primary_output_size_set(e_randr_screen_info.root, i); if (SIZE_EQUAL(*size))
{
return ecore_x_randr_screen_primary_output_size_set(e_randr_screen_info.root, i);
}
i++;
} }
i++;
} }
else if (e_randr_screen_info.randr_version > ECORE_X_RANDR_1_1)
{
sizes = ecore_x_randr_screen_primary_output_sizes_get(e_randr_screen_info.root, &nsizes);
for (i = 0; i < nsizes; i++)
{
if (SIZE_EQUAL(sizes[i]))
{
free(sizes);
return ecore_x_randr_screen_primary_output_size_set(e_randr_screen_info.root, i);
}
}
}
#undef SIZE_EQUAL
return EINA_FALSE; return EINA_FALSE;
} }
void
_11_store_configuration(E_Randr_Configuration_Store_Modifier modifier)
{
if (e_config->randr_serialized_setup->serialized_setup_11)
e_config->randr_serialized_setup->serialized_setup_11 = _serialized_setup_11_update(e_config->randr_serialized_setup->serialized_setup_11);
else
e_config->randr_serialized_setup->serialized_setup_11 = _serialized_setup_11_new();
}

View File

@ -18,6 +18,12 @@ _new_serialized_setup(void)
return E_NEW(E_Randr_Serialized_Setup, 1); return E_NEW(E_Randr_Serialized_Setup, 1);
} }
EINTERN E_Randr_Serialized_Setup *
e_randr_serialized_setup_new(void)
{
return _new_serialized_setup();
}
EAPI void EAPI void
e_randr_store_configuration(E_Randr_Configuration_Store_Modifier modifier) e_randr_store_configuration(E_Randr_Configuration_Store_Modifier modifier)
{ {
@ -43,7 +49,8 @@ _try_restore_configuration(void)
EINA_SAFETY_ON_NULL_RETURN_VAL(e_config, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(e_config, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(e_config->randr_serialized_setup, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(e_config->randr_serialized_setup, EINA_FALSE);
if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1) if ((e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1) ||
((e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_1) && e_config->randr_serialized_setup->serialized_setup_11 && !e_config->randr_serialized_setup->serialized_setups_12)) // either be 1.1 or maybe we have stored a resolution using the old conf_display dialog (which uses randr 1.1)
return _11_try_restore_configuration(); return _11_try_restore_configuration();
else if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2) else if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
return _12_try_restore_configuration(); return _12_try_restore_configuration();
@ -51,6 +58,11 @@ _try_restore_configuration(void)
return EINA_FALSE; return EINA_FALSE;
} }
EINTERN void e_randr_try_restore_configuration(void)
{
return _try_restore_configuration();
}
EINTERN void e_randr_serialized_setup_free(E_Randr_Serialized_Setup *ss) EINTERN void e_randr_serialized_setup_free(E_Randr_Serialized_Setup *ss)
{ {
E_Randr_Serialized_Setup_12 *serialized_setup_12 = NULL; E_Randr_Serialized_Setup_12 *serialized_setup_12 = NULL;

View File

@ -85,14 +85,11 @@ static void
_surebox_dialog_cb_yes(void *data, E_Dialog *dia) _surebox_dialog_cb_yes(void *data, E_Dialog *dia)
{ {
SureBox *sb; SureBox *sb;
Ecore_X_Randr_Screen_Size c_size;
E_Manager *man;
sb = data; sb = data;
man = e_manager_current_get();
ecore_x_randr_screen_primary_output_current_size_get(man->root, &c_size.width, &c_size.height, NULL, NULL, NULL);
e_randr_store_configuration(E_RANDR_CONFIGURATION_STORE_ALL); if (sb->cfdata->restore)
e_randr_11_store_configuration(E_RANDR_CONFIGURATION_STORE_ALL);
_fill_data(sb->cfdata); _fill_data(sb->cfdata);
_load_resolutions(sb->cfdata); _load_resolutions(sb->cfdata);