aboutsummaryrefslogtreecommitdiffstats
path: root/method-x-randr.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-05 18:23:13 +0100
committerMattias Andrée <maandree@kth.se>2021-03-05 18:33:49 +0100
commitf52513b09580c1533e6c48a4162d3d5f61f3b081 (patch)
tree141d0974a777f4ec5b51daed9879a2cb0d781505 /method-x-randr.h
parentSplit source files, merge public header files, eliminite use gpp, rewrite makefile (diff)
downloadlibgamma-f52513b09580c1533e6c48a4162d3d5f61f3b081.tar.gz
libgamma-f52513b09580c1533e6c48a4162d3d5f61f3b081.tar.bz2
libgamma-f52513b09580c1533e6c48a4162d3d5f61f3b081.tar.xz
misc
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--method-x-randr.h (renamed from gamma-x-randr.h)87
1 files changed, 84 insertions, 3 deletions
diff --git a/gamma-x-randr.h b/method-x-randr.h
index 3591192..81c5275 100644
--- a/gamma-x-randr.h
+++ b/method-x-randr.h
@@ -1,6 +1,54 @@
/* See LICENSE file for copyright and license details. */
-#ifndef LIBGAMMA_GAMMA_X_RANDR_H
-#define LIBGAMMA_GAMMA_X_RANDR_H
+
+#include <xcb/xcb.h>
+#include <xcb/randr.h>
+
+
+/**
+ * The major version of RandR the library expects
+ */
+#define RANDR_VERSION_MAJOR 1
+
+/**
+ * The minor version of RandR the library expects
+ */
+#define RANDR_VERSION_MINOR 3
+
+
+/**
+ * Data structure for partition data
+ */
+typedef struct libgamma_x_randr_partition_data {
+ /**
+ * Mapping from CRTC indices to CRTC identifiers
+ */
+ xcb_randr_crtc_t *crtcs;
+
+ /**
+ * Mapping from output indices to output identifiers
+ */
+ xcb_randr_output_t *outputs;
+
+ /**
+ * The number of outputs available
+ */
+ size_t outputs_count;
+
+ /**
+ * Mapping from CRTC indices to output indices.
+ * CRTC's without an output (should be impossible)
+ * have the value `SIZE_MAX` which is impossible
+ * for an existing mapping
+ */
+ size_t *crtc_to_output;
+
+ /**
+ * Screen configuration timestamp
+ */
+ xcb_timestamp_t config_timestamp;
+
+} libgamma_x_randr_partition_data_t;
+
/**
@@ -8,6 +56,7 @@
*
* @param this The data structure to fill with the method's capabilities
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__)))
void libgamma_x_randr_method_capabilities(libgamma_method_capabilities_t *restrict);
/**
@@ -23,6 +72,7 @@ void libgamma_x_randr_method_capabilities(libgamma_method_capabilities_t *restri
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__(1), __warn_unused_result__)))
int libgamma_x_randr_site_initialise(libgamma_site_state_t *restrict, char *restrict);
/**
@@ -30,6 +80,7 @@ int libgamma_x_randr_site_initialise(libgamma_site_state_t *restrict, char *rest
*
* @param this The site state.
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__)))
void libgamma_x_randr_site_destroy(libgamma_site_state_t *restrict);
/**
@@ -39,6 +90,7 @@ void libgamma_x_randr_site_destroy(libgamma_site_state_t *restrict);
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
int libgamma_x_randr_site_restore(libgamma_site_state_t *restrict);
@@ -51,6 +103,7 @@ int libgamma_x_randr_site_restore(libgamma_site_state_t *restrict);
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
int libgamma_x_randr_partition_initialise(libgamma_partition_state_t *restrict, libgamma_site_state_t *restrict, size_t);
/**
@@ -58,6 +111,7 @@ int libgamma_x_randr_partition_initialise(libgamma_partition_state_t *restrict,
*
* @param this The partition state
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__)))
void libgamma_x_randr_partition_destroy(libgamma_partition_state_t *restrict);
/**
@@ -67,6 +121,7 @@ void libgamma_x_randr_partition_destroy(libgamma_partition_state_t *restrict);
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
int libgamma_x_randr_partition_restore(libgamma_partition_state_t *restrict);
@@ -79,6 +134,7 @@ int libgamma_x_randr_partition_restore(libgamma_partition_state_t *restrict);
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
int libgamma_x_randr_crtc_initialise(libgamma_crtc_state_t *restrict, libgamma_partition_state_t *restrict, size_t);
/**
@@ -86,6 +142,7 @@ int libgamma_x_randr_crtc_initialise(libgamma_crtc_state_t *restrict, libgamma_p
*
* @param this The CRTC state
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__)))
void libgamma_x_randr_crtc_destroy(libgamma_crtc_state_t *restrict);
/**
@@ -95,6 +152,7 @@ void libgamma_x_randr_crtc_destroy(libgamma_crtc_state_t *restrict);
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
int libgamma_x_randr_crtc_restore(libgamma_crtc_state_t *restrict);
@@ -106,6 +164,7 @@ int libgamma_x_randr_crtc_restore(libgamma_crtc_state_t *restrict);
* @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`
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t *restrict, libgamma_crtc_state_t *restrict, int32_t);
/**
@@ -116,6 +175,7 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t *restrict,
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
int libgamma_x_randr_crtc_get_gamma_ramps16(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps16_t *restrict);
/**
@@ -126,7 +186,28 @@ int libgamma_x_randr_crtc_get_gamma_ramps16(libgamma_crtc_state_t *restrict, lib
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
-int libgamma_x_randr_crtc_set_gamma_ramps16(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps16_t);
+LIBGAMMA_GCC_ONLY__(__attribute__((__nonnull__, __warn_unused_result__)))
+int libgamma_x_randr_crtc_set_gamma_ramps16(libgamma_crtc_state_t *restrict, const libgamma_gamma_ramps16_t *restrict);
+
+
+
+/**
+ * Translate an xcb error into a libgamma error
+ *
+ * @param error_code The xcb error
+ * @param default_error The libgamma error to use if the xcb error is not recognised
+ * @param return_errno Whether an `errno` value may be returned
+ * @return The libgamma error
+ */
+LIBGAMMA_GCC_ONLY__(__attribute__((__warn_unused_result__)))
+int libgamma_x_randr_internal_translate_error(int, int, int);
+
+/* xcb violates the rule to never return struct:s */
+#ifdef IN_LIBGAMMA_X_RANDR
+# ifdef __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Waggregate-return"
+# endif
#endif