More cleanup of the randr code ... don't include headers that are
already included via e.h. Do not need to do eina/ecore init or shutdown...handled by E already. SVN revision: 51205
This commit is contained in:
parent
ccfe4ba8d8
commit
db5ec3e8c1
|
@ -38,7 +38,6 @@
|
|||
#define E_RANDR_NO_CRTC_OUTPUT(crtc, output) (!e_randr_screen_info || (e_randr_screen_info->randr_version < ECORE_X_RANDR_1_2) || !e_randr_screen_info->rrvd_info.randr_info_12 || !e_randr_screen_info->rrvd_info.randr_info_12->crtcs || !crtc || !e_randr_screen_info->rrvd_info.randr_info_12->outputs || !output)
|
||||
#define E_RANDR_NO_CRTC_OUTPUT_MODE(crtc, output, mode) (!e_randr_screen_info || (e_randr_screen_info->randr_version < ECORE_X_RANDR_1_2) || !e_randr_screen_info->rrvd_info.randr_info_12 || !e_randr_screen_info->rrvd_info.randr_info_12->crtcs || !crtc || !e_randr_screen_info->rrvd_info.randr_info_12->outputs || !output || !e_randr_screen_info->rrvd_info.randr_info_12->modes || !mode)
|
||||
|
||||
|
||||
static Eina_Bool _e_randr_init(void);
|
||||
static void _e_randr_shutdown(void);
|
||||
static void _e_randr_event_listeners_add(void);
|
||||
|
@ -120,26 +119,29 @@ _e_randr_init(void)
|
|||
root = roots[0];
|
||||
free(roots);
|
||||
|
||||
if (!eina_init()) return EINA_FALSE;
|
||||
if (!ecore_init()) goto ecore_x_randr_init_fail_eina_shutdown;
|
||||
if (!ecore_x_randr_query() || !(e_randr_screen_info = _e_randr_screen_info_new()))
|
||||
goto ecore_x_randr_init_fail_free_screen;
|
||||
|
||||
if (!ecore_x_randr_query() || !(e_randr_screen_info = _e_randr_screen_info_new())) goto ecore_x_randr_init_fail_ecore_shutdown;
|
||||
|
||||
if ((e_randr_screen_info->randr_version = ecore_x_randr_version_get())) e_randr_screen_info->root = root;
|
||||
if ((e_randr_screen_info->randr_version = ecore_x_randr_version_get()))
|
||||
e_randr_screen_info->root = root;
|
||||
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())) goto ecore_x_randr_init_fail_ecore_shutdown;
|
||||
if (!(e_randr_screen_info->rrvd_info.randr_info_11 = _e_randr_screen_info_11_new()))
|
||||
goto ecore_x_randr_init_fail_free_screen;
|
||||
_e_randr_screen_info_11_set();
|
||||
//_e_randr_config_find_and_enable();
|
||||
return EINA_TRUE;
|
||||
}
|
||||
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())) goto ecore_x_randr_init_fail_ecore_shutdown;
|
||||
if (!(e_randr_screen_info->rrvd_info.randr_info_12 = _e_randr_screen_info_12_new()))
|
||||
goto ecore_x_randr_init_fail_free_screen;
|
||||
_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()) goto ecore_x_randr_init_fail_free_screen;
|
||||
if (!_e_randr_screen_crtcs_init()) goto ecore_x_randr_init_fail_free_screen;
|
||||
if (!_e_randr_screen_outputs_init())
|
||||
goto ecore_x_randr_init_fail_free_screen;
|
||||
if (!_e_randr_screen_crtcs_init())
|
||||
goto ecore_x_randr_init_fail_free_screen;
|
||||
_e_randr_screen_primary_output_assign(NULL);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -147,11 +149,8 @@ _e_randr_init(void)
|
|||
//FILO free stack in case we fail to allocate something/can't get hold of
|
||||
//necessary information
|
||||
ecore_x_randr_init_fail_free_screen:
|
||||
if (e_randr_screen_info)
|
||||
_e_randr_screen_info_free(e_randr_screen_info);
|
||||
ecore_x_randr_init_fail_ecore_shutdown:
|
||||
ecore_shutdown();
|
||||
ecore_x_randr_init_fail_eina_shutdown:
|
||||
eina_shutdown();
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -160,8 +159,6 @@ ecore_x_randr_init_fail_eina_shutdown:
|
|||
_e_randr_shutdown(void)
|
||||
{
|
||||
_e_randr_screen_info_free(e_randr_screen_info);
|
||||
ecore_shutdown();
|
||||
eina_shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,7 +170,8 @@ _e_randr_shutdown(void)
|
|||
_e_randr_screen_info_new(void)
|
||||
{
|
||||
E_Randr_Screen_Info *ret = NULL;
|
||||
E_Randr_Screen_Info default_info = {
|
||||
E_Randr_Screen_Info default_info =
|
||||
{
|
||||
.root = Ecore_X_Randr_Unset,
|
||||
.randr_version = Ecore_X_Randr_None,
|
||||
.rrvd_info.randr_info_11 = NULL
|
||||
|
@ -192,7 +190,7 @@ _e_randr_screen_info_new(void)
|
|||
static void
|
||||
_e_randr_screen_info_free(E_Randr_Screen_Info *screen_info)
|
||||
{
|
||||
if (!screen_info || !(screen_info->rrvd_info.randr_info_11)) return;
|
||||
if ((!screen_info) || !(screen_info->rrvd_info.randr_info_11)) return;
|
||||
switch (e_randr_screen_info->randr_version)
|
||||
{
|
||||
case ECORE_X_RANDR_1_1:
|
||||
|
@ -215,7 +213,8 @@ _e_randr_screen_info_free(E_Randr_Screen_Info *screen_info)
|
|||
_e_randr_screen_info_11_new(void)
|
||||
{
|
||||
E_Randr_Screen_Info_11 *ret = NULL;
|
||||
static const E_Randr_Screen_Info_11 default_info = {
|
||||
static const E_Randr_Screen_Info_11 default_info =
|
||||
{
|
||||
.sizes = NULL,
|
||||
.csize_index = Ecore_X_Randr_Unset,
|
||||
.corientation = Ecore_X_Randr_Unset,
|
||||
|
@ -237,7 +236,8 @@ _e_randr_screen_info_11_new(void)
|
|||
static void
|
||||
_e_randr_screen_info_11_free(E_Randr_Screen_Info_11 *screen_info)
|
||||
{
|
||||
if (!screen_info || (e_randr_screen_info->randr_version < ECORE_X_RANDR_1_1)) return;
|
||||
if (!screen_info || (e_randr_screen_info->randr_version < ECORE_X_RANDR_1_1))
|
||||
return;
|
||||
|
||||
if (screen_info->sizes)
|
||||
{
|
||||
|
@ -261,7 +261,8 @@ _e_randr_screen_info_11_free(E_Randr_Screen_Info_11 *screen_info)
|
|||
_e_randr_screen_info_12_new(void)
|
||||
{
|
||||
E_Randr_Screen_Info_12 *ret = NULL;
|
||||
static const E_Randr_Screen_Info_12 default_info = {
|
||||
static const E_Randr_Screen_Info_12 default_info =
|
||||
{
|
||||
.min_size = {Ecore_X_Randr_Unset, Ecore_X_Randr_Unset},
|
||||
.max_size = {Ecore_X_Randr_Unset, Ecore_X_Randr_Unset},
|
||||
.current_size = {Ecore_X_Randr_Unset, Ecore_X_Randr_Unset},
|
||||
|
@ -283,8 +284,15 @@ _e_randr_screen_info_12_set(E_Randr_Screen_Info_12 *screen_info)
|
|||
{
|
||||
E_RANDR_NO_12_RET(EINA_FALSE);
|
||||
|
||||
ecore_x_randr_screen_size_range_get(e_randr_screen_info->root, &screen_info->min_size.width, &screen_info->min_size.height, &screen_info->max_size.width , &screen_info->max_size.height);
|
||||
ecore_x_randr_screen_current_size_get(e_randr_screen_info->root, &screen_info->current_size.width , &screen_info->current_size.height , NULL, NULL);
|
||||
ecore_x_randr_screen_size_range_get(e_randr_screen_info->root,
|
||||
&screen_info->min_size.width,
|
||||
&screen_info->min_size.height,
|
||||
&screen_info->max_size.width ,
|
||||
&screen_info->max_size.height);
|
||||
ecore_x_randr_screen_current_size_get(e_randr_screen_info->root,
|
||||
&screen_info->current_size.width ,
|
||||
&screen_info->current_size.height ,
|
||||
NULL, NULL);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -300,7 +308,8 @@ _e_randr_screen_info_11_set(void)
|
|||
Eina_List *rates_list;
|
||||
int i, nsizes, nrates;
|
||||
|
||||
if (!(sizes = ecore_x_randr_screen_primary_output_sizes_get(e_randr_screen_info->root, &nsizes))) return EINA_FALSE;
|
||||
if (!(sizes = ecore_x_randr_screen_primary_output_sizes_get(e_randr_screen_info->root, &nsizes)))
|
||||
return EINA_FALSE;
|
||||
for (i = 0; i < nsizes; i++)
|
||||
if (!(screen_info_11->sizes = eina_list_append(screen_info_11->sizes, &sizes[i]))) goto _e_randr_screen_info_11_fill_fail_sizes;
|
||||
ecore_x_randr_screen_primary_output_current_size_get(e_randr_screen_info->root, NULL, NULL, NULL, NULL, &(screen_info_11->csize_index));
|
||||
|
@ -377,7 +386,8 @@ _e_randr_screen_info_12_free(E_Randr_Screen_Info_12 *screen_info)
|
|||
_e_randr_crtc_info_new(int nrequested)
|
||||
{
|
||||
E_Randr_Crtc_Info *ret = NULL;
|
||||
static E_Randr_Crtc_Info default_info = {
|
||||
static E_Randr_Crtc_Info default_info =
|
||||
{
|
||||
.xid = Ecore_X_Randr_Unset,
|
||||
.geometry = {Ecore_X_Randr_Unset, Ecore_X_Randr_Unset, Ecore_X_Randr_Unset, Ecore_X_Randr_Unset},
|
||||
.panning = {Ecore_X_Randr_Unset, Ecore_X_Randr_Unset, Ecore_X_Randr_Unset, Ecore_X_Randr_Unset},
|
||||
|
@ -425,7 +435,8 @@ static E_Randr_Output_Info *
|
|||
_e_randr_output_info_new(int nrequested)
|
||||
{
|
||||
E_Randr_Output_Info *ret = NULL;
|
||||
static E_Randr_Output_Info default_info = {
|
||||
static E_Randr_Output_Info default_info =
|
||||
{
|
||||
.xid = Ecore_X_Randr_Unset,
|
||||
.name = NULL,
|
||||
.crtc = NULL,
|
||||
|
@ -465,8 +476,8 @@ _e_randr_output_info_free(E_Randr_Output_Info *output_info)
|
|||
{
|
||||
Eina_List *iter;
|
||||
E_Randr_Crtc_Info *crtc_info;
|
||||
if (!output_info) return;
|
||||
|
||||
if (!output_info) return;
|
||||
if (output_info->name)
|
||||
{
|
||||
free(output_info->name);
|
||||
|
@ -562,8 +573,8 @@ _e_randr_screen_crtcs_init(void)
|
|||
{
|
||||
Ecore_X_Randr_Crtc *crtcs = NULL;
|
||||
E_Randr_Crtc_Info *crtcs_info = NULL, *crtc = NULL;
|
||||
|
||||
int i, ncrtcs;
|
||||
|
||||
if (E_RANDR_NO_12 || !(crtcs = ecore_x_randr_crtcs_get(e_randr_screen_info->root, &ncrtcs))) return EINA_FALSE;
|
||||
|
||||
if (!(crtcs_info = _e_randr_crtc_info_new(ncrtcs))) goto ecore_x_randr_screen_crtcs_init_fail_free_crtcs;
|
||||
|
@ -767,7 +778,6 @@ _e_randr_event_cb(void *data, int type, void *ev)
|
|||
output_info->connection_status = event->connection;
|
||||
output_info->subpixel_order = event->subpixel_order;
|
||||
|
||||
|
||||
if(event->connection == ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
||||
{
|
||||
if (event->crtc)
|
||||
|
@ -863,7 +873,7 @@ _e_randr_notify_crtc_mode_change(E_Randr_Crtc_Info *crtc_info)
|
|||
{
|
||||
// E_Notification *n;
|
||||
// char buff[200];
|
||||
|
||||
//
|
||||
if (crtc_info->current_mode)
|
||||
{
|
||||
// snprintf(buff, 200, "New resolution is %dx%d. Click here for further information.", crtc_info->current_mode->width, crtc_info->current_mode->height);
|
||||
|
@ -1107,7 +1117,6 @@ _e_randr_config_find_suiting_config_12(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static Ecore_X_Randr_Output *
|
||||
_e_randr_outputs_to_array(Eina_List *outputs_info)
|
||||
{
|
||||
|
@ -1734,8 +1743,8 @@ _e_randr_outputs_are_clones(E_Randr_Output_Info *output_info, Eina_List *outputs
|
|||
{
|
||||
E_Randr_Output_Info *output;
|
||||
Eina_List *iter;
|
||||
if (!outputs || !output_info)
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!outputs || !output_info) return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(output_info->clones, iter, output)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue