summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-11-05 09:41:57 +0100
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-11-07 09:18:16 +0100
commit144d124445466dfbf7b79d86dbdb701f43e67e84 (patch)
tree6cabb999fff1e8c03b7a6dcf9b7faa053fd5e500
parenta7382dacfa56fd7fd3e98c06f6693612cc9fc5d4 (diff)
ecore_x: store atoms internally
No need to request them every time.
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_randr.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/lib/ecore_x/xlib/ecore_x_randr.c b/src/lib/ecore_x/xlib/ecore_x_randr.c
index 0128ca9498..c6729c3e31 100644
--- a/src/lib/ecore_x/xlib/ecore_x_randr.c
+++ b/src/lib/ecore_x/xlib/ecore_x_randr.c
@@ -16,6 +16,9 @@
16/* local variables */ 16/* local variables */
17static Eina_Bool _randr_avail = EINA_FALSE; 17static Eina_Bool _randr_avail = EINA_FALSE;
18 18
19static Ecore_X_Atom connector_type = 0;
20static Ecore_X_Atom connector_number = 0;
21
19#ifdef ECORE_XRANDR 22#ifdef ECORE_XRANDR
20 23
21# define RANDR_VERSION_1_1 ((1 << 16) | 1) 24# define RANDR_VERSION_1_1 ((1 << 16) | 1)
@@ -65,6 +68,9 @@ _ecore_x_randr_init(void)
65 _ecore_x_randr_screen_resources_get = XRRGetScreenResources; 68 _ecore_x_randr_screen_resources_get = XRRGetScreenResources;
66 69
67 _randr_avail = EINA_TRUE; 70 _randr_avail = EINA_TRUE;
71
72 connector_type = ecore_x_atom_get(RR_PROPERTY_CONNECTOR_TYPE);
73 connector_number = ecore_x_atom_get(RR_PROPERTY_CONNECTOR_NUMBER);
68 } 74 }
69#endif 75#endif
70} 76}
@@ -3044,7 +3050,7 @@ ecore_x_randr_output_connector_number_get(Ecore_X_Window root EINA_UNUSED, Ecore
3044{ 3050{
3045#ifdef ECORE_XRANDR 3051#ifdef ECORE_XRANDR
3046 XRRPropertyInfo *info = NULL; 3052 XRRPropertyInfo *info = NULL;
3047 Atom conn, type; 3053 Atom type;
3048 unsigned long bytes = 0; 3054 unsigned long bytes = 0;
3049 unsigned long items = 0; 3055 unsigned long items = 0;
3050 unsigned char *prop = NULL; 3056 unsigned char *prop = NULL;
@@ -3052,14 +3058,10 @@ ecore_x_randr_output_connector_number_get(Ecore_X_Window root EINA_UNUSED, Ecore
3052 3058
3053 if (_randr_version < RANDR_VERSION_1_3) return -1; 3059 if (_randr_version < RANDR_VERSION_1_3) return -1;
3054 3060
3055 /* try to get the connector number atom */
3056 if (!(conn = XInternAtom(_ecore_x_disp, RR_PROPERTY_CONNECTOR_NUMBER, True)))
3057 return -1;
3058
3059 /* try to get the output property from Xrandr 3061 /* try to get the output property from Xrandr
3060 * 3062 *
3061 * NB: Returns 0 on success */ 3063 * NB: Returns 0 on success */
3062 if (XRRGetOutputProperty(_ecore_x_disp, output, conn, 0, 100, 3064 if (XRRGetOutputProperty(_ecore_x_disp, output, connector_number, 0, 100,
3063 False, False, AnyPropertyType, &type, &format, 3065 False, False, AnyPropertyType, &type, &format,
3064 &items, &bytes, &prop)) 3066 &items, &bytes, &prop))
3065 { 3067 {
@@ -3075,7 +3077,7 @@ ecore_x_randr_output_connector_number_get(Ecore_X_Window root EINA_UNUSED, Ecore
3075 free(prop); 3077 free(prop);
3076 3078
3077 /* try to get the output property from Xrandr */ 3079 /* try to get the output property from Xrandr */
3078 if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, conn))) 3080 if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, connector_number)))
3079 { 3081 {
3080 int ret = 0; 3082 int ret = 0;
3081 3083
@@ -3096,7 +3098,7 @@ ecore_x_randr_output_connector_type_get(Ecore_X_Window root EINA_UNUSED, Ecore_X
3096{ 3098{
3097#ifdef ECORE_XRANDR 3099#ifdef ECORE_XRANDR
3098 XRRPropertyInfo *info = NULL; 3100 XRRPropertyInfo *info = NULL;
3099 Atom conn, type; 3101 Atom type;
3100 unsigned long bytes = 0; 3102 unsigned long bytes = 0;
3101 unsigned long items = 0; 3103 unsigned long items = 0;
3102 unsigned char *prop = NULL; 3104 unsigned char *prop = NULL;
@@ -3105,13 +3107,15 @@ ecore_x_randr_output_connector_type_get(Ecore_X_Window root EINA_UNUSED, Ecore_X
3105 if (_randr_version < RANDR_VERSION_1_3) return -1; 3107 if (_randr_version < RANDR_VERSION_1_3) return -1;
3106 3108
3107 /* try to get the connector type atom */ 3109 /* try to get the connector type atom */
3108 if ((conn = XInternAtom(_ecore_x_disp, RR_PROPERTY_CONNECTOR_TYPE, True))) 3110 if (XRRGetOutputProperty(_ecore_x_disp, output, connector_type, 0, 100,
3109 XRRGetOutputProperty(_ecore_x_disp, output, conn, 0, 4, 3111 False, False, AnyPropertyType, &type, &format,
3110 False, False, AnyPropertyType, &type, &format, 3112 &items, &bytes, &prop) != Success)
3111 &items, &bytes, &prop); 3113 return -1;
3112 3114
3113 if ((!prop) || (items == 0)) 3115 if ((!prop) || (items == 0))
3114 { 3116 {
3117 Atom conn;
3118
3115 /* NB: some butthead drivers (*cough* nouveau *cough*) do not 3119 /* NB: some butthead drivers (*cough* nouveau *cough*) do not
3116 * implement randr properly. They are not using the connector type 3120 * implement randr properly. They are not using the connector type
3117 * property of randr, but rather a "subconnector" property */ 3121 * property of randr, but rather a "subconnector" property */
@@ -3135,7 +3139,7 @@ ecore_x_randr_output_connector_type_get(Ecore_X_Window root EINA_UNUSED, Ecore_X
3135 free(prop); 3139 free(prop);
3136 3140
3137 /* try to get the output property from Xrandr */ 3141 /* try to get the output property from Xrandr */
3138 if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, conn))) 3142 if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, connector_type)))
3139 { 3143 {
3140 int ret = 0; 3144 int ret = 0;
3141 3145