From aab360bf2f357be65dab90c41af1a684e967925d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 28 Dec 2016 02:04:51 -0500 Subject: Add redshift support --- protocols/CMakeLists.txt | 6 ++ protocols/gamma-control.xml | 57 ++++++++++++++++ sway/extensions.c | 155 +++++++++++++++++++++++++++++++++----------- 3 files changed, 179 insertions(+), 39 deletions(-) create mode 100644 protocols/gamma-control.xml diff --git a/protocols/CMakeLists.txt b/protocols/CMakeLists.txt index ff0a2e4d..a9b459ab 100644 --- a/protocols/CMakeLists.txt +++ b/protocols/CMakeLists.txt @@ -22,12 +22,18 @@ WAYLAND_ADD_PROTOCOL_SERVER(proto-server-swaylock swaylock ) +WAYLAND_ADD_PROTOCOL_SERVER(proto-server-gamma-control + gamma-control.xml + gamma-control +) + add_library(sway-protocols STATIC ${proto-client-xdg-shell} ${proto-client-desktop-shell} ${proto-server-desktop-shell} ${proto-client-swaylock} ${proto-server-swaylock} + ${proto-server-gamma-control} ) set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE) diff --git a/protocols/gamma-control.xml b/protocols/gamma-control.xml new file mode 100644 index 00000000..e6e33265 --- /dev/null +++ b/protocols/gamma-control.xml @@ -0,0 +1,57 @@ + + + + + Copyright © 2015 Giulio camuffo + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sway/extensions.c b/sway/extensions.c index 5fee7d38..15d2f971 100644 --- a/sway/extensions.c +++ b/sway/extensions.c @@ -4,6 +4,7 @@ #include #include "wayland-desktop-shell-server-protocol.h" #include "wayland-swaylock-server-protocol.h" +#include "wayland-gamma-control-server-protocol.h" #include "sway/layout.h" #include "sway/input_state.h" #include "sway/extensions.h" @@ -140,6 +141,52 @@ static void desktop_unlock(struct wl_client *client, struct wl_resource *resourc sway_log(L_ERROR, "desktop_unlock is not currently supported"); } +static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { + sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported"); +} + +static void desktop_ready(struct wl_client *client, struct wl_resource *resource) { + // nop +} + +static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) { + pid_t pid; + wl_client_get_credentials(client, &pid, NULL, NULL); + if (!(get_feature_policy(pid) & FEATURE_PANEL)) { + sway_log(L_INFO, "Denying panel feature to %d", pid); + return; + } + struct panel_config *config = find_or_create_panel_config(resource); + sway_log(L_DEBUG, "Panel position for wl_resource %p changed %d => %d", resource, config->panel_position, position); + config->panel_position = position; + arrange_windows(&root_container, -1, -1); +} + +static struct desktop_shell_interface desktop_shell_implementation = { + .set_background = set_background, + .set_panel = set_panel, + .set_lock_surface = desktop_set_lock_surface, + .unlock = desktop_unlock, + .set_grab_surface = set_grab_surface, + .desktop_ready = desktop_ready, + .set_panel_position = set_panel_position +}; + +static void desktop_shell_bind(struct wl_client *client, void *data, + unsigned int version, unsigned int id) { + if (version > 3) { + // Unsupported version + return; + } + + struct wl_resource *resource = wl_resource_create(client, &desktop_shell_interface, version, id); + if (!resource) { + wl_client_post_no_memory(client); + } + + wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL); +} + static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *_output, struct wl_resource *surface) { pid_t pid; @@ -179,70 +226,98 @@ static void unlock(struct wl_client *client, struct wl_resource *resource) { // This isn't really necessary, we just unlock when the client exits. } -static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { - sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported"); -} - -static void desktop_ready(struct wl_client *client, struct wl_resource *resource) { - // nop -} - -static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) { - pid_t pid; - wl_client_get_credentials(client, &pid, NULL, NULL); - if (!(get_feature_policy(pid) & FEATURE_PANEL)) { - sway_log(L_INFO, "Denying panel feature to %d", pid); - return; - } - struct panel_config *config = find_or_create_panel_config(resource); - sway_log(L_DEBUG, "Panel position for wl_resource %p changed %d => %d", resource, config->panel_position, position); - config->panel_position = position; - arrange_windows(&root_container, -1, -1); -} - -static struct desktop_shell_interface desktop_shell_implementation = { - .set_background = set_background, - .set_panel = set_panel, - .set_lock_surface = desktop_set_lock_surface, - .unlock = desktop_unlock, - .set_grab_surface = set_grab_surface, - .desktop_ready = desktop_ready, - .set_panel_position = set_panel_position -}; - static struct lock_interface swaylock_implementation = { .set_lock_surface = set_lock_surface, .unlock = unlock }; -static void desktop_shell_bind(struct wl_client *client, void *data, +static void swaylock_bind(struct wl_client *client, void *data, unsigned int version, unsigned int id) { - if (version > 3) { + if (version > 1) { // Unsupported version return; } - struct wl_resource *resource = wl_resource_create(client, &desktop_shell_interface, version, id); + struct wl_resource *resource = wl_resource_create(client, &lock_interface, version, id); if (!resource) { wl_client_post_no_memory(client); } - wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL); + wl_resource_set_implementation(resource, &swaylock_implementation, NULL, NULL); } -static void swaylock_bind(struct wl_client *client, void *data, - unsigned int version, unsigned int id) { +static void gamma_control_destroy(struct wl_client *client, struct wl_resource *res) { + wl_resource_destroy(res); +} + +static void gamma_control_set_gamma(struct wl_client *client, + struct wl_resource *res, struct wl_array *red, + struct wl_array *green, struct wl_array *blue) { + if (red->size != green->size || red->size != blue->size) { + wl_resource_post_error(res, GAMMA_CONTROL_ERROR_INVALID_GAMMA, + "The gamma ramps don't have the same size"); + return; + } + uint16_t *r = (uint16_t *)red->data; + uint16_t *g = (uint16_t *)green->data; + uint16_t *b = (uint16_t *)blue->data; + wlc_handle output = wlc_handle_from_wl_output_resource( + wl_resource_get_user_data(res)); + if (!output) { + return; + } + sway_log(L_DEBUG, "Setting gamma for output"); + wlc_output_set_gamma(output, red->size / sizeof(uint16_t), r, g, b); +} + +static void gamma_control_reset_gamma(struct wl_client *client, + struct wl_resource *resource) { + // This space intentionally left blank +} + +static struct gamma_control_interface gamma_control_implementation = { + .destroy = gamma_control_destroy, + .set_gamma = gamma_control_set_gamma, + .reset_gamma = gamma_control_reset_gamma +}; + +static void gamma_control_manager_destroy(struct wl_client *client, + struct wl_resource *res) { + wl_resource_destroy(res); +} + +static void gamma_control_manager_get(struct wl_client *client, + struct wl_resource *res, uint32_t id, struct wl_resource *_output) { + struct wl_resource *manager_res = wl_resource_create(client, + &gamma_control_interface, wl_resource_get_version(res), id); + wlc_handle output = wlc_handle_from_wl_output_resource(_output); + if (!output) { + return; + } + wl_resource_set_implementation(manager_res, &gamma_control_implementation, + _output, NULL); + gamma_control_send_gamma_size(manager_res, wlc_output_get_gamma_size(output)); +} + +static struct gamma_control_manager_interface gamma_manager_implementation = { + .destroy = gamma_control_manager_destroy, + .get_gamma_control = gamma_control_manager_get +}; + +static void gamma_control_manager_bind(struct wl_client *client, void *data, + unsigned int version, unsigned int fd) { if (version > 1) { // Unsupported version return; } - struct wl_resource *resource = wl_resource_create(client, &lock_interface, version, id); + struct wl_resource *resource = wl_resource_create(client, + &gamma_control_manager_interface, version, fd); if (!resource) { wl_client_post_no_memory(client); } - wl_resource_set_implementation(resource, &swaylock_implementation, NULL, NULL); + wl_resource_set_implementation(resource, &gamma_manager_implementation, NULL, NULL); } void register_extensions(void) { @@ -252,4 +327,6 @@ void register_extensions(void) { desktop_shell.lock_surfaces = create_list(); desktop_shell.is_locked = false; wl_global_create(wlc_get_wl_display(), &lock_interface, 1, NULL, swaylock_bind); + wl_global_create(wlc_get_wl_display(), &gamma_control_manager_interface, 1, + NULL, gamma_control_manager_bind); } -- cgit v1.2.3-54-g00ecf From 98aad80eee0582c1e044b66e72e625f4c51ee4b9 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Thu, 5 Jan 2017 15:56:40 -0700 Subject: Fix broken link in CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc9079e9..aa3a632b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,7 +71,7 @@ message as well. ## Coding Style Sway is written in C. The style guidelines is [kernel -style](https://www.kernel.org/doc/Documentation/CodingStyle), but all braces go +style](https://www.kernel.org/doc/Documentation/process/coding-style.rst), but all braces go on the same line (*"but K&R says so!" is a silly way of justifying something*). Some points to note: -- cgit v1.2.3-54-g00ecf From d59af31256363c38f260fd69ec40c209ff632c10 Mon Sep 17 00:00:00 2001 From: Hummer12007 Date: Fri, 6 Jan 2017 01:28:36 +0200 Subject: Fix workspace layouts in json data --- sway/ipc-json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sway/ipc-json.c b/sway/ipc-json.c index fd17216e..876fc87c 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -132,7 +132,7 @@ static void ipc_json_describe_output(swayc_t *output, json_object *object) { static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { int num = (isdigit(workspace->name[0])) ? atoi(workspace->name) : -1; - const char *layout = ipc_json_layout_description(workspace->layout); + const char *layout = ipc_json_layout_description(workspace->workspace_layout); json_object_object_add(object, "num", json_object_new_int(num)); json_object_object_add(object, "output", (workspace->parent) ? json_object_new_string(workspace->parent->name) : NULL); @@ -173,7 +173,7 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) { json_object_object_add(object, "last_split_layout", (strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout)); json_object_object_add(object, "workspace_layout", - json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->layout))); + json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->workspace_layout))); json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(c))); json_object_object_add(object, "current_border_width", json_object_new_int(c->border_thickness)); -- cgit v1.2.3-54-g00ecf From 3b2bc894a5ebbcbbd6707d45a25d171779c2e874 Mon Sep 17 00:00:00 2001 From: Jesin Date: Thu, 5 Jan 2017 21:49:28 -0500 Subject: Recompressed PNG files zopflipng -m --lossy_transparent --- assets/Sway_Logo+Text_Ver1_1500x716.png | Bin 59701 -> 31406 bytes assets/Sway_Logo+Text_Ver2.png | Bin 95077 -> 53879 bytes assets/Sway_Logo+Text_Ver3.png | Bin 33621 -> 10939 bytes assets/Sway_Logo+Text_Ver4.png | Bin 83096 -> 50926 bytes assets/Sway_Tree.png | Bin 26239 -> 5710 bytes assets/Sway_Tree_1000x934.png | Bin 63569 -> 32509 bytes assets/Sway_Wallpaper_Blue_1136x640.png | Bin 654549 -> 325238 bytes assets/Sway_Wallpaper_Blue_1136x640_Portrait.png | Bin 665307 -> 351985 bytes assets/Sway_Wallpaper_Blue_1366x768.png | Bin 954377 -> 532990 bytes assets/Sway_Wallpaper_Blue_1920x1080.png | Bin 1782033 -> 857863 bytes assets/Sway_Wallpaper_Blue_2048x1536.png | Bin 2620628 -> 1132084 bytes assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png | Bin 2591031 -> 1069724 bytes assets/Sway_Wallpaper_Blue_768x1024.png | Bin 729020 -> 413034 bytes assets/Sway_Wallpaper_Blue_768x1024_Portrait.png | Bin 708212 -> 347190 bytes 14 files changed, 0 insertions(+), 0 deletions(-) diff --git a/assets/Sway_Logo+Text_Ver1_1500x716.png b/assets/Sway_Logo+Text_Ver1_1500x716.png index 9eff243b..b84167cf 100644 Binary files a/assets/Sway_Logo+Text_Ver1_1500x716.png and b/assets/Sway_Logo+Text_Ver1_1500x716.png differ diff --git a/assets/Sway_Logo+Text_Ver2.png b/assets/Sway_Logo+Text_Ver2.png index bcaf4e53..d92b0461 100644 Binary files a/assets/Sway_Logo+Text_Ver2.png and b/assets/Sway_Logo+Text_Ver2.png differ diff --git a/assets/Sway_Logo+Text_Ver3.png b/assets/Sway_Logo+Text_Ver3.png index 6b87f706..3532ce40 100644 Binary files a/assets/Sway_Logo+Text_Ver3.png and b/assets/Sway_Logo+Text_Ver3.png differ diff --git a/assets/Sway_Logo+Text_Ver4.png b/assets/Sway_Logo+Text_Ver4.png index 4a090ad2..b1a9f49a 100644 Binary files a/assets/Sway_Logo+Text_Ver4.png and b/assets/Sway_Logo+Text_Ver4.png differ diff --git a/assets/Sway_Tree.png b/assets/Sway_Tree.png index 8cc0aa5b..2edc5841 100644 Binary files a/assets/Sway_Tree.png and b/assets/Sway_Tree.png differ diff --git a/assets/Sway_Tree_1000x934.png b/assets/Sway_Tree_1000x934.png index 51f1bf46..d982641c 100644 Binary files a/assets/Sway_Tree_1000x934.png and b/assets/Sway_Tree_1000x934.png differ diff --git a/assets/Sway_Wallpaper_Blue_1136x640.png b/assets/Sway_Wallpaper_Blue_1136x640.png index 90a8436c..fdab9971 100644 Binary files a/assets/Sway_Wallpaper_Blue_1136x640.png and b/assets/Sway_Wallpaper_Blue_1136x640.png differ diff --git a/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png b/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png index 1faf265e..669e76fd 100644 Binary files a/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png and b/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png differ diff --git a/assets/Sway_Wallpaper_Blue_1366x768.png b/assets/Sway_Wallpaper_Blue_1366x768.png index 014d0d39..9128406f 100644 Binary files a/assets/Sway_Wallpaper_Blue_1366x768.png and b/assets/Sway_Wallpaper_Blue_1366x768.png differ diff --git a/assets/Sway_Wallpaper_Blue_1920x1080.png b/assets/Sway_Wallpaper_Blue_1920x1080.png index eae32931..034f0040 100644 Binary files a/assets/Sway_Wallpaper_Blue_1920x1080.png and b/assets/Sway_Wallpaper_Blue_1920x1080.png differ diff --git a/assets/Sway_Wallpaper_Blue_2048x1536.png b/assets/Sway_Wallpaper_Blue_2048x1536.png index 5ea72642..bcb36c0d 100644 Binary files a/assets/Sway_Wallpaper_Blue_2048x1536.png and b/assets/Sway_Wallpaper_Blue_2048x1536.png differ diff --git a/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png b/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png index b8a2c5b9..087d5d72 100644 Binary files a/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png and b/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png differ diff --git a/assets/Sway_Wallpaper_Blue_768x1024.png b/assets/Sway_Wallpaper_Blue_768x1024.png index eb4d8612..cc05bb9e 100644 Binary files a/assets/Sway_Wallpaper_Blue_768x1024.png and b/assets/Sway_Wallpaper_Blue_768x1024.png differ diff --git a/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png b/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png index c5a0d396..6af90536 100644 Binary files a/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png and b/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png differ -- cgit v1.2.3-54-g00ecf From baa84a0cd7b547021551675b175e241b2166c317 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 6 Jan 2017 13:45:09 -0500 Subject: MIT license Update to 2017 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index a4db75f7..3e0cacc2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016 Drew DeVault +Copyright (c) 2016-2017 Drew DeVault Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in -- cgit v1.2.3-54-g00ecf