forked from enlightenment/enlightenment
Remove All Old Randr Code.
Signed-off-by: Christopher Michael <cp.michael@samsung.com> SVN revision: 84107
This commit is contained in:
parent
339e4ad906
commit
a6a159be63
|
@ -1,158 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:expandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "e.h"
|
||||
#include "e_randr_private.h"
|
||||
|
||||
#define ECORE_X_RANDR_1_1 ((1 << 16) | 1)
|
||||
#define ECORE_X_RANDR_1_2 ((1 << 16) | 2)
|
||||
#define ECORE_X_RANDR_1_3 ((1 << 16) | 3)
|
||||
|
||||
#define Ecore_X_Randr_None 0
|
||||
#define Ecore_X_Randr_Unset -1
|
||||
|
||||
/*
|
||||
* Save mechanism:
|
||||
* Single monitor:
|
||||
* - Save monitor using the resolution
|
||||
*
|
||||
* Multiple monitors:
|
||||
* - Use the EDID information to make sure we restore the right monitor.
|
||||
* - Depend on the sequence in which the XIDs are returned provided by the X
|
||||
* server. This means that relative indexes are used for setup store/restore.
|
||||
*
|
||||
*/
|
||||
|
||||
static Eina_Bool _init(void);
|
||||
static void _shutdown(void);
|
||||
static Eina_Bool _screen_info_refresh(void);
|
||||
static Eina_Bool _e_event_config_loaded_cb(void *data, int type, void *e);
|
||||
static void _event_listeners_add(void);
|
||||
static void _event_listeners_remove(void);
|
||||
|
||||
EAPI E_Randr_Screen_Info e_randr_screen_info;
|
||||
static Eina_List *_event_handlers = NULL;
|
||||
|
||||
EAPI Eina_Bool
|
||||
e_randr_screen_info_refresh(void)
|
||||
{
|
||||
return _screen_info_refresh();
|
||||
}
|
||||
|
||||
EINTERN Eina_Bool
|
||||
e_randr_init(void)
|
||||
{
|
||||
return _init();
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_randr_shutdown(void)
|
||||
{
|
||||
_shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_init(void)
|
||||
{
|
||||
if (!e_randr_screen_info_refresh())
|
||||
return EINA_FALSE;
|
||||
_event_listeners_add();
|
||||
|
||||
if (e_config->randr_serialized_setup)
|
||||
{
|
||||
e_randr_try_restore_configuration();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
|
||||
{
|
||||
_11_screen_info_free(e_randr_screen_info.rrvd_info.randr_info_11);
|
||||
e_randr_screen_info.rrvd_info.randr_info_11 = NULL;
|
||||
}
|
||||
else if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
|
||||
{
|
||||
_12_screen_info_free(e_randr_screen_info.rrvd_info.randr_info_12);
|
||||
e_randr_screen_info.rrvd_info.randr_info_12 = NULL;
|
||||
}
|
||||
_event_listeners_remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EINA_TRUE if info could be refreshed, else EINA_FALSE
|
||||
*/
|
||||
static Eina_Bool
|
||||
_screen_info_refresh(void)
|
||||
{
|
||||
Ecore_X_Window *roots;
|
||||
Ecore_X_Window root;
|
||||
int n;
|
||||
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(ecore_x_randr_query(), EINA_FALSE);
|
||||
|
||||
if (!(roots = ecore_x_window_root_list(&n))) return EINA_FALSE;
|
||||
/* first (and only) root window */
|
||||
root = roots[0];
|
||||
free(roots);
|
||||
|
||||
e_randr_screen_info.randr_version = ecore_x_randr_version_get();
|
||||
e_randr_screen_info.root = root;
|
||||
e_randr_screen_info.rrvd_info.randr_info_11 = NULL;
|
||||
|
||||
// Value set/retrieval helper functions
|
||||
if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
|
||||
{
|
||||
return _11_screen_info_refresh();
|
||||
}
|
||||
else if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
|
||||
{
|
||||
return _12_screen_info_refresh();
|
||||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_event_config_loaded_cb(void *data __UNUSED__, int type, void *ev __UNUSED__)
|
||||
{
|
||||
if (type != E_EVENT_CONFIG_LOADED) return EINA_TRUE;
|
||||
|
||||
return e_randr_try_restore_configuration();
|
||||
}
|
||||
|
||||
static void
|
||||
_event_listeners_add(void)
|
||||
{
|
||||
_event_handlers = eina_list_append(_event_handlers, ecore_event_handler_add(E_EVENT_CONFIG_LOADED, _e_event_config_loaded_cb, NULL));
|
||||
|
||||
if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
|
||||
{
|
||||
_12_event_listeners_add();
|
||||
}
|
||||
}
|
||||
|
||||
// "Free" helper functions
|
||||
static void
|
||||
_event_listeners_remove(void)
|
||||
{
|
||||
Ecore_Event_Handler *_event_handler = NULL;
|
||||
EINA_LIST_FREE(_event_handlers, _event_handler)
|
||||
ecore_event_handler_del(_event_handler);
|
||||
|
||||
if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
|
||||
{
|
||||
_12_event_listeners_remove();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Randr_Crtc_Info E_Randr_Crtc_Info;
|
||||
typedef struct _E_Randr_Edid_Hash E_Randr_Edid_Hash;
|
||||
typedef struct _E_Randr_Monitor_Info E_Randr_Monitor_Info;
|
||||
typedef struct _E_Randr_Output_Info E_Randr_Output_Info;
|
||||
typedef struct _E_Randr_Screen_Info_11 E_Randr_Screen_Info_11;
|
||||
typedef struct _E_Randr_Screen_Info_12 E_Randr_Screen_Info_12;
|
||||
typedef union _E_Randr_Screen_RRVD_Info E_Randr_Screen_RRVD_Info;
|
||||
typedef struct _E_Randr_Screen_Info E_Randr_Screen_Info;
|
||||
typedef struct _E_Randr_Serialized_Output_Policy E_Randr_Serialized_Output_Policy;
|
||||
typedef struct _E_Randr_Serialized_Output E_Randr_Serialized_Output;
|
||||
typedef struct _E_Randr_Serialized_Crtc E_Randr_Serialized_Crtc;
|
||||
typedef struct _E_Randr_Serialized_Setup_11 E_Randr_Serialized_Setup_11;
|
||||
typedef struct _E_Randr_Serialized_Setup_12 E_Randr_Serialized_Setup_12;
|
||||
typedef struct _E_Randr_Serialized_Setup E_Randr_Serialized_Setup;
|
||||
|
||||
typedef enum _E_Randr_Configuration_Store_Modifier
|
||||
{
|
||||
E_RANDR_CONFIGURATION_STORE_POLICIES = (1 << 0),
|
||||
E_RANDR_CONFIGURATION_STORE_RESOLUTIONS = (1 << 1),
|
||||
E_RANDR_CONFIGURATION_STORE_ARRANGEMENT = (1 << 2),
|
||||
E_RANDR_CONFIGURATION_STORE_ORIENTATIONS = (1 << 3),
|
||||
E_RANDR_CONFIGURATION_STORE_ALL = (
|
||||
E_RANDR_CONFIGURATION_STORE_POLICIES
|
||||
| E_RANDR_CONFIGURATION_STORE_RESOLUTIONS
|
||||
| E_RANDR_CONFIGURATION_STORE_ARRANGEMENT
|
||||
| E_RANDR_CONFIGURATION_STORE_ORIENTATIONS)
|
||||
} E_Randr_Configuration_Store_Modifier;
|
||||
|
||||
#else
|
||||
#ifndef E_RANDR_H
|
||||
#define E_RANDR_H
|
||||
|
||||
struct _E_Randr_Crtc_Info
|
||||
{
|
||||
Ecore_X_Randr_Crtc xid;
|
||||
Eina_Rectangle geometry;
|
||||
Eina_Rectangle panning;
|
||||
Eina_Rectangle tracking;
|
||||
Eina_Rectangle border;
|
||||
Ecore_X_Randr_Orientation current_orientation;
|
||||
Ecore_X_Randr_Orientation orientations;
|
||||
Ecore_X_Randr_Crtc_Gamma **gamma_ramps;
|
||||
int gamma_ramp_size;
|
||||
Eina_List *outputs;
|
||||
Eina_List *possible_outputs;
|
||||
Eina_List *outputs_common_modes;
|
||||
Ecore_X_Randr_Mode_Info *current_mode;
|
||||
};
|
||||
|
||||
struct _E_Randr_Edid_Hash
|
||||
{
|
||||
int hash;
|
||||
};
|
||||
|
||||
struct _E_Randr_Monitor_Info
|
||||
{
|
||||
Eina_List *modes;
|
||||
Eina_List *preferred_modes;
|
||||
Ecore_X_Randr_Screen_Size size_mm;
|
||||
unsigned char *edid;
|
||||
unsigned long edid_length;
|
||||
E_Randr_Edid_Hash edid_hash;
|
||||
int max_backlight;
|
||||
double backlight_level;
|
||||
};
|
||||
|
||||
struct _E_Randr_Output_Info
|
||||
{
|
||||
Ecore_X_Randr_Output xid;
|
||||
Eina_Stringshare *name;
|
||||
int name_length;
|
||||
E_Randr_Crtc_Info *crtc;
|
||||
Eina_List *wired_clones;
|
||||
Ecore_X_Randr_Signal_Format signalformats;
|
||||
Ecore_X_Randr_Signal_Format signalformat;
|
||||
int connector_number;
|
||||
Ecore_X_Randr_Connector_Type connector_type;
|
||||
Ecore_X_Randr_Connection_Status connection_status;
|
||||
Ecore_X_Randr_Output_Policy policy;
|
||||
Eina_List *possible_crtcs;
|
||||
Eina_List *compatibility_list;
|
||||
Ecore_X_Render_Subpixel_Order subpixel_order;
|
||||
/*
|
||||
* Attached Monitor specific:
|
||||
*/
|
||||
E_Randr_Monitor_Info *monitor;
|
||||
};
|
||||
|
||||
struct _E_Randr_Screen_Info_11
|
||||
{
|
||||
Ecore_X_Randr_Screen_Size_MM *sizes;
|
||||
int nsizes;
|
||||
int csize_index;
|
||||
Ecore_X_Randr_Orientation corientation;
|
||||
Ecore_X_Randr_Orientation orientations;
|
||||
Ecore_X_Randr_Refresh_Rate **rates;
|
||||
int *nrates; // size is nsizes
|
||||
Ecore_X_Randr_Refresh_Rate current_rate;
|
||||
};
|
||||
|
||||
struct _E_Randr_Screen_Info_12
|
||||
{
|
||||
Ecore_X_Randr_Screen_Size min_size;
|
||||
Ecore_X_Randr_Screen_Size max_size;
|
||||
Ecore_X_Randr_Screen_Size current_size;
|
||||
Eina_List *modes;
|
||||
Eina_List *crtcs;
|
||||
Eina_List *outputs;
|
||||
E_Randr_Output_Info *primary_output;
|
||||
Ecore_X_Randr_Relative_Alignment alignment;
|
||||
};
|
||||
|
||||
//RRVD == RandR(R) Version Depended
|
||||
union _E_Randr_Screen_RRVD_Info
|
||||
{
|
||||
E_Randr_Screen_Info_11 *randr_info_11;
|
||||
E_Randr_Screen_Info_12 *randr_info_12;
|
||||
};
|
||||
|
||||
struct _E_Randr_Screen_Info
|
||||
{
|
||||
Ecore_X_Window root;
|
||||
int randr_version;
|
||||
E_Randr_Screen_RRVD_Info rrvd_info;
|
||||
};
|
||||
|
||||
//Following stuff is just for configuration purposes
|
||||
|
||||
struct _E_Randr_Serialized_Output_Policy
|
||||
{
|
||||
Eina_Stringshare *name;
|
||||
Ecore_X_Randr_Output_Policy policy;
|
||||
};
|
||||
|
||||
struct _E_Randr_Serialized_Output
|
||||
{
|
||||
Eina_Stringshare *name;
|
||||
double backlight_level;
|
||||
};
|
||||
|
||||
struct _E_Randr_Serialized_Crtc
|
||||
{
|
||||
int index;
|
||||
//List of E_Randr_Serialized_Output objects that were used on the same output
|
||||
Eina_List *outputs;
|
||||
Evas_Coord_Point pos;
|
||||
Ecore_X_Randr_Orientation orientation;
|
||||
//the serialized mode_info
|
||||
Ecore_X_Randr_Mode_Info *mode_info;
|
||||
};
|
||||
|
||||
struct _E_Randr_Serialized_Setup_12
|
||||
{
|
||||
double timestamp;
|
||||
//List of E_Randr_Serialized_Crtc objects
|
||||
Eina_List *crtcs;
|
||||
/*
|
||||
* List of E_Randr_Edid_Hash elements of all connected monitors
|
||||
*/
|
||||
Eina_List *edid_hashes;
|
||||
};
|
||||
|
||||
struct _E_Randr_Serialized_Setup_11
|
||||
{
|
||||
Ecore_X_Randr_Screen_Size_MM size;
|
||||
Ecore_X_Randr_Refresh_Rate refresh_rate;
|
||||
Ecore_X_Randr_Orientation orientation;
|
||||
};
|
||||
|
||||
struct _E_Randr_Serialized_Setup
|
||||
{
|
||||
E_Randr_Serialized_Setup_11 *serialized_setup_11;
|
||||
//List of E_Randr_Serialized_Setup_12 objects
|
||||
Eina_List *serialized_setups_12;
|
||||
//List of E_Randr_Serialized_Output_Policy objects
|
||||
Eina_List *outputs_policies;
|
||||
};
|
||||
|
||||
EAPI Eina_Bool e_randr_screen_info_refresh(void);
|
||||
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);
|
||||
EAPI Eina_Bool e_randr_try_restore_configuration(void);
|
||||
|
||||
EINTERN Eina_Bool e_randr_init(void);
|
||||
EINTERN int e_randr_shutdown(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_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_output_policy_free(E_Randr_Serialized_Output_Policy *policy);
|
||||
|
||||
EINTERN Eina_Bool e_randr_12_try_enable_output(E_Randr_Output_Info *output_info, Ecore_X_Randr_Output_Policy policy, Eina_Bool force);
|
||||
EINTERN void e_randr_12_ask_dialog_new(E_Randr_Output_Info *oi);
|
||||
|
||||
EAPI extern E_Randr_Screen_Info e_randr_screen_info;
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,89 +0,0 @@
|
|||
#include "e_randr_private.h"
|
||||
#include "e_randr.h"
|
||||
|
||||
//New helper functions
|
||||
/**
|
||||
* @brief allocate and initialize a new E_Randr_Screen_Info_11 element
|
||||
* @return E_Randr_Screen_Info_11 elements or in case it could
|
||||
* not be created and properly initialized, NULL
|
||||
*/
|
||||
E_Randr_Screen_Info_11 *
|
||||
_11_screen_info_new(void)
|
||||
{
|
||||
E_Randr_Screen_Info_11 *randr_info_11 = NULL;
|
||||
Ecore_X_Randr_Screen_Size_MM *sizes = NULL;
|
||||
Ecore_X_Randr_Refresh_Rate *rates = NULL;
|
||||
int i, nsizes;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_11_NO, NULL);
|
||||
|
||||
randr_info_11 = E_NEW(E_Randr_Screen_Info_11, 1);
|
||||
|
||||
randr_info_11->csize_index = Ecore_X_Randr_Unset;
|
||||
randr_info_11->corientation = Ecore_X_Randr_Unset;
|
||||
randr_info_11->orientations = Ecore_X_Randr_Unset;
|
||||
randr_info_11->current_rate = Ecore_X_Randr_Unset;
|
||||
|
||||
if (!(sizes = ecore_x_randr_screen_primary_output_sizes_get(e_randr_screen_info.root, &nsizes)))
|
||||
goto _info_11_new_fail;
|
||||
randr_info_11->sizes = sizes, randr_info_11->nsizes = nsizes;
|
||||
ecore_x_randr_screen_primary_output_current_size_get(e_randr_screen_info.root, NULL, NULL, NULL, NULL, &(randr_info_11->csize_index));
|
||||
randr_info_11->corientation = ecore_x_randr_screen_primary_output_orientation_get(e_randr_screen_info.root);
|
||||
randr_info_11->orientations = ecore_x_randr_screen_primary_output_orientations_get(e_randr_screen_info.root);
|
||||
randr_info_11->rates = malloc(sizeof(Ecore_X_Randr_Refresh_Rate *) * nsizes);
|
||||
randr_info_11->nrates = malloc(sizeof(int) * nsizes);
|
||||
for (i = 0; i < nsizes; i++)
|
||||
{
|
||||
if (!(rates = ecore_x_randr_screen_primary_output_refresh_rates_get(e_randr_screen_info.root, i, &randr_info_11->nrates[i])))
|
||||
goto _info_11_new_fail;
|
||||
randr_info_11->rates[i] = rates;
|
||||
}
|
||||
randr_info_11->current_rate = ecore_x_randr_screen_primary_output_current_refresh_rate_get(e_randr_screen_info.root);
|
||||
|
||||
return randr_info_11;
|
||||
|
||||
_info_11_new_fail:
|
||||
if (randr_info_11)
|
||||
{
|
||||
free(randr_info_11->rates);
|
||||
free(randr_info_11->nrates);
|
||||
}
|
||||
free(sizes);
|
||||
free(randr_info_11);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Free helper functions
|
||||
/**
|
||||
* @param screen_info the screen info to be freed.
|
||||
*/
|
||||
void
|
||||
_11_screen_info_free(E_Randr_Screen_Info_11 *screen_info)
|
||||
{
|
||||
int x;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(screen_info);
|
||||
|
||||
for (x = 0; x < screen_info->nsizes; x++)
|
||||
free(screen_info->rates[x]);
|
||||
free(screen_info->sizes);
|
||||
free(screen_info);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Init. and Shutdown code
|
||||
*
|
||||
*****************************************************************
|
||||
*/
|
||||
Eina_Bool
|
||||
_11_screen_info_refresh(void)
|
||||
{
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_11_NO, EINA_FALSE);
|
||||
|
||||
_11_screen_info_free(e_randr_screen_info.rrvd_info.randr_info_11);
|
||||
e_randr_screen_info.rrvd_info.randr_info_11 = _11_screen_info_new();
|
||||
|
||||
return e_randr_screen_info.rrvd_info.randr_info_11 != NULL;
|
||||
}
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
#include "e_randr_private.h"
|
||||
#include "e_randr.h"
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* Storage/Restorage of setups
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
//New helper functions
|
||||
|
||||
E_Randr_Serialized_Setup_11 *
|
||||
_serialized_setup_11_new(void)
|
||||
{
|
||||
E_Randr_Serialized_Setup_11 *ss;
|
||||
Ecore_X_Randr_Screen_Size_MM *size;
|
||||
Ecore_X_Randr_Orientation ori = ECORE_X_RANDR_ORIENTATION_ROT_0;
|
||||
Ecore_X_Randr_Refresh_Rate rate = 0;
|
||||
|
||||
ss = malloc(sizeof(*ss));
|
||||
|
||||
if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
|
||||
{
|
||||
if (e_randr_screen_info.rrvd_info.randr_info_11->csize_index >= e_randr_screen_info.rrvd_info.randr_info_11->nsizes) goto _serialized_setup_11_new_failed_free_ss;
|
||||
size = e_randr_screen_info.rrvd_info.randr_info_11->sizes + e_randr_screen_info.rrvd_info.randr_info_11->csize_index;
|
||||
if (!size) goto _serialized_setup_11_new_failed_free_ss; ;
|
||||
rate = e_randr_screen_info.rrvd_info.randr_info_11->current_rate;
|
||||
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;
|
||||
|
||||
_serialized_setup_11_new_failed_free_ss:
|
||||
free(ss);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Update/value set helper functions
|
||||
E_Randr_Serialized_Setup_11 *
|
||||
_serialized_setup_11_update(E_Randr_Serialized_Setup_11 *ss_11)
|
||||
{
|
||||
if (ss_11)
|
||||
e_randr_11_serialized_setup_free(ss_11);
|
||||
|
||||
ss_11 = _serialized_setup_11_new();
|
||||
|
||||
return ss_11;
|
||||
}
|
||||
|
||||
void
|
||||
_11_store_configuration(E_Randr_Configuration_Store_Modifier modifier __UNUSED__)
|
||||
{
|
||||
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
|
||||
void
|
||||
_e_randr_serialized_setup_11_free(E_Randr_Serialized_Setup_11 *ss11)
|
||||
{
|
||||
free(ss11);
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
e_randr_11_serialized_setup_free(E_Randr_Serialized_Setup_11 *ss_11)
|
||||
{
|
||||
_e_randr_serialized_setup_11_free(ss_11);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_11_try_restore_configuration(void)
|
||||
{
|
||||
Ecore_X_Randr_Screen_Size_MM *stored_size, *sizes = NULL;
|
||||
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;
|
||||
stored_size = &e_config->randr_serialized_setup->serialized_setup_11->size;
|
||||
if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
|
||||
{
|
||||
int x;
|
||||
for (x = 0; x < e_randr_screen_info.rrvd_info.randr_info_11->nsizes; x++)
|
||||
{
|
||||
if (SIZE_EQUAL(e_randr_screen_info.rrvd_info.randr_info_11->sizes[x]))
|
||||
{
|
||||
return ecore_x_randr_screen_primary_output_size_set(e_randr_screen_info.root, 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
|
||||
|
||||
free(sizes);
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
|
@ -1,823 +0,0 @@
|
|||
#include "e.h"
|
||||
#include "e_randr_private.h"
|
||||
|
||||
#define POLLINTERVAL 128
|
||||
|
||||
// Set functions for the global e_randr_screen_info struct
|
||||
static void _screen_primary_output_assign(E_Randr_Output_Info *removed);
|
||||
|
||||
// Init helper functions
|
||||
static void _outputs_init(void);
|
||||
static void _crtcs_init(void);
|
||||
static Eina_Bool _structs_init(void);
|
||||
|
||||
// Retrieval helper functions
|
||||
static Ecore_X_Randr_Mode_Info *_mode_geo_identical_find(Eina_List *modes, Ecore_X_Randr_Mode_Info *mode);
|
||||
|
||||
// Event helper functions
|
||||
static Eina_Bool _x_poll_cb(void *data __UNUSED__);
|
||||
static Eina_Bool _crtc_change_event_cb(void *data, int type, void *e);
|
||||
static Eina_Bool _output_change_event_cb(void *data, int type, void *e);
|
||||
static Eina_Bool _output_property_change_event_cb(void *data, int type, void *e);
|
||||
|
||||
static Ecore_Poller *poller = NULL;
|
||||
static Eina_List *_event_handlers = NULL;
|
||||
static const char *_CONNECTION_STATES_STRINGS[] = {"CONNECTED", "DISCONNECTED", "UNKNOWN"};
|
||||
static const char *_POLICIES_STRINGS[] = {"ABOVE", "RIGHT", "BELOW", "LEFT", "CLONE", "NONE"};
|
||||
|
||||
//"New" helper functions
|
||||
/**
|
||||
* @return array of E_Randr_Screen_Info_12 elements, or in case not all could
|
||||
* be created or parameter 'nrequested'==0, NULL
|
||||
*/
|
||||
static E_Randr_Screen_Info_12 *
|
||||
_screen_info_12_new(void)
|
||||
{
|
||||
E_Randr_Screen_Info_12 *randr_info_12 = NULL;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((e_randr_screen_info.randr_version < ECORE_X_RANDR_1_2), NULL);
|
||||
|
||||
randr_info_12 = E_NEW(E_Randr_Screen_Info_12, 1);
|
||||
|
||||
randr_info_12->min_size.width = Ecore_X_Randr_Unset;
|
||||
randr_info_12->min_size.height = Ecore_X_Randr_Unset;
|
||||
randr_info_12->max_size.width = Ecore_X_Randr_Unset;
|
||||
randr_info_12->max_size.height = Ecore_X_Randr_Unset;
|
||||
randr_info_12->current_size.width = Ecore_X_Randr_Unset;
|
||||
randr_info_12->current_size.height = Ecore_X_Randr_Unset;
|
||||
randr_info_12->crtcs = NULL;
|
||||
randr_info_12->outputs = NULL;
|
||||
randr_info_12->modes = NULL;
|
||||
randr_info_12->primary_output = NULL;
|
||||
randr_info_12->alignment = ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE;
|
||||
|
||||
ecore_x_randr_screen_size_range_get(e_randr_screen_info.root,
|
||||
&randr_info_12->min_size.width,
|
||||
&randr_info_12->min_size.height,
|
||||
&randr_info_12->max_size.width,
|
||||
&randr_info_12->max_size.height);
|
||||
ecore_x_randr_screen_current_size_get(e_randr_screen_info.root,
|
||||
&randr_info_12->current_size.width,
|
||||
&randr_info_12->current_size.height,
|
||||
NULL, NULL);
|
||||
|
||||
return randr_info_12;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_structs_init(void)
|
||||
{
|
||||
//Output stuff
|
||||
Ecore_X_Randr_Output *outputs;
|
||||
E_Randr_Output_Info *output_info = NULL;
|
||||
int noutputs = 0;
|
||||
//CRTC stuff
|
||||
Ecore_X_Randr_Crtc *crtcs = NULL;
|
||||
E_Randr_Crtc_Info *crtc_info = NULL;
|
||||
int ncrtcs = 0;
|
||||
//Modes stuff
|
||||
Ecore_X_Randr_Mode_Info **modes = NULL;
|
||||
int nmodes = 0;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, EINA_FALSE);
|
||||
|
||||
outputs = ecore_x_randr_outputs_get(e_randr_screen_info.root, &noutputs);
|
||||
if (noutputs == 0) return EINA_FALSE;
|
||||
|
||||
while (--noutputs >= 0)
|
||||
{
|
||||
output_info = _output_info_new(outputs[noutputs]);
|
||||
if (output_info)
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->outputs = eina_list_append(e_randr_screen_info.rrvd_info.randr_info_12->outputs, output_info);
|
||||
}
|
||||
free(outputs);
|
||||
|
||||
crtcs = ecore_x_randr_crtcs_get(e_randr_screen_info.root, &ncrtcs);
|
||||
if (ncrtcs == 0) return EINA_FALSE;
|
||||
|
||||
while (--ncrtcs >= 0)
|
||||
{
|
||||
crtc_info = _crtc_info_new(crtcs[ncrtcs]);
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->crtcs = eina_list_append(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, crtc_info);
|
||||
}
|
||||
free(crtcs);
|
||||
|
||||
modes = ecore_x_randr_modes_info_get(e_randr_screen_info.root, &nmodes);
|
||||
if (nmodes == 0) return EINA_FALSE;
|
||||
|
||||
while (--nmodes >= 0)
|
||||
{
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->modes = eina_list_append(e_randr_screen_info.rrvd_info.randr_info_12->modes, modes[nmodes]);
|
||||
}
|
||||
|
||||
free(modes);
|
||||
_outputs_init();
|
||||
_crtcs_init();
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
//Set value / retrieval helper functions
|
||||
|
||||
static void
|
||||
_crtcs_init(void)
|
||||
{
|
||||
E_Randr_Crtc_Info *crtc = NULL;
|
||||
Eina_List *iter;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN(E_RANDR_12_NO);
|
||||
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, crtc)
|
||||
_crtc_refs_set(crtc);
|
||||
}
|
||||
|
||||
static void
|
||||
_outputs_init(void)
|
||||
{
|
||||
E_Randr_Output_Info *output = NULL;
|
||||
Eina_List *iter;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN(E_RANDR_12_NO);
|
||||
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->outputs, iter, output)
|
||||
{
|
||||
_output_refs_set(output);
|
||||
if (output->connection_status == ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
||||
{
|
||||
_monitor_info_free(output->monitor);
|
||||
output->monitor = _monitor_info_new(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_screen_primary_output_assign(E_Randr_Output_Info *removed)
|
||||
{
|
||||
Eina_List *iter;
|
||||
E_Randr_Output_Info *primary_output = NULL, *output_info;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN(E_RANDR_12_NO_OUTPUTS);
|
||||
|
||||
if (e_randr_screen_info.rrvd_info.randr_info_12->primary_output && (removed != e_randr_screen_info.rrvd_info.randr_info_12->primary_output)) return;
|
||||
if (!(primary_output = _12_screen_info_output_info_get(ecore_x_randr_primary_output_get(e_randr_screen_info.root))))
|
||||
{
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->outputs, iter, output_info)
|
||||
{
|
||||
if (!output_info || (output_info->connection_status != ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED) || !output_info->crtc || !output_info->crtc->current_mode) continue;
|
||||
primary_output = output_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->primary_output = primary_output;
|
||||
}
|
||||
|
||||
//"Free" helper functions
|
||||
|
||||
/**
|
||||
* @param screen_info the screen info to be freed.
|
||||
*/
|
||||
void
|
||||
_12_screen_info_free(E_Randr_Screen_Info_12 *screen_info)
|
||||
{
|
||||
Ecore_X_Randr_Mode_Info *mode_info;
|
||||
E_Randr_Crtc_Info *crtc_info;
|
||||
E_Randr_Output_Info *output_info;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(screen_info);
|
||||
EINA_SAFETY_ON_TRUE_RETURN(E_RANDR_12_NO);
|
||||
|
||||
EINA_LIST_FREE(screen_info->crtcs, crtc_info)
|
||||
_crtc_info_free(crtc_info);
|
||||
|
||||
EINA_LIST_FREE(screen_info->outputs, output_info)
|
||||
_output_info_free(output_info);
|
||||
|
||||
EINA_LIST_FREE(screen_info->modes, mode_info)
|
||||
ecore_x_randr_mode_info_free(mode_info);
|
||||
|
||||
free(screen_info);
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************
|
||||
*
|
||||
* Getter functions for e_randr_screen_info struct
|
||||
*
|
||||
* ********************************************
|
||||
*/
|
||||
Ecore_X_Randr_Mode_Info *
|
||||
_12_screen_info_mode_info_get(const Ecore_X_Randr_Mode mode)
|
||||
{
|
||||
Eina_List *iter;
|
||||
Ecore_X_Randr_Mode_Info *mode_info;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO_MODE(mode), NULL);
|
||||
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->modes, iter, mode_info)
|
||||
{
|
||||
if (mode_info && (mode_info->xid == mode)) return mode_info;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
E_Randr_Output_Info *
|
||||
_12_screen_info_output_info_get(const Ecore_X_Randr_Output output)
|
||||
{
|
||||
Eina_List *iter;
|
||||
E_Randr_Output_Info *output_info;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO_OUTPUTS, NULL);
|
||||
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->outputs, iter, output_info)
|
||||
{
|
||||
if (output_info && (output_info->xid == output)) return output_info;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
E_Randr_Crtc_Info *
|
||||
_12_screen_info_crtc_info_get(const Ecore_X_Randr_Crtc crtc)
|
||||
{
|
||||
Eina_List *iter;
|
||||
E_Randr_Crtc_Info *crtc_info;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO_CRTCS, NULL);
|
||||
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, crtc_info)
|
||||
{
|
||||
if (crtc_info && (crtc_info->xid == crtc)) return crtc_info;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_12_screen_info_edid_is_available(const E_Randr_Edid_Hash *hash)
|
||||
{
|
||||
Eina_List *iter;
|
||||
E_Randr_Output_Info *output_info;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO_OUTPUTS, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->outputs, iter, output_info)
|
||||
{
|
||||
if (!output_info || !output_info->monitor)
|
||||
continue;
|
||||
if (output_info->monitor->edid_hash.hash == hash->hash)
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns a mode within a given list of modes that is gemetrically identical.
|
||||
* If none is found, NULL is returned.
|
||||
*/
|
||||
static Ecore_X_Randr_Mode_Info *
|
||||
_mode_geo_identical_find(Eina_List *modes, Ecore_X_Randr_Mode_Info *mode)
|
||||
{
|
||||
Eina_List *iter;
|
||||
Ecore_X_Randr_Mode_Info *mode_info;
|
||||
|
||||
EINA_LIST_FOREACH(modes, iter, mode_info)
|
||||
{
|
||||
if ((mode_info->width == mode->width) && (mode_info->height == mode->height))
|
||||
return mode_info;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Init. and Shutdown code
|
||||
*
|
||||
*****************************************************************
|
||||
*/
|
||||
Eina_Bool
|
||||
_12_screen_info_refresh(void)
|
||||
{
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((e_randr_screen_info.randr_version < ECORE_X_RANDR_1_2), EINA_FALSE);
|
||||
|
||||
if (e_randr_screen_info.rrvd_info.randr_info_12)
|
||||
_12_screen_info_free(e_randr_screen_info.rrvd_info.randr_info_12);
|
||||
if (!(e_randr_screen_info.rrvd_info.randr_info_12 = _screen_info_12_new()) ||
|
||||
!_structs_init())
|
||||
return EINA_FALSE;
|
||||
|
||||
_screen_primary_output_assign(NULL);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
* Event code
|
||||
*
|
||||
******************************************************************
|
||||
*/
|
||||
|
||||
static Eina_Bool
|
||||
_x_poll_cb(void *data __UNUSED__)
|
||||
{
|
||||
if (!e_randr_screen_info.rrvd_info.randr_info_12)
|
||||
{
|
||||
poller = NULL;
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
ecore_x_randr_screen_primary_output_orientations_get(e_randr_screen_info.root);
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
void
|
||||
_12_event_listeners_add(void)
|
||||
{
|
||||
EINA_SAFETY_ON_TRUE_RETURN(E_RANDR_12_NO);
|
||||
|
||||
ecore_x_randr_events_select(e_randr_screen_info.root, EINA_TRUE);
|
||||
_event_handlers = eina_list_append(_event_handlers, ecore_event_handler_add(ECORE_X_EVENT_RANDR_CRTC_CHANGE, _crtc_change_event_cb, NULL));
|
||||
_event_handlers = eina_list_append(_event_handlers, ecore_event_handler_add(ECORE_X_EVENT_RANDR_OUTPUT_CHANGE, _output_change_event_cb, NULL));
|
||||
_event_handlers = eina_list_append(_event_handlers, ecore_event_handler_add(ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY, _output_property_change_event_cb, NULL));
|
||||
// WORKAROUND problem of X not sending events
|
||||
poller = ecore_poller_add(ECORE_POLLER_CORE, POLLINTERVAL, _x_poll_cb, NULL);
|
||||
}
|
||||
|
||||
/* Usually events are triggered in the following order.
|
||||
* (Dis)connect Display Scenario:
|
||||
* 1.) ECORE_X_EVENT_OUTPUT_CHANGE //Triggered, when a display is connected to an
|
||||
* output
|
||||
* 2.) ECORE_X_EVENT_CRTC_CHANGE //Triggered when the CRTC mode is changed (eg.
|
||||
* enabled by e.g. e_randr or xrandr)
|
||||
* 3.) ECORE_X_EVENT_OUTPUT_CHANGE //Triggered for each output changed by the
|
||||
* preceeding enabling.
|
||||
*
|
||||
* When the mode of a CRTC is changed only events 2 and 3 are triggered
|
||||
*
|
||||
*/
|
||||
static Eina_Bool
|
||||
_output_change_event_cb(void *data __UNUSED__, int type, void *ev)
|
||||
{
|
||||
Ecore_X_Event_Randr_Output_Change *oce = (Ecore_X_Event_Randr_Output_Change *)ev;
|
||||
E_Randr_Output_Info *output_info = NULL;
|
||||
E_Randr_Crtc_Info *crtc_info = NULL;
|
||||
Eina_Bool policy_success = EINA_FALSE, con_state_changed = EINA_FALSE;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, ECORE_CALLBACK_RENEW);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((type != ECORE_X_EVENT_RANDR_OUTPUT_CHANGE), ECORE_CALLBACK_RENEW);
|
||||
|
||||
/* event information:
|
||||
Ecore_X_Window win;
|
||||
Ecore_X_Randr_Output output;
|
||||
Ecore_X_Randr_Crtc crtc;
|
||||
Ecore_X_Randr_Mode mode;
|
||||
Ecore_X_Randr_Orientation orientation;
|
||||
Ecore_X_Randr_Connection_Status connection;
|
||||
Ecore_X_Render_Subpixel_Order subpixel_order;
|
||||
*/
|
||||
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL((output_info = _12_screen_info_output_info_get(oce->output)), ECORE_CALLBACK_RENEW);
|
||||
|
||||
DBG("E_RANDR: Output event: \n"
|
||||
"\t\t: relative to win: %d\n"
|
||||
"\t\t: output (xid): %d\n"
|
||||
"\t\t: used by crtc (xid): %d\n"
|
||||
"\t\t: mode: %d\n"
|
||||
"\t\t: orientation: %d\n"
|
||||
"\t\t: connection state: %s\n"
|
||||
"\t\t: subpixel_order: %d",
|
||||
oce->win,
|
||||
oce->output,
|
||||
oce->crtc,
|
||||
oce->mode,
|
||||
oce->orientation,
|
||||
_CONNECTION_STATES_STRINGS[oce->connection],
|
||||
oce->subpixel_order);
|
||||
|
||||
crtc_info = _12_screen_info_crtc_info_get(oce->crtc);
|
||||
//WORKAROUND
|
||||
//Reason: Missing events, when an output is moved from one CRTC to
|
||||
// another
|
||||
if (output_info->crtc && (crtc_info != output_info->crtc))
|
||||
output_info->crtc->outputs = eina_list_remove(output_info->crtc->outputs, output_info);
|
||||
//END WORKAROUND
|
||||
output_info->crtc = crtc_info;
|
||||
|
||||
//Update mode references in case a mode was added manually
|
||||
if (output_info->monitor)
|
||||
{
|
||||
eina_list_free(output_info->monitor->modes);
|
||||
output_info->monitor->modes = NULL;
|
||||
eina_list_free(output_info->monitor->preferred_modes);
|
||||
output_info->monitor->preferred_modes = NULL;
|
||||
_monitor_modes_refs_set(output_info->monitor, output_info->xid);
|
||||
//Also update common modes of the used CRTC
|
||||
if (crtc_info && crtc_info->current_mode)
|
||||
{
|
||||
eina_list_free(crtc_info->outputs);
|
||||
crtc_info->outputs = NULL;
|
||||
eina_list_free(crtc_info->outputs_common_modes);
|
||||
crtc_info->outputs_common_modes = NULL;
|
||||
_crtc_outputs_refs_set(crtc_info);
|
||||
}
|
||||
}
|
||||
|
||||
con_state_changed = (Eina_Bool)(output_info->connection_status != oce->connection);
|
||||
output_info->connection_status = oce->connection;
|
||||
output_info->subpixel_order = oce->subpixel_order;
|
||||
|
||||
if (con_state_changed)
|
||||
{
|
||||
_monitor_info_free(output_info->monitor);
|
||||
output_info->monitor = NULL;
|
||||
|
||||
if (oce->connection == ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
||||
{
|
||||
//New device connected!
|
||||
output_info->monitor = _monitor_info_new(output_info);
|
||||
INF("E_RANDR: Output %d was newly connected.", output_info->xid);
|
||||
|
||||
//only try to enable the monitor if there is no serialized setup
|
||||
if (!_12_try_restore_configuration())
|
||||
{
|
||||
policy_success = e_randr_12_try_enable_output(output_info, output_info->policy, EINA_FALSE); //maybe give a success message?
|
||||
INF("E_RANDR: Policy \"%s\" was enforced %ssuccesfully.", _POLICIES_STRINGS[output_info->policy - 1], (policy_success ? "" : "un"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//connection_state is 'unknown' or 'disconnected': treat as disconnected!
|
||||
if (output_info->crtc)
|
||||
{
|
||||
output_info->crtc->outputs = eina_list_remove(output_info->crtc->outputs, output_info);
|
||||
//in case this output was the last one connected on a CRTC,
|
||||
//disable it again
|
||||
if (eina_list_count(output_info->crtc->outputs) == 0)
|
||||
{
|
||||
//in case it was the only output running on this CRTC, disable
|
||||
//it.
|
||||
ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, output_info->crtc->xid, NULL, Ecore_X_Randr_None, Ecore_X_Randr_None);
|
||||
}
|
||||
}
|
||||
//retry to find a suiting serialized setup for the remaining
|
||||
//connected monitors
|
||||
_12_try_restore_configuration();
|
||||
}
|
||||
}
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_crtc_change_event_cb(void *data __UNUSED__, int type, void *ev)
|
||||
{
|
||||
Ecore_X_Event_Randr_Crtc_Change *cce = (Ecore_X_Event_Randr_Crtc_Change *)ev;
|
||||
E_Randr_Crtc_Info *crtc_info;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, ECORE_CALLBACK_RENEW);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((type != ECORE_X_EVENT_RANDR_CRTC_CHANGE), ECORE_CALLBACK_RENEW);
|
||||
|
||||
/* event information:
|
||||
Ecore_X_Window win;
|
||||
Ecore_X_Randr_Crtc crtc;
|
||||
Ecore_X_Randr_Mode mode;
|
||||
Ecore_X_Randr_Orientation orientation;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
*/
|
||||
DBG("E_RANDR: CRTC event: \n"
|
||||
"\t\t: relative to win: %d\n"
|
||||
"\t\t: crtc (xid): %d\n"
|
||||
"\t\t: mode (xid): %d\n"
|
||||
"\t\t: orientation: %d\n"
|
||||
"\t\t: x: %d\n"
|
||||
"\t\t: y: %d\n"
|
||||
"\t\t: width: %d\n"
|
||||
"\t\t: height: %d",
|
||||
cce->win,
|
||||
cce->crtc,
|
||||
cce->mode,
|
||||
cce->orientation,
|
||||
cce->geo.x,
|
||||
cce->geo.y,
|
||||
cce->geo.w,
|
||||
cce->geo.h);
|
||||
|
||||
crtc_info = _12_screen_info_crtc_info_get(cce->crtc);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(crtc_info, ECORE_CALLBACK_RENEW);
|
||||
|
||||
crtc_info->current_mode = _12_screen_info_mode_info_get(cce->mode);
|
||||
crtc_info->current_orientation = cce->orientation;
|
||||
crtc_info->geometry.x = cce->geo.x;
|
||||
crtc_info->geometry.y = cce->geo.y;
|
||||
crtc_info->geometry.w = cce->geo.w;
|
||||
crtc_info->geometry.h = cce->geo.h;
|
||||
|
||||
//update screensize if necessary
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->current_size.width = MAX((cce->geo.x + cce->geo.w), e_randr_screen_info.rrvd_info.randr_info_12->current_size.width);
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->current_size.height = MAX((cce->geo.y + cce->geo.h), e_randr_screen_info.rrvd_info.randr_info_12->current_size.height);
|
||||
|
||||
//update output data
|
||||
eina_list_free(crtc_info->outputs);
|
||||
crtc_info->outputs = NULL;
|
||||
eina_list_free(crtc_info->outputs_common_modes);
|
||||
crtc_info->outputs_common_modes = NULL;
|
||||
|
||||
//if still enabled, update references to outputs
|
||||
if (crtc_info->current_mode)
|
||||
{
|
||||
eina_list_free(crtc_info->outputs);
|
||||
crtc_info->outputs = NULL;
|
||||
eina_list_free(crtc_info->outputs_common_modes);
|
||||
crtc_info->outputs_common_modes = NULL;
|
||||
_crtc_outputs_refs_set(crtc_info);
|
||||
}
|
||||
|
||||
//crop the screen
|
||||
ecore_x_randr_screen_reset(e_randr_screen_info.root);
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_output_property_change_event_cb(void *data __UNUSED__, int type, void *ev)
|
||||
{
|
||||
Ecore_X_Event_Randr_Output_Property_Notify *opce = (Ecore_X_Event_Randr_Output_Property_Notify *)ev;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, ECORE_CALLBACK_RENEW);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((type != ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY), ECORE_CALLBACK_RENEW);
|
||||
|
||||
/* event information:
|
||||
Ecore_X_Window win;
|
||||
Ecore_X_Randr_Output output;
|
||||
Ecore_X_Atom property;
|
||||
Ecore_X_Time time;
|
||||
Ecore_X_Randr_Property_Change state;
|
||||
*/
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL((_12_screen_info_output_info_get(opce->output)), ECORE_CALLBACK_RENEW);
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to enable this output on an unoccupied CRTC. 'Force' in this context
|
||||
* means, that if there are only occupied CRTCs, we disable another output to
|
||||
* enable this one. If not forced we will - if we don't find an unoccupied CRTC
|
||||
* - try to share the output of a CRTC with other outputs already using it
|
||||
* (clone).
|
||||
*/
|
||||
EINTERN Eina_Bool
|
||||
e_randr_12_try_enable_output(E_Randr_Output_Info *output_info, Ecore_X_Randr_Output_Policy policy, Eina_Bool force)
|
||||
{
|
||||
Eina_List *iter, *outputs_list = NULL, *common_modes = NULL;
|
||||
E_Randr_Crtc_Info *crtc_info = NULL, *usable_crtc = NULL;
|
||||
const E_Randr_Crtc_Info *crtc_rel = NULL;
|
||||
E_Randr_Output_Info *primary_output;
|
||||
Ecore_X_Randr_Output *outputs;
|
||||
Ecore_X_Randr_Mode_Info *mode_info;
|
||||
int dx = Ecore_X_Randr_None, dy = Ecore_X_Randr_None;
|
||||
Eina_Bool ret = EINA_TRUE;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(output_info, EINA_FALSE);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((output_info->crtc && output_info->crtc->current_mode), EINA_FALSE);
|
||||
|
||||
/*
|
||||
* Try to find a usable crtc for this output. Either unused or forced.
|
||||
*/
|
||||
EINA_LIST_FOREACH(output_info->possible_crtcs, iter, crtc_info)
|
||||
{
|
||||
if (!crtc_info->current_mode || !crtc_info->outputs || force)
|
||||
{
|
||||
usable_crtc = crtc_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* apparently we don't have a CRTC to make use of the device
|
||||
*/
|
||||
if (!usable_crtc)
|
||||
return EINA_FALSE;
|
||||
|
||||
//get the CRTC we will refer to, dependend on policy
|
||||
switch (policy)
|
||||
{
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_NONE:
|
||||
return EINA_TRUE;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_ASK:
|
||||
e_randr_12_ask_dialog_new(output_info);
|
||||
return EINA_TRUE; //This is a bit incorrect (dialog feedback is async), but probably not worth a lock.
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_CLONE:
|
||||
/*
|
||||
* Order of approaches to enable a clone (of the primary output):
|
||||
*
|
||||
* 0. Get Primary output from Server
|
||||
* 1. Try to add new Output to primary output's CRTC, using the mode used
|
||||
* by the primary output
|
||||
* 2. Try to enable clone in the same
|
||||
* 2a. exact mode or a
|
||||
* 2b. geometrically identical mode
|
||||
* 3. Find a most high resolution mode in common to enable on primary output's CRTC and the new
|
||||
* output's CRTC
|
||||
* 4. fail.
|
||||
*/
|
||||
//Assign new output, if necessary
|
||||
_screen_primary_output_assign(output_info);
|
||||
if ((primary_output = e_randr_screen_info.rrvd_info.randr_info_12->primary_output))
|
||||
{
|
||||
if (primary_output->crtc && primary_output->crtc->current_mode && eina_list_data_find(output_info->monitor->modes, primary_output->crtc->current_mode))
|
||||
{
|
||||
/*
|
||||
* mode currently used by primary output's CRTC is also supported by the new output
|
||||
*/
|
||||
if (eina_list_data_find(primary_output->crtc->possible_outputs, output_info) && eina_list_data_find(output_info->monitor->modes, primary_output->crtc->current_mode))
|
||||
{
|
||||
/*
|
||||
* 1. Try to add new Output to primary output's CRTC, using the mode used
|
||||
* by the primary output
|
||||
* TODO: check with compatibility list in RandRR >= 1.3
|
||||
* if available
|
||||
*
|
||||
* The new output is also usable by the primary output's
|
||||
* CRTC. Try to enable this output together with the already
|
||||
* enabled outputs on the CRTC in already used mode.
|
||||
*/
|
||||
outputs_list = primary_output->crtc->outputs;
|
||||
outputs_list = eina_list_append(outputs_list, output_info);
|
||||
outputs = _outputs_to_array(outputs_list);
|
||||
primary_output->crtc->outputs = NULL;
|
||||
ret &= ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, primary_output->crtc->xid, outputs, eina_list_count(outputs_list), primary_output->crtc->current_mode->xid);
|
||||
free(outputs);
|
||||
eina_list_free(outputs_list);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* 2. Try to enable clone in the same
|
||||
*/
|
||||
|
||||
/*
|
||||
* 2a. exact mode.
|
||||
*/
|
||||
ret &= ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, usable_crtc->xid, &output_info->xid, 1, primary_output->crtc->current_mode->xid);
|
||||
ret &= ecore_x_randr_crtc_pos_relative_set(e_randr_screen_info.root, usable_crtc->xid, primary_output->crtc->xid, ECORE_X_RANDR_OUTPUT_POLICY_CLONE, e_randr_screen_info.rrvd_info.randr_info_12->alignment);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* 2b. geometrically identical mode
|
||||
*/
|
||||
if (primary_output->crtc && (mode_info = _mode_geo_identical_find(output_info->monitor->modes, primary_output->crtc->current_mode)))
|
||||
{
|
||||
ret &= ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, usable_crtc->xid, &output_info->xid, 1, mode_info->xid);
|
||||
ret &= ecore_x_randr_crtc_pos_relative_set(e_randr_screen_info.root, usable_crtc->xid, primary_output->crtc->xid, ECORE_X_RANDR_OUTPUT_POLICY_CLONE, e_randr_screen_info.rrvd_info.randr_info_12->alignment);
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* 3. Find the highest resolution mode common to enable on primary output's CRTC and the new one.
|
||||
*/
|
||||
if (((outputs_list = eina_list_append(outputs_list, primary_output)) && (outputs_list = eina_list_append(outputs_list, output_info))))
|
||||
{
|
||||
if (primary_output->crtc)
|
||||
{
|
||||
common_modes = _outputs_common_modes_get(outputs_list, primary_output->crtc->current_mode);
|
||||
if ((mode_info = eina_list_nth(common_modes, 0)))
|
||||
{
|
||||
eina_list_free(common_modes);
|
||||
INF("Will try to set mode: %dx%d for primary and clone.", mode_info->width, mode_info->height);
|
||||
ret &= ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, primary_output->crtc->xid, ((Ecore_X_Randr_Output *)Ecore_X_Randr_Unset), Ecore_X_Randr_Unset, mode_info->xid);
|
||||
ret &= ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, usable_crtc->xid, &output_info->xid, 1, mode_info->xid);
|
||||
ret &= ecore_x_randr_crtc_pos_relative_set(e_randr_screen_info.root, usable_crtc->xid, primary_output->crtc->xid, ECORE_X_RANDR_OUTPUT_POLICY_CLONE, e_randr_screen_info.rrvd_info.randr_info_12->alignment);
|
||||
}
|
||||
}
|
||||
eina_list_free(outputs_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
ERR("E_RANDR: Failed to clone, because of missing or disabled primary output!");
|
||||
/*
|
||||
* 4. FAIL
|
||||
*/
|
||||
break;
|
||||
|
||||
default:
|
||||
//enable and position according to used policies
|
||||
if (!(mode_info = ((Ecore_X_Randr_Mode_Info *)eina_list_data_get(output_info->monitor->preferred_modes))))
|
||||
{
|
||||
ERR("E_RANDR: Could not enable output(%d), as it has no preferred modes (and there for none at all)!", output_info->xid);
|
||||
ret = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
//get the crtc we will place our's relative to. If it's NULL, this is the
|
||||
//only output attached, work done.
|
||||
if (!(crtc_rel = _crtc_according_to_policy_get(usable_crtc, policy)))
|
||||
{
|
||||
INF("E_RANDR: CRTC %d enabled. No other CRTC had to be moved.", usable_crtc->xid);
|
||||
ret &= ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, usable_crtc->xid, &output_info->xid, 1, mode_info->xid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//Calculate new CRTC's position according to policy
|
||||
switch (policy)
|
||||
{
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE:
|
||||
usable_crtc->geometry.x = crtc_rel->geometry.x;
|
||||
usable_crtc->geometry.y = 0;
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT:
|
||||
usable_crtc->geometry.x = (crtc_rel->geometry.x + crtc_rel->geometry.w);
|
||||
usable_crtc->geometry.y = crtc_rel->geometry.y;
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_BELOW:
|
||||
usable_crtc->geometry.x = crtc_rel->geometry.x;
|
||||
usable_crtc->geometry.y = (crtc_rel->geometry.y + crtc_rel->geometry.h);
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_LEFT:
|
||||
usable_crtc->geometry.y = crtc_rel->geometry.y;
|
||||
usable_crtc->geometry.x = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
usable_crtc->geometry.y = 0;
|
||||
usable_crtc->geometry.x = 0;
|
||||
}
|
||||
|
||||
if ((ret &= ecore_x_randr_crtc_settings_set(e_randr_screen_info.root, usable_crtc->xid, &output_info->xid, 1, usable_crtc->geometry.x, usable_crtc->geometry.y, mode_info->xid, ECORE_X_RANDR_ORIENTATION_ROT_0)))
|
||||
{
|
||||
//WORKAROUND
|
||||
//Reason: the CRTC event, that'd bring the new info about the set
|
||||
//mode is arriving too late here.
|
||||
usable_crtc->current_mode = mode_info;
|
||||
usable_crtc->geometry.w = mode_info->width;
|
||||
usable_crtc->geometry.h = mode_info->height;
|
||||
//WORKAROUND END
|
||||
|
||||
INF("E_RANDR: Moved CRTC %d has geometry (x,y,wxh): %d, %d, %dx%d.", usable_crtc->xid, usable_crtc->geometry.x, usable_crtc->geometry.y, usable_crtc->geometry.w, usable_crtc->geometry.h);
|
||||
//following is policy dependend.
|
||||
switch (policy)
|
||||
{
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE:
|
||||
dy = (crtc_rel->geometry.y - usable_crtc->geometry.h);
|
||||
if (dy < 0)
|
||||
{
|
||||
//virtual move (move other CRTCs as nessesary)
|
||||
dy = -dy;
|
||||
ret &= ecore_x_randr_move_all_crtcs_but(e_randr_screen_info.root,
|
||||
&usable_crtc->xid,
|
||||
1,
|
||||
dx,
|
||||
dy);
|
||||
INF("E_RANDR: Moving all CRTCs but %d, by %dx%d delta.", usable_crtc->xid, dx, dy);
|
||||
}
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_LEFT:
|
||||
dx = (crtc_rel->geometry.x - usable_crtc->geometry.w);
|
||||
if (dx < 0)
|
||||
{
|
||||
//virtual move (move other CRTCs as nessesary)
|
||||
dx = -dx;
|
||||
ret &= ecore_x_randr_move_all_crtcs_but(e_randr_screen_info.root,
|
||||
&usable_crtc->xid,
|
||||
1,
|
||||
dx,
|
||||
dy);
|
||||
INF("E_RANDR: Moving all CRTCs but %d, by %dx%d delta.", usable_crtc->xid, dx, dy);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
ecore_x_randr_screen_reset(e_randr_screen_info.root);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
_12_event_listeners_remove(void)
|
||||
{
|
||||
Ecore_Event_Handler *_event_handler = NULL;
|
||||
|
||||
EINA_LIST_FREE(_event_handlers, _event_handler)
|
||||
ecore_event_handler_del(_event_handler);
|
||||
ecore_poller_del(poller);
|
||||
poller = NULL;
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
#include "e.h"
|
||||
|
||||
static void _e_randr_ask_cb(void *data, E_Dialog *dia);
|
||||
|
||||
static void e_randr_12_memorize_monitor_dialog_new(void);
|
||||
static void _e_randr_ask_memorize_monitor_cb(void *data, E_Dialog *dia);
|
||||
|
||||
static E_Randr_Output_Info *_ask_output_info = NULL;
|
||||
|
||||
EINTERN void
|
||||
e_randr_12_ask_dialog_new(E_Randr_Output_Info *oi)
|
||||
{
|
||||
E_Dialog *dia = NULL;
|
||||
|
||||
if (!oi) return;
|
||||
dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_randr_ask");
|
||||
if (!dia) return;
|
||||
|
||||
_ask_output_info = oi;
|
||||
e_dialog_title_set(dia, _("Position of New Monitor"));
|
||||
e_dialog_icon_set(dia, "display", 64);
|
||||
e_dialog_text_set(dia, _("<b>Where</b> should the newly connected monitor be put?"));
|
||||
e_dialog_button_add(dia, _("Left"), "stock-left", _e_randr_ask_cb, (void *)ECORE_X_RANDR_OUTPUT_POLICY_LEFT);
|
||||
e_dialog_button_add(dia, _("Right"), "stock-right", _e_randr_ask_cb, (void *)ECORE_X_RANDR_OUTPUT_POLICY_RIGHT);
|
||||
e_dialog_button_add(dia, _("Above"), "stock-top", _e_randr_ask_cb, (void *)ECORE_X_RANDR_OUTPUT_POLICY_ABOVE);
|
||||
e_dialog_button_add(dia, _("Below"), "stock-bottom", _e_randr_ask_cb, (void *)ECORE_X_RANDR_OUTPUT_POLICY_BELOW);
|
||||
e_dialog_button_focus_num(dia, 1);
|
||||
e_win_centered_set(dia->win, 1);
|
||||
e_dialog_show(dia);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_randr_ask_cb(void *data __UNUSED__, E_Dialog *dia)
|
||||
{
|
||||
Ecore_X_Randr_Output_Policy pos = (Ecore_X_Randr_Output_Policy)data;
|
||||
Eina_Bool successful = EINA_FALSE;
|
||||
|
||||
if (!_ask_output_info)
|
||||
goto _close_ret;
|
||||
|
||||
successful = e_randr_12_try_enable_output(_ask_output_info, pos, EINA_FALSE);
|
||||
|
||||
if (successful)
|
||||
e_randr_12_memorize_monitor_dialog_new();
|
||||
|
||||
_ask_output_info = NULL;
|
||||
|
||||
_close_ret:
|
||||
e_object_del(E_OBJECT(dia));
|
||||
}
|
||||
|
||||
static void
|
||||
e_randr_12_memorize_monitor_dialog_new(void)
|
||||
{
|
||||
E_Dialog *dia = NULL;
|
||||
|
||||
dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_randr_ask");
|
||||
if (!dia) return;
|
||||
|
||||
e_dialog_title_set(dia, _("Memorize This Monitor?"));
|
||||
e_dialog_icon_set(dia, "display", 64);
|
||||
e_dialog_text_set(dia, _("Should the position of this monitor be <b>memorized</b>?"));
|
||||
e_dialog_button_add(dia, _("Yes"), "stock-yes", _e_randr_ask_memorize_monitor_cb, (void *)EINA_TRUE);
|
||||
e_dialog_button_add(dia, _("No"), "stock-no", _e_randr_ask_memorize_monitor_cb, (void *)EINA_FALSE);
|
||||
e_dialog_button_focus_num(dia, 1);
|
||||
e_win_centered_set(dia->win, 1);
|
||||
e_dialog_show(dia);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_randr_ask_memorize_monitor_cb(void *data, E_Dialog *dia)
|
||||
{
|
||||
Eina_Bool memorize = (Eina_Bool)(intptr_t)data;
|
||||
const E_Randr_Configuration_Store_Modifier modifier = (
|
||||
E_RANDR_CONFIGURATION_STORE_RESOLUTIONS
|
||||
| E_RANDR_CONFIGURATION_STORE_ARRANGEMENT
|
||||
| E_RANDR_CONFIGURATION_STORE_ORIENTATIONS);
|
||||
|
||||
if (memorize)
|
||||
e_randr_store_configuration(modifier);
|
||||
|
||||
e_object_del(E_OBJECT(dia));
|
||||
}
|
||||
|
|
@ -1,275 +0,0 @@
|
|||
#include "e_randr_private.h"
|
||||
#include "e_randr.h"
|
||||
|
||||
// E_Randr_Crtc_Info helper functions
|
||||
/* static Eina_Bool _crtc_mode_intersects_crtcs(E_Randr_Crtc_Info *crtc_info, Ecore_X_Randr_Mode_Info *mode); */
|
||||
/* static Eina_Bool _crtc_outputs_mode_max_set(E_Randr_Crtc_Info *crtc_info); */
|
||||
|
||||
void
|
||||
_crtc_outputs_refs_set(E_Randr_Crtc_Info *crtc_info)
|
||||
{
|
||||
E_Randr_Output_Info *output_info = NULL;
|
||||
Ecore_X_Randr_Output *outputs = NULL;
|
||||
int noutputs = 0;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(crtc_info);
|
||||
|
||||
outputs = ecore_x_randr_crtc_outputs_get(e_randr_screen_info.root, crtc_info->xid, &noutputs);
|
||||
|
||||
while (--noutputs >= 0)
|
||||
{
|
||||
output_info = _12_screen_info_output_info_get(outputs[noutputs]);
|
||||
if (!output_info)
|
||||
{
|
||||
ERR("E_RANDR: Could not find output struct for output %d.", outputs[noutputs]);
|
||||
continue;
|
||||
}
|
||||
crtc_info->outputs = eina_list_append(crtc_info->outputs, output_info);
|
||||
}
|
||||
free(outputs);
|
||||
E_FREE_LIST(crtc_info->outputs_common_modes, ecore_x_randr_mode_info_free);
|
||||
crtc_info->outputs_common_modes = _outputs_common_modes_get(crtc_info->outputs, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_crtc_refs_set(E_Randr_Crtc_Info *crtc_info)
|
||||
{
|
||||
Ecore_X_Randr_Mode mode = Ecore_X_Randr_None;
|
||||
Ecore_X_Randr_Mode_Info *mode_info = NULL;
|
||||
Ecore_X_Randr_Output *poutputs = NULL;
|
||||
E_Randr_Output_Info *output_info = NULL;
|
||||
int npoutputs = 0;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(crtc_info);
|
||||
|
||||
mode = ecore_x_randr_crtc_mode_get(e_randr_screen_info.root, crtc_info->xid);
|
||||
if (!(mode_info = _12_screen_info_mode_info_get(mode)) && (mode != Ecore_X_Randr_None))
|
||||
{
|
||||
//Mode does not equal "disabled" and is unknown to the global structure, so add it
|
||||
mode_info = ecore_x_randr_mode_info_get(e_randr_screen_info.root, mode);
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->modes = eina_list_append(e_randr_screen_info.rrvd_info.randr_info_12->modes, mode_info);
|
||||
}
|
||||
crtc_info->current_mode = mode_info;
|
||||
|
||||
poutputs = ecore_x_randr_crtc_possible_outputs_get(e_randr_screen_info.root, crtc_info->xid, &npoutputs);
|
||||
|
||||
while (--npoutputs >= 0)
|
||||
{
|
||||
output_info = _12_screen_info_output_info_get(poutputs[npoutputs]);
|
||||
if (!output_info)
|
||||
{
|
||||
ERR("E_RANDR: Could not find output struct for output %d.", poutputs[npoutputs]);
|
||||
continue;
|
||||
}
|
||||
crtc_info->possible_outputs = eina_list_append(crtc_info->possible_outputs, output_info);
|
||||
}
|
||||
free(poutputs);
|
||||
|
||||
_crtc_outputs_refs_set(crtc_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Allocate and init with values.
|
||||
* @param crtc the crtc the display is queried for. If Ecore_X_Randr_None is
|
||||
* given, a struct with only the xid will be set
|
||||
* @return E_Randr_Crtc_Info element
|
||||
*/
|
||||
E_Randr_Crtc_Info *
|
||||
_crtc_info_new(Ecore_X_Randr_Crtc crtc)
|
||||
{
|
||||
E_Randr_Crtc_Info *crtc_info = NULL;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, NULL);
|
||||
|
||||
crtc_info = E_NEW(E_Randr_Crtc_Info, 1);
|
||||
|
||||
crtc_info->xid = crtc;
|
||||
crtc_info->panning.x = Ecore_X_Randr_Unset;
|
||||
crtc_info->panning.y = Ecore_X_Randr_Unset;
|
||||
crtc_info->panning.w = Ecore_X_Randr_Unset;
|
||||
crtc_info->panning.h = Ecore_X_Randr_Unset;
|
||||
crtc_info->tracking.x = Ecore_X_Randr_Unset;
|
||||
crtc_info->tracking.y = Ecore_X_Randr_Unset;
|
||||
crtc_info->tracking.w = Ecore_X_Randr_Unset;
|
||||
crtc_info->tracking.h = Ecore_X_Randr_Unset;
|
||||
crtc_info->border.x = Ecore_X_Randr_Unset;
|
||||
crtc_info->border.y = Ecore_X_Randr_Unset;
|
||||
crtc_info->border.w = Ecore_X_Randr_Unset;
|
||||
crtc_info->border.h = Ecore_X_Randr_Unset;
|
||||
|
||||
crtc_info->gamma_ramps = NULL;
|
||||
crtc_info->gamma_ramp_size = Ecore_X_Randr_Unset;
|
||||
crtc_info->outputs = NULL;
|
||||
crtc_info->possible_outputs = NULL;
|
||||
crtc_info->outputs_common_modes = NULL;
|
||||
crtc_info->current_mode = NULL;
|
||||
|
||||
ecore_x_randr_crtc_geometry_get(e_randr_screen_info.root, crtc_info->xid, &crtc_info->geometry.x, &crtc_info->geometry.y, &crtc_info->geometry.w, &crtc_info->geometry.h);
|
||||
crtc_info->current_orientation = ecore_x_randr_crtc_orientation_get(e_randr_screen_info.root, crtc_info->xid);
|
||||
crtc_info->orientations = ecore_x_randr_crtc_orientations_get(e_randr_screen_info.root, crtc_info->xid);
|
||||
|
||||
return crtc_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param crtc_info the crtc info to be freed.
|
||||
*/
|
||||
void
|
||||
_crtc_info_free(E_Randr_Crtc_Info *crtc_info)
|
||||
{
|
||||
if (!crtc_info) return;
|
||||
|
||||
free(crtc_info->gamma_ramps);
|
||||
crtc_info->outputs = eina_list_free(crtc_info->outputs);
|
||||
crtc_info->possible_outputs = eina_list_free(crtc_info->possible_outputs);
|
||||
free(crtc_info);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns EINA_TRUE if given CRTC would intersect with other CRTCs if set to
|
||||
* given mode
|
||||
*/
|
||||
/* static Eina_Bool */
|
||||
/* _crtc_mode_intersects_crtcs(E_Randr_Crtc_Info *crtc_info, Ecore_X_Randr_Mode_Info *mode) */
|
||||
/* { */
|
||||
/* Eina_List *iter; */
|
||||
/* E_Randr_Crtc_Info *tmp; */
|
||||
/* int width, height; */
|
||||
|
||||
/* EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, tmp) */
|
||||
/* { */
|
||||
/* if ((tmp == crtc_info) || */
|
||||
/* ((tmp->geometry.w <= 0) || (tmp->geometry.h <= 0))) */
|
||||
/* continue; */
|
||||
/* width = (mode->width > INT_MAX) ? INT_MAX : mode->width; */
|
||||
/* height = (mode->height > INT_MAX) ? INT_MAX : mode->height; */
|
||||
/* if (E_INTERSECTS(crtc_info->geometry.x, crtc_info->geometry.y, */
|
||||
/* width, height, tmp->geometry.x, */
|
||||
/* tmp->geometry.y, tmp->geometry.w, tmp->geometry.h) */
|
||||
/* && ((crtc_info->geometry.x != tmp->geometry.x) && */
|
||||
/* (crtc_info->geometry.y != tmp->geometry.y))) */
|
||||
/* return EINA_TRUE; */
|
||||
/* } */
|
||||
/* return EINA_FALSE; */
|
||||
/* } */
|
||||
|
||||
/*
|
||||
* reconfigures a CRTC enabling the highest resolution amongst its outputs,
|
||||
* without touching any other CRTC currently activated
|
||||
*/
|
||||
/* static Eina_Bool */
|
||||
/* _crtc_outputs_mode_max_set(E_Randr_Crtc_Info *crtc_info) */
|
||||
/* { */
|
||||
/* Ecore_X_Randr_Mode_Info *mode_info; */
|
||||
/* Eina_List *iter; */
|
||||
/* Eina_Bool ret = EINA_TRUE; */
|
||||
/* Ecore_X_Randr_Output *outputs; */
|
||||
|
||||
/* if (!crtc_info || !crtc_info->outputs || !crtc_info->outputs_common_modes) return EINA_FALSE; */
|
||||
|
||||
/* EINA_LIST_REVERSE_FOREACH(crtc_info->outputs_common_modes, iter, mode_info) */
|
||||
/* { */
|
||||
/* if (!_crtc_mode_intersects_crtcs(crtc_info, mode_info)) */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* if (!mode_info) */
|
||||
/* { */
|
||||
/* //eina_list_free(crtc_info->outputs_common_modes); */
|
||||
/* return EINA_FALSE; */
|
||||
/* } */
|
||||
/* if ((outputs = _outputs_to_array(crtc_info->outputs))) */
|
||||
/* { */
|
||||
/* ret = ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, crtc_info->xid, outputs, eina_list_count(crtc_info->outputs), mode_info->xid); */
|
||||
/* free(outputs); */
|
||||
/* } */
|
||||
/* //eina_list_free(crtc_info->outputs_common_modes); */
|
||||
/* //crtc_info->outputs_common_modes = NULL; */
|
||||
|
||||
/* ecore_x_randr_screen_reset(e_randr_screen_info.root); */
|
||||
|
||||
/* return ret; */
|
||||
/* } */
|
||||
|
||||
/*
|
||||
* this retrieves a CRTC depending on a policy.
|
||||
* Note that this is enlightenment specific! Enlightenment doesn't 'allow' zones
|
||||
* to overlap. Thus we always use the output with the most extreme position
|
||||
* instead of trying to fill gaps like tetris. Though this could be done by
|
||||
* simply implementing another policy.
|
||||
*
|
||||
* Simply put: get the
|
||||
* -right
|
||||
* -left
|
||||
* -top
|
||||
* -bottom
|
||||
* most CRTC and return it.
|
||||
*/
|
||||
const E_Randr_Crtc_Info *
|
||||
_crtc_according_to_policy_get(E_Randr_Crtc_Info *but, Ecore_X_Randr_Output_Policy policy)
|
||||
{
|
||||
Eina_List *iter, *possible_crtcs = NULL;
|
||||
E_Randr_Crtc_Info *crtc_info, *ret = NULL;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO_CRTCS, NULL);
|
||||
|
||||
//get any crtc that besides 'but' to start with
|
||||
possible_crtcs = eina_list_clone(e_randr_screen_info.rrvd_info.randr_info_12->crtcs);
|
||||
possible_crtcs = eina_list_remove(possible_crtcs, but);
|
||||
|
||||
if ((eina_list_count(possible_crtcs) == 0) && (policy != ECORE_X_RANDR_OUTPUT_POLICY_CLONE))
|
||||
{
|
||||
eina_list_free(possible_crtcs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get an initial value for ret
|
||||
ret = (E_Randr_Crtc_Info *)eina_list_last_data_get(possible_crtcs);
|
||||
|
||||
switch (policy)
|
||||
{
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE:
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, crtc_info)
|
||||
{
|
||||
if (crtc_info->geometry.y < ret->geometry.y)
|
||||
ret = crtc_info;
|
||||
}
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT:
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, crtc_info)
|
||||
{
|
||||
if ((crtc_info->geometry.x + crtc_info->geometry.w) >
|
||||
(ret->geometry.x + ret->geometry.w))
|
||||
ret = crtc_info;
|
||||
}
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_BELOW:
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, crtc_info)
|
||||
{
|
||||
if ((crtc_info->geometry.y + crtc_info->geometry.h) >
|
||||
(ret->geometry.y + ret->geometry.h))
|
||||
ret = crtc_info;
|
||||
}
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_LEFT:
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, crtc_info)
|
||||
{
|
||||
if (crtc_info->geometry.x < ret->geometry.x)
|
||||
ret = crtc_info;
|
||||
}
|
||||
break;
|
||||
|
||||
case ECORE_X_RANDR_OUTPUT_POLICY_CLONE:
|
||||
ret = (e_randr_screen_info.rrvd_info.randr_info_12->primary_output) ? e_randr_screen_info.rrvd_info.randr_info_12->primary_output->crtc : NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
eina_list_free(possible_crtcs);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
#include "e_randr_private.h"
|
||||
#include "e_randr.h"
|
||||
|
||||
E_Randr_Monitor_Info *_monitor_info_new(E_Randr_Output_Info *output_info);
|
||||
static int _modes_size_sort_cb(const void *d1, const void *d2);
|
||||
|
||||
void
|
||||
_monitor_modes_refs_set(E_Randr_Monitor_Info *mi, Ecore_X_Randr_Output o)
|
||||
{
|
||||
Ecore_X_Randr_Mode *modes = NULL;
|
||||
Ecore_X_Randr_Mode_Info *mode_info = NULL;
|
||||
int nmodes = 0, npreferred = 0;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(mi);
|
||||
EINA_SAFETY_ON_TRUE_RETURN(o == Ecore_X_Randr_None);
|
||||
|
||||
// Add (preferred) modes
|
||||
modes = ecore_x_randr_output_modes_get(e_randr_screen_info.root, o, &nmodes, &npreferred);
|
||||
while (--nmodes >= 0)
|
||||
{
|
||||
if (!modes[nmodes]) continue;
|
||||
if (!(mode_info = _12_screen_info_mode_info_get(modes[nmodes])))
|
||||
{
|
||||
//Mode unknown to the global structure, so add it
|
||||
mode_info = ecore_x_randr_mode_info_get(e_randr_screen_info.root, modes[nmodes]);
|
||||
e_randr_screen_info.rrvd_info.randr_info_12->modes = eina_list_append(e_randr_screen_info.rrvd_info.randr_info_12->modes, mode_info);
|
||||
}
|
||||
mi->modes = eina_list_prepend(mi->modes, mode_info);
|
||||
if (nmodes <= npreferred)
|
||||
mi->preferred_modes = eina_list_prepend(mi->preferred_modes, mode_info);
|
||||
}
|
||||
free(modes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Allocates a new E_Randr_Monitor_Info struct and initializes it with
|
||||
* default values.
|
||||
* @return E_Randr_Monitor_Info element, or if it could not be
|
||||
* created, NULL
|
||||
*/
|
||||
E_Randr_Monitor_Info *
|
||||
_monitor_info_new(E_Randr_Output_Info *oi)
|
||||
{
|
||||
E_Randr_Monitor_Info *mi = NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(oi, NULL);
|
||||
|
||||
mi = E_NEW(E_Randr_Monitor_Info, 1);
|
||||
|
||||
// Set some default values
|
||||
mi->modes = NULL;
|
||||
mi->preferred_modes = NULL;
|
||||
mi->size_mm.width = Ecore_X_Randr_Unset;
|
||||
mi->size_mm.height = Ecore_X_Randr_Unset;
|
||||
mi->edid = NULL;
|
||||
mi->edid_length = 0;
|
||||
mi->edid_hash.hash = 0;
|
||||
mi->max_backlight = Ecore_X_Randr_Unset;
|
||||
mi->backlight_level = 0.0;
|
||||
|
||||
_monitor_modes_refs_set(mi, oi->xid);
|
||||
|
||||
ecore_x_randr_output_size_mm_get(e_randr_screen_info.root, oi->xid, &mi->size_mm.width, &mi->size_mm.height);
|
||||
mi->edid = ecore_x_randr_output_edid_get(e_randr_screen_info.root, oi->xid, &mi->edid_length);
|
||||
if (mi->edid_length > 0)
|
||||
mi->edid_hash.hash = eina_hash_superfast((char *)mi->edid, mi->edid_length);
|
||||
|
||||
return mi;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Frees E_Randr_Monitor_Info structure
|
||||
*/
|
||||
void
|
||||
_monitor_info_free(E_Randr_Monitor_Info *monitor_info)
|
||||
{
|
||||
if (!monitor_info)
|
||||
return;
|
||||
|
||||
eina_list_free(monitor_info->modes);
|
||||
eina_list_free(monitor_info->preferred_modes);
|
||||
free(monitor_info->edid);
|
||||
free(monitor_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief allocates a struct and fills it with default values.
|
||||
* @param output the output the display is queried for. If Ecore_X_Randr_None is
|
||||
* given, a struct with only the xid will be set
|
||||
* @return E_Randr_Output_Info element
|
||||
*/
|
||||
E_Randr_Output_Info *
|
||||
_output_info_new(Ecore_X_Randr_Output output)
|
||||
{
|
||||
E_Randr_Output_Info *output_info = NULL;
|
||||
char *str;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, NULL);
|
||||
|
||||
output_info = E_NEW(E_Randr_Output_Info, 1);
|
||||
|
||||
output_info->xid = output;
|
||||
|
||||
//Use default values
|
||||
output_info->crtc = NULL;
|
||||
output_info->wired_clones = NULL;
|
||||
output_info->possible_crtcs = NULL;
|
||||
output_info->signalformats = Ecore_X_Randr_Unset;
|
||||
output_info->signalformat = Ecore_X_Randr_Unset;
|
||||
output_info->connector_number = 0;
|
||||
output_info->monitor = NULL;
|
||||
output_info->connector_type = Ecore_X_Randr_Unset;
|
||||
output_info->policy = ECORE_X_RANDR_OUTPUT_POLICY_NONE;
|
||||
output_info->compatibility_list = NULL;
|
||||
output_info->subpixel_order = Ecore_X_Randr_Unset;
|
||||
|
||||
str = ecore_x_randr_output_name_get(e_randr_screen_info.root, output_info->xid, &output_info->name_length);
|
||||
output_info->name = eina_stringshare_add(str);
|
||||
free(str);
|
||||
output_info->connection_status = ecore_x_randr_output_connection_status_get(e_randr_screen_info.root, output_info->xid);
|
||||
|
||||
return output_info;
|
||||
}
|
||||
|
||||
void
|
||||
_output_info_free(E_Randr_Output_Info *output_info)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(output_info);
|
||||
|
||||
eina_list_free(output_info->wired_clones);
|
||||
eina_list_free(output_info->possible_crtcs);
|
||||
eina_list_free(output_info->compatibility_list);
|
||||
eina_stringshare_del(output_info->name);
|
||||
_monitor_info_free(output_info->monitor);
|
||||
output_info->monitor = NULL;
|
||||
free(output_info);
|
||||
}
|
||||
|
||||
void
|
||||
_output_refs_set(E_Randr_Output_Info *output_info)
|
||||
{
|
||||
Ecore_X_Randr_Crtc crtc, *crtcs = NULL;
|
||||
E_Randr_Crtc_Info *crtc_info;
|
||||
int ncrtcs = 0;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN(E_RANDR_12_NO);
|
||||
EINA_SAFETY_ON_NULL_RETURN(output_info);
|
||||
|
||||
eina_list_free(output_info->possible_crtcs);
|
||||
|
||||
//Add possible crtcs
|
||||
crtcs = ecore_x_randr_output_possible_crtcs_get(e_randr_screen_info.root, output_info->xid, &ncrtcs);
|
||||
while (--ncrtcs >= 0)
|
||||
{
|
||||
if (!(crtc_info = _12_screen_info_crtc_info_get(crtcs[ncrtcs])))
|
||||
continue;
|
||||
output_info->possible_crtcs = eina_list_append(output_info->possible_crtcs, crtc_info);
|
||||
}
|
||||
free(crtcs);
|
||||
|
||||
crtc = ecore_x_randr_output_crtc_get(e_randr_screen_info.root, output_info->xid);
|
||||
output_info->crtc = _12_screen_info_crtc_info_get(crtc);
|
||||
|
||||
if (output_info->connection_status == ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
||||
output_info->monitor = _monitor_info_new(output_info);
|
||||
else
|
||||
output_info->monitor = NULL;
|
||||
}
|
||||
|
||||
Ecore_X_Randr_Output *
|
||||
_outputs_to_array(Eina_List *outputs_info)
|
||||
{
|
||||
Ecore_X_Randr_Output *ret = NULL;
|
||||
E_Randr_Output_Info *output_info;
|
||||
Eina_List *output_iter;
|
||||
int i = 0;
|
||||
|
||||
if (!outputs_info || !(ret = malloc(sizeof(Ecore_X_Randr_Output) * eina_list_count(outputs_info)))) return NULL;
|
||||
EINA_LIST_FOREACH(outputs_info, output_iter, output_info)
|
||||
/* output_info == NULL should _not_ be possible! */
|
||||
ret[i++] = output_info ? output_info->xid : Ecore_X_Randr_None;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns a list of modes common ammongst the given outputs,
|
||||
* optionally limited by max_size_mode. If none are found, NULL is returned.
|
||||
*/
|
||||
Eina_List
|
||||
*
|
||||
_outputs_common_modes_get(Eina_List *outputs, Ecore_X_Randr_Mode_Info *max_size_mode)
|
||||
{
|
||||
Eina_List *common_modes = NULL, *mode_iter, *output_iter, *mode_next, *output_next;
|
||||
E_Randr_Output_Info *output_info;
|
||||
Ecore_X_Randr_Mode_Info *mode_info;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(outputs, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e_randr_screen_info.rrvd_info.randr_info_12->modes, NULL);
|
||||
|
||||
//create a list of all common modes
|
||||
common_modes = eina_list_clone(e_randr_screen_info.rrvd_info.randr_info_12->modes);
|
||||
common_modes = eina_list_sort(common_modes, 0, _modes_size_sort_cb);
|
||||
|
||||
EINA_LIST_FOREACH_SAFE(common_modes, mode_iter, mode_next, mode_info)
|
||||
{
|
||||
EINA_LIST_FOREACH_SAFE(outputs, output_iter, output_next, output_info)
|
||||
{
|
||||
if (!output_info || !output_info->monitor)
|
||||
continue;
|
||||
if (!eina_list_data_find(output_info->monitor->modes, mode_info))
|
||||
common_modes = eina_list_remove(common_modes, mode_info);
|
||||
}
|
||||
}
|
||||
|
||||
if (max_size_mode)
|
||||
{
|
||||
//remove all modes that are larger than max_size_mode
|
||||
EINA_LIST_FOREACH_SAFE(common_modes, mode_iter, mode_next, mode_info)
|
||||
{
|
||||
if (_modes_size_sort_cb((void *)max_size_mode, (void *)mode_info) < 0)
|
||||
common_modes = eina_list_remove(common_modes, mode_info);
|
||||
}
|
||||
}
|
||||
|
||||
//sort modes desc. by their sizes
|
||||
common_modes = eina_list_reverse(common_modes);
|
||||
|
||||
return common_modes;
|
||||
}
|
||||
|
||||
static int
|
||||
_modes_size_sort_cb(const void *d1, const void *d2)
|
||||
{
|
||||
Ecore_X_Randr_Mode_Info *mode1 = ((Ecore_X_Randr_Mode_Info *)d1), *mode2 = ((Ecore_X_Randr_Mode_Info *)d2);
|
||||
|
||||
if (!d1) return 1;
|
||||
if (!d2) return -1;
|
||||
|
||||
return (mode1->width * mode1->height) - (mode2->width * mode2->height);
|
||||
}
|
||||
|
|
@ -1,601 +0,0 @@
|
|||
#include "e_randr_private.h"
|
||||
#include "e_randr.h"
|
||||
|
||||
#define MODE_STR_LENGTH_MAX 100
|
||||
|
||||
static const char *_POLICIES_STRINGS[] = {"ABOVE", "RIGHT", "BELOW", "LEFT", "CLONE", "NONE"};
|
||||
|
||||
static E_Randr_Serialized_Crtc *_serialized_crtc_new(E_Randr_Crtc_Info *crtc_info);
|
||||
static inline int _sort_by_number_of_edids(const void *d1, const void *d2);
|
||||
static inline Eina_List *_find_matching_outputs(Eina_List *sois);
|
||||
static inline E_Randr_Crtc_Info *_find_matching_crtc(E_Randr_Serialized_Crtc *sc);
|
||||
static inline Ecore_X_Randr_Mode_Info *_find_matching_mode_info(Ecore_X_Randr_Mode_Info *mode);
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* Storage/Restorage of setups
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Layout:
|
||||
*
|
||||
* Serialized_Setup_12 {
|
||||
* - timestamp
|
||||
* - List<Serialized_CRTC>
|
||||
* - List<EDID>
|
||||
* }
|
||||
* Serialized_Crtc {
|
||||
* - index
|
||||
* - List<Serialized_Output>
|
||||
* - pos
|
||||
* - orientation
|
||||
* - mode
|
||||
* }
|
||||
* Serialized_Output {
|
||||
* - name
|
||||
* - name_length
|
||||
* - serialized_edid
|
||||
* - backlight_level
|
||||
* }
|
||||
* Serialized_EDID {
|
||||
* - edid_hash
|
||||
* }
|
||||
*
|
||||
*/
|
||||
//"Free" helper functions
|
||||
|
||||
void
|
||||
_serialized_output_free(E_Randr_Serialized_Output *so)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(so);
|
||||
|
||||
eina_stringshare_del(so->name);
|
||||
|
||||
free(so);
|
||||
}
|
||||
|
||||
void
|
||||
_serialized_output_policy_free(E_Randr_Serialized_Output_Policy *sop)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(sop);
|
||||
|
||||
eina_stringshare_del(sop->name);
|
||||
free(sop);
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
e_randr_12_serialized_output_policy_free(E_Randr_Serialized_Output_Policy *policy)
|
||||
{
|
||||
_serialized_output_policy_free(policy);
|
||||
}
|
||||
|
||||
void
|
||||
_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(mode_info);
|
||||
|
||||
eina_stringshare_del(mode_info->name);
|
||||
free(mode_info);
|
||||
}
|
||||
|
||||
void
|
||||
_serialized_crtc_free(E_Randr_Serialized_Crtc *sc)
|
||||
{
|
||||
E_Randr_Serialized_Output *so;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(sc);
|
||||
|
||||
EINA_LIST_FREE(sc->outputs, so)
|
||||
_serialized_output_free(so);
|
||||
_mode_info_free(sc->mode_info);
|
||||
free(sc);
|
||||
}
|
||||
|
||||
//"New" helper functions
|
||||
|
||||
/**
|
||||
* @brief Seeks given data in the list and returns the index
|
||||
* of the first element equaling @data
|
||||
* @param list The list to be examined
|
||||
* @param data The data to be found
|
||||
* @return if found, the index of the list node. Else -1.
|
||||
*/
|
||||
int
|
||||
_eina_list_data_index_get(const Eina_List *list, const void *data)
|
||||
{
|
||||
Eina_List *iter;
|
||||
void *ndata;
|
||||
int i = 0;
|
||||
|
||||
EINA_LIST_REVERSE_FOREACH(list, iter, ndata)
|
||||
{
|
||||
if (ndata == data)
|
||||
return i;
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Ecore_X_Randr_Mode_Info
|
||||
*
|
||||
_mode_info_clone(const Ecore_X_Randr_Mode_Info *src)
|
||||
{
|
||||
Ecore_X_Randr_Mode_Info *mi = NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(src, NULL);
|
||||
|
||||
mi = E_NEW(Ecore_X_Randr_Mode_Info, 1);
|
||||
|
||||
mi->xid = src->xid;
|
||||
mi->width = src->width;
|
||||
mi->height = src->height;
|
||||
mi->dotClock = src->dotClock;
|
||||
mi->hSyncStart = src->hSyncStart;
|
||||
mi->hSyncEnd = src->hSyncEnd;
|
||||
mi->hTotal = src->hTotal;
|
||||
mi->hSkew = src->hSkew;
|
||||
mi->vSyncStart = src->vSyncStart;
|
||||
mi->vSyncEnd = src->vSyncEnd;
|
||||
mi->vTotal = src->vTotal;
|
||||
if (src->nameLength > 0)
|
||||
{
|
||||
mi->name = (char *)eina_stringshare_add(src->name);
|
||||
}
|
||||
mi->nameLength = src->nameLength;
|
||||
mi->modeFlags = src->modeFlags;
|
||||
|
||||
return mi;
|
||||
}
|
||||
|
||||
E_Randr_Edid_Hash
|
||||
*
|
||||
_monitor_edid_hash_clone(E_Randr_Monitor_Info *mi)
|
||||
{
|
||||
E_Randr_Edid_Hash *edid_hash;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(mi, NULL);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((mi->edid_hash.hash == 0), NULL);
|
||||
edid_hash = malloc(sizeof(E_Randr_Edid_Hash));
|
||||
|
||||
edid_hash->hash = mi->edid_hash.hash;
|
||||
|
||||
return edid_hash;
|
||||
}
|
||||
|
||||
Eina_List *
|
||||
_outputs_policies_list_new(Eina_List *outputs)
|
||||
{
|
||||
E_Randr_Serialized_Output_Policy *sop;
|
||||
Eina_List *iter, *list = NULL;
|
||||
E_Randr_Output_Info *oi;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(outputs, NULL);
|
||||
|
||||
EINA_LIST_FOREACH(outputs, iter, oi)
|
||||
{
|
||||
if (!oi->name) continue;
|
||||
|
||||
sop = E_NEW(E_Randr_Serialized_Output_Policy, 1);
|
||||
sop->name = eina_stringshare_add(oi->name);
|
||||
sop->policy = oi->policy;
|
||||
list = eina_list_append(list, sop);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
E_Randr_Serialized_Output *
|
||||
_serialized_output_new(E_Randr_Output_Info *output_info)
|
||||
{
|
||||
E_Randr_Serialized_Output *so;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(output_info, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(output_info->name, NULL);
|
||||
|
||||
so = E_NEW(E_Randr_Serialized_Output, 1);
|
||||
|
||||
so->name = eina_stringshare_add(output_info->name);
|
||||
if (output_info->monitor)
|
||||
{
|
||||
so->backlight_level = output_info->monitor->backlight_level;
|
||||
}
|
||||
else
|
||||
{
|
||||
so->backlight_level = Ecore_X_Randr_Unset;
|
||||
}
|
||||
|
||||
return so;
|
||||
}
|
||||
|
||||
E_Randr_Serialized_Crtc *
|
||||
_serialized_crtc_new(E_Randr_Crtc_Info *crtc_info)
|
||||
{
|
||||
E_Randr_Serialized_Crtc *sc = NULL;
|
||||
E_Randr_Serialized_Output *so = NULL;
|
||||
E_Randr_Output_Info *output_info = NULL;
|
||||
Eina_List *iter;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(crtc_info, NULL);
|
||||
|
||||
sc = E_NEW(E_Randr_Serialized_Crtc, 1);
|
||||
|
||||
//Get relative index of CRTC
|
||||
sc->index = _eina_list_data_index_get(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, crtc_info);
|
||||
|
||||
//Create list of serialized outputs
|
||||
EINA_LIST_FOREACH(crtc_info->outputs, iter, output_info)
|
||||
{
|
||||
if (!(so = _serialized_output_new(output_info)))
|
||||
continue;
|
||||
sc->outputs = eina_list_append(sc->outputs, so);
|
||||
INF("E_RANDR:\t Serialized output %s.", so->name);
|
||||
}
|
||||
sc->pos.x = crtc_info->geometry.x;
|
||||
sc->pos.y = crtc_info->geometry.y;
|
||||
sc->orientation = crtc_info->current_orientation;
|
||||
//Clone mode
|
||||
sc->mode_info = _mode_info_clone(crtc_info->current_mode);
|
||||
|
||||
return sc;
|
||||
}
|
||||
|
||||
E_Randr_Serialized_Setup_12 *
|
||||
_12_serialized_setup_new(void)
|
||||
{
|
||||
E_Randr_Serialized_Setup_12 *ss = NULL;
|
||||
Eina_List *iter;
|
||||
E_Randr_Crtc_Info *ci;
|
||||
E_Randr_Output_Info *oi;
|
||||
E_Randr_Serialized_Crtc *sc;
|
||||
E_Randr_Edid_Hash *edid_hash;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e_randr_screen_info.rrvd_info.randr_info_12->outputs, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, NULL);
|
||||
|
||||
ss = E_NEW(E_Randr_Serialized_Setup_12, 1);
|
||||
|
||||
ss->timestamp = ecore_time_get();
|
||||
|
||||
//Add CRTCs and their configuration
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, ci)
|
||||
{
|
||||
if (!(sc = _serialized_crtc_new(ci))) continue;
|
||||
ss->crtcs = eina_list_append(ss->crtcs, sc);
|
||||
INF("E_RANDR: Serialized CRTC %d (index %d) in mode %s.", ci->xid, sc->index, (sc->mode_info ? sc->mode_info->name : "(disabled)"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add EDID hashes of connected outputs
|
||||
* for easier comparison during
|
||||
* setup restoration
|
||||
*/
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->outputs, iter, oi)
|
||||
{
|
||||
if (oi->connection_status != ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
||||
continue;
|
||||
if (!(edid_hash = _monitor_edid_hash_clone(oi->monitor)))
|
||||
continue;
|
||||
ss->edid_hashes = eina_list_append(ss->edid_hashes, edid_hash);
|
||||
}
|
||||
|
||||
return ss;
|
||||
}
|
||||
|
||||
//Update (also retrieval) helper functions
|
||||
|
||||
E_Randr_Serialized_Setup_12 *
|
||||
_matching_serialized_setup_get(Eina_List *setups_12)
|
||||
{
|
||||
E_Randr_Serialized_Setup_12 *ss_12;
|
||||
Eina_List *setups_iter, *edid_iter;
|
||||
E_Randr_Edid_Hash *edid_hash;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(setups_12, NULL);
|
||||
|
||||
//Sort list of setups by the number of monitors involved
|
||||
setups_12 = eina_list_sort(setups_12, 0, _sort_by_number_of_edids);
|
||||
|
||||
EINA_LIST_FOREACH(setups_12, setups_iter, ss_12)
|
||||
{
|
||||
//1. Make sure: #outputs >= #serialized EDIDs
|
||||
if (eina_list_count(e_randr_screen_info.rrvd_info.randr_info_12->outputs) < eina_list_count(ss_12->edid_hashes))
|
||||
continue;
|
||||
//2. Compare #CRTCs
|
||||
if (eina_list_count(e_randr_screen_info.rrvd_info.randr_info_12->crtcs) != eina_list_count(ss_12->crtcs))
|
||||
continue;
|
||||
|
||||
//3. Find all serialized EDIDs
|
||||
EINA_LIST_FOREACH(ss_12->edid_hashes, edid_iter, edid_hash)
|
||||
{
|
||||
if (!_12_screen_info_edid_is_available(edid_hash))
|
||||
goto _setup_12_skip;
|
||||
}
|
||||
|
||||
//4. All EDIDs found? Great, let's go!
|
||||
return ss_12;
|
||||
_setup_12_skip:
|
||||
continue;
|
||||
}
|
||||
|
||||
// None found!
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Eina_List *
|
||||
_outputs_policies_update(Eina_List *sops)
|
||||
{
|
||||
E_Randr_Serialized_Output_Policy *sop;
|
||||
|
||||
EINA_LIST_FREE(sops, sop)
|
||||
{
|
||||
_serialized_output_policy_free(sop);
|
||||
}
|
||||
|
||||
return _outputs_policies_list_new(e_randr_screen_info.rrvd_info.randr_info_12->outputs);
|
||||
}
|
||||
|
||||
Eina_List *
|
||||
_12_serialized_setup_update(Eina_List *setups_12)
|
||||
{
|
||||
E_Randr_Serialized_Setup_12 *ss_12;
|
||||
|
||||
if (setups_12)
|
||||
{
|
||||
/*
|
||||
* try to find the setup with the same monitors
|
||||
* connected in order to replace it
|
||||
*/
|
||||
if ((ss_12 = _matching_serialized_setup_get(setups_12)))
|
||||
{
|
||||
INF("E_RANDR: Found stored configuration that matches current setup. It was created at %f. Freeing it...", ss_12->timestamp);
|
||||
setups_12 = eina_list_remove(setups_12, ss_12);
|
||||
_12_serialized_setup_free(ss_12);
|
||||
}
|
||||
}
|
||||
ss_12 = _12_serialized_setup_new();
|
||||
setups_12 = eina_list_append(setups_12, ss_12);
|
||||
|
||||
return setups_12;
|
||||
}
|
||||
|
||||
void
|
||||
_12_policies_restore(void)
|
||||
{
|
||||
E_Randr_Output_Info *output;
|
||||
E_Randr_Serialized_Output_Policy *sop;
|
||||
Eina_List *iter, *iter2;
|
||||
|
||||
EINA_SAFETY_ON_TRUE_RETURN(E_RANDR_12_NO);
|
||||
EINA_SAFETY_ON_NULL_RETURN(e_config->randr_serialized_setup);
|
||||
EINA_SAFETY_ON_NULL_RETURN(e_config->randr_serialized_setup->outputs_policies);
|
||||
|
||||
// Restore policies
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->outputs, iter, output)
|
||||
{
|
||||
EINA_LIST_FOREACH(e_config->randr_serialized_setup->outputs_policies, iter2, sop)
|
||||
{
|
||||
if ((output->name_length > 0) &&
|
||||
(!strncmp(sop->name, output->name, output->name_length)))
|
||||
{
|
||||
output->policy = sop->policy;
|
||||
INF("E_RANDR: Policy \"%s\" for output \"%s\" restored.", _POLICIES_STRINGS[sop->policy - 1], output->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_12_try_restore_configuration(void)
|
||||
{
|
||||
E_Randr_Serialized_Setup_12 *ss_12;
|
||||
E_Randr_Serialized_Crtc *sc;
|
||||
E_Randr_Crtc_Info *ci;
|
||||
Ecore_X_Randr_Output *outputs_array;
|
||||
E_Randr_Output_Info *output_info;
|
||||
Ecore_X_Randr_Mode_Info *mi = NULL;
|
||||
Ecore_X_Randr_Mode mode = 0;
|
||||
Eina_List *iter, *outputs_list, *outputs_iter;
|
||||
Eina_Bool ret = EINA_TRUE;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e_config, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e_config->randr_serialized_setup, EINA_FALSE);
|
||||
|
||||
if (!(ss_12 = _matching_serialized_setup_get(e_config->randr_serialized_setup->serialized_setups_12)))
|
||||
return EINA_FALSE;
|
||||
|
||||
INF("E_RANDR: Found matching serialized setup.");
|
||||
EINA_LIST_FOREACH(ss_12->crtcs, iter, sc)
|
||||
{
|
||||
ci = _find_matching_crtc(sc);
|
||||
if (!ci)
|
||||
{
|
||||
ERR("E_RANDR: Cannot find a matching CRTC for serialized CRTC index %d.", sc->index);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
outputs_list = _find_matching_outputs(sc->outputs);
|
||||
outputs_array = _outputs_to_array(outputs_list);
|
||||
|
||||
if (!sc->mode_info)
|
||||
{
|
||||
INF("E_RANDR: \tSerialized mode was disabled.");
|
||||
mode = Ecore_X_Randr_None;
|
||||
}
|
||||
else if ((mi = _find_matching_mode_info(sc->mode_info)))
|
||||
{
|
||||
INF("E_RANDR: \tSerialized mode is now known under the name %s.", mi->name);
|
||||
mode = mi->xid;
|
||||
}
|
||||
else if (mi) /* FIXME: this is impossible, so whoever wrote it probably meant something else */
|
||||
{
|
||||
// The serialized mode is no longer available
|
||||
mi->name = malloc(MODE_STR_LENGTH_MAX);
|
||||
//IMPROVABLE: Use random string, like mktemp for files
|
||||
snprintf(mi->name, (MODE_STR_LENGTH_MAX - 1), "%ux%u,%lu,%lu", sc->mode_info->width, sc->mode_info->height, sc->mode_info->dotClock, sc->mode_info->modeFlags);
|
||||
mi = sc->mode_info;
|
||||
mode = ecore_x_randr_mode_info_add(e_randr_screen_info.root, mi);
|
||||
if (mode == Ecore_X_Randr_None)
|
||||
{
|
||||
eina_list_free(outputs_list);
|
||||
free(outputs_array);
|
||||
continue;
|
||||
}
|
||||
EINA_LIST_FOREACH(outputs_list, outputs_iter, output_info)
|
||||
ecore_x_randr_output_mode_add(output_info->xid, mode);
|
||||
INF("E_RANDR: \tSerialized mode was added to the server manually using the name %s.", mi->name);
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
if (mi)
|
||||
DBG("E_RANDR: \tRestoring CRTC %d (index %d) in mode %s.", ci->xid, sc->index, (mode == Ecore_X_Randr_None) ? "(disabled)" : mi->name);
|
||||
DBG("E_RANDR: \t\tUsed outputs:");
|
||||
EINA_LIST_FOREACH(outputs_list, outputs_iter, output_info)
|
||||
DBG("\t\t%s", output_info->name);
|
||||
// DEBUG END
|
||||
|
||||
ret &= ecore_x_randr_crtc_settings_set(e_randr_screen_info.root, ci->xid, outputs_array, eina_list_count(outputs_list), sc->pos.x, sc->pos.y, mode, sc->orientation);
|
||||
eina_list_free(outputs_list);
|
||||
free(outputs_array);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
_12_serialized_setup_free(E_Randr_Serialized_Setup_12 *ss_12)
|
||||
{
|
||||
E_Randr_Serialized_Crtc *sc;
|
||||
E_Randr_Edid_Hash *edid_hash;
|
||||
|
||||
if (!ss_12) return;
|
||||
|
||||
EINA_LIST_FREE(ss_12->crtcs, sc)
|
||||
{
|
||||
_serialized_crtc_free(sc);
|
||||
}
|
||||
EINA_LIST_FREE(ss_12->edid_hashes, edid_hash)
|
||||
free(edid_hash);
|
||||
|
||||
free(ss_12);
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
e_randr_12_serialized_setup_free(E_Randr_Serialized_Setup_12 *ss_12)
|
||||
{
|
||||
_12_serialized_setup_free(ss_12);
|
||||
}
|
||||
|
||||
void
|
||||
_12_store_configuration(E_Randr_Configuration_Store_Modifier modifier)
|
||||
{
|
||||
if (modifier & (E_RANDR_CONFIGURATION_STORE_RESOLUTIONS | E_RANDR_CONFIGURATION_STORE_ARRANGEMENT | E_RANDR_CONFIGURATION_STORE_ORIENTATIONS))
|
||||
{
|
||||
e_config->randr_serialized_setup->serialized_setups_12 = _12_serialized_setup_update(e_config->randr_serialized_setup->serialized_setups_12);
|
||||
}
|
||||
|
||||
if (modifier & E_RANDR_CONFIGURATION_STORE_POLICIES)
|
||||
{
|
||||
//update output policies
|
||||
e_config->randr_serialized_setup->outputs_policies = _outputs_policies_update(e_config->randr_serialized_setup->outputs_policies);
|
||||
}
|
||||
}
|
||||
|
||||
//Retrievel functions for the current e_randr_screen_info context
|
||||
|
||||
// Find entities for restoration in current e_randr_screen_info context
|
||||
static E_Randr_Crtc_Info *
|
||||
_find_matching_crtc(E_Randr_Serialized_Crtc *sc)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(sc, NULL);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(E_RANDR_12_NO, NULL);
|
||||
|
||||
INF("E_RANDR: Setup restore.. Runtime system knows about %d CRTCs. Requested CRTC has index %d", eina_list_count(e_randr_screen_info.rrvd_info.randr_info_12->crtcs), sc->index);
|
||||
return eina_list_nth(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, sc->index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates list of E_Randr_Output_Info* elements for list of
|
||||
* E_Randr_Serialized_Output* objects.
|
||||
* @param sois list of E_Randr_Serialized_Output* elements
|
||||
* @return List of E_Randr_Output* elements or NULL, if not all outputs could be
|
||||
* found or monitors are connected to different outputs
|
||||
*/
|
||||
static Eina_List *
|
||||
_find_matching_outputs(Eina_List *sois)
|
||||
{
|
||||
Eina_List *r_output_iter, *s_output_iter, *list = NULL;
|
||||
E_Randr_Output_Info *oi;
|
||||
E_Randr_Serialized_Output *so;
|
||||
|
||||
EINA_LIST_FOREACH(sois, s_output_iter, so)
|
||||
{
|
||||
INF("E_RANDR: \tLooking for serialized output \"%s\"", so->name);
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->outputs, r_output_iter, oi)
|
||||
{
|
||||
INF("E_RANDR: \t\tComparing to output \"%s\"", oi->name);
|
||||
if (!strncmp(so->name, oi->name, oi->name_length))
|
||||
{
|
||||
list = eina_list_append(list, oi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list && (eina_list_count(sois) != eina_list_count(list)))
|
||||
{
|
||||
eina_list_free(list);
|
||||
list = NULL;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static Ecore_X_Randr_Mode_Info *
|
||||
_find_matching_mode_info(Ecore_X_Randr_Mode_Info *mode)
|
||||
{
|
||||
Eina_List *iter;
|
||||
Ecore_X_Randr_Mode_Info *mi = NULL;
|
||||
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->modes, iter, mi)
|
||||
{
|
||||
if (!strncmp(mode->name, mi->name, mode->nameLength))
|
||||
return mi;
|
||||
}
|
||||
EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->modes, iter, mi)
|
||||
{
|
||||
#define EQL(arg) (mi->arg == mode->arg)
|
||||
if (EQL(width) &&
|
||||
EQL(height) &&
|
||||
EQL(dotClock) &&
|
||||
EQL(hSyncStart) &&
|
||||
EQL(hSyncEnd) &&
|
||||
EQL(hTotal) &&
|
||||
EQL(hSkew) &&
|
||||
EQL(vSyncStart) &&
|
||||
EQL(vSyncEnd) &&
|
||||
EQL(vTotal) &&
|
||||
EQL(modeFlags))
|
||||
return mi;
|
||||
#undef EQL
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_sort_by_number_of_edids(const void *d1, const void *d2)
|
||||
{
|
||||
const E_Randr_Serialized_Setup_12 *ss1 = (const E_Randr_Serialized_Setup_12 *)d1;
|
||||
const E_Randr_Serialized_Setup_12 *ss2 = (const E_Randr_Serialized_Setup_12 *)d2;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ss1, 1);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ss2, -1);
|
||||
|
||||
if (eina_list_count(ss2->edid_hashes) > eina_list_count(ss1->edid_hashes))
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
|
||||
#else
|
||||
#ifndef E_RANDR_PRIVATE_H
|
||||
#define E_RANDR_PRIVATE_H
|
||||
|
||||
#include "e.h"
|
||||
|
||||
#define ECORE_X_RANDR_1_1 ((1 << 16) | 1)
|
||||
#define ECORE_X_RANDR_1_2 ((1 << 16) | 2)
|
||||
#define ECORE_X_RANDR_1_3 ((1 << 16) | 3)
|
||||
|
||||
#define Ecore_X_Randr_Unset -1
|
||||
#define Ecore_X_Randr_None 0
|
||||
|
||||
#define E_RANDR_11_NO ((e_randr_screen_info.randr_version < ECORE_X_RANDR_1_1) || !e_randr_screen_info.rrvd_info.randr_info_11)
|
||||
#define E_RANDR_12_NO ((e_randr_screen_info.randr_version < ECORE_X_RANDR_1_2) || !e_randr_screen_info.rrvd_info.randr_info_12)
|
||||
#define E_RANDR_12_NO_CRTCS (E_RANDR_12_NO || !e_randr_screen_info.rrvd_info.randr_info_12->crtcs)
|
||||
#define E_RANDR_12_NO_CRTC(crtc) (E_RANDR_12_NO || !e_randr_screen_info.rrvd_info.randr_info_12->crtcs || (crtc == Ecore_X_Randr_None))
|
||||
#define E_RANDR_12_NO_OUTPUTS (E_RANDR_12_NO || !e_randr_screen_info.rrvd_info.randr_info_12->outputs)
|
||||
#define E_RANDR_12_NO_OUTPUT(output) (E_RANDR_12_NO || !e_randr_screen_info.rrvd_info.randr_info_12->outputs || (output == Ecore_X_Randr_None))
|
||||
#define E_RANDR_12_NO_MODES (E_RANDR_12_NO || !e_randr_screen_info.rrvd_info.randr_info_12->modes)
|
||||
#define E_RANDR_12_NO_MODE(mode) (E_RANDR_12_NO || !e_randr_screen_info.rrvd_info.randr_info_12->modes || (mode == Ecore_X_Randr_None))
|
||||
|
||||
// RandRR == 1.1
|
||||
E_Randr_Screen_Info_11 *_11_screen_info_new(void);
|
||||
void _11_screen_info_free(E_Randr_Screen_Info_11 *screen_info_11);
|
||||
Eina_Bool _11_screen_info_refresh(void);
|
||||
Eina_Bool _11_try_restore_configuration(void);
|
||||
void _11_store_configuration(E_Randr_Configuration_Store_Modifier modifier);
|
||||
|
||||
// RandRR >= 1.2
|
||||
E_Randr_Screen_Info_12 *_12_screen_info_new(void);
|
||||
void _12_screen_info_free(E_Randr_Screen_Info_12 *screen_info_12);
|
||||
Eina_Bool _12_screen_info_refresh(void);
|
||||
void _12_policies_restore(void);
|
||||
void _12_event_listeners_add(void);
|
||||
void _12_event_listeners_remove(void);
|
||||
// Retrieval functions
|
||||
Ecore_X_Randr_Mode_Info *_12_screen_info_mode_info_get(const Ecore_X_Randr_Mode mode);
|
||||
E_Randr_Crtc_Info *_12_screen_info_crtc_info_get(const Ecore_X_Randr_Crtc crtc);
|
||||
E_Randr_Output_Info *_12_screen_info_output_info_get(const Ecore_X_Randr_Output output);
|
||||
Eina_Bool _12_screen_info_edid_is_available(const E_Randr_Edid_Hash *hash);
|
||||
// (Re)store data
|
||||
E_Randr_Serialized_Setup_12 *_12_serialized_setup_new(void);
|
||||
void _12_serialized_setup_free(E_Randr_Serialized_Setup_12 *ss_12);
|
||||
Eina_Bool _12_try_restore_configuration(void);
|
||||
void _12_store_configuration(E_Randr_Configuration_Store_Modifier modifier);
|
||||
|
||||
// >= 1.2 Substructures helper functions
|
||||
E_Randr_Monitor_Info *_monitor_info_new(E_Randr_Output_Info *output_info);
|
||||
void _monitor_info_free(E_Randr_Monitor_Info *monitor_info);
|
||||
void _monitor_modes_refs_set(E_Randr_Monitor_Info *mi, Ecore_X_Randr_Output output);
|
||||
E_Randr_Output_Info *_output_info_new(Ecore_X_Randr_Output output);
|
||||
void _output_info_free(E_Randr_Output_Info *output_info);
|
||||
void _output_refs_set(E_Randr_Output_Info *output_info);
|
||||
Ecore_X_Randr_Output *_outputs_to_array(Eina_List *outputs_info);
|
||||
Eina_List *_outputs_common_modes_get(Eina_List *outputs, Ecore_X_Randr_Mode_Info *max_size_mode);
|
||||
|
||||
E_Randr_Crtc_Info * _crtc_info_new(Ecore_X_Randr_Crtc crtc);
|
||||
void _crtc_info_free(E_Randr_Crtc_Info *crtc_info);
|
||||
void _crtc_refs_set(E_Randr_Crtc_Info *crtc_info);
|
||||
void _crtc_outputs_refs_set(E_Randr_Crtc_Info *crtc_info);
|
||||
const E_Randr_Crtc_Info *_crtc_according_to_policy_get(E_Randr_Crtc_Info *but, Ecore_X_Randr_Output_Policy policy);
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,82 +0,0 @@
|
|||
#include "e_randr_private.h"
|
||||
#include "e_randr.h"
|
||||
|
||||
#define ECORE_X_RANDR_1_1 ((1 << 16) | 1)
|
||||
#define ECORE_X_RANDR_1_2 ((1 << 16) | 2)
|
||||
#define ECORE_X_RANDR_1_3 ((1 << 16) | 3)
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* Storage/Restorage of setups
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
EAPI void
|
||||
e_randr_store_configuration(E_Randr_Configuration_Store_Modifier modifier)
|
||||
{
|
||||
if (!e_config->randr_serialized_setup)
|
||||
e_config->randr_serialized_setup = e_randr_serialized_setup_new();
|
||||
|
||||
fprintf(stderr, "E_RANDR: Configuration shall be stored using the following modifier:%s\n%s%s%s%s",
|
||||
((!modifier) ? "NONE" : ""),
|
||||
((modifier & E_RANDR_CONFIGURATION_STORE_POLICIES) ? "\tPOLICIES\n" : ""),
|
||||
((modifier & E_RANDR_CONFIGURATION_STORE_RESOLUTIONS) ? "\tRESOLUTIONS\n" : ""),
|
||||
((modifier & E_RANDR_CONFIGURATION_STORE_ARRANGEMENT) ? "\tARRANGEMENTS\n" : ""),
|
||||
((modifier & E_RANDR_CONFIGURATION_STORE_ORIENTATIONS) ? "\tORIENTATIONS\n" : ""));
|
||||
|
||||
if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1)
|
||||
{
|
||||
_11_store_configuration(modifier);
|
||||
}
|
||||
else if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
|
||||
{
|
||||
_12_store_configuration(modifier);
|
||||
}
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
e_randr_try_restore_configuration(void)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e_config, EINA_FALSE);
|
||||
if (!e_config->randr_serialized_setup) return EINA_FALSE;
|
||||
|
||||
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();
|
||||
else if (e_randr_screen_info.randr_version >= ECORE_X_RANDR_1_2)
|
||||
return _12_try_restore_configuration();
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EINTERN E_Randr_Serialized_Setup *
|
||||
e_randr_serialized_setup_new(void)
|
||||
{
|
||||
return E_NEW(E_Randr_Serialized_Setup, 1);
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
e_randr_serialized_setup_free(E_Randr_Serialized_Setup *ss)
|
||||
{
|
||||
E_Randr_Serialized_Setup_12 *serialized_setup_12 = NULL;
|
||||
E_Randr_Serialized_Output_Policy *serialized_output_policy = NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(ss);
|
||||
|
||||
e_randr_11_serialized_setup_free(ss->serialized_setup_11);
|
||||
if (ss->serialized_setups_12)
|
||||
{
|
||||
EINA_LIST_FREE(ss->serialized_setups_12, serialized_setup_12)
|
||||
{
|
||||
e_randr_12_serialized_setup_free(serialized_setup_12);
|
||||
}
|
||||
}
|
||||
EINA_LIST_FREE(ss->outputs_policies, serialized_output_policy)
|
||||
{
|
||||
e_randr_12_serialized_output_policy_free(serialized_output_policy);
|
||||
}
|
||||
free(ss);
|
||||
}
|
||||
|
Loading…
Reference in New Issue