diff options
-rw-r--r-- | src/servers/crtc.c | 33 | ||||
-rw-r--r-- | src/servers/crtc.h | 15 | ||||
-rw-r--r-- | src/servers/gamma.c | 28 | ||||
-rw-r--r-- | src/servers/gamma.h | 13 |
4 files changed, 52 insertions, 37 deletions
diff --git a/src/servers/crtc.c b/src/servers/crtc.c index 5b3af43..41056bf 100644 --- a/src/servers/crtc.c +++ b/src/servers/crtc.c @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "crtc.h" +#include "gamma.h" #include "../state.h" #include "../communication.h" @@ -195,3 +196,35 @@ int merge_state(struct output* restrict old_outputs, size_t old_outputs_n) return 0; } + + +/** + * Disconnect from the site + * + * @return Zero on success, -1 on error + */ +int disconnect(void) +{ + if (!connected) + return 0; + + connected = 0; + return 0; /* TODO disconnect() */ +} + + +/** + * Reconnect to the site + * + * @return Zero on success, -1 on error + */ +int reconnect(void) +{ + if (connected) + return 0; + + connected = 1; + reapply_gamma(); + return 0; /* TODO reconnect() */ +} + diff --git a/src/servers/crtc.h b/src/servers/crtc.h index 1670ee2..3bf9eed 100644 --- a/src/servers/crtc.h +++ b/src/servers/crtc.h @@ -74,5 +74,20 @@ int initialise_crtcs(void); int merge_state(struct output* restrict old_outputs, size_t old_outputs_n); +/** + * Disconnect from the site + * + * @return Zero on success, -1 on error + */ +int disconnect(void); + +/** + * Reconnect to the site + * + * @return Zero on success, -1 on error + */ +int reconnect(void); + + #endif diff --git a/src/servers/gamma.c b/src/servers/gamma.c index a481095..0330c51 100644 --- a/src/servers/gamma.c +++ b/src/servers/gamma.c @@ -248,35 +248,14 @@ void restore_gamma(void) } - /** - * Disconnect from the site - * - * @return Zero on success, -1 on error + * Reapplu all gamma ramps */ -int disconnect(void) -{ - if (!connected) - return 0; - - connected = 0; - return 0; /* TODO disconnect() */ -} - - -/** - * Reconnect to the site - * - * @return Zero on success, -1 on error - */ -int reconnect(void) +void reapply_gamma(void) { union gamma_ramps plain; size_t i; - if (connected) - return 0; - /* Reapply gamma ramps */ for (i = 0; i < outputs_n; i++) { @@ -290,8 +269,5 @@ int reconnect(void) libgamma_gamma_ramps8_destroy(&(plain.u8)); } } - - connected = 1; - return 0; /* TODO reconnect() */ } diff --git a/src/servers/gamma.h b/src/servers/gamma.h index ee9af84..ac269e0 100644 --- a/src/servers/gamma.h +++ b/src/servers/gamma.h @@ -76,18 +76,9 @@ void restore_gamma(void); /** - * Disconnect from the site - * - * @return Zero on success, -1 on error - */ -int disconnect(void); - -/** - * Reconnect to the site - * - * @return Zero on success, -1 on error + * Reapplu all gamma ramps */ -int reconnect(void); +void reapply_gamma(void); #endif |