diff options
Diffstat (limited to '')
-rw-r--r-- | libgamma_error.py (renamed from src/libgamma_error.py) | 199 | ||||
-rw-r--r-- | libgamma_facade.py (renamed from src/libgamma_facade.py) | 85 | ||||
-rw-r--r-- | libgamma_method.py (renamed from src/libgamma_method.py) | 526 | ||||
-rw-r--r-- | libgamma_native_error.posix.pyx (renamed from src/libgamma_native_error.pyx) | 101 | ||||
-rw-r--r-- | libgamma_native_error.w32.pyx (renamed from src/libgamma_native_error.w32.pyx) | 84 | ||||
-rw-r--r-- | libgamma_native_facade.pyx (renamed from src/libgamma_native_facade.pyx) | 1028 | ||||
-rw-r--r-- | libgamma_native_method.pyx (renamed from src/libgamma_native_method.pyx) | 592 | ||||
-rw-r--r-- | src/include-libgamma.h | 19 | ||||
-rw-r--r-- | src/libgamma.py | 23 | ||||
-rwxr-xr-x | test.py (renamed from src/test.py) | 21 |
10 files changed, 1179 insertions, 1499 deletions
diff --git a/src/libgamma_error.py b/libgamma_error.py index afefd5e..bd3a9aa 100644 --- a/src/libgamma_error.py +++ b/libgamma_error.py @@ -1,74 +1,55 @@ -# -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - - +# See LICENSE file for copyright and license details. class LibgammaGroup: ''' Class for `group` ''' - + @property def gid(self) -> int: ''' - Getter. + Getter Group that the user needs to be a member of if - `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. + `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' from libgamma_native_error import libgamma_native_get_group_gid return libgamma_native_get_group_gid() - + @gid.setter def gid(self, value : int): ''' - Setter. + Setter Group that the user needs to be a member of if - `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. + `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' from libgamma_native_error import libgamma_native_set_group_gid libgamma_native_set_group_gid(value) - - + + @property def name(self) -> str: ''' - Getter. + Getter Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `None` if the name of the group `group.gid` - cannot be determined. + cannot be determined ''' from libgamma_native_error import libgamma_native_get_group_name return libgamma_native_get_group_name() - + @name.setter def name(self, value : str): ''' - Setter. + Setter Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `None` if the name of the group `group.gid` - cannot be determined. + cannot be determined ''' from libgamma_native_error import libgamma_native_set_group_name libgamma_native_set_group_name(value) @@ -77,7 +58,7 @@ class LibgammaGroup: group = LibgammaGroup() ''' Group that the user needs to be a member of if -`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. +`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' @@ -96,8 +77,8 @@ def perror(name : str, error_code : int): required group will be printed with its numerical value and, if known, its name. - @param name The text to add at the beginning. - @param value The error code, may be an `errno` value. + @param name The text to add at the beginning + @param value The error code, may be an `errno` value ''' from libgamma_native_error import libgamma_native_perror libgamma_native_perror(name, error_code) @@ -105,11 +86,11 @@ def perror(name : str, error_code : int): def name_of_error(value : int) -> str: ''' - Returns the name of the definition associated with a `libgamma` error code. + Returns the name of the definition associated with a `libgamma` error code - @param value The error code. + @param value The error code @return The name of the definition associated with the error code, - `None` if the error code does not exist. + `None` if the error code does not exist ''' from libgamma_native_error import libgamma_native_name_of_error return libgamma_native_name_of_error(value) @@ -117,11 +98,11 @@ def name_of_error(value : int) -> str: def value_of_error(name : str) -> int: ''' - Return the value of a `libgamma` error definition refered to by name. + Return the value of a `libgamma` error definition refered to by name - @param name The name of the definition associated with the error code. + @param name The name of the definition associated with the error code @return The error code, zero if the name is `None` - or does not refer to a `libgamma` error. + or does not refer to a `libgamma` error ''' from libgamma_native_error import libgamma_native_value_of_error return libgamma_native_value_of_error(name) @@ -131,126 +112,126 @@ def value_of_error(name : str) -> int: LIBGAMMA_ERRNO_SET = -1 ''' `errno` has be set with a standard error number -to indicate the what has gone wrong. +to indicate the what has gone wrong ''' LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD = -2 ''' The selected adjustment method does not exist -or has been excluded at compile-time. +or has been excluded at compile-time ''' LIBGAMMA_NO_SUCH_SITE = -3 ''' -The selected site does not exist. +The selected site does not exist ''' LIBGAMMA_NO_SUCH_PARTITION = -4 ''' -The selected partition does not exist. +The selected partition does not exist ''' LIBGAMMA_NO_SUCH_CRTC = -5 ''' -The selected CRTC does not exist. +The selected CRTC does not exist ''' LIBGAMMA_IMPOSSIBLE_AMOUNT = -6 ''' Counter overflowed when counting the number -of available items. +of available items ''' LIBGAMMA_CONNECTOR_DISABLED = -7 ''' The selected connector is disabled, it does -not have a CRTC. +not have a CRTC ''' LIBGAMMA_OPEN_CRTC_FAILED = -8 ''' The selected CRTC could not be opened, -reason unknown. +reason unknown ''' LIBGAMMA_CRTC_INFO_NOT_SUPPORTED = -9 ''' The CRTC information field is not supported -by the adjustment method. +by the adjustment method ''' LIBGAMMA_GAMMA_RAMP_READ_FAILED = -10 ''' Failed to read the current gamma ramps for -the selected CRTC, reason unknown. +the selected CRTC, reason unknown ''' LIBGAMMA_GAMMA_RAMP_WRITE_FAILED = -11 ''' Failed to write the current gamma ramps for -the selected CRTC, reason unknown. +the selected CRTC, reason unknown ''' LIBGAMMA_GAMMA_RAMP_SIZE_CHANGED = -12 ''' The specified ramp sizes does not match the ramps sizes returned by the adjustment methods -in response to the query/command. +in response to the query/command ''' LIBGAMMA_MIXED_GAMMA_RAMP_SIZE = -13 ''' The specified ramp sizes are not identical -which is required by the adjustment method. -(Only returned in debug mode.) +which is required by the adjustment method +(Only returned in debug mode) ''' LIBGAMMA_WRONG_GAMMA_RAMP_SIZE = -14 ''' The specified ramp sizes are not supported -by the adjustment method. -(Only returned in debug mode.) +by the adjustment method +(Only returned in debug mode) ''' LIBGAMMA_SINGLETON_GAMMA_RAMP = -15 ''' The adjustment method reported that the gamma -ramps size is 1, or perhaps even zero or negative. +ramps size is 1, or perhaps even zero or negative ''' LIBGAMMA_LIST_CRTCS_FAILED = -16 ''' The adjustment method failed to list -available CRTC:s, reason unknown. +available CRTC:s, reason unknown ''' LIBGAMMA_ACQUIRING_MODE_RESOURCES_FAILED = -17 ''' Failed to acquire mode resources from the -adjustment method. +adjustment method ''' LIBGAMMA_NEGATIVE_PARTITION_COUNT = -18 ''' The adjustment method reported that a negative -number of partitions exists in the site. +number of partitions exists in the site ''' LIBGAMMA_NEGATIVE_CRTC_COUNT = -19 ''' The adjustment method reported that a negative -number of CRTC:s exists in the partition. +number of CRTC:s exists in the partition ''' LIBGAMMA_DEVICE_RESTRICTED = -20 ''' Device cannot be access becauses of -insufficient permissions. +insufficient permissions ''' LIBGAMMA_DEVICE_ACCESS_FAILED = -21 ''' -Device cannot be access, reason unknown. +Device cannot be access, reason unknown ''' LIBGAMMA_DEVICE_REQUIRE_GROUP = -22 @@ -258,150 +239,150 @@ LIBGAMMA_DEVICE_REQUIRE_GROUP = -22 Device cannot be access, membership of the `group.gid` (named by `group.name` (can be `None`, if so `errno` may have been set to -tell why)) is required. +tell why)) is required ''' LIBGAMMA_GRAPHICS_CARD_REMOVED = -23 ''' -The graphics card appear to have been removed. +The graphics card appear to have been removed ''' LIBGAMMA_STATE_UNKNOWN = -24 ''' -The state of the requested information is unknown. +The state of the requested information is unknown ''' LIBGAMMA_CONNECTOR_UNKNOWN = -25 ''' Failed to determine which connector the -CRTC belongs to. +CRTC belongs to ''' LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED = -26 ''' The detected connector type is not listed -in this library and has to be updated. +in this library and has to be updated ''' LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED = -27 ''' The detected subpixel order is not listed -in this library and has to be updated. +in this library and has to be updated ''' LIBGAMMA_EDID_LENGTH_UNSUPPORTED = -28 ''' The length of the EDID does not match that -of any supported EDID structure revision. +of any supported EDID structure revision ''' LIBGAMMA_EDID_WRONG_MAGIC_NUMBER = -29 ''' The magic number in the EDID does not match -that of any supported EDID structure revision. +that of any supported EDID structure revision ''' LIBGAMMA_EDID_REVISION_UNSUPPORTED = -30 ''' The EDID structure revision used by the -monitor is not supported. +monitor is not supported ''' LIBGAMMA_GAMMA_NOT_SPECIFIED = -31 ''' The gamma characteristics field in the EDID -is left unspecified. -(This could be considered a non-error.) +is left unspecified +(This could be considered a non-error) ''' LIBGAMMA_EDID_CHECKSUM_ERROR = -32 ''' The checksum in the EDID is incorrect, all request information has been provided -by you cannot count on it. +by you cannot count on it ''' LIBGAMMA_GAMMA_NOT_SPECIFIED_AND_EDID_CHECKSUM_ERROR = -33 ''' Both of the errors `LIBGAMMA_GAMMA_NOT_SPECIFIED` -and `LIBGAMMA_EDID_CHECKSUM_ERROR` have occurred. +and `LIBGAMMA_EDID_CHECKSUM_ERROR` have occurred ''' LIBGAMMA_GAMMA_RAMPS_SIZE_QUERY_FAILED = -34 ''' Failed to query the gamma ramps size from the -adjustment method, reason unknown. +adjustment method, reason unknown ''' LIBGAMMA_OPEN_PARTITION_FAILED = -35 ''' The selected partition could not be opened, -reason unknown. +reason unknown ''' LIBGAMMA_OPEN_SITE_FAILED = -36 ''' The selected site could not be opened, -reason unknown. +reason unknown ''' LIBGAMMA_PROTOCOL_VERSION_QUERY_FAILED = -37 ''' Failed to query the adjustment method for -its protocol version, reason unknown. +its protocol version, reason unknown ''' LIBGAMMA_PROTOCOL_VERSION_NOT_SUPPORTED = -38 ''' The adjustment method's version of its -protocol is not supported. +protocol is not supported ''' LIBGAMMA_LIST_PARTITIONS_FAILED = -39 ''' The adjustment method failed to list -available partitions, reason unknown. +available partitions, reason unknown ''' LIBGAMMA_NULL_PARTITION = -40 ''' Partition exists by index, but the partition -at that index does not exist. +at that index does not exist ''' LIBGAMMA_NOT_CONNECTED = -41 ''' There is not monitor connected to the -connector of the selected CRTC. +connector of the selected CRTC ''' LIBGAMMA_REPLY_VALUE_EXTRACTION_FAILED = -42 ''' Data extraction from a reply from the -adjustment method failed, reason unknown. +adjustment method failed, reason unknown ''' LIBGAMMA_EDID_NOT_FOUND = -43 ''' -No EDID property was found on the output. +No EDID property was found on the output ''' LIBGAMMA_LIST_PROPERTIES_FAILED = -44 ''' Failed to list properties on the output, -reason unknown. +reason unknown ''' LIBGAMMA_PROPERTY_VALUE_QUERY_FAILED = -45 ''' Failed to query a property's value from -the output, reason unknown. +the output, reason unknown ''' LIBGAMMA_OUTPUT_INFORMATION_QUERY_FAILED = -46 ''' A request for information on an output -failed, reason unknown. +failed, reason unknown ''' @@ -414,50 +395,47 @@ update your program for new errors. ''' - class LibgammaError(Exception): ''' - libgamma error class. + libgamma error class - @variable errno The error code. - @variable strerror The name of the error. + @variable errno The error code + @variable strerror The name of the error ''' - + def __init__(self, errno : int, strerror : str): ''' - Constructor. + Constructor - @param errno The error code. - @param strerror The name of the error. + @param errno The error code + @param strerror The name of the error ''' self.errno = errno self.strerror = strerror - + def __str__(self) -> str: ''' - Return the name of the error. + Return the name of the error - @return The name of the error. + @return The name of the error ''' return self.strerror - - + def __repr__(self) -> str: ''' - Create a string representation of the error. + Create a string representation of the error - @return A string representation of the error. + @return A string representation of the error ''' return 'LibgammaError(%i, %s)' % (self.errno, repr(self.strerror)) - def create_error(error_code : int) -> Exception: ''' - Create an exception from an error code. + Create an exception from an error code - @param error_code The error code. - @return :OSError|LibgammaError The error as a throwable object. + @param error_code The error code + @return :OSError|LibgammaError The error as a throwable object ''' if error_code == LIBGAMMA_ERRNO_SET: import ctypes @@ -473,4 +451,3 @@ def create_error(error_code : int) -> Exception: e = LibgammaError(error_code, strerror) return e - diff --git a/src/libgamma_facade.py b/libgamma_facade.py index 5920a5b..ac2ec2c 100644 --- a/src/libgamma_facade.py +++ b/libgamma_facade.py @@ -1,39 +1,19 @@ -# -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - - +# See LICENSE file for copyright and license details. from libgamma_method import MethodCapabilities - def list_methods(operation : int) -> list: ''' - List available adjustment methods by their order of preference based on the environment. + List available adjustment methods by their order of preference based on the environment - @param operation Allowed values: - 0: Methods that the environment suggests will work, excluding fake. - 1: Methods that the environment suggests will work, including fake. - 2: All real non-fake methods. - 3: All real methods. - 4: All methods. - Other values invoke undefined behaviour. - @return :list<int> A list of available adjustment methods. + @param operation Allowed values + 0: Methods that the environment suggests will work, excluding fake + 1: Methods that the environment suggests will work, including fake + 2: All real non-fake methods + 3: All real methods + 4: All methods + Other values invoke undefined behaviour + @return :list<int> A list of available adjustment methods ''' from libgamma_native_facade import libgamma_native_list_methods return libgamma_native_list_methods(operation) @@ -42,10 +22,10 @@ def list_methods(operation : int) -> list: def is_method_available(method : int) -> bool: ''' Check whether an adjustment method is available, non-existing (invalid) methods will be - identified as not available under the rationale that the library may be out of date. + identified as not available under the rationale that the library may be out of date - @param method The adjustment method. - @return Whether the adjustment method is available. + @param method The adjustment method + @return Whether the adjustment method is available ''' from libgamma_native_facade import libgamma_native_is_method_available return not libgamma_native_is_method_available(method) == 0 @@ -53,10 +33,10 @@ def is_method_available(method : int) -> bool: def method_capabilities(method : int) -> MethodCapabilities: ''' - Return the capabilities of an adjustment method. + Return the capabilities of an adjustment method @param this The data structure to fill with the method's capabilities - @param method The adjustment method (display server and protocol). + @param method The adjustment method (display server and protocol) ''' from libgamma_native_facade import libgamma_native_method_capabilities caps = libgamma_native_method_capabilities(method) @@ -65,12 +45,12 @@ def method_capabilities(method : int) -> MethodCapabilities: def method_default_site(method : int) -> str: ''' - Return the default site for an adjustment method. + Return the default site for an adjustment method - @param method The adjustment method (display server and protocol.) + @param method The adjustment method (display server and protocol) @return The default site, `None` if it cannot be determined or if multiple sites are not supported by the adjustment - method. + method ''' from libgamma_native_facade import libgamma_native_method_default_site return libgamma_native_method_default_site(method) @@ -79,9 +59,9 @@ def method_default_site(method : int) -> str: def method_default_site_variable(method : int) -> str: ''' Return the default variable that determines - the default site for an adjustment method. + the default site for an adjustment method - @param method The adjustment method (display server and protocol.) + @param method The adjustment method (display server and protocol) @return The environ variables that is used to determine the default site. `None` if there is none, that is, if the method does not support multiple sites. @@ -93,20 +73,20 @@ def method_default_site_variable(method : int) -> str: def behex_edid(edid : bytes) -> str: ''' - Convert a raw representation of an EDID to a lowercase hexadecimal representation. + Convert a raw representation of an EDID to a lowercase hexadecimal representation - @param edid The EDID in raw representation. - @return The EDID in lowercase hexadecimal representation. + @param edid The EDID in raw representation + @return The EDID in lowercase hexadecimal representation ''' return behex_edid_lowercase(edid) def behex_edid_lowercase(edid : bytes) -> str: ''' - Convert a raw representation of an EDID to a lowercase hexadecimal representation. + Convert a raw representation of an EDID to a lowercase hexadecimal representation - @param edid The EDID in raw representation. - @return The EDID in lowercase hexadecimal representation. + @param edid The EDID in raw representation + @return The EDID in lowercase hexadecimal representation ''' rc = '' for b in edid: @@ -117,10 +97,10 @@ def behex_edid_lowercase(edid : bytes) -> str: def behex_edid_uppercase(edid : bytes) -> str: ''' - Convert a raw representation of an EDID to an uppercase hexadecimal representation. + Convert a raw representation of an EDID to an uppercase hexadecimal representation - @param edid The EDID in raw representation. - @return The EDID in uppercase hexadecimal representation. + @param edid The EDID in raw representation + @return The EDID in uppercase hexadecimal representation ''' rc = '' for b in edid: @@ -131,10 +111,10 @@ def behex_edid_uppercase(edid : bytes) -> str: def unhex_edid(edid : str) -> bytes: ''' - Convert an hexadecimal representation of an EDID to a raw representation. + Convert an hexadecimal representation of an EDID to a raw representation - @param edid The EDID in hexadecimal representation. - @return The EDID in raw representation. + @param edid The EDID in hexadecimal representation + @return The EDID in raw representation ''' rc = [] edid = edid.lower() @@ -144,4 +124,3 @@ def unhex_edid(edid : str) -> bytes: b = '0123456789abcdef'.find(b) << 0 rc.append(a | b) return bytes(rc) - diff --git a/src/libgamma_method.py b/libgamma_method.py index dcd4f6a..c606959 100644 --- a/src/libgamma_method.py +++ b/libgamma_method.py @@ -1,26 +1,7 @@ -# -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - +# See LICENSE file for copyright and license details. from libgamma_error import create_error - LIBGAMMA_METHOD_DUMMY = 0 ''' The identifier for the dummy adjustment method. @@ -31,7 +12,7 @@ testing your program's ability to handle errors. LIBGAMMA_METHOD_X_RANDR = 1 ''' The identifier for the adjustment method with -uses the RandR protocol under the X display server. +uses the RandR protocol under the X display server ''' LIBGAMMA_METHOD_X_VIDMODE = 2 @@ -97,33 +78,33 @@ class MethodCapabilities: ---- Integer variables ---- @variable crtc_information OR of the CRTC information fields in `CRTCInformation` - that may (but can fail) be read successfully. + that may (but can fail) be read successfully ---- Boolean variables ---- @variable default_site_known Whether the default site is known, if true the site is integrated - to the system or can be determined using environment variables. + to the system or can be determined using environment variables @variable multiple_sites Whether the adjustment method supports multiple sites rather - than just the default site. + than just the default site @variable multiple_partitions Whether the adjustment method supports multiple partitions - per site. + per site @variable multiple_crtcs Whether the adjustment method supports multiple CRTC:s - per partition per site. - @variable partitions_are_graphics_cards Whether the partition to graphics card is a bijection. - @variable site_restore Whether the adjustment method supports `site_restore`. - @variable partition_restore Whether the adjustment method supports `partition_restore`. - @variable crtc_restore Whether the adjustment method supports `crtc_restore`. + per partition per site + @variable partitions_are_graphics_cards Whether the partition to graphics card is a bijection + @variable site_restore Whether the adjustment method supports `site_restore` + @variable partition_restore Whether the adjustment method supports `partition_restore` + @variable crtc_restore Whether the adjustment method supports `crtc_restore` @variable identical_gamma_sizes Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size` fields in `CRTCInformation` will always - have the same values as each other for the adjustment method. + have the same values as each other for the adjustment method @variable fixed_gamma_size Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size` fields in `CRTCInformation` will always be - filled with the same value for the adjustment method. + filled with the same value for the adjustment method @variable fixed_gamma_depth Whether the `gamma_depth` field in `CRTCInformation` will - always be filled with the same value for the adjustment method. - @variable real Whether the adjustment method will actually perform adjustments. + always be filled with the same value for the adjustment method + @variable real Whether the adjustment method will actually perform adjustments @variable fake Whether the adjustment method is implement using a translation - layer. + layer ''' def __init__(self, crtc_information : int = 0, booleans : int = 0): @@ -131,7 +112,7 @@ class MethodCapabilities: Constructor @param crtc_information The value for `CRTCInformation` - @param booleans The value for each booleanic variable + @param booleans The value for each boolean variable ''' self.crtc_information = crtc_information self.default_site_known = (booleans & (1 << 0)) != 0 @@ -151,14 +132,14 @@ class MethodCapabilities: class CRTCInformation: ''' - Cathode ray tube controller information data structure. + Cathode ray tube controller information data structure @variable edid:bytes The Extended Display Identification Data associated with the attached monitor. This is raw byte array that is usually 128 bytes long. @variable edid_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable width_mm:int The phyical width, in millimetres, of the viewport of the attached monitor, as reported by the adjustment method. This @@ -169,7 +150,7 @@ class CRTCInformation: for projectors. @variable width_mm_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable height_mm:int The phyical height, in millimetres, of the viewport of the attached monitor, as reported by the adjustment method. This value may be incorrect, which is a known issue with the X @@ -179,7 +160,7 @@ class CRTCInformation: for projectors. @variable height_mm_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable width_mm_edid:int The phyical width, in millimetres, of the viewport of the attached monitor, as reported by it the monitor's Extended @@ -191,7 +172,7 @@ class CRTCInformation: for projectors. @variable width_mm_edid_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable height_mm_edid:int The phyical height, in millimetres, of the viewport of the attached monitor, as reported by it the monitor's Extended Display Information Data. This value can only contain whole @@ -202,50 +183,50 @@ class CRTCInformation: for projectors. @variable height_mm_edid_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library - @variable red_gamma_size:int The size of the encoding axis of the red gamma ramp. - @variable green_gamma_size:int The size of the encoding axis of the green gamma ramp. - @variable blue_gamma_size:int The size of the encoding axis of the blue gamma ramp. + @variable red_gamma_size:int The size of the encoding axis of the red gamma ramp + @variable green_gamma_size:int The size of the encoding axis of the green gamma ramp + @variable blue_gamma_size:int The size of the encoding axis of the blue gamma ramp @variable gamma_size_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable gamma_depth:int The bit-depth of the value axes of gamma ramps, -1 for single precision floating point, and -2 for - double precision floating point. + double precision floating point @variable gamma_depth_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library - @variable gamma_support:int Non-zero gamma ramp adjustments are supported. + @variable gamma_support:int Non-zero gamma ramp adjustments are supported @variable gamma_support_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable subpixel_order:int The layout of the subpixels. You cannot count on this value — especially for CRT:s — but it is provided anyway as a means of distinguishing monitors. @variable subpixel_order_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library - @variable active:bool Whether there is a monitors connected to the CRTC. + @variable active:bool Whether there is a monitors connected to the CRTC @variable active_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable connector_name:str The name of the connector as designated by the display server or as give by this library in case the display - server lacks this feature. + server lacks this feature @variable connector_name_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library - @variable connector_type:int The type of the connector that is associated with the CRTC. + @variable connector_type:int The type of the connector that is associated with the CRTC @variable connector_type_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library @variable gamma_red:float The gamma characteristics of the monitor as reported in its Extended Display Information Data. The value @@ -270,7 +251,7 @@ class CRTCInformation: the result for the blue channel in the gamma correction. @variable gamma_error:int Zero on success, positive it holds the value `errno` had when the reading failed, otherwise (negative) the value - of an error identifier provided by this library. + of an error identifier provided by this library ''' def __init__(self, data): @@ -314,236 +295,236 @@ class CRTCInformation: LIBGAMMA_CONNECTOR_TYPE_Unknown = 0 ''' The adjustment method does not know the connector's type -(This could be considered an error). +(This could be considered an error) ''' LIBGAMMA_CONNECTOR_TYPE_VGA = 1 ''' -Video Graphics Array (VGA). +Video Graphics Array (VGA) ''' LIBGAMMA_CONNECTOR_TYPE_DVI = 2 ''' -Digital Visual Interface, unknown type. +Digital Visual Interface, unknown type ''' LIBGAMMA_CONNECTOR_TYPE_DVII = 3 ''' -Digital Visual Interface, integrated (DVI-I). +Digital Visual Interface, integrated (DVI-I) ''' LIBGAMMA_CONNECTOR_TYPE_DVID = 4 ''' -Digital Visual Interface, digital only (DVI-D). +Digital Visual Interface, digital only (DVI-D) ''' LIBGAMMA_CONNECTOR_TYPE_DVIA = 5 ''' -Digital Visual Interface, analogue only (DVI-A). +Digital Visual Interface, analogue only (DVI-A) ''' LIBGAMMA_CONNECTOR_TYPE_Composite = 6 ''' -Composite video. +Composite video ''' LIBGAMMA_CONNECTOR_TYPE_SVIDEO = 7 ''' -Separate Video (S-video). +Separate Video (S-video) ''' LIBGAMMA_CONNECTOR_TYPE_LVDS = 8 ''' -Low-voltage differential signaling (LVDS). +Low-voltage differential signaling (LVDS) ''' LIBGAMMA_CONNECTOR_TYPE_Component = 9 ''' -Component video, usually separate cables for each channel. +Component video, usually separate cables for each channel ''' LIBGAMMA_CONNECTOR_TYPE_9PinDIN = 10 ''' -9 pin DIN (Deutsches Institut für Normung) connector. +9 pin DIN (Deutsches Institut für Normung) connector ''' LIBGAMMA_CONNECTOR_TYPE_DisplayPort = 11 ''' -DisplayPort. +DisplayPort ''' LIBGAMMA_CONNECTOR_TYPE_HDMI = 12 ''' -High-Definition Multimedia Interface (HDMI), unknown type. +High-Definition Multimedia Interface (HDMI), unknown type ''' LIBGAMMA_CONNECTOR_TYPE_HDMIA = 13 ''' -High-Definition Multimedia Interface, type A (HDMI-A). +High-Definition Multimedia Interface, type A (HDMI-A) ''' LIBGAMMA_CONNECTOR_TYPE_HDMIB = 14 ''' -High-Definition Multimedia Interface, type B (HDMI-B). +High-Definition Multimedia Interface, type B (HDMI-B) ''' LIBGAMMA_CONNECTOR_TYPE_TV = 15 ''' -Television, unknown connector. +Television, unknown connector ''' LIBGAMMA_CONNECTOR_TYPE_eDP = 16 ''' -Embedded DisplayPort (eDP). +Embedded DisplayPort (eDP) ''' LIBGAMMA_CONNECTOR_TYPE_VIRTUAL = 17 ''' -A virtual connector. +A virtual connector ''' LIBGAMMA_CONNECTOR_TYPE_DSI = 18 ''' -Display Serial Interface (DSI). +Display Serial Interface (DSI) ''' LIBGAMMA_CONNECTOR_TYPE_LFP = 19 ''' -LFP connector. -(If you know what this is add it to Wikipedia.) +LFP connector +(If you know what this is add it to Wikipedia) ''' LIBGAMMA_CONNECTOR_TYPE_COUNT = 20 ''' -The number of `LIBGAMMA_CONNECTOR_*` values defined. +The number of `LIBGAMMA_CONNECTOR_*` values defined ''' LIBGAMMA_SUBPIXEL_ORDER_UNKNOWN = 0 ''' -The adjustment method does not know the order of the subpixels. -(This could be considered an error.) +The adjustment method does not know the order of the subpixels +(This could be considered an error) ''' LIBGAMMA_SUBPIXEL_ORDER_NONE = 1 ''' -There are no subpixels in the monitor. +There are no subpixels in the monitor ''' LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB = 2 ''' -The subpixels are ordered red, green and then blue, from left to right. +The subpixels are ordered red, green and then blue, from left to right ''' LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_BGR = 3 ''' -The subpixels are ordered blue, green and then red, from left to right. +The subpixels are ordered blue, green and then red, from left to right ''' LIBGAMMA_SUBPIXEL_ORDER_VERTICAL_RGB = 4 ''' -The subpixels are ordered red, green and then blue, from the top down. +The subpixels are ordered red, green and then blue, from the top down ''' LIBGAMMA_SUBPIXEL_ORDER_VERTICAL_BGR = 5 ''' -The subpixels are ordered blue, green and then red, from the top down. +The subpixels are ordered blue, green and then red, from the top down ''' LIBGAMMA_SUBPIXEL_ORDER_COUNT = 6 ''' -The number of `LIBGAMMA_SUBPIXEL_ORDER_*` values defined. +The number of `LIBGAMMA_SUBPIXEL_ORDER_*` values defined ''' LIBGAMMA_CRTC_INFO_EDID = 1 << 0 ''' -For a `CRTCInformation` fill in the -values for `edid` and `edid_length` and report errors to `edid_error`. +For a `CRTCInformation` fill in the values for +`edid` and `edid_length` and report errors to `edid_error` ''' LIBGAMMA_CRTC_INFO_WIDTH_MM = 1 << 1 ''' -For a `CRTCInformation` fill in the -value for `width_mm` and report errors to `width_mm_error`. +For a `CRTCInformation` fill in the value for +`width_mm` and report errors to `width_mm_error` ''' LIBGAMMA_CRTC_INFO_HEIGHT_MM = 1 << 2 ''' -For a `CRTCInformation` fill in the -value for `height_mm` and report errors to `height_mm_error`. +For a `CRTCInformation` fill in the value for +`height_mm` and report errors to `height_mm_error` ''' LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID = 1 << 3 ''' -For a `CRTCInformation` fill in the -value for `width_mm_edid` and report errors to `width_mm_edid_error`. +For a `CRTCInformation` fill in the value for +`width_mm_edid` and report errors to `width_mm_edid_error` ''' LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID = 1 << 4 ''' -For a `CRTCInformation` fill in the -value for `height_mm_edid` and report errors to `height_mm_edid_error`. +For a `CRTCInformation` fill in the value for +`height_mm_edid` and report errors to `height_mm_edid_error` ''' LIBGAMMA_CRTC_INFO_GAMMA_SIZE = 1 << 5 ''' -For a `CRTCInformation` fill in the -values for `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`. +For a `CRTCInformation` fill in the values for +`red_gamma_size`, `green_gamma_size` and `blue_gamma_size`, and report errors to `gamma_size_error` ''' LIBGAMMA_CRTC_INFO_GAMMA_DEPTH = 1 << 6 ''' -For a `CRTCInformation` fill in the -value for `gamma_depth` and report errors to `gamma_depth_error`. +For a `CRTCInformation` fill in the value for +`gamma_depth` and report errors to `gamma_depth_error` ''' LIBGAMMA_CRTC_INFO_GAMMA_SUPPORT = 1 << 7 ''' -For a `CRTCInformation` fill in the -value for `gamma_support` and report errors to `gamma_support_error`. +For a `CRTCInformation` fill in the value for +`gamma_support` and report errors to `gamma_support_error` ''' LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER = 1 << 8 ''' -For a `CRTCInformation` fill in the -value for `subpixel_order` and report errors to `subpixel_order_error`. +For a `CRTCInformation` fill in the value for +`subpixel_order` and report errors to `subpixel_order_error` ''' LIBGAMMA_CRTC_INFO_ACTIVE = 1 << 9 ''' -For a `CRTCInformation` fill in the -value for `active` and report errors to `active_error`. +For a `CRTCInformation` fill in the value for +`active` and report errors to `active_error` ''' LIBGAMMA_CRTC_INFO_CONNECTOR_NAME = 1 << 10 ''' -For a `CRTCInformation` fill in the -value for `connector_name` and report errors to `connector_name_error`. +For a `CRTCInformation` fill in the value for +`connector_name` and report errors to `connector_name_error` ''' LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE = 1 << 11 ''' -For a `CRTCInformation` fill in the -value for `connector_type` and report errors to `connector_type_error`. +For a `CRTCInformation` fill in the value for +`connector_type` and report errors to `connector_type_error` ''' LIBGAMMA_CRTC_INFO_GAMMA = 1 << 12 ''' -For a `CRTCInformation` fill in the -values for `gamma_red`, `gamma_green` and `gamma_blue` -and report errors to `gamma_error`. +For a `CRTCInformation` fill in the values for +`gamma_red`, `gamma_green` and `gamma_blue` and +report errors to `gamma_error` ''' LIBGAMMA_CRTC_INFO_COUNT = 13 ''' -The number of `LIBGAMMA_CRTC_INFO_*` values defined. +The number of `LIBGAMMA_CRTC_INFO_*` values defined ''' @@ -551,46 +532,42 @@ The number of `LIBGAMMA_CRTC_INFO_*` values defined. LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT = LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID | \ LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID ''' -Macro for both `CRTCInformation` fields -that can specify the size of the monitor's viewport -as specified in the monitor's Extended Display -Information Data. +Macro for both `CRTCInformation` fields that can +specify the size of the monitor's viewport as specified +in the monitor's Extended Display Information Data ''' LIBGAMMA_CRTC_INFO_MACRO_EDID = LIBGAMMA_CRTC_INFO_EDID | \ LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT | \ LIBGAMMA_CRTC_INFO_GAMMA ''' -Macro for all `CRTCInformation` fields -that can be filled if the adjustment method have -support for reading the monitors' Extended Display -Information Data. +Macro for all `CRTCInformation` fields that can be +filled if the adjustment method have support for +reading the monitors' Extended Display Information Data ''' LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT = LIBGAMMA_CRTC_INFO_WIDTH_MM | \ LIBGAMMA_CRTC_INFO_HEIGHT_MM ''' -Macro for both `CRTCInformation` fields -that can specify the size of the monitor's viewport -as provided by the adjustment method without this -library having to parse the monitor's Extended Display -Information Data. +Macro for both `CRTCInformation` fields that can +specify the size of the monitor's viewport as provided +by the adjustment method without this library having to +parse the monitor's Extended Display Information Data ''' LIBGAMMA_CRTC_INFO_MACRO_RAMP = LIBGAMMA_CRTC_INFO_GAMMA_SIZE | \ LIBGAMMA_CRTC_INFO_GAMMA_DEPTH ''' -Macro for the `CRTCInformation` fields -that specifies the CRTC's gamma ramp sizes and gamma -ramp depth. +Macro for the `CRTCInformation` fields that specifies +the CRTC's gamma ramp sizes and gamma ramp depth ''' LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR = LIBGAMMA_CRTC_INFO_CONNECTOR_NAME | \ LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE ''' -Macro for the `CRTCInformation` fields -that specifies the CRTC's connector type and the -partition unique name of the connector. +Macro for the `CRTCInformation` fields that specifies +the CRTC's connector type and the partition unique +name of the connector ''' LIBGAMMA_CRTC_INFO_MACRO_ACTIVE = LIBGAMMA_CRTC_INFO_MACRO_EDID | \ @@ -598,30 +575,30 @@ LIBGAMMA_CRTC_INFO_MACRO_ACTIVE = LIBGAMMA_CRTC_INFO_MACRO_EDID | \ LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER | \ LIBGAMMA_CRTC_INFO_ACTIVE ''' -Macro for the `CRTCInformation` fields -that required there is a monitor attached to the connector, -and that status itself. +Macro for the `CRTCInformation` fields that required +there is a monitor attached to the connector, and +that status itself ''' class GammaRamps: ''' - Gamma ramp structure. + Gamma ramp structure ''' - + class Ramp: ''' - A gamma ramp for one single channel. + A gamma ramp for one single channel ''' - + def __init__(self, ramp, size : int, depth : int): ''' - Constructor. + Constructor - @param ramp The gamma ramp. - @param size The number of stops in the gamma ramp. - @param depth The depth of the gamma ramp. + @param ramp The gamma ramp + @param size The number of stops in the gamma ramp + @param depth The depth of the gamma ramp ''' from libgamma_native_method import libgamma_native_gamma_ramps8_get from libgamma_native_method import libgamma_native_gamma_ramps16_get @@ -644,44 +621,44 @@ class GammaRamps: elif depth == -1: fs = (libgamma_native_gamma_rampsf_get, libgamma_native_gamma_rampsf_set) elif depth == -2: fs = (libgamma_native_gamma_rampsd_get, libgamma_native_gamma_rampsd_set) (self._get, self._set) = fs - - + + @property def size(self) -> int: ''' - Get the number of stops in the gamma ramp. + Get the number of stops in the gamma ramp - @return The number of stops in the gamma ramp. + @return The number of stops in the gamma ramp ''' return self._size - + @size.setter def size(self, value : int): ''' - It is not possible to change this attribute, but a setter is - required for the getter to function. + It is not possible to change this attribute, but + a setter is required for the getter to function ''' raise AttributeError('cannot resize ramp') - + def __len__(self) -> int: ''' - Get the number of stops in the gamma ramp. + Get the number of stops in the gamma ramp - @return The number of stops in the gamma ramp. + @return The number of stops in the gamma ramp ''' return self._size - + def __getitem__(self, indices): ''' - Read the gamma ramp. + Read the gamma ramp - @param indices:slice The stops to read. - @return :list<int|float> The values of the read stops. + @param indices:slice The stops to read + @return :list<int|float> The values of the read stops -- OR -- - @param indices:int The index of the stop to read. - @return :int|float The value of the read stop. + @param indices:int The index of the stop to read + @return :int|float The value of the read stop ''' if isinstance(indices, slice): start = indices.start @@ -697,18 +674,18 @@ class GammaRamps: if indices < 0: indices += self._size return self._get(self._ramp, indices) - + def __setitem__(self, indices, values): ''' - Modify the gamma ramp. + Modify the gamma ramp - @param indices:slice The stops to modify. - @param values:itr<int|float> The values for the selected stops. + @param indices:slice The stops to modify + @param values:itr<int|float> The values for the selected stops -- OR -- - @param indices:int The index of the stop to modify. - @param values:int|float The new value for the stop. + @param indices:int The index of the stop to modify + @param values:int|float The new value for the stop ''' if isinstance(indices, slice): start = indices.start @@ -728,37 +705,38 @@ class GammaRamps: if indices < 0: indices += self._size self._set(self._ramp, indices, values) - + def __iter__(self) -> iter: ''' - Read the gamma ramp. + Read the gamma ramp - @return :itr<int|float> The values of each stop. + @return :itr<int|float> The values of each stop ''' for value in self[:]: yield value - + def map(self, function): ''' Modify the entire ramp using a function that - maps encoding value to output value. + maps encoding value to output value @param function:(float)→int|float Function that takes the encoding value as a - [0, 1] floating point and returns its output - value as the format using in the gamma ramp. + [0, 1] floating point and returns its output + value as the format using in the gamma ramp ''' max_i = self._size - 1 for i in range(self._size): self._set(self._ramp, i, function(i / max_i)) - + + def __init__(self, red_size : int, green_size : int = ..., blue_size : int = ..., *, depth : int = 16): ''' - Constructor. + Constructor - @param red_size The number of stops in the gamma ramp for the red channel. - @param green_size The number of stops in the gamma ramp for the green channel, `...` for `red_size`. - @param blue_size The number of stops in the gamma ramp for the blue channel, `...` for `green_size`. - @param depth The depth of the gamma ramps. + @param red_size The number of stops in the gamma ramp for the red channel + @param green_size The number of stops in the gamma ramp for the green channel, `...` for `red_size` + @param blue_size The number of stops in the gamma ramp for the blue channel, `...` for `green_size` + @param depth The depth of the gamma ramps ''' if green_size is ...: green_size = red_size if blue_size is ...: blue_size = green_size @@ -790,11 +768,11 @@ class GammaRamps: self._red = GammaRamps.Ramp(red, red_size, depth) self._green = GammaRamps.Ramp(green, green_size, depth) self._blue = GammaRamps.Ramp(blue, blue_size, depth) - - + + def __del__(self): ''' - This function is called when the object is not longer in use. + This function is called when the object is not longer in use ''' from libgamma_native_method import libgamma_native_gamma_ramps8_free from libgamma_native_method import libgamma_native_gamma_ramps16_free @@ -810,108 +788,107 @@ class GammaRamps: elif self._depth == 64: libgamma_native_gamma_ramps64_free(self._ramps) elif self._depth == -1: libgamma_native_gamma_rampsf_free(self._ramps) elif self._depth == -2: libgamma_native_gamma_rampsd_free(self._ramps) - - + + @property def red(self) -> Ramp: ''' - Get the gamma ramp for the red channel. + Get the gamma ramp for the red channel - @return The gamma ramp for the red channel. + @return The gamma ramp for the red channel ''' return self._red - - + + @red.setter def red(self, value): ''' It is not possible to change this attribute, but a setter is - required for the getter to function. + required for the getter to function ''' raise AttributeError('cannot change ramps') - - + + @property def green(self) -> Ramp: ''' - Get the gamma ramp for the green channel. + Get the gamma ramp for the green channel - @return The gamma ramp for the green channel. + @return The gamma ramp for the green channel ''' return self._green - - + + @green.setter def green(self, value) -> Ramp: ''' It is not possible to change this attribute, but a setter is - required for the getter to function. + required for the getter to function ''' raise AttributeError('cannot change ramps') - - + + @property def blue(self): ''' - Get the gamma ramp for the blue channel. + Get the gamma ramp for the blue channel - @return The gamma ramp for the blue channel. + @return The gamma ramp for the blue channel ''' return self._blue - - + + @blue.setter def blue(self, value): ''' It is not possible to change this attribute, but a setter is - required for the getter to function. + required for the getter to function ''' raise AttributeError('cannot change ramps') - - + + @property def size(self) -> tuple: ''' - Get the ramps' sizes. + Get the ramps' sizes - @return :(red:int, green:int, blue:int) The size of each individual ramp. + @return :(red:int, green:int, blue:int) The size of each individual ramp ''' return (self._red.size, self._green.size, self._blue.size) - - + + @size.setter def size(self, value): ''' It is not possible to change this attribute, but a setter is - required for the getter to function. + required for the getter to function ''' raise AttributeError('cannot resize ramps') - - + + @property def depth(self) -> int: ''' - Get the depth of ramps. + Get the depth of ramps @return :int The ramps' depth in bits and -1 for single precision floating - point and -2 for doublesingle precision floating point. + point and -2 for doublesingle precision floating point ''' return self._depth - - + + @depth.setter def depth(self, value): ''' It is not possible to change this attribute, but a setter is - required for the getter to function. + required for the getter to function ''' raise AttributeError('cannot change depth') - class Site: ''' - Site state. + Site state On operating systems that integrate a graphical environment there is usually just one site. However, one systems with @@ -919,17 +896,17 @@ class Site: and the BSD:s, there can usually be any (feasible) number of sites. In X.org parlance they are called displays. - @variable method:int The adjustment method of the site. - @variable site:str? The site identifier. - @variable partitions_available:int The number of paritions available in the site. + @variable method:int The adjustment method of the site + @variable site:str? The site identifier + @variable partitions_available:int The number of paritions available in the site ''' - + def __init__(self, method : int, site : str = None): ''' - Constructor. + Constructor - @param method:int The adjustment method of the site. - @param site:str? The site identifier. + @param method:int The adjustment method of the site + @param site:str? The site identifier ''' from libgamma_native_facade import libgamma_native_site_create (self._state, n) = libgamma_native_site_create(method, site) @@ -938,20 +915,20 @@ class Site: self.partitions_available = n self.method = method self.site = site - - + + def __del__(self): ''' - This function is called when the object is not longer in use. + This function is called when the object is not longer in use ''' from libgamma_native_facade import libgamma_native_site_free if not self._state == 0: libgamma_native_site_free(self._state) - - + + def restore(self): ''' - Restore the gamma ramps all CRTC:s with the site to the system settings. + Restore the gamma ramps all CRTC:s with the site to the system settings ''' from libgamma_native_facade import libgamma_native_site_restore r = libgamma_native_site_restore(self._state) @@ -961,7 +938,7 @@ class Site: class Partition: ''' - Partition state. + Partition state Probably the majority of display server only one partition per site. However, X.org can, and traditional used to have @@ -972,17 +949,17 @@ class Partition: On hardware-level adjustment methods, such as Direct Rendering Manager, a partition is a graphics card - @variable site:Site The site of the partition. - @variable partition:int The index of the partition. - @variable crtcs_available:int The number of CRTC:s available in the parition. + @variable site:Site The site of the partition + @variable partition:int The index of the partition + @variable crtcs_available:int The number of CRTC:s available in the parition ''' - + def __init__(self, site : Site, partition : int): ''' Constructor. - @param site The site of the partition. - @param partition The index of the partition. + @param site The site of the partition + @param partition The index of the partition ''' from libgamma_native_facade import libgamma_native_partition_create (self._state, n) = libgamma_native_partition_create(site._state, partition) @@ -991,20 +968,20 @@ class Partition: self.crtcs_available = n self.site = site self.partition = partition - - + + def __del__(self): ''' - This function is called when the object is not longer in use. + This function is called when the object is not longer in use ''' from libgamma_native_facade import libgamma_native_partition_free if not self._state == 0: libgamma_native_partition_free(self._state) - - + + def restore(self): ''' - Restore the gamma ramps all CRTC:s with the partition to the system settings. + Restore the gamma ramps all CRTC:s with the partition to the system settings ''' from libgamma_native_facade import libgamma_native_partition_restore r = libgamma_native_partition_restore(self._state) @@ -1014,22 +991,22 @@ class Partition: class CRTC: ''' - Cathode ray tube controller state. + Cathode ray tube controller state The CRTC controls the gamma ramps for the monitor that is plugged in to the connector - that the CRTC belongs to. + that the CRTC belongs to - @variable partition:Partition The partition of the CRTC. - @variable crtc:int The index of the CRTC. + @variable partition:Partition The partition of the CRTC + @variable crtc:int The index of the CRTC ''' - + def __init__(self, partition : Partition, crtc : int): ''' - Constructor. + Constructor - @param partition The partition the of the CRTC. - @param crtc The index of the CRTC. + @param partition The partition the of the CRTC + @param crtc The index of the CRTC ''' from libgamma_native_facade import libgamma_native_crtc_create (self._state, n) = libgamma_native_crtc_create(partition._state, crtc) @@ -1037,46 +1014,46 @@ class CRTC: raise create_error(n) self.partition = partition self.crtc = crtc - - + + def __del__(self): ''' - This function is called when the object is not longer in use. + This function is called when the object is not longer in use ''' from libgamma_native_facade import libgamma_native_crtc_free if not self._state == 0: libgamma_native_crtc_free(self._state) - - + + def restore(self): ''' - Restore the gamma ramps for a CRTC to the system settings for that CRTC. + Restore the gamma ramps for a CRTC to the system settings for that CRTC ''' from libgamma_native_facade import libgamma_native_crtc_restore r = libgamma_native_crtc_restore(self._state) if not r == 0: raise create_error(r) - - + + def information(self, fields : int) -> tuple: ''' - Read information about a CRTC. + Read information about a CRTC @param field OR:ed identifiers for the information - about the CRTC that should be read. + about the CRTC that should be read @return :(:CRTCInformation, :bool) The information about the CRTC and - whether no errors occurred. + whether no errors occurred ''' from libgamma_native_facade import libgamma_native_get_crtc_information (data, e) = libgamma_native_get_crtc_information(self._state, fields) return (CRTCInformation(data), e == 0) - - + + def get_gamma(self, ramps : GammaRamps): ''' - Get the current gamma ramps for the CRTC. + Get the current gamma ramps for the CRTC - @param ramps The gamma ramps to fill with the current values. + @param ramps The gamma ramps to fill with the current values ''' from libgamma_native_facade import libgamma_native_crtc_get_gamma_ramps8 from libgamma_native_facade import libgamma_native_crtc_get_gamma_ramps16 @@ -1092,13 +1069,13 @@ class CRTC: elif ramps.depth == -2: r = libgamma_native_crtc_get_gamma_rampsd(self._state, ramps._ramps) if not r == 0: raise create_error(r) - - + + def set_gamma(self, ramps : GammaRamps): ''' - Set gamma ramps for the CRTC. + Set gamma ramps for the CRTC - @param ramps The gamma ramps to apply. + @param ramps The gamma ramps to apply ''' from libgamma_native_facade import libgamma_native_crtc_set_gamma_ramps8 from libgamma_native_facade import libgamma_native_crtc_set_gamma_ramps16 @@ -1114,4 +1091,3 @@ class CRTC: elif ramps.depth == -2: r = libgamma_native_crtc_set_gamma_rampsd(self._state, ramps._ramps) if not r == 0: raise create_error(r) - diff --git a/src/libgamma_native_error.pyx b/libgamma_native_error.posix.pyx index 6963a44..0370eb4 100644 --- a/src/libgamma_native_error.pyx +++ b/libgamma_native_error.posix.pyx @@ -1,22 +1,5 @@ # -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - +# See LICENSE file for copyright and license details. cimport cython from posix.unistd cimport gid_t @@ -27,20 +10,20 @@ cdef extern gid_t libgamma_group_gid_get() nogil cdef extern void libgamma_group_gid_set(gid_t) nogil ''' Group that the user needs to be a member of if -`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. +`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' -cdef extern const char* libgamma_group_name_get() nogil -cdef extern void libgamma_group_name_set(const char*) nogil +cdef extern const char *libgamma_group_name_get() nogil +cdef extern void libgamma_group_name_set(const char *) nogil ''' Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `NULL` if the name of the group `libgamma_group_gid` -cannot be determined. +cannot be determined ''' -cdef extern void libgamma_perror(const char* name, int error_code) nogil +cdef extern void libgamma_perror(const char *name, int error_code) nogil ''' Prints an error to stderr in a `perror` fashion, however this function will not translate the `libgamma` @@ -55,60 +38,60 @@ the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the required group will be printed with its numerical value and, if known, its name. -@param name The text to add at the beginning. -@param value The error code, may be an `errno` value. +@param name The text to add at the beginning +@param value The error code, may be an `errno` value ''' -cdef extern const char* libgamma_name_of_error(int value) nogil +cdef extern const char *libgamma_name_of_error(int value) nogil ''' -Returns the name of the definition associated with a `libgamma` error code. +Returns the name of the definition associated with a `libgamma` error code -@param value The error code. +@param value The error code @return The name of the definition associated with the error code, `NULL` if the error code does not exist. The return string should not be `free`:d. ''' -cdef extern int libgamma_value_of_error(const char* name) nogil +cdef extern int libgamma_value_of_error(const char *name) nogil ''' -Return the value of a `libgamma` error definition refered to by name. +Return the value of a `libgamma` error definition refered to by name -@param name The name of the definition associated with the error code. +@param name The name of the definition associated with the error code @return The error code, zero if the name does is `NULL` - or does not refer to a `libgamma` error. + or does not refer to a `libgamma` error ''' - def libgamma_native_get_group_gid() -> int: ''' - Getter. + Getter Group that the user needs to be a member of if - `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. + `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' return int(libgamma_group_gid_get()) + def libgamma_native_set_group_gid(gid : int): ''' - Setter. + Setter Group that the user needs to be a member of if - `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. + `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' libgamma_group_gid_set(<int>gid) def libgamma_native_get_group_name() -> str: ''' - Getter. + Getter Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `None` if the name of the group `libgamma_group_gid` - cannot be determined. + cannot be determined ''' - cdef const char* group_name + cdef const char *group_name cdef bytes bs group_name = libgamma_group_name_get() if group_name is NULL: @@ -116,19 +99,20 @@ def libgamma_native_get_group_name() -> str: bs = group_name return bs.decode('utf-8', 'strict') + def libgamma_native_set_group_name(name : str): ''' - Setter. + Setter Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `None` if the name of the group `libgamma_group_gid` - cannot be determined. + cannot be determined ''' - cdef const char* group_name + cdef const char *group_name cdef bytes bs if name is None: - libgamma_group_name_set(<char*>NULL) + libgamma_group_name_set(<char *>NULL) return bs = name.encode('utf-8') + bytes([0]) group_name = bs @@ -150,8 +134,8 @@ def libgamma_native_perror(name : str, error_code : int): required group will be printed with its numerical value and, if known, its name. - @param name The text to add at the beginning. - @param value The error code, may be an `errno` value. + @param name The text to add at the beginning + @param value The error code, may be an `errno` value ''' cdef bytes bs bs = name.encode('utf-8') + bytes([0]) @@ -160,13 +144,13 @@ def libgamma_native_perror(name : str, error_code : int): def libgamma_native_name_of_error(value : int) -> str: ''' - Returns the name of the definition associated with a `libgamma` error code. + Returns the name of the definition associated with a `libgamma` error code - @param value The error code. + @param value The error code @return The name of the definition associated with the error code, - `None` if the error code does not exist. + `None` if the error code does not exist ''' - cdef const char* name + cdef const char *name cdef bytes bs name = libgamma_name_of_error(<int>value) if name is NULL: @@ -177,29 +161,28 @@ def libgamma_native_name_of_error(value : int) -> str: def libgamma_native_value_of_error(name : str) -> int: ''' - Return the value of a `libgamma` error definition refered to by name. + Return the value of a `libgamma` error definition refered to by name - @param name The name of the definition associated with the error code. + @param name The name of the definition associated with the error code @return The error code, zero if the name is `None`, - or does not refer to a `libgamma` error. + or does not refer to a `libgamma` error ''' cdef bytes bs if name is None: return 0 bs = name.encode('utf-8') + bytes([0]) return int(libgamma_value_of_error(bs)) - + def strerror(error : int) -> str: ''' - Get a textual description of an error. + Get a textual description of an error - @param error The number of the error. - @return The description of the error. + @param error The number of the error + @return The description of the error ''' - cdef const char* text + cdef const char *text cdef bytes bs text = c_strerror(<int>error) bs = text return bs.decode('utf-8', 'strict') - diff --git a/src/libgamma_native_error.w32.pyx b/libgamma_native_error.w32.pyx index abef314..21548f0 100644 --- a/src/libgamma_native_error.w32.pyx +++ b/libgamma_native_error.w32.pyx @@ -1,29 +1,12 @@ # -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - +# See LICENSE file for copyright and license details. cimport cython cdef extern short libgamma_group_gid ''' Group that the user needs to be a member of if -`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. +`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' cdef extern const char* libgamma_group_name @@ -31,11 +14,11 @@ cdef extern const char* libgamma_group_name Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `NULL` if the name of the group `libgamma_group_gid` -cannot be determined. +cannot be determined ''' -cdef extern void libgamma_perror(const char* name, int error_code) nogil +cdef extern void libgamma_perror(const char *name, int error_code) nogil ''' Prints an error to stderr in a `perror` fashion, however this function will not translate the `libgamma` @@ -50,58 +33,58 @@ the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the required group will be printed with its numerical value and, if known, its name. -@param name The text to add at the beginning. -@param value The error code, may be an `errno` value. +@param name The text to add at the beginning +@param value The error code, may be an `errno` value ''' -cdef extern const char* libgamma_name_of_error(int value) nogil +cdef extern const char *libgamma_name_of_error(int value) nogil ''' -Returns the name of the definition associated with a `libgamma` error code. +Returns the name of the definition associated with a `libgamma` error code -@param value The error code. +@param value The error code @return The name of the definition associated with the error code, `NULL` if the error code does not exist. The return string - should not be `free`:d. + should not be `free`:d ''' -cdef extern int libgamma_value_of_error(const char* name) nogil +cdef extern int libgamma_value_of_error(const char *name) nogil ''' -Return the value of a `libgamma` error definition refered to by name. +Return the value of a `libgamma` error definition refered to by name -@param name The name of the definition associated with the error code. +@param name The name of the definition associated with the error code @return The error code, zero if the name does is `NULL` - or does not refer to a `libgamma` error. + or does not refer to a `libgamma` error ''' - def libgamma_native_get_group_gid() -> int: ''' - Getter. + Getter Group that the user needs to be a member of if - `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. + `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' return int(libgamma_group_gid) + def libgamma_native_set_group_gid(gid : int): ''' - Setter. + Setter Group that the user needs to be a member of if - `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. + `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned ''' libgamma_group_gid = <int>gid def libgamma_native_get_group_name() -> str: ''' - Getter. + Getter Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `None` if the name of the group `libgamma_group_gid` - cannot be determined. + cannot be determined ''' cdef bytes bs if libgamma_group_name is NULL: @@ -109,18 +92,19 @@ def libgamma_native_get_group_name() -> str: bs = libgamma_group_name return bs.decode('utf-8', 'strict') + def libgamma_native_set_group_name(name : str): ''' - Setter. + Setter Group that the user needs to be a member of if `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, `None` if the name of the group `libgamma_group_gid` - cannot be determined. + cannot be determined ''' cdef bytes bs if name is None: - libgamma_group_name = <char*>NULL + libgamma_group_name = <char *>NULL return bs = name.encode('utf-8') + bytes([0]) libgamma_group_name = bs @@ -141,8 +125,8 @@ def libgamma_native_perror(name : str, error_code : int): required group will be printed with its numerical value and, if known, its name. - @param name The text to add at the beginning. - @param value The error code, may be an `errno` value. + @param name The text to add at the beginning + @param value The error code, may be an `errno` value ''' cdef bytes bs bs = name.encode('utf-8') + bytes([0]) @@ -151,12 +135,12 @@ def libgamma_native_perror(name : str, error_code : int): def libgamma_native_name_of_error(value : int) -> str: ''' - Returns the name of the definition associated with a `libgamma` error code. + Returns the name of the definition associated with a `libgamma` error code - @param value The error code. + @param value The error code @return The name of the definition associated with the error code, `None` if the error code does not exist. The return string - should not be `free`:d. + should not be `free`:d ''' cdef const char* name cdef bytes bs @@ -169,15 +153,15 @@ def libgamma_native_name_of_error(value : int) -> str: def libgamma_native_value_of_error(name : str) -> int: ''' - Return the value of a `libgamma` error definition refered to by name. + Return the value of a `libgamma` error definition refered to by name - @param name The name of the definition associated with the error code. + @param name The name of the definition associated with the error code @return The error code, zero if the name is `None`, - or does not refer to a `libgamma` error. + or does not refer to a `libgamma` error ''' cdef bytes bs if name is None: return 0 bs = name.encode('utf-8') + bytes([0]) return int(libgamma_value_of_error(bs)) - + diff --git a/src/libgamma_native_facade.pyx b/libgamma_native_facade.pyx index 32846e2..19da8b1 100644 --- a/src/libgamma_native_facade.pyx +++ b/libgamma_native_facade.pyx @@ -1,22 +1,5 @@ # -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - +# See LICENSE file for copyright and license details. cimport cython from libc.stddef cimport size_t @@ -28,90 +11,88 @@ from libc.errno cimport errno ctypedef int libgamma_subpixel_order_t ctypedef int libgamma_connector_type_t - cdef extern from "include-libgamma.h": - + ctypedef struct libgamma_method_capabilities_t: - # Capabilities of adjustment methods. - + # Capabilities of adjustment methods + int32_t crtc_information # OR of the CRTC information fields in `libgamma_crtc_information_t` - # that may (but can fail) be read successfully. - + # that may (but can fail) be read successfully + unsigned default_site_known # : 1 # Whether the default site is known, if true the site is integrated - # to the system or can be determined using environment variables. - + # to the system or can be determined using environment variables + unsigned multiple_sites # : 1 # Whether the adjustment method supports multiple sites rather - # than just the default site. - + # than just the default site + unsigned multiple_partitions # : 1 # Whether the adjustment method supports multiple partitions - # per site. - + # per site + unsigned multiple_crtcs # : 1 # Whether the adjustment method supports multiple CRTC:s - # per partition per site. - + # per partition per site + unsigned partitions_are_graphics_cards # : 1 - # Whether the partition to graphics card is a bijection. - + # Whether the partition to graphics card is a bijection + unsigned site_restore # : 1 - # Whether the adjustment method supports `libgamma_site_restore`. - + # Whether the adjustment method supports `libgamma_site_restore` + unsigned partition_restore # : 1 - # Whether the adjustment method supports `libgamma_partition_restore`. - + # Whether the adjustment method supports `libgamma_partition_restore` + unsigned crtc_restore # : 1 - # Whether the adjustment method supports `libgamma_crtc_restore`. - + # Whether the adjustment method supports `libgamma_crtc_restore` + unsigned identical_gamma_sizes # : 1 # Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size` # fields in `libgamma_crtc_information_t` will always have the same - # values as each other for the adjustment method. - + # values as each other for the adjustment method + unsigned fixed_gamma_size # : 1 # Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size` # fields in `libgamma_crtc_information_t` will always be filled with the - # same value for the adjustment method. - + # same value for the adjustment method + unsigned fixed_gamma_depth # : 1 # Whether the `gamma_depth` field in `libgamma_crtc_information_t` - # will always be filled with the same value for the adjustment method. - + # will always be filled with the same value for the adjustment method + unsigned real # : 1 - # Whether the adjustment method will actually perform adjustments. - + # Whether the adjustment method will actually perform adjustments + unsigned fake # : 1 - # Whether the adjustment method is implement using a translation layer. - - + # Whether the adjustment method is implement using a translation layer + ctypedef struct libgamma_site_state_t: - # Site state. + # Site state # # On operating systems that integrate a graphical environment # there is usually just one site. However, one systems with # pluggable graphics, like Unix-like systems such as GNU/Linux # and the BSD:s, there can usually be any (feasible) number of # sites. In X.org parlance they are called displays. - - void* data + + void *data # Adjustment method implementation specific data. # You as a user of this library should not touch this. - + int method # This field specifies, for the methods if this library, # which adjustment method (display server and protocol) - # is used to adjust the gamma ramps. - - char* site + # is used to adjust the gamma ramps + + char *site # The site identifier. It can either be `NULL` or a string. # `NULL` indicates the default site. On systems like the # Unix-like systems, where the graphics are pluggable, this # is usually resolved by an environment variable, such as # "DISPLAY" for X.org. - + size_t partitions_available # The number of partitions that is available on this site. # Probably the majority of display server only one partition @@ -122,10 +103,9 @@ cdef extern from "include-libgamma.h": # and the mapping from monitors to screens is a surjection. # On hardware-level adjustment methods, such as Direct # Rendering Manager, a partition is a graphics card. - - + ctypedef struct libgamma_partition_state_t: - # Partition state. + # Partition state # # Probably the majority of display server only one partition # per site. However, X.org can, and traditional used to have @@ -135,59 +115,56 @@ cdef extern from "include-libgamma.h": # and the mapping from monitors to screens is a surjection. # On hardware-level adjustment methods, such as Direct # Rendering Manager, a partition is a graphics card. - - void* data + + void *data # Adjustment method implementation specific data. # You as a user of this library should not touch this. - + libgamma_site_state_t* site - # The site this partition belongs to. - + # The site this partition belongs to + size_t partition - # The index of the partition. - + # The index of the partition + size_t crtcs_available # The number of CRTC:s that are available under this # partition. Note that the CRTC:s are not necessarily # online. - - + ctypedef struct libgamma_crtc_state_t: - # Cathode ray tube controller state. + # Cathode ray tube controller state # # The CRTC controls the gamma ramps for the # monitor that is plugged in to the connector - # that the CRTC belongs to. - + # that the CRTC belongs to + void* data # Adjustment method implementation specific data. # You as a user of this library should not touch this. - + libgamma_partition_state_t* partition - # The partition this CRTC belongs to. - + # The partition this CRTC belongs to + size_t crtc - # The index of the CRTC within its partition. - - + # The index of the CRTC within its partition + ctypedef struct libgamma_crtc_information_t: - # Cathode ray tube controller information data structure. - - unsigned char* edid + # Cathode ray tube controller information data structure + + unsigned char *edid # The Extended Display Identification Data associated with # the attached monitor. This is raw byte array that is usually # 128 bytes long. It is not NUL-terminate, rather its length # is stored in `edid_length`. - + size_t edid_length - # The length of `edid`. - + # The length of `edid` + int edid_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value # of an error identifier provided by this library. - - + size_t width_mm # The phyical width, in millimetres, of the viewport of the # attached monitor, as reported by the adjustment method. This @@ -196,13 +173,12 @@ cdef extern from "include-libgamma.h": # the estimate the size on its own. # Zero means that its is not applicable, which is the case # for projectors. - + int width_mm_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + size_t height_mm # The phyical height, in millimetres, of the viewport of the # attached monitor, as reported by the adjustment method. This @@ -211,13 +187,12 @@ cdef extern from "include-libgamma.h": # the estimate the size on its own. # Zero means that its is not applicable, which is the case # for projectors. - + int height_mm_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + size_t width_mm_edid # The phyical width, in millimetres, of the viewport of the # attached monitor, as reported by it the monitor's Extended @@ -227,13 +202,12 @@ cdef extern from "include-libgamma.h": # the EDID structure. # Zero means that its is not applicable, which is the case # for projectors. - + int width_mm_edid_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + size_t height_mm_edid # The phyical height, in millimetres, of the viewport of the # attached monitor, as reported by it the monitor's Extended @@ -243,88 +217,80 @@ cdef extern from "include-libgamma.h": # the EDID structure. # Zero means that its is not applicable, which is the case # for projectors. - + int height_mm_edid_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + size_t red_gamma_size - # The size of the encoding axis of the red gamma ramp. - + # The size of the encoding axis of the red gamma ramp + size_t green_gamma_size - # The size of the encoding axis of the green gamma ramp. - + # The size of the encoding axis of the green gamma ramp + size_t blue_gamma_size - # The size of the encoding axis of the blue gamma ramp. - + # The size of the encoding axis of the blue gamma ramp + int gamma_size_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + signed gamma_depth # The bit-depth of the value axes of gamma ramps, # -1 for single precision floating point, and -2 for - # double precision floating point. - + # double precision floating point + int gamma_depth_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + int gamma_support - # Non-zero gamma ramp adjustments are supported. - + # Non-zero gamma ramp adjustments are supported + int gamma_support_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + libgamma_subpixel_order_t subpixel_order # The layout of the subpixels. # You cannot count on this value --- especially for CRT:s --- # but it is provided anyway as a means of distinguishing monitors. - + int subpixel_order_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value # of an error identifier provided by this library. - - + int active - # Whether there is a monitors connected to the CRTC. - + # Whether there is a monitors connected to the CRTC + int active_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - - char* connector_name + # of an error identifier provided by this library + + char *connector_name # The name of the connector as designated by the display # server or as give by this library in case the display - # server lacks this feature. - + # server lacks this feature + int connector_name_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + libgamma_connector_type_t connector_type - # The type of the connector that is associated with the CRTC. - + # The type of the connector that is associated with the CRTC + int connector_type_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + float gamma_red # The gamma characteristics of the monitor as reported # in its Extended Display Information Data. The value @@ -333,7 +299,7 @@ cdef extern from "include-libgamma.h": # monitor this could be used to give a rought gamma # correction; simply divide the value with 2.2 and use # the result for the red channel in the gamma correction. - + float gamma_green # The gamma characteristics of the monitor as reported # in its Extended Display Information Data. The value @@ -342,7 +308,7 @@ cdef extern from "include-libgamma.h": # monitor this could be used to give a rought gamma # correction; simply divide the value with 2.2 and use # the result for the green channel in the gamma correction. - + float gamma_blue # The gamma characteristics of the monitor as reported # in its Extended Display Information Data. The value @@ -351,160 +317,123 @@ cdef extern from "include-libgamma.h": # monitor this could be used to give a rought gamma # correction; simply divide the value with 2.2 and use # the result for the blue channel in the gamma correction. - + int gamma_error # Zero on success, positive it holds the value `errno` had # when the reading failed, otherwise (negative) the value - # of an error identifier provided by this library. - - + # of an error identifier provided by this library + ctypedef struct libgamma_gamma_ramps8_t: - # Gamma ramp structure for 8-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint8_t* red - # The gamma ramp for the red channel. - uint8_t* green - # The gamma ramp for the green channel. - uint8_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 8-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint8_t *red # The gamma ramp for the red channel + uint8_t *green # The gamma ramp for the green channel + uint8_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_ramps16_t: - # Gamma ramp structure for 16-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint16_t* red - # The gamma ramp for the red channel. - uint16_t* green - # The gamma ramp for the green channel. - uint16_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 16-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint16_t *red # The gamma ramp for the red channel + uint16_t *green # The gamma ramp for the green channel + uint16_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_ramps32_t: - # Gamma ramp structure for 32-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint32_t* red - # The gamma ramp for the red channel. - uint32_t* green - # The gamma ramp for the green channel. - uint32_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 32-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint32_t *red # The gamma ramp for the red channel + uint32_t *green # The gamma ramp for the green channel + uint32_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_ramps64_t: - # Gamma ramp structure for 64-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint64_t* red - # The gamma ramp for the red channel. - uint64_t* green - # The gamma ramp for the green channel. - uint64_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 64-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint64_t *red # The gamma ramp for the red channel + uint64_t *green # The gamma ramp for the green channel + uint64_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_rampsf_t: - # Gamma ramp structure for `float` gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - float* red - # The gamma ramp for the red channel. - float* green - # The gamma ramp for the green channel. - float* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for `float` gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + float *red # The gamma ramp for the red channel + float *green # The gamma ramp for the green channel + float *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_rampsd_t: - # Gamma ramp structure for `double` gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - double* red - # The gamma ramp for the red channel. - double* green - # The gamma ramp for the green channel. - double* blue - # The gamma ramp for the blue channel. - - -cdef extern size_t libgamma_list_methods(int* methods, size_t buf_size, int operation) nogil + # Gamma ramp structure for `double` gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + double *red # The gamma ramp for the red channel + double *green # The gamma ramp for the green channel + double *blue # The gamma ramp for the blue channel + + +cdef extern size_t libgamma_list_methods(int *methods, size_t buf_size, int operation) nogil ''' -List available adjustment methods by their order of preference based on the environment. +List available adjustment methods by their order of preference based on the environment -@param methods Output array of methods, should be able to hold `LIBGAMMA_METHOD_COUNT` elements. +@param methods Output array of methods, should be able to hold `LIBGAMMA_METHOD_COUNT` elements @param buf_size The number of elements that fits in `methods`, it should be `LIBGAMMA_METHOD_COUNT`, This is used to avoid writing outside the output buffer if this library adds new - adjustment methods without the users of the library recompiling. + adjustment methods without the users of the library recompiling @param operation Allowed values: - 0: Methods that the environment suggests will work, excluding fake. - 1: Methods that the environment suggests will work, including fake. - 2: All real non-fake methods. - 3: All real methods. - 4: All methods. - Other values invoke undefined behaviour. + 0: Methods that the environment suggests will work, excluding fake + 1: Methods that the environment suggests will work, including fake + 2: All real non-fake methods + 3: All real methods + 4: All methods + Other values invoke undefined behaviour @return The number of element that have been stored in `methods`, or should - have been stored if the buffer was large enough. + have been stored if the buffer was large enough ''' cdef extern int libgamma_is_method_available(int method) nogil ''' Check whether an adjustment method is available, non-existing (invalid) methods will be -identified as not available under the rationale that the library may be out of date. +identified as not available under the rationale that the library may be out of date -@param method The adjustment method. -@return Whether the adjustment method is available. +@param method The adjustment method +@return Whether the adjustment method is available ''' -cdef extern void libgamma_method_capabilities(libgamma_method_capabilities_t* this, int method) nogil +cdef extern void libgamma_method_capabilities(libgamma_method_capabilities_t *this, int method) nogil ''' -Return the capabilities of an adjustment method. +Return the capabilities of an adjustment method @param this The data structure to fill with the method's capabilities -@param method The adjustment method (display server and protocol). +@param method The adjustment method (display server and protocol) ''' -cdef extern char* libgamma_method_default_site(int method) nogil +cdef extern char *libgamma_method_default_site(int method) nogil ''' -Return the default site for an adjustment method. +Return the default site for an adjustment method -@param method The adjustment method (display server and protocol.) +@param method The adjustment method (display server and protocol) @return The default site, `NULL` if it cannot be determined or if multiple sites are not supported by the adjustment - method. This value should not be `free`:d. + method. This value should not be `free`:d ''' -cdef extern const char* libgamma_method_default_site_variable(int method) nogil +cdef extern const char *libgamma_method_default_site_variable(int method) nogil ''' Return the default variable that determines -the default site for an adjustment method. +the default site for an adjustment method -@param method The adjustment method (display server and protocol.) +@param method The adjustment method (display server and protocol) @return The environ variables that is used to determine the default site. `NULL` if there is none, that is, if the method does not support multiple sites. @@ -512,13 +441,12 @@ the default site for an adjustment method. ''' - -cdef extern int libgamma_site_initialise(libgamma_site_state_t* this, int method, char* site) nogil +cdef extern int libgamma_site_initialise(libgamma_site_state_t *this, int method, char *site) nogil ''' -Initialise an allocated site state. +Initialise an allocated site state -@param this The site state to initialise. -@param method The adjustment method (display server and protocol.) +@param this The site state to initialise +@param method The adjustment method (display server and protocol) @param site The site identifier, unless it is `NULL` it must a `free`:able. One the state is destroyed the library will attempt to free it. There you should not free @@ -526,277 +454,268 @@ Initialise an allocated site state. or allocate on the stack. Note however that it will not be `free`:d if this function fails. @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern void libgamma_site_free(libgamma_site_state_t* this) nogil +cdef extern void libgamma_site_free(libgamma_site_state_t *this) nogil ''' Release all resources held by a site state -and free the site state pointer. +and free the site state pointer -@param this The site state. +@param this The site state ''' -cdef extern int libgamma_site_restore(libgamma_site_state_t* this) nogil +cdef extern int libgamma_site_restore(libgamma_site_state_t *this) nogil ''' -Restore the gamma ramps all CRTC:s with a site to the system settings. +Restore the gamma ramps all CRTC:s with a site to the system settings -@param this The site state. +@param this The site state @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - -cdef extern int libgamma_partition_initialise(libgamma_partition_state_t* this, libgamma_site_state_t* site, size_t partition) nogil +cdef extern int libgamma_partition_initialise(libgamma_partition_state_t *this, libgamma_site_state_t* site, size_t partition) nogil ''' -Initialise an allocated partition state. +Initialise an allocated partition state -@param this The partition state to initialise. +@param this The partition state to initialise @param site The site state for the site that the partition belongs to. -@param partition The index of the partition within the site. +@param partition The index of the partition within the site @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern void libgamma_partition_free(libgamma_partition_state_t* this) nogil +cdef extern void libgamma_partition_free(libgamma_partition_state_t *this) nogil ''' Release all resources held by a partition state -and free the partition state pointer. +and free the partition state pointer -@param this The partition state. +@param this The partition state ''' -cdef extern int libgamma_partition_restore(libgamma_partition_state_t* this) nogil +cdef extern int libgamma_partition_restore(libgamma_partition_state_t *this) nogil ''' -Restore the gamma ramps all CRTC:s with a partition to the system settings. +Restore the gamma ramps all CRTC:s with a partition to the system settings -@param this The partition state. +@param this The partition state @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - -cdef extern int libgamma_crtc_initialise(libgamma_crtc_state_t* this, libgamma_partition_state_t* partition, size_t crtc) nogil +cdef extern int libgamma_crtc_initialise(libgamma_crtc_state_t *this, libgamma_partition_state_t *partition, size_t crtc) nogil ''' -Initialise an allocated CRTC state. +Initialise an allocated CRTC state -@param this The CRTC state to initialise. -@param partition The partition state for the partition that the CRTC belongs to. -@param crtc The index of the CRTC within the partition. +@param this The CRTC state to initialise +@param partition The partition state for the partition that the CRTC belongs to +@param crtc The index of the CRTC within the partition @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern void libgamma_crtc_free(libgamma_crtc_state_t* this) nogil +cdef extern void libgamma_crtc_free(libgamma_crtc_state_t *this) nogil ''' Release all resources held by a CRTC state -and free the CRTC state pointer. +and free the CRTC state pointer -@param this The CRTC state. +@param this The CRTC state ''' -cdef extern int libgamma_crtc_restore(libgamma_crtc_state_t* this) nogil +cdef extern int libgamma_crtc_restore(libgamma_crtc_state_t *this) nogil ''' -Restore the gamma ramps for a CRTC to the system settings for that CRTC. +Restore the gamma ramps for a CRTC to the system settings for that CRTC @param this The CRTC state @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - -cdef extern int libgamma_get_crtc_information(libgamma_crtc_information_t* this, libgamma_crtc_state_t* crtc, int32_t fields) nogil +cdef extern int libgamma_get_crtc_information(libgamma_crtc_information_t *this, libgamma_crtc_state_t *crtc, int32_t fields) nogil ''' -Read information about a CRTC. +Read information about a CRTC -@param this Instance of a data structure to fill with the information about the CRTC. -@param crtc The state of the CRTC whose information should be read. -@param fields OR:ed identifiers for the information about the CRTC that should be read. -@return Zero on success, -1 on error. On error refer to the error reports in `this`. +@param this Instance of a data structure to fill with the information about the CRTC +@param crtc The state of the CRTC whose information should be read +@param fields OR:ed identifiers for the information about the CRTC that should be read +@return Zero on success, -1 on error; on error refer to the error reports in `this` ''' -cdef extern void libgamma_crtc_information_destroy(libgamma_crtc_information_t* this) nogil +cdef extern void libgamma_crtc_information_destroy(libgamma_crtc_information_t *this) nogil ''' -Release all resources in an information data structure for a CRTC. +Release all resources in an information data structure for a CRTC -@param this The CRTC information. +@param this The CRTC information ''' - -cdef extern int libgamma_crtc_get_gamma_ramps8(libgamma_crtc_state_t* this, libgamma_gamma_ramps8_t* ramps) nogil +cdef extern int libgamma_crtc_get_gamma_ramps8(libgamma_crtc_state_t *this, libgamma_gamma_ramps8_t *ramps) nogil ''' -Get the current gamma ramps for a CRTC, 8-bit gamma-depth version. +Get the current gamma ramps for a CRTC, 8-bit gamma-depth version -@param this The CRTC state. +@param this The CRTC state @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern int libgamma_crtc_set_gamma_ramps8(libgamma_crtc_state_t* this, libgamma_gamma_ramps8_t ramps) nogil +cdef extern int libgamma_crtc_set_gamma_ramps8(libgamma_crtc_state_t *this, libgamma_gamma_ramps8_t ramps) nogil ''' -Set the gamma ramps for a CRTC, 8-bit gamma-depth version. +Set the gamma ramps for a CRTC, 8-bit gamma-depth version -@param this The CRTC state. -@param ramps The gamma ramps to apply. +@param this The CRTC state +@param ramps The gamma ramps to apply @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - -cdef extern int libgamma_crtc_get_gamma_ramps16(libgamma_crtc_state_t* this, libgamma_gamma_ramps16_t* ramps) nogil +cdef extern int libgamma_crtc_get_gamma_ramps16(libgamma_crtc_state_t *this, libgamma_gamma_ramps16_t *ramps) nogil ''' -Get the current gamma ramps for a CRTC, 16-bit gamma-depth version. +Get the current gamma ramps for a CRTC, 16-bit gamma-depth version -@param this The CRTC state. +@param this The CRTC state @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern int libgamma_crtc_set_gamma_ramps16(libgamma_crtc_state_t* this, libgamma_gamma_ramps16_t ramps) nogil +cdef extern int libgamma_crtc_set_gamma_ramps16(libgamma_crtc_state_t *this, libgamma_gamma_ramps16_t ramps) nogil ''' -Set the gamma ramps for a CRTC, 16-bit gamma-depth version. +Set the gamma ramps for a CRTC, 16-bit gamma-depth version -@param this The CRTC state. -@param ramps The gamma ramps to apply. +@param this The CRTC state +@param ramps The gamma ramps to apply @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - -cdef extern int libgamma_crtc_get_gamma_ramps32(libgamma_crtc_state_t* this, libgamma_gamma_ramps32_t* ramps) nogil +cdef extern int libgamma_crtc_get_gamma_ramps32(libgamma_crtc_state_t *this, libgamma_gamma_ramps32_t *ramps) nogil ''' -Get the current gamma ramps for a CRTC, 32-bit gamma-depth version. +Get the current gamma ramps for a CRTC, 32-bit gamma-depth version -@param this The CRTC state. -@param ramps The gamma ramps to fill with the current values. +@param this The CRTC state +@param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern int libgamma_crtc_set_gamma_ramps32(libgamma_crtc_state_t* this, libgamma_gamma_ramps32_t ramps) nogil +cdef extern int libgamma_crtc_set_gamma_ramps32(libgamma_crtc_state_t *this, libgamma_gamma_ramps32_t ramps) nogil ''' -Set the gamma ramps for a CRTC, 32-bit gamma-depth version. +Set the gamma ramps for a CRTC, 32-bit gamma-depth version -@param this The CRTC state. -@param ramps The gamma ramps to apply. +@param this The CRTC state +@param ramps The gamma ramps to apply @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - -cdef extern int libgamma_crtc_get_gamma_ramps64(libgamma_crtc_state_t* this, libgamma_gamma_ramps64_t* ramps) nogil +cdef extern int libgamma_crtc_get_gamma_ramps64(libgamma_crtc_state_t *this, libgamma_gamma_ramps64_t *ramps) nogil ''' -Get the current gamma ramps for a CRTC, 64-bit gamma-depth version. +Get the current gamma ramps for a CRTC, 64-bit gamma-depth version -@param this The CRTC state. -@param ramps The gamma ramps to fill with the current values. +@param this The CRTC state +@param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern int libgamma_crtc_set_gamma_ramps64(libgamma_crtc_state_t* this, libgamma_gamma_ramps64_t ramps) nogil +cdef extern int libgamma_crtc_set_gamma_ramps64(libgamma_crtc_state_t *this, libgamma_gamma_ramps64_t ramps) nogil ''' -Set the gamma ramps for a CRTC, 64-bit gamma-depth version. +Set the gamma ramps for a CRTC, 64-bit gamma-depth version -@param this The CRTC state. -@param ramps The gamma ramps to apply. +@param this The CRTC state +@param ramps The gamma ramps to apply @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - -cdef extern int libgamma_crtc_set_gamma_rampsf(libgamma_crtc_state_t* this, libgamma_gamma_rampsf_t ramps) nogil +cdef extern int libgamma_crtc_get_gamma_rampsf(libgamma_crtc_state_t *this, libgamma_gamma_rampsf_t *ramps) nogil ''' -Set the gamma ramps for a CRTC, `float` version. +Get the current gamma ramps for a CRTC, `float` version -@param this The CRTC state. -@param ramps The gamma ramps to apply. +@param this The CRTC state +@param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern int libgamma_crtc_get_gamma_rampsf(libgamma_crtc_state_t* this, libgamma_gamma_rampsf_t* ramps) nogil +cdef extern int libgamma_crtc_set_gamma_rampsf(libgamma_crtc_state_t *this, libgamma_gamma_rampsf_t ramps) nogil ''' -Get the current gamma ramps for a CRTC, `float` version. +Set the gamma ramps for a CRTC, `float` version -@param this The CRTC state. -@param ramps The gamma ramps to fill with the current values. +@param this The CRTC state +@param ramps The gamma ramps to apply @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern int libgamma_crtc_get_gamma_rampsd(libgamma_crtc_state_t* this, libgamma_gamma_rampsd_t* ramps) nogil +cdef extern int libgamma_crtc_get_gamma_rampsd(libgamma_crtc_state_t *this, libgamma_gamma_rampsd_t *ramps) nogil ''' -Get the current gamma ramps for a CRTC, `double` version. +Get the current gamma ramps for a CRTC, `double` version -@param this The CRTC state. -@param ramps The gamma ramps to fill with the current values. +@param this The CRTC state +@param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' -cdef extern int libgamma_crtc_set_gamma_rampsd(libgamma_crtc_state_t* this, libgamma_gamma_rampsd_t ramps) nogil +cdef extern int libgamma_crtc_set_gamma_rampsd(libgamma_crtc_state_t *this, libgamma_gamma_rampsd_t ramps) nogil ''' -Set the gamma ramps for a CRTC, `double` version. +Set the gamma ramps for a CRTC, `double` version -@param this The CRTC state. -@param ramps The gamma ramps to apply. +@param this The CRTC state +@param ramps The gamma ramps to apply @return Zero on success, otherwise (negative) the value of an - error identifier provided by this library. + error identifier provided by this library ''' - def libgamma_native_list_methods(operation : int) -> list: ''' - List available adjustment methods by their order of preference based on the environment. + List available adjustment methods by their order of preference based on the environment @param operation Allowed values: - 0: Methods that the environment suggests will work, excluding fake. - 1: Methods that the environment suggests will work, including fake. - 2: All real non-fake methods. - 3: All real methods. - 4: All methods. - Other values invoke undefined behaviour. - @return :list<int> A list of available adjustment methods. + 0: Methods that the environment suggests will work, excluding fake + 1: Methods that the environment suggests will work, including fake + 2: All real non-fake methods + 3: All real methods + 4: All methods + Other values invoke undefined behaviour + @return :list<int> A list of available adjustment methods ''' - cdef int* methods + cdef int *methods cdef size_t buf_size cdef size_t r buf_size = 6 - methods = <int*>malloc(buf_size * sizeof(size_t)) + methods = <int *>malloc(buf_size * sizeof(size_t)) if methods == NULL: raise MemoryError() r = libgamma_list_methods(methods, buf_size, operation) if r > buf_size: buf_size = r free(methods) - methods = <int*>malloc(buf_size * sizeof(size_t)) + methods = <int *>malloc(buf_size * sizeof(size_t)) if methods == NULL: raise MemoryError() libgamma_list_methods(methods, buf_size, operation) @@ -810,20 +729,20 @@ def libgamma_native_list_methods(operation : int) -> list: def libgamma_native_is_method_available(method : int) -> int: ''' Check whether an adjustment method is available, non-existing (invalid) methods will be - identified as not available under the rationale that the library may be out of date. + identified as not available under the rationale that the library may be out of date - @param method The adjustment method. - @return Whether the adjustment method is available. + @param method The adjustment method + @return Whether the adjustment method is available ''' return int(libgamma_is_method_available(<int>method)) def libgamma_native_method_capabilities(method : int) -> tuple: ''' - Return the capabilities of an adjustment method. + Return the capabilities of an adjustment method - @param method The adjustment method (display server and protocol). - @return :(int, int) Input parameters for `MethodCapabilities.__init__`. + @param method The adjustment method (display server and protocol) + @return :(int, int) Input parameters for `MethodCapabilities.__init__` ''' cdef libgamma_method_capabilities_t caps libgamma_method_capabilities(&caps, <int>method) @@ -847,14 +766,14 @@ def libgamma_native_method_capabilities(method : int) -> tuple: def libgamma_native_method_default_site(method : int) -> str: ''' - Return the default site for an adjustment method. + Return the default site for an adjustment method - @param method The adjustment method (display server and protocol.) + @param method The adjustment method (display server and protocol) @return The default site, `None` if it cannot be determined or if multiple sites are not supported by the adjustment - method. + method ''' - cdef char* var + cdef char *var cdef bytes bs var = libgamma_method_default_site(<int>method) if var is NULL: @@ -866,14 +785,14 @@ def libgamma_native_method_default_site(method : int) -> str: def libgamma_native_method_default_site_variable(method : int) -> str: ''' Return the default variable that determines - the default site for an adjustment method. + the default site for an adjustment method - @param method The adjustment method (display server and protocol.) + @param method The adjustment method (display server and protocol) @return The environ variables that is used to determine the default site. `None` if there is none, that is, if the method does not support multiple sites. ''' - cdef const char* var + cdef const char *var cdef bytes bs var = libgamma_method_default_site_variable(<int>method) if var is NULL: @@ -882,12 +801,11 @@ def libgamma_native_method_default_site_variable(method : int) -> str: return bs.decode('utf-8', 'strict') - def libgamma_native_site_create(method : int, site : str) -> tuple: ''' - Create an allocated site state. + Create an allocated site state - @param method The adjustment method (display server and protocol.) + @param method The adjustment method (display server and protocol) @param site The site identifier, unless it is `NULL` it must a `free`:able. One the state is destroyed the library will attempt to free it. There you should not free @@ -897,19 +815,19 @@ def libgamma_native_site_create(method : int, site : str) -> tuple: @return :(site:int, partitions:int) First value: The created site, zero on error Second value: The number of partitions in the site, on error: the value of the error identifier - provided by this library or `errno`. + provided by this library or `errno` ''' - cdef libgamma_site_state_t* this - cdef char* site_ + cdef libgamma_site_state_t *this + cdef char *site_ cdef size_t this_address - this = <libgamma_site_state_t*>malloc(sizeof(libgamma_site_state_t)) + this = <libgamma_site_state_t *>malloc(sizeof(libgamma_site_state_t)) if this is NULL: raise MemoryError() - this_address = <size_t><void*>this + this_address = <size_t><void *>this site_ = NULL if site is not None: site_bs = site.encode('utf-8') + bytes([0]) - site_ = <char*>malloc(len(site_bs) * sizeof(char)) + site_ = <char *>malloc(len(site_bs) * sizeof(char)) if site_ is None: free(this) raise MemoryError() @@ -925,55 +843,54 @@ def libgamma_native_site_create(method : int, site : str) -> tuple: def libgamma_native_site_free(this : int): ''' Release all resources held by a site state - and free the CRTC state pointer. + and free the CRTC state pointer - @param this The site state. + @param this The site state ''' cdef size_t this_address - cdef libgamma_site_state_t* this_ + cdef libgamma_site_state_t *this_ this_address = <size_t>this - this_ = <libgamma_site_state_t*><void*>this_address + this_ = <libgamma_site_state_t *><void *>this_address libgamma_site_free(this_) def libgamma_native_site_restore(this : int) -> int: ''' - Restore the gamma ramps all CRTC:s with a site to the system settings. + Restore the gamma ramps all CRTC:s with a site to the system settings - @param this The site state. + @param this The site state @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address - cdef libgamma_site_state_t* this_ + cdef libgamma_site_state_t *this_ this_address = <size_t>this - this_ = <libgamma_site_state_t*><void*>this_address + this_ = <libgamma_site_state_t *><void *>this_address r = int(libgamma_site_restore(this_)) return int(errno) if r == -1 else r - def libgamma_native_partition_create(site : int, partition : int) -> tuple: ''' - Create an allocated partition state. + Create an allocated partition state - @param site The site state for the site that the partition belongs to. - @param partition The index of the partition within the site. + @param site The site state for the site that the partition belongs to + @param partition The index of the partition within the site @return :(site:int, partitions:int) First value: The created partition, zero on error Second value: The number of CRTC:s in the partition, on error: the value of the error identifier - provided by this library or `errno`. + provided by this library or `errno` ''' - cdef libgamma_partition_state_t* this - cdef libgamma_site_state_t* site_ + cdef libgamma_partition_state_t *this + cdef libgamma_site_state_t *site_ cdef size_t this_address cdef size_t site_address site_address = <size_t>site - site_ = <libgamma_site_state_t*><void*>site_address - this = <libgamma_partition_state_t*>malloc(sizeof(libgamma_partition_state_t)) + site_ = <libgamma_site_state_t *><void *>site_address + this = <libgamma_partition_state_t *>malloc(sizeof(libgamma_partition_state_t)) if this is NULL: raise MemoryError() - this_address = <size_t><void*>this + this_address = <size_t><void *>this r = int(libgamma_partition_initialise(this, site_, <size_t>partition)) if not r == 0: libgamma_partition_free(this) @@ -984,54 +901,53 @@ def libgamma_native_partition_create(site : int, partition : int) -> tuple: def libgamma_native_partition_free(this : int): ''' Release all resources held by a partition state - and free the partition state pointer. + and free the partition state pointer - @param this The partition state. + @param this The partition state ''' cdef size_t this_address - cdef libgamma_partition_state_t* this_ + cdef libgamma_partition_state_t *this_ this_address = <size_t>this - this_ = <libgamma_partition_state_t*><void*>this_address + this_ = <libgamma_partition_state_t *><void *>this_address libgamma_partition_free(this_) def libgamma_native_partition_restore(this : int) -> int: ''' - Restore the gamma ramps all CRTC:s with a partition to the system settings. + Restore the gamma ramps all CRTC:s with a partition to the system settings - @param this The partition state. + @param this The partition state @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address - cdef libgamma_partition_state_t* this_ + cdef libgamma_partition_state_t *this_ this_address = <size_t>this - this_ = <libgamma_partition_state_t*><void*>this_address + this_ = <libgamma_partition_state_t *><void *>this_address r = int(libgamma_partition_restore(this_)) return int(errno) if r == -1 else r - def libgamma_native_crtc_create(partition : int, crtc : int) -> tuple: ''' - Create an allocated CRTC state. + Create an allocated CRTC state @param partition The partition state for the partition that the CRTC belongs to. - @param crtc The index of the CRTC within the partition. - @return :(int, int) First value: The created CRTC, zero on error. + @param crtc The index of the CRTC within the partition + @return :(int, int) First value: The created CRTC, zero on error Second value: Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' - cdef libgamma_crtc_state_t* this - cdef libgamma_partition_state_t* partition_ + cdef libgamma_crtc_state_t *this + cdef libgamma_partition_state_t *partition_ cdef size_t this_address cdef size_t partition_address partition_address = <size_t>partition - partition_ = <libgamma_partition_state_t*><void*>partition_address - this = <libgamma_crtc_state_t*>malloc(sizeof(libgamma_crtc_state_t)) + partition_ = <libgamma_partition_state_t *><void *>partition_address + this = <libgamma_crtc_state_t *>malloc(sizeof(libgamma_crtc_state_t)) if this is NULL: raise MemoryError() - this_address = <size_t><void*>this + this_address = <size_t><void *>this r = int(libgamma_crtc_initialise(this, partition_, <size_t>crtc)) if not r == 0: libgamma_crtc_free(this) @@ -1042,50 +958,49 @@ def libgamma_native_crtc_create(partition : int, crtc : int) -> tuple: def libgamma_native_crtc_free(this : int): ''' Release all resources held by a CRTC state - and free the CRTC state pointer. + and free the CRTC state pointer - @param this The CRTC state. + @param this The CRTC state ''' cdef size_t this_address - cdef libgamma_crtc_state_t* this_ + cdef libgamma_crtc_state_t *this_ this_address = <size_t>this - this_ = <libgamma_crtc_state_t*><void*>this_address + this_ = <libgamma_crtc_state_t *><void *>this_address libgamma_crtc_free(this_) def libgamma_native_crtc_restore(this : int) -> int: ''' - Restore the gamma ramps for a CRTC to the system settings for that CRTC. + Restore the gamma ramps for a CRTC to the system settings for that CRTC @param this The CRTC state @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address - cdef libgamma_crtc_state_t* this_ + cdef libgamma_crtc_state_t *this_ this_address = <size_t>this - this_ = <libgamma_crtc_state_t*><void*>this_address + this_ = <libgamma_crtc_state_t *><void *>this_address r = int(libgamma_crtc_restore(this_)) return int(errno) if r == -1 else r - def libgamma_native_get_crtc_information(crtc : int, fields : int) -> tuple: ''' - Read information about a CRTC. + Read information about a CRTC - @param crtc The state of the CRTC whose information should be read. - @param field OR:ed identifiers for the information about the CRTC that should be read. + @param crtc The state of the CRTC whose information should be read + @param field OR:ed identifiers for the information about the CRTC that should be read @return :(list, :int) First value: Input parametrs for `CRTCInformation.__init__` - Second value: Zero on success, -1 on error. On error refer to - the error reports in the return. + Second value: Zero on success, -1 on error; on error refer to + the error reports in the return ''' cdef libgamma_crtc_information_t info cdef size_t crtc_address - cdef libgamma_crtc_state_t* crtc_ + cdef libgamma_crtc_state_t *crtc_ cdef bytes bs crtc_address = <size_t>crtc - crtc_ = <libgamma_crtc_state_t*><void*>crtc_address + crtc_ = <libgamma_crtc_state_t *><void *>crtc_address r = int(libgamma_get_crtc_information(&info, crtc_, <int32_t>fields)) rc = [] connector_name = None @@ -1130,260 +1045,253 @@ def libgamma_native_get_crtc_information(crtc : int, fields : int) -> tuple: return (rc, r) - def libgamma_native_crtc_get_gamma_ramps8(this : int, ramps : int) -> int: ''' - Get the current gamma ramps for a CRTC, 8-bit gamma-depth version. + Get the current gamma ramps for a CRTC, 8-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to fill with the current values. + @param this The CRTC state + @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps8_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_ramps8_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps8_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps8_t *><void *>ramps_address r = int(libgamma_crtc_get_gamma_ramps8(this_, ramps_)) return int(errno) if r == -1 else r def libgamma_native_crtc_set_gamma_ramps8(this : int, ramps : int) -> int: ''' - Set the gamma ramps for a CRTC, 8-bit gamma-depth version. + Set the gamma ramps for a CRTC, 8-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to apply. + @param this The CRTC state + @param ramps The gamma ramps to apply @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps8_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_ramps8_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps8_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps8_t *><void *>ramps_address r = int(libgamma_crtc_set_gamma_ramps8(this_, ramps_[0])) return int(errno) if r == -1 else r - def libgamma_native_crtc_get_gamma_ramps16(this : int, ramps : int) -> int: ''' - Get the current gamma ramps for a CRTC, 16-bit gamma-depth version. + Get the current gamma ramps for a CRTC, 16-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to fill with the current values. + @param this The CRTC state + @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps16_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_ramps16_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps16_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps16_t *><void *>ramps_address r = int(libgamma_crtc_get_gamma_ramps16(this_, ramps_)) return int(errno) if r == -1 else r def libgamma_native_crtc_set_gamma_ramps16(this : int, ramps : int) -> int: ''' - Set the gamma ramps for a CRTC, 16-bit gamma-depth version. + Set the gamma ramps for a CRTC, 16-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to apply. + @param this The CRTC state + @param ramps The gamma ramps to apply @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps16_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_ramps16_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps16_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps16_t *><void *>ramps_address r = int(libgamma_crtc_set_gamma_ramps16(this_, ramps_[0])) return int(errno) if r == -1 else r - def libgamma_native_crtc_get_gamma_ramps32(this : int, ramps : int) -> int: ''' - Get the current gamma ramps for a CRTC, 32-bit gamma-depth version. + Get the current gamma ramps for a CRTC, 32-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to fill with the current values. + @param this The CRTC state + @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps32_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_ramps32_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps32_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps32_t *><void *>ramps_address r = int(libgamma_crtc_get_gamma_ramps32(this_, ramps_)) return int(errno) if r == -1 else r def libgamma_native_crtc_set_gamma_ramps32(this : int, ramps : int) -> int: ''' - Set the gamma ramps for a CRTC, 32-bit gamma-depth version. + Set the gamma ramps for a CRTC, 32-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to apply. + @param this The CRTC state + @param ramps The gamma ramps to apply @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps32_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_ramps32_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps32_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps32_t *><void *>ramps_address r = int(libgamma_crtc_set_gamma_ramps32(this_, ramps_[0])) return int(errno) if r == -1 else r - def libgamma_native_crtc_get_gamma_ramps64(this : int, ramps : int) -> int: ''' - Get the current gamma ramps for a CRTC, 64-bit gamma-depth version. + Get the current gamma ramps for a CRTC, 64-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to fill with the current values. + @param this The CRTC state + @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps64_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_ramps64_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps64_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps64_t *><void *>ramps_address r = int(libgamma_crtc_get_gamma_ramps64(this_, ramps_)) return int(errno) if r == -1 else r def libgamma_native_crtc_set_gamma_ramps64(this : int, ramps : int) -> int: ''' - Set the gamma ramps for a CRTC, 64-bit gamma-depth version. + Set the gamma ramps for a CRTC, 64-bit gamma-depth version - @param this The CRTC state. - @param ramps The gamma ramps to apply. + @param this The CRTC state + @param ramps The gamma ramps to apply @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_ramps64_t* ramps_ + cdef libgamma_crtc_state_t * this_ + cdef libgamma_gamma_ramps64_t * ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_ramps64_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_ramps64_t *><void *>ramps_address r = int(libgamma_crtc_set_gamma_ramps64(this_, ramps_[0])) return int(errno) if r == -1 else r - def libgamma_native_crtc_get_gamma_rampsf(this : int, ramps : int) -> int: ''' - Get the current gamma ramps for a CRTC, `float` version. + Get the current gamma ramps for a CRTC, `float` version - @param this The CRTC state. - @param ramps The gamma ramps to fill with the current values. + @param this The CRTC state + @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_rampsf_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_rampsf_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_rampsf_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_rampsf_t *><void *>ramps_address r = int(libgamma_crtc_get_gamma_rampsf(this_, ramps_)) return int(errno) if r == -1 else r def libgamma_native_crtc_set_gamma_rampsf(this : int, ramps : int) -> int: ''' - Set the gamma ramps for a CRTC, `float` version. + Set the gamma ramps for a CRTC, `float` version - @param this The CRTC state. - @param ramps The gamma ramps to apply. + @param this The CRTC state + @param ramps The gamma ramps to apply @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_rampsf_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_rampsf_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_rampsf_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_rampsf_t *><void *>ramps_address r = int(libgamma_crtc_set_gamma_rampsf(this_, ramps_[0])) return int(errno) if r == -1 else r - def libgamma_native_crtc_get_gamma_rampsd(this : int, ramps : int) -> int: ''' - Get the current gamma ramps for a CRTC, `double` version. + Get the current gamma ramps for a CRTC, `double` version - @param this The CRTC state. - @param ramps The gamma ramps to fill with the current values. + @param this The CRTC state + @param ramps The gamma ramps to fill with the current values @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_rampsd_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_rampsd_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_rampsd_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_rampsd_t *><void *>ramps_address r = int(libgamma_crtc_get_gamma_rampsd(this_, ramps_)) return int(errno) if r == -1 else r def libgamma_native_crtc_set_gamma_rampsd(this : int, ramps : int) -> int: ''' - Set the gamma ramps for a CRTC, `double` version. + Set the gamma ramps for a CRTC, `double` version - @param this The CRTC state. - @param ramps The gamma ramps to apply. + @param this The CRTC state + @param ramps The gamma ramps to apply @return Zero on success, otherwise the value of an error - identifier provided by this library or `errno`. + identifier provided by this library or `errno` ''' cdef size_t this_address cdef size_t ramps_address - cdef libgamma_crtc_state_t* this_ - cdef libgamma_gamma_rampsd_t* ramps_ + cdef libgamma_crtc_state_t *this_ + cdef libgamma_gamma_rampsd_t *ramps_ this_address = <size_t>this ramps_address = <size_t>ramps - this_ = <libgamma_crtc_state_t*><void*>this_address - ramps_ = <libgamma_gamma_rampsd_t*><void*>ramps_address + this_ = <libgamma_crtc_state_t *><void *>this_address + ramps_ = <libgamma_gamma_rampsd_t *><void *>ramps_address r = int(libgamma_crtc_set_gamma_rampsd(this_, ramps_[0])) return int(errno) if r == -1 else r - diff --git a/src/libgamma_native_method.pyx b/libgamma_native_method.pyx index 1550caf..96eee7c 100644 --- a/src/libgamma_native_method.pyx +++ b/libgamma_native_method.pyx @@ -1,22 +1,5 @@ # -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - +# See LICENSE file for copyright and license details. cimport cython from libc.stdint cimport * @@ -27,239 +10,196 @@ from libc.errno cimport errno cdef extern from "include-libgamma.h": ctypedef struct libgamma_gamma_ramps8_t: - # Gamma ramp structure for 8-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint8_t* red - # The gamma ramp for the red channel. - uint8_t* green - # The gamma ramp for the green channel. - uint8_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 8-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint8_t *red # The gamma ramp for the red channel + uint8_t *green # The gamma ramp for the green channel + uint8_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_ramps16_t: - # Gamma ramp structure for 16-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint16_t* red - # The gamma ramp for the red channel. - uint16_t* green - # The gamma ramp for the green channel. - uint16_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 16-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint16_t *red # The gamma ramp for the red channel + uint16_t *green # The gamma ramp for the green channel + uint16_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_ramps32_t: - # Gamma ramp structure for 32-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint32_t* red - # The gamma ramp for the red channel. - uint32_t* green - # The gamma ramp for the green channel. - uint32_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 32-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint32_t *red # The gamma ramp for the red channel + uint32_t *green # The gamma ramp for the green channel + uint32_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_ramps64_t: - # Gamma ramp structure for 64-bit gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - uint64_t* red - # The gamma ramp for the red channel. - uint64_t* green - # The gamma ramp for the green channel. - uint64_t* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for 64-bit gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + uint64_t *red # The gamma ramp for the red channel + uint64_t *green # The gamma ramp for the green channel + uint64_t *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_rampsf_t: - # Gamma ramp structure for `float` gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - float* red - # The gamma ramp for the red channel. - float* green - # The gamma ramp for the green channel. - float* blue - # The gamma ramp for the blue channel. - + # Gamma ramp structure for `float` gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + float *red # The gamma ramp for the red channel + float *green # The gamma ramp for the green channel + float *blue # The gamma ramp for the blue channel + ctypedef struct libgamma_gamma_rampsd_t: - # Gamma ramp structure for `double` gamma ramps. - size_t red_size - # The size of `red`. - size_t green_size - # The size of `green`. - size_t blue_size - # The size of `blue`. - double* red - # The gamma ramp for the red channel. - double* green - # The gamma ramp for the green channel. - double* blue - # The gamma ramp for the blue channel. - - -cdef extern int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t* this) nogil + # Gamma ramp structure for `double` gamma ramps + size_t red_size # The size of `red` + size_t green_size # The size of `green` + size_t blue_size # The size of `blue` + double *red # The gamma ramp for the red channel + double *green # The gamma ramp for the green channel + double *blue # The gamma ramp for the blue channel + +cdef extern int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t *this) nogil ''' Initialise a gamma ramp in the proper way that allows all adjustment -methods to read from and write to it without causing segmentation violation. +methods to read from and write to it without causing segmentation violation -The input must have `red_size`, `green_size` and `blue_size` set to the -sizes of the gamma ramps that should be allocated. +The input must have `red_size`, `green_size` and `blue_size` +set to the sizes of the gamma ramps that should be allocated -@param this The gamma ramps. -@return Zero on success, -1 on allocation error, `errno` will be set accordingly. +@param this The gamma ramps +@return Zero on success, -1 on allocation error, `errno` will be set accordingly ''' -cdef extern void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t* this) nogil +cdef extern void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t *this) nogil ''' Release resources that are held by a gamma ramp strcuture that -has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise -initialises in the proper manner, as well as release the pointer -to the structure. +has been allocated by `libgamma_gamma_ramps8_initialise` or +otherwise initialises in the proper manner, as well as release +the pointer to the structure -@param this The gamma ramps. +@param this The gamma ramps ''' - -cdef extern int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t* this) nogil +cdef extern int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t *this) nogil ''' Initialise a gamma ramp in the proper way that allows all adjustment -methods to read from and write to it without causing segmentation violation. +methods to read from and write to it without causing segmentation violation -The input must have `red_size`, `green_size` and `blue_size` set to the -sizes of the gamma ramps that should be allocated. +The input must have `red_size`, `green_size` and `blue_size` +set to the sizes of the gamma ramps that should be allocated -@param this The gamma ramps. -@return Zero on success, -1 on allocation error, `errno` will be set accordingly. +@param this The gamma ramps +@return Zero on success, -1 on allocation error, `errno` will be set accordingly ''' -cdef extern void libgamma_gamma_ramps16_free(libgamma_gamma_ramps16_t* this) nogil +cdef extern void libgamma_gamma_ramps16_free(libgamma_gamma_ramps16_t *this) nogil ''' Release resources that are held by a gamma ramp strcuture that -has been allocated by `libgamma_gamma_ramps16_initialise` or otherwise -initialises in the proper manner, as well as release the pointer -to the structure. +has been allocated by `libgamma_gamma_ramps16_initialise` or +otherwise initialises in the proper manner, as well as release +the pointer to the structure -@param this The gamma ramps. +@param this The gamma ramps ''' - -cdef extern int libgamma_gamma_ramps32_initialise(libgamma_gamma_ramps32_t* this) nogil +cdef extern int libgamma_gamma_ramps32_initialise(libgamma_gamma_ramps32_t *this) nogil ''' Initialise a gamma ramp in the proper way that allows all adjustment -methods to read from and write to it without causing segmentation violation. +methods to read from and write to it without causing segmentation violation -The input must have `red_size`, `green_size` and `blue_size` set to the -sizes of the gamma ramps that should be allocated. +The input must have `red_size`, `green_size` and `blue_size` +set to the sizes of the gamma ramps that should be allocated -@param this The gamma ramps. -@return Zero on success, -1 on allocation error, `errno` will be set accordingly. +@param this The gamma ramps +@return Zero on success, -1 on allocation error, `errno` will be set accordingly ''' -cdef extern void libgamma_gamma_ramps32_free(libgamma_gamma_ramps32_t* this) nogil +cdef extern void libgamma_gamma_ramps32_free(libgamma_gamma_ramps32_t *this) nogil ''' Release resources that are held by a gamma ramp strcuture that -has been allocated by `libgamma_gamma_ramps32_initialise` or otherwise -initialises in the proper manner, as well as release the pointer -to the structure. +has been allocated by `libgamma_gamma_ramps32_initialise` or +otherwise initialises in the proper manner, as well as release +the pointer to the structure -@param this The gamma ramps. +@param this The gamma ramps ''' - -cdef extern int libgamma_gamma_ramps64_initialise(libgamma_gamma_ramps64_t* this) nogil +cdef extern int libgamma_gamma_ramps64_initialise(libgamma_gamma_ramps64_t *this) nogil ''' Initialise a gamma ramp in the proper way that allows all adjustment -methods to read from and write to it without causing segmentation violation. +methods to read from and write to it without causing segmentation violation -The input must have `red_size`, `green_size` and `blue_size` set to the -sizes of the gamma ramps that should be allocated. +The input must have `red_size`, `green_size` and `blue_size` +set to the sizes of the gamma ramps that should be allocated -@param this The gamma ramps. -@return Zero on success, -1 on allocation error, `errno` will be set accordingly. +@param this The gamma ramps +@return Zero on success, -1 on allocation error, `errno` will be set accordingly ''' -cdef extern void libgamma_gamma_ramps64_free(libgamma_gamma_ramps64_t* this) nogil +cdef extern void libgamma_gamma_ramps64_free(libgamma_gamma_ramps64_t *this) nogil ''' Release resources that are held by a gamma ramp strcuture that -has been allocated by `libgamma_gamma_ramps64_initialise` or otherwise -initialises in the proper manner, as well as release the pointer -to the structure. +has been allocated by `libgamma_gamma_ramps64_initialise` or +otherwise initialises in the proper manner, as well as release +the pointer to the structure -@param this The gamma ramps. +@param this The gamma ramps ''' - -cdef extern int libgamma_gamma_rampsf_initialise(libgamma_gamma_rampsf_t* this) nogil +cdef extern int libgamma_gamma_rampsf_initialise(libgamma_gamma_rampsf_t *this) nogil ''' Initialise a gamma ramp in the proper way that allows all adjustment -methods to read from and write to it without causing segmentation violation. +methods to read from and write to it without causing segmentation violation -The input must have `red_size`, `green_size` and `blue_size` set to the -sizes of the gamma ramps that should be allocated. +The input must have `red_size`, `green_size` and `blue_size` +set to the sizes of the gamma ramps that should be allocated -@param this The gamma ramps. -@return Zero on success, -1 on allocation error, `errno` will be set accordingly. +@param this The gamma ramps +@return Zero on success, -1 on allocation error, `errno` will be set accordingly ''' -cdef extern void libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t* this) nogil +cdef extern void libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t *this) nogil ''' Release resources that are held by a gamma ramp strcuture that -has been allocated by `libgamma_gamma_rampsf_initialise` or otherwise -initialises in the proper manner, as well as release the pointer -to the structure. +has been allocated by `libgamma_gamma_rampsf_initialise` or +otherwise initialises in the proper manner, as well as release +the pointer to the structure -@param this The gamma ramps. +@param this The gamma ramps ''' - -cdef extern int libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t* this) nogil +cdef extern int libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t *this) nogil ''' Initialise a gamma ramp in the proper way that allows all adjustment -methods to read from and write to it without causing segmentation violation. +methods to read from and write to it without causing segmentation violation -The input must have `red_size`, `green_size` and `blue_size` set to the -sizes of the gamma ramps that should be allocated. +The input must have `red_size`, `green_size` and `blue_size` +set to the sizes of the gamma ramps that should be allocated @param this The gamma ramps -@return Zero on success, -1 on allocation error, `errno` will be set accordingly. +@return Zero on success, -1 on allocation error, `errno` will be set accordingly ''' -cdef extern void libgamma_gamma_rampsd_free(libgamma_gamma_rampsd_t* this) nogil +cdef extern void libgamma_gamma_rampsd_free(libgamma_gamma_rampsd_t *this) nogil ''' Release resources that are held by a gamma ramp strcuture that -has been allocated by `libgamma_gamma_rampsd_initialise` or otherwise -initialises in the proper manner, as well as release the pointer -to the structure. +has been allocated by `libgamma_gamma_rampsd_initialise` or +otherwise initialises in the proper manner, as well as release +the pointer to the structure -@param this The gamma ramps. +@param this The gamma ramps ''' - def libgamma_native_gamma_ramps8_create(red_size : int, green_size : int, blue_size : int): ''' - Create a gamma ramp in the proper way that allows all adjustment - methods to read from and write to it without causing segmentation violation. + Create a gamma ramp in the proper way that allows all adjustment methods + to read from and write to it without causing segmentation violation @param red_size The size of the gamma ramp for the red channel @param green_size The size of the gamma ramp for the green channel @@ -270,8 +210,8 @@ def libgamma_native_gamma_ramps8_create(red_size : int, green_size : int, blue_s Element 3: The address of the gamma ramp for the green channel Element 4: The address of the gamma ramp for the blue channel ''' - cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps8_t)) - cdef libgamma_gamma_ramps8_t* item = <libgamma_gamma_ramps8_t*>allocation + cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps8_t)) + cdef libgamma_gamma_ramps8_t *item = <libgamma_gamma_ramps8_t *>allocation cdef size_t red, green, blue if item is NULL: return int(errno) @@ -280,57 +220,56 @@ def libgamma_native_gamma_ramps8_create(red_size : int, green_size : int, blue_s item.blue_size = blue_size if libgamma_gamma_ramps8_initialise(item) < 0: return int(errno) - red = <size_t><void*>(item.red) - green = <size_t><void*>(item.green) - blue = <size_t><void*>(item.blue) + red = <size_t><void *>(item.red) + green = <size_t><void *>(item.green) + blue = <size_t><void *>(item.blue) return (int(<size_t>allocation), int(red), int(green), int(blue)) def libgamma_native_gamma_ramps8_free(this : int): ''' Release resources that are held by a gamma ramp strcuture that - has been allocated by `libgamma_native_gamma_ramps8_create` or otherwise - created in the proper manner, as well as release the pointer - to the structure. + has been allocated by `libgamma_native_gamma_ramps8_create` or + otherwise created in the proper manner, as well as release the + pointer to the structure - @param this The gamma ramps. + @param this The gamma ramps ''' - cdef void* address = <void*><size_t>this - cdef libgamma_gamma_ramps8_t* item = <libgamma_gamma_ramps8_t*>address + cdef void *address = <void *><size_t>this + cdef libgamma_gamma_ramps8_t *item = <libgamma_gamma_ramps8_t *>address libgamma_gamma_ramps8_free(item) def libgamma_native_gamma_ramps8_get(this : int, index : int) -> int: ''' - Read a stop in a gamma ramp. + Read a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @return The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @return The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint8_t* ramp = <uint8_t*>address + cdef void *address = <void *><size_t>this + cdef uint8_t *ramp = <uint8_t *>address return int(ramp[<size_t>index]) def libgamma_native_gamma_ramps8_set(this : int, index : int, value : int): ''' - Modify a stop in a gamma ramp. + Modify a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @param value The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @param value The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint8_t* ramp = <uint8_t*>address + cdef void *address = <void *><size_t>this + cdef uint8_t *ramp = <uint8_t *>address ramp[<size_t>index] = <uint8_t>value - def libgamma_native_gamma_ramps16_create(red_size : int, green_size : int, blue_size : int): ''' - Create a gamma ramp in the proper way that allows all adjustment - methods to read from and write to it without causing segmentation violation. + Create a gamma ramp in the proper way that allows all adjustment methods + to read from and write to it without causing segmentation violation @param red_size The size of the gamma ramp for the red channel @param green_size The size of the gamma ramp for the green channel @@ -341,8 +280,8 @@ def libgamma_native_gamma_ramps16_create(red_size : int, green_size : int, blue_ Element 3: The address of the gamma ramp for the green channel Element 4: The address of the gamma ramp for the blue channel ''' - cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps16_t)) - cdef libgamma_gamma_ramps16_t* item = <libgamma_gamma_ramps16_t*>allocation + cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps16_t)) + cdef libgamma_gamma_ramps16_t *item = <libgamma_gamma_ramps16_t *>allocation cdef size_t red, green, blue if item is NULL: return int(errno) @@ -351,57 +290,56 @@ def libgamma_native_gamma_ramps16_create(red_size : int, green_size : int, blue_ item.blue_size = blue_size if libgamma_gamma_ramps16_initialise(item) < 0: return int(errno) - red = <size_t><void*>(item.red) - green = <size_t><void*>(item.green) - blue = <size_t><void*>(item.blue) + red = <size_t><void *>(item.red) + green = <size_t><void *>(item.green) + blue = <size_t><void *>(item.blue) return (int(<size_t>allocation), int(red), int(green), int(blue)) def libgamma_native_gamma_ramps16_free(this : int): ''' Release resources that are held by a gamma ramp strcuture that - has been allocated by `libgamma_native_gamma_ramps16_create` or otherwise - created in the proper manner, as well as release the pointer - to the structure. + has been allocated by `libgamma_native_gamma_ramps16_create` or + otherwise created in the proper manner, as well as release the + pointer to the structure - @param this The gamma ramps. + @param this The gamma ramps ''' - cdef void* address = <void*><size_t>this - cdef libgamma_gamma_ramps16_t* item = <libgamma_gamma_ramps16_t*>address + cdef void *address = <void*><size_t>this + cdef libgamma_gamma_ramps16_t *item = <libgamma_gamma_ramps16_t *>address libgamma_gamma_ramps16_free(item) def libgamma_native_gamma_ramps16_get(this : int, index : int) -> int: ''' - Read a stop in a gamma ramp. + Read a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @return The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @return The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint16_t* ramp = <uint16_t*>address + cdef void *address = <void *><size_t>this + cdef uint16_t *ramp = <uint16_t *>address return int(ramp[<size_t>index]) def libgamma_native_gamma_ramps16_set(this : int, index : int, value : int): ''' - Modify a stop in a gamma ramp. + Modify a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @param value The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @param value The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint16_t* ramp = <uint16_t*>address + cdef void *address = <void *><size_t>this + cdef uint16_t *ramp = <uint16_t *>address ramp[<size_t>index] = <uint16_t>value - def libgamma_native_gamma_ramps32_create(red_size : int, green_size : int, blue_size : int): ''' - Create a gamma ramp in the proper way that allows all adjustment - methods to read from and write to it without causing segmentation violation. + Create a gamma ramp in the proper way that allows all adjustment methods + to read from and write to it without causing segmentation violation @param red_size The size of the gamma ramp for the red channel @param green_size The size of the gamma ramp for the green channel @@ -412,8 +350,8 @@ def libgamma_native_gamma_ramps32_create(red_size : int, green_size : int, blue_ Element 3: The address of the gamma ramp for the green channel Element 4: The address of the gamma ramp for the blue channel ''' - cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps32_t)) - cdef libgamma_gamma_ramps32_t* item = <libgamma_gamma_ramps32_t*>allocation + cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps32_t)) + cdef libgamma_gamma_ramps32_t *item = <libgamma_gamma_ramps32_t *>allocation cdef size_t red, green, blue if item is NULL: return int(errno) @@ -422,57 +360,56 @@ def libgamma_native_gamma_ramps32_create(red_size : int, green_size : int, blue_ item.blue_size = blue_size if libgamma_gamma_ramps32_initialise(item) < 0: return int(errno) - red = <size_t><void*>(item.red) - green = <size_t><void*>(item.green) - blue = <size_t><void*>(item.blue) + red = <size_t><void *>(item.red) + green = <size_t><void *>(item.green) + blue = <size_t><void *>(item.blue) return (int(<size_t>allocation), int(red), int(green), int(blue)) def libgamma_native_gamma_ramps32_free(this : int): ''' Release resources that are held by a gamma ramp strcuture that - has been allocated by `libgamma_native_gamma_ramps32_create` or otherwise - created in the proper manner, as well as release the pointer - to the structure. + has been allocated by `libgamma_native_gamma_ramps32_create` or + otherwise created in the proper manner, as well as release the + pointer to the structure - @param this The gamma ramps. + @param this The gamma ramps ''' - cdef void* address = <void*><size_t>this - cdef libgamma_gamma_ramps32_t* item = <libgamma_gamma_ramps32_t*>address + cdef void *address = <void *><size_t>this + cdef libgamma_gamma_ramps32_t *item = <libgamma_gamma_ramps32_t *>address libgamma_gamma_ramps32_free(item) def libgamma_native_gamma_ramps32_get(this : int, index : int) -> int: ''' - Read a stop in a gamma ramp. + Read a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @return The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @return The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint32_t* ramp = <uint32_t*>address + cdef void *address = <void *><size_t>this + cdef uint32_t *ramp = <uint32_t *>address return int(ramp[<size_t>index]) def libgamma_native_gamma_ramps32_set(this : int, index : int, value : int): ''' - Modify a stop in a gamma ramp. + Modify a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @param value The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @param value The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint32_t* ramp = <uint32_t*>address + cdef void *address = <void*><size_t>this + cdef uint32_t *ramp = <uint32_t *>address ramp[<size_t>index] = <uint32_t>value - def libgamma_native_gamma_ramps64_create(red_size : int, green_size : int, blue_size : int): ''' - Create a gamma ramp in the proper way that allows all adjustment - methods to read from and write to it without causing segmentation violation. + Create a gamma ramp in the proper way that allows all adjustment methods + to read from and write to it without causing segmentation violation @param red_size The size of the gamma ramp for the red channel @param green_size The size of the gamma ramp for the green channel @@ -483,8 +420,8 @@ def libgamma_native_gamma_ramps64_create(red_size : int, green_size : int, blue_ Element 3: The address of the gamma ramp for the green channel Element 4: The address of the gamma ramp for the blue channel ''' - cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps64_t)) - cdef libgamma_gamma_ramps64_t* item = <libgamma_gamma_ramps64_t*>allocation + cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps64_t)) + cdef libgamma_gamma_ramps64_t *item = <libgamma_gamma_ramps64_t *>allocation cdef size_t red, green, blue if item is NULL: return int(errno) @@ -493,57 +430,56 @@ def libgamma_native_gamma_ramps64_create(red_size : int, green_size : int, blue_ item.blue_size = blue_size if libgamma_gamma_ramps64_initialise(item) < 0: return int(errno) - red = <size_t><void*>(item.red) - green = <size_t><void*>(item.green) - blue = <size_t><void*>(item.blue) + red = <size_t><void *>(item.red) + green = <size_t><void *>(item.green) + blue = <size_t><void *>(item.blue) return (int(<size_t>allocation), int(red), int(green), int(blue)) def libgamma_native_gamma_ramps64_free(this : int): ''' Release resources that are held by a gamma ramp strcuture that - has been allocated by `libgamma_native_gamma_ramps64_create` or otherwise - created in the proper manner, as well as release the pointer - to the structure. + has been allocated by `libgamma_native_gamma_ramps64_create` or + otherwise created in the proper manner, as well as release the + pointer to the structure - @param this The gamma ramps. + @param this The gamma ramps ''' - cdef void* address = <void*><size_t>this - cdef libgamma_gamma_ramps64_t* item = <libgamma_gamma_ramps64_t*>address + cdef void *address = <void *><size_t>this + cdef libgamma_gamma_ramps64_t *item = <libgamma_gamma_ramps64_t *>address libgamma_gamma_ramps64_free(item) def libgamma_native_gamma_ramps64_get(this : int, index : int) -> int: ''' - Read a stop in a gamma ramp. + Read a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @return The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @return The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint64_t* ramp = <uint64_t*>address + cdef void *address = <void *><size_t>this + cdef uint64_t *ramp = <uint64_t *>address return int(ramp[<size_t>index]) def libgamma_native_gamma_ramps64_set(this : int, index : int, value : int): ''' - Modify a stop in a gamma ramp. + Modify a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @param value The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @param value The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef uint64_t* ramp = <uint64_t*>address + cdef void *address = <void *><size_t>this + cdef uint64_t *ramp = <uint64_t *>address ramp[<size_t>index] = <uint64_t>value - def libgamma_native_gamma_rampsf_create(red_size : int, green_size : int, blue_size : int): ''' - Create a gamma ramp in the proper way that allows all adjustment - methods to read from and write to it without causing segmentation violation. + Create a gamma ramp in the proper way that allows all adjustment methods + to read from and write to it without causing segmentation violation @param red_size The size of the gamma ramp for the red channel @param green_size The size of the gamma ramp for the green channel @@ -554,8 +490,8 @@ def libgamma_native_gamma_rampsf_create(red_size : int, green_size : int, blue_s Element 3: The address of the gamma ramp for the green channel Element 4: The address of the gamma ramp for the blue channel ''' - cdef void* allocation = malloc(sizeof(libgamma_gamma_rampsf_t)) - cdef libgamma_gamma_rampsf_t* item = <libgamma_gamma_rampsf_t*>allocation + cdef void *allocation = malloc(sizeof(libgamma_gamma_rampsf_t)) + cdef libgamma_gamma_rampsf_t *item = <libgamma_gamma_rampsf_t *>allocation cdef size_t red, green, blue if item is NULL: return int(errno) @@ -564,57 +500,56 @@ def libgamma_native_gamma_rampsf_create(red_size : int, green_size : int, blue_s item.blue_size = blue_size if libgamma_gamma_rampsf_initialise(item) < 0: return int(errno) - red = <size_t><void*>(item.red) - green = <size_t><void*>(item.green) - blue = <size_t><void*>(item.blue) + red = <size_t><void *>(item.red) + green = <size_t><void *>(item.green) + blue = <size_t><void *>(item.blue) return (int(<size_t>allocation), int(red), int(green), int(blue)) def libgamma_native_gamma_rampsf_free(this : int): ''' Release resources that are held by a gamma ramp strcuture that - has been allocated by `libgamma_native_gamma_rampsf_create` or otherwise - created in the proper manner, as well as release the pointer - to the structure. + has been allocated by `libgamma_native_gamma_rampsf_create` or + otherwise created in the proper manner, as well as release the + pointer to the structure - @param this The gamma ramps. + @param this The gamma ramps ''' - cdef void* address = <void*><size_t>this - cdef libgamma_gamma_rampsf_t* item = <libgamma_gamma_rampsf_t*>address + cdef void *address = <void *><size_t>this + cdef libgamma_gamma_rampsf_t *item = <libgamma_gamma_rampsf_t *>address libgamma_gamma_rampsf_free(item) def libgamma_native_gamma_rampsf_get(this : int, index : int) -> float: ''' - Read a stop in a gamma ramp. + Read a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @return The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @return The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef float* ramp = <float*>address + cdef void *address = <void *><size_t>this + cdef float *ramp = <float *>address return float(ramp[<size_t>index]) def libgamma_native_gamma_rampsf_set(this : int, index : int, value : float): ''' - Modify a stop in a gamma ramp. + Modify a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @param value The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @param value The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef float* ramp = <float*>address + cdef void *address = <void *><size_t>this + cdef float *ramp = <float *>address ramp[<size_t>index] = <float>value - def libgamma_native_gamma_rampsd_create(red_size : int, green_size : int, blue_size : int): ''' Create a gamma ramp in the proper way that allows all adjustment - methods to read from and write to it without causing segmentation violation. + methods to read from and write to it without causing segmentation violation @param red_size The size of the gamma ramp for the red channel @param green_size The size of the gamma ramp for the green channel @@ -625,8 +560,8 @@ def libgamma_native_gamma_rampsd_create(red_size : int, green_size : int, blue_s Element 3: The address of the gamma ramp for the green channel Element 4: The address of the gamma ramp for the blue channel ''' - cdef void* allocation = malloc(sizeof(libgamma_gamma_rampsd_t)) - cdef libgamma_gamma_rampsd_t* item = <libgamma_gamma_rampsd_t*>allocation + cdef void *allocation = malloc(sizeof(libgamma_gamma_rampsd_t)) + cdef libgamma_gamma_rampsd_t *item = <libgamma_gamma_rampsd_t *>allocation cdef size_t red, green, blue if item is NULL: return int(errno) @@ -635,48 +570,47 @@ def libgamma_native_gamma_rampsd_create(red_size : int, green_size : int, blue_s item.blue_size = blue_size if libgamma_gamma_rampsd_initialise(item) < 0: return int(errno) - red = <size_t><void*>(item.red) - green = <size_t><void*>(item.green) - blue = <size_t><void*>(item.blue) + red = <size_t><void *>(item.red) + green = <size_t><void *>(item.green) + blue = <size_t><void *>(item.blue) return (int(<size_t>allocation), int(red), int(green), int(blue)) def libgamma_native_gamma_rampsd_free(this : int): ''' Release resources that are held by a gamma ramp strcuture that - has been allocated by `libgamma_native_gamma_rampsd_create` or otherwise - created in the proper manner, as well as release the pointer - to the structure. + has been allocated by `libgamma_native_gamma_rampsd_create` or + otherwise created in the proper manner, as well as release the + pointer to the structure - @param this The gamma ramps. + @param this The gamma ramps ''' - cdef void* address = <void*><size_t>this - cdef libgamma_gamma_rampsd_t* item = <libgamma_gamma_rampsd_t*>address + cdef void *address = <void *><size_t>this + cdef libgamma_gamma_rampsd_t *item = <libgamma_gamma_rampsd_t *>address libgamma_gamma_rampsd_free(item) def libgamma_native_gamma_rampsd_get(this : int, index : int) -> float: ''' - Read a stop in a gamma ramp. + Read a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @return The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @return The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef double* ramp = <double*>address + cdef void *address = <void *><size_t>this + cdef double *ramp = <double *>address return float(ramp[<size_t>index]) def libgamma_native_gamma_rampsd_set(this : int, index : int, value : float): ''' - Modify a stop in a gamma ramp. + Modify a stop in a gamma ramp - @param this The gamma ramp. - @param index The index of the gamma ramp stop. - @param value The value of the gamma ramp stop. + @param this The gamma ramp + @param index The index of the gamma ramp stop + @param value The value of the gamma ramp stop ''' - cdef void* address = <void*><size_t>this - cdef double* ramp = <double*>address + cdef void *address = <void *><size_t>this + cdef double *ramp = <double *>address ramp[<size_t>index] = <double>value - diff --git a/src/include-libgamma.h b/src/include-libgamma.h deleted file mode 100644 index eb857e1..0000000 --- a/src/include-libgamma.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - * pylibgamma — Python 3 wrapper for libgamma - * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library. If not, see <http://www.gnu.org/licenses/>. - */ -#include <libgamma.h> - diff --git a/src/libgamma.py b/src/libgamma.py deleted file mode 100644 index 34c646c..0000000 --- a/src/libgamma.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - -from libgamma_error import * -from libgamma_method import * -from libgamma_facade import * - @@ -1,23 +1,5 @@ #!/usr/bin/env python3 -# -*- python -*- -''' -pylibgamma — Python 3 wrapper for libgamma -Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library. If not, see <http://www.gnu.org/licenses/>. -''' - +# See LICENSE file for copyright and license details. import libgamma from time import sleep @@ -121,4 +103,3 @@ del site del partition del crtc del ramps - |