Introduce refetching of all RandRR info.

SVN revision: 66287
This commit is contained in:
Leif Middelschulte 2011-12-16 14:19:25 +00:00
parent ecdd149227
commit f5bf360e9a
2 changed files with 32 additions and 17 deletions

View File

@ -57,6 +57,7 @@
static Eina_Bool _e_randr_init(void); static Eina_Bool _e_randr_init(void);
static void _e_randr_shutdown(void); static void _e_randr_shutdown(void);
static Eina_Bool _e_randr_screen_info_refresh(void);
static void _e_randr_event_listeners_add(void); static void _e_randr_event_listeners_add(void);
static void _e_randr_event_listeners_remove(void); static void _e_randr_event_listeners_remove(void);
static Eina_Bool _e_randr_event_cb(void *data, int type, void *e); static Eina_Bool _e_randr_event_cb(void *data, int type, void *e);
@ -122,13 +123,36 @@ e_randr_shutdown(void)
return 1; return 1;
} }
EAPI Eina_Bool
e_randr_screen_info_refresh(void)
{
return _e_randr_screen_info_refresh();
}
static Eina_Bool static Eina_Bool
_e_randr_init(void) _e_randr_init(void)
{
EINA_SAFETY_ON_FALSE_RETURN_VAL(e_randr_screen_info_refresh(), EINA_FALSE);
_e_randr_event_listeners_add();
return EINA_TRUE;
}
static void
_e_randr_shutdown(void)
{
_e_randr_screen_info_free(e_randr_screen_info);
}
static Eina_Bool
_e_randr_screen_info_refresh(void)
{ {
int n; int n;
Ecore_X_Window *roots; Ecore_X_Window *roots;
Ecore_X_Window root; Ecore_X_Window root;
if (e_randr_screen_info)
_e_randr_screen_info_free(e_randr_screen_info);
if (!(roots = ecore_x_window_root_list(&n))) return EINA_FALSE; if (!(roots = ecore_x_window_root_list(&n))) return EINA_FALSE;
/* first (and only) root window */ /* first (and only) root window */
root = roots[0]; root = roots[0];
@ -136,46 +160,36 @@ _e_randr_init(void)
if ((!ecore_x_randr_query()) || if ((!ecore_x_randr_query()) ||
!(e_randr_screen_info = _e_randr_screen_info_new())) !(e_randr_screen_info = _e_randr_screen_info_new()))
goto ecore_x_randr_init_fail_free_screen; goto e_randr_screen_info_refresh_fail_free_screen;
if ((e_randr_screen_info->randr_version = ecore_x_randr_version_get())) if ((e_randr_screen_info->randr_version = ecore_x_randr_version_get()))
e_randr_screen_info->root = root; e_randr_screen_info->root = root;
if (e_randr_screen_info->randr_version == ECORE_X_RANDR_1_1) if (e_randr_screen_info->randr_version == ECORE_X_RANDR_1_1)
{ {
if (!(e_randr_screen_info->rrvd_info.randr_info_11 = _e_randr_screen_info_11_new())) if (!(e_randr_screen_info->rrvd_info.randr_info_11 = _e_randr_screen_info_11_new()))
goto ecore_x_randr_init_fail_free_screen; goto e_randr_screen_info_refresh_fail_free_screen;
_e_randr_screen_info_11_set(); _e_randr_screen_info_11_set();
} }
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)
{ {
if (!(e_randr_screen_info->rrvd_info.randr_info_12 = _e_randr_screen_info_12_new())) if (!(e_randr_screen_info->rrvd_info.randr_info_12 = _e_randr_screen_info_12_new()))
goto ecore_x_randr_init_fail_free_screen; goto e_randr_screen_info_refresh_fail_free_screen;
_e_randr_screen_info_12_set(e_randr_screen_info->rrvd_info.randr_info_12); _e_randr_screen_info_12_set(e_randr_screen_info->rrvd_info.randr_info_12);
_e_randr_event_listeners_add(); if (!_e_randr_screen_outputs_init()
if (!_e_randr_screen_outputs_init()) || !_e_randr_screen_crtcs_init())
goto ecore_x_randr_init_fail_free_screen; goto e_randr_screen_info_refresh_fail_free_screen;
if (!_e_randr_screen_crtcs_init())
goto ecore_x_randr_init_fail_free_screen;
_e_randr_screen_primary_output_assign(NULL); _e_randr_screen_primary_output_assign(NULL);
} }
return EINA_TRUE; return EINA_TRUE;
//FILO free stack in case we fail to allocate something/can't get hold of e_randr_screen_info_refresh_fail_free_screen:
//necessary information
ecore_x_randr_init_fail_free_screen:
if (e_randr_screen_info) if (e_randr_screen_info)
_e_randr_screen_info_free(e_randr_screen_info); _e_randr_screen_info_free(e_randr_screen_info);
return EINA_FALSE; return EINA_FALSE;
} }
static void
_e_randr_shutdown(void)
{
_e_randr_screen_info_free(e_randr_screen_info);
}
/** /**
* @param nrequeste * @param nrequeste
* @return Instance of E_Randr_Screen_Info or if memory couldn't be * @return Instance of E_Randr_Screen_Info or if memory couldn't be

View File

@ -183,6 +183,7 @@ 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);
EINTERN int e_randr_shutdown(void); EINTERN int e_randr_shutdown(void);
EAPI extern E_Randr_Screen_Info *e_randr_screen_info; EAPI extern E_Randr_Screen_Info *e_randr_screen_info;