diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-05-24 02:30:43 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-05-24 02:30:43 +0200 |
commit | 003965a79b4f9f4b2f84a7574f6760632a00b889 (patch) | |
tree | ad669e9ba43329f69b957dea125968ef78a79dee /src/gamma-x-randr.c | |
parent | gamma-x-randr: read connector info (diff) | |
download | libgamma-003965a79b4f9f4b2f84a7574f6760632a00b889.tar.gz libgamma-003965a79b4f9f4b2f84a7574f6760632a00b889.tar.bz2 libgamma-003965a79b4f9f4b2f84a7574f6760632a00b889.tar.xz |
gamma-x-randr use connector name to get connector type
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/gamma-x-randr.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/gamma-x-randr.c b/src/gamma-x-randr.c index cc30307..161443b 100644 --- a/src/gamma-x-randr.c +++ b/src/gamma-x-randr.c @@ -424,6 +424,41 @@ static int read_output_data(libgamma_crtc_information_t* restrict out, xcb_randr /** + * Determine the connector type from the connector name + * + * @param this The CRTC information to use and extend + * @param Non-zero on error + */ +static int get_connector_type(libgamma_crtc_information_t* restrict this) +{ + if ((this->connector_type_error = this->connector_name_error)) + return -1; + +#define __select(name, type) \ + if (strstr(this->connector_name, name "-") == this->connector_name) \ + return this->connector_type = LIBGAMMA_CONNECTOR_TYPE_##type, 0 + + __select ("None", Unknown); + __select ("VGA", VGA); + __select ("DVI-I", DVII); + __select ("DVI-D", DVID); + __select ("DVI-A", DVIA); + __select ("Composite", Composite); + __select ("S-Video", SVIDEO); + __select ("Component", Component); + __select ("LFP", LFP); + __select ("Proprietary", Unknown); + __select ("HDMI", HDMI); + __select ("DisplayPort", DisplayPort); + +#undef __select + + this->connector_name_error = LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED; + return -1; +} + + +/** * Read information about a CRTC * * @param this Instance of a data structure to fill with the information about the CRTC @@ -455,8 +490,9 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict /* FIXME output */ - e |= this->connector_type = -1; /* FIXME */ e |= this->connector_name_error = -1; /* FIXME */ + if ((fields & CRTC_INFO_CONNECTOR_TYPE)) + e |= get_connector_type(this); e |= read_output_data(this, output); if ((fields & (CRTC_INFO_WIDTH_MM | CRTC_INFO_HEIGHT_MM))) e |= this->width_mm_error | this->height_mm_error; |