diff options
author | Sebastian Dransfeld <sebastian.dransfeld@sintef.no> | 2013-11-05 09:41:57 +0100 |
---|---|---|
committer | Sebastian Dransfeld <sebastian.dransfeld@sintef.no> | 2013-11-07 09:18:16 +0100 |
commit | 144d124445466dfbf7b79d86dbdb701f43e67e84 (patch) | |
tree | 6cabb999fff1e8c03b7a6dcf9b7faa053fd5e500 | |
parent | a7382dacfa56fd7fd3e98c06f6693612cc9fc5d4 (diff) | |
download | efl-144d124445466dfbf7b79d86dbdb701f43e67e84.tar.gz |
ecore_x: store atoms internally
No need to request them every time.
-rw-r--r-- | src/lib/ecore_x/xlib/ecore_x_randr.c | 30 |
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 @@ /* local variables */ static Eina_Bool _randr_avail = EINA_FALSE; +static Ecore_X_Atom connector_type = 0; +static Ecore_X_Atom connector_number = 0; + #ifdef ECORE_XRANDR # define RANDR_VERSION_1_1 ((1 << 16) | 1) @@ -65,6 +68,9 @@ _ecore_x_randr_init(void) _ecore_x_randr_screen_resources_get = XRRGetScreenResources; _randr_avail = EINA_TRUE; + + connector_type = ecore_x_atom_get(RR_PROPERTY_CONNECTOR_TYPE); + connector_number = ecore_x_atom_get(RR_PROPERTY_CONNECTOR_NUMBER); } #endif } @@ -3044,7 +3050,7 @@ ecore_x_randr_output_connector_number_get(Ecore_X_Window root EINA_UNUSED, Ecore { #ifdef ECORE_XRANDR XRRPropertyInfo *info = NULL; - Atom conn, type; + Atom type; unsigned long bytes = 0; unsigned long items = 0; unsigned char *prop = NULL; @@ -3052,14 +3058,10 @@ ecore_x_randr_output_connector_number_get(Ecore_X_Window root EINA_UNUSED, Ecore if (_randr_version < RANDR_VERSION_1_3) return -1; - /* try to get the connector number atom */ - if (!(conn = XInternAtom(_ecore_x_disp, RR_PROPERTY_CONNECTOR_NUMBER, True))) - return -1; - /* try to get the output property from Xrandr * * NB: Returns 0 on success */ - if (XRRGetOutputProperty(_ecore_x_disp, output, conn, 0, 100, + if (XRRGetOutputProperty(_ecore_x_disp, output, connector_number, 0, 100, False, False, AnyPropertyType, &type, &format, &items, &bytes, &prop)) { @@ -3075,7 +3077,7 @@ ecore_x_randr_output_connector_number_get(Ecore_X_Window root EINA_UNUSED, Ecore free(prop); /* try to get the output property from Xrandr */ - if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, conn))) + if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, connector_number))) { int ret = 0; @@ -3096,7 +3098,7 @@ ecore_x_randr_output_connector_type_get(Ecore_X_Window root EINA_UNUSED, Ecore_X { #ifdef ECORE_XRANDR XRRPropertyInfo *info = NULL; - Atom conn, type; + Atom type; unsigned long bytes = 0; unsigned long items = 0; unsigned char *prop = NULL; @@ -3105,13 +3107,15 @@ ecore_x_randr_output_connector_type_get(Ecore_X_Window root EINA_UNUSED, Ecore_X if (_randr_version < RANDR_VERSION_1_3) return -1; /* try to get the connector type atom */ - if ((conn = XInternAtom(_ecore_x_disp, RR_PROPERTY_CONNECTOR_TYPE, True))) - XRRGetOutputProperty(_ecore_x_disp, output, conn, 0, 4, - False, False, AnyPropertyType, &type, &format, - &items, &bytes, &prop); + if (XRRGetOutputProperty(_ecore_x_disp, output, connector_type, 0, 100, + False, False, AnyPropertyType, &type, &format, + &items, &bytes, &prop) != Success) + return -1; if ((!prop) || (items == 0)) { + Atom conn; + /* NB: some butthead drivers (*cough* nouveau *cough*) do not * implement randr properly. They are not using the connector type * 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 free(prop); /* try to get the output property from Xrandr */ - if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, conn))) + if ((info = XRRQueryOutputProperty(_ecore_x_disp, output, connector_type))) { int ret = 0; |