aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/servers/coopgamma.c50
-rw-r--r--src/servers/gamma.c18
-rw-r--r--src/util.c51
-rw-r--r--src/util.h12
4 files changed, 80 insertions, 51 deletions
diff --git a/src/servers/coopgamma.c b/src/servers/coopgamma.c
index 7f8b815..935bed0 100644
--- a/src/servers/coopgamma.c
+++ b/src/servers/coopgamma.c
@@ -208,56 +208,6 @@ static ssize_t add_filter(struct output* restrict out, struct filter* restrict f
/**
- * Make identity mapping ramps
- *
- * @param ramps Output parameter for the ramps
- * @param output The output for which the ramps shall be configured
- * @return Zero on success, -1 on error
- */
-static int make_plain_ramps(union gamma_ramps* restrict ramps, struct output* restrict output)
-{
- COPY_RAMP_SIZES(&(ramps->u8), output);
- switch (output->depth)
- {
- case 8:
- if (libgamma_gamma_ramps8_initialise(&(ramps->u8)))
- return -1;
- libclut_start_over(&(ramps->u8), UINT8_MAX, uint8_t, 1, 1, 1);
- break;
- case 16:
- if (libgamma_gamma_ramps16_initialise(&(ramps->u16)))
- return -1;
- libclut_start_over(&(ramps->u16), UINT16_MAX, uint16_t, 1, 1, 1);
- break;
- case 32:
- if (libgamma_gamma_ramps32_initialise(&(ramps->u32)))
- return -1;
- libclut_start_over(&(ramps->u32), UINT32_MAX, uint32_t, 1, 1, 1);
- break;
- case 64:
- if (libgamma_gamma_ramps64_initialise(&(ramps->u64)))
- return -1;
- libclut_start_over(&(ramps->u64), UINT64_MAX, uint64_t, 1, 1, 1);
- break;
- case -1:
- if (libgamma_gamma_rampsf_initialise(&(ramps->f)))
- return -1;
- libclut_start_over(&(ramps->f), 1.0f, float, 1, 1, 1);
- break;
- case -2:
- if (libgamma_gamma_rampsd_initialise(&(ramps->d)))
- return -1;
- libclut_start_over(&(ramps->d), (double)1, double, 1, 1, 1);
- break;
- default:
- abort();
- }
- return 0;
-}
-
-
-
-/**
* Handle a closed connection
*
* @param client The file descriptor for the client
diff --git a/src/servers/gamma.c b/src/servers/gamma.c
index 95130e6..a481095 100644
--- a/src/servers/gamma.c
+++ b/src/servers/gamma.c
@@ -19,6 +19,7 @@
#include "crtc.h"
#include "../state.h"
#include "../communication.h"
+#include "../util.h"
#include <errno.h>
#include <string.h>
@@ -270,9 +271,26 @@ int disconnect(void)
*/
int reconnect(void)
{
+ union gamma_ramps plain;
+ size_t i;
+
if (connected)
return 0;
+ /* Reapply gamma ramps */
+ for (i = 0; i < outputs_n; i++)
+ {
+ struct output* output = outputs + i;
+ if (output->table_size > 0)
+ set_gamma(output, output->table_sums + output->table_size - 1);
+ else
+ {
+ make_plain_ramps(&plain, output);
+ set_gamma(output, &plain);
+ libgamma_gamma_ramps8_destroy(&(plain.u8));
+ }
+ }
+
connected = 1;
return 0; /* TODO reconnect() */
}
diff --git a/src/util.c b/src/util.c
index c116998..3e2bdd2 100644
--- a/src/util.c
+++ b/src/util.c
@@ -17,6 +17,8 @@
*/
#include "util.h"
+#include <libclut.h>
+
#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
@@ -265,3 +267,52 @@ int verify_utf8(const char* restrict string, int allow_modified_nul)
return read_bytes == 0 ? 0 : -1;
}
+
+/**
+ * Make identity mapping ramps
+ *
+ * @param ramps Output parameter for the ramps
+ * @param output The output for which the ramps shall be configured
+ * @return Zero on success, -1 on error
+ */
+int make_plain_ramps(union gamma_ramps* restrict ramps, struct output* restrict output)
+{
+ COPY_RAMP_SIZES(&(ramps->u8), output);
+ switch (output->depth)
+ {
+ case 8:
+ if (libgamma_gamma_ramps8_initialise(&(ramps->u8)))
+ return -1;
+ libclut_start_over(&(ramps->u8), UINT8_MAX, uint8_t, 1, 1, 1);
+ break;
+ case 16:
+ if (libgamma_gamma_ramps16_initialise(&(ramps->u16)))
+ return -1;
+ libclut_start_over(&(ramps->u16), UINT16_MAX, uint16_t, 1, 1, 1);
+ break;
+ case 32:
+ if (libgamma_gamma_ramps32_initialise(&(ramps->u32)))
+ return -1;
+ libclut_start_over(&(ramps->u32), UINT32_MAX, uint32_t, 1, 1, 1);
+ break;
+ case 64:
+ if (libgamma_gamma_ramps64_initialise(&(ramps->u64)))
+ return -1;
+ libclut_start_over(&(ramps->u64), UINT64_MAX, uint64_t, 1, 1, 1);
+ break;
+ case -1:
+ if (libgamma_gamma_rampsf_initialise(&(ramps->f)))
+ return -1;
+ libclut_start_over(&(ramps->f), 1.0f, float, 1, 1, 1);
+ break;
+ case -2:
+ if (libgamma_gamma_rampsd_initialise(&(ramps->d)))
+ return -1;
+ libclut_start_over(&(ramps->d), (double)1, double, 1, 1, 1);
+ break;
+ default:
+ abort();
+ }
+ return 0;
+}
+
diff --git a/src/util.h b/src/util.h
index 7429f5f..5d23f93 100644
--- a/src/util.h
+++ b/src/util.h
@@ -19,7 +19,7 @@
#define UTIL_H
-#include <stddef.h>
+#include "types/output.h"
@@ -101,6 +101,16 @@ void msleep(int ms);
GCC_ONLY(__attribute__((pure, nonnull)))
int verify_utf8(const char* restrict string, int allow_modified_nul);
+/**
+ * Make identity mapping ramps
+ *
+ * @param ramps Output parameter for the ramps
+ * @param output The output for which the ramps shall be configured
+ * @return Zero on success, -1 on error
+ */
+GCC_ONLY(__attribute__((nonnull)))
+int make_plain_ramps(union gamma_ramps* restrict ramps, struct output* restrict output);
+
#endif