summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar willakat <willakat@users.noreply.github.com>2017-01-07 21:33:02 +0100
committerLibravatar GitHub <noreply@github.com>2017-01-07 21:33:02 +0100
commit653e96f530325f76c2e63befd1f4e916a08c770f (patch)
tree16ae997cc181c0960861e4549b697fa35aed647e
parentAdded mouse resize for auto layouts (diff)
parentMIT license (diff)
downloadsway-653e96f530325f76c2e63befd1f4e916a08c770f.tar.gz
sway-653e96f530325f76c2e63befd1f4e916a08c770f.tar.zst
sway-653e96f530325f76c2e63befd1f4e916a08c770f.zip
Merge branch 'master' into master
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--LICENSE2
-rw-r--r--assets/Sway_Logo+Text_Ver1_1500x716.pngbin59701 -> 31406 bytes
-rw-r--r--assets/Sway_Logo+Text_Ver2.pngbin95077 -> 53879 bytes
-rw-r--r--assets/Sway_Logo+Text_Ver3.pngbin33621 -> 10939 bytes
-rw-r--r--assets/Sway_Logo+Text_Ver4.pngbin83096 -> 50926 bytes
-rw-r--r--assets/Sway_Tree.pngbin26239 -> 5710 bytes
-rw-r--r--assets/Sway_Tree_1000x934.pngbin63569 -> 32509 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_1136x640.pngbin654549 -> 325238 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_1136x640_Portrait.pngbin665307 -> 351985 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_1366x768.pngbin954377 -> 532990 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_1920x1080.pngbin1782033 -> 857863 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_2048x1536.pngbin2620628 -> 1132084 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_2048x1536_Portrait.pngbin2591031 -> 1069724 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_768x1024.pngbin729020 -> 413034 bytes
-rw-r--r--assets/Sway_Wallpaper_Blue_768x1024_Portrait.pngbin708212 -> 347190 bytes
-rw-r--r--protocols/CMakeLists.txt6
-rw-r--r--protocols/gamma-control.xml57
-rw-r--r--sway/extensions.c155
-rw-r--r--sway/ipc-json.c4
20 files changed, 183 insertions, 43 deletions
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.
71## Coding Style 71## Coding Style
72 72
73Sway is written in C. The style guidelines is [kernel 73Sway is written in C. The style guidelines is [kernel
74style](https://www.kernel.org/doc/Documentation/CodingStyle), but all braces go 74style](https://www.kernel.org/doc/Documentation/process/coding-style.rst), but all braces go
75on the same line (*"but K&R says so!" is a silly way of justifying something*). 75on the same line (*"but K&R says so!" is a silly way of justifying something*).
76Some points to note: 76Some points to note:
77 77
diff --git a/LICENSE b/LICENSE
index a4db75f7..3e0cacc2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
1Copyright (c) 2016 Drew DeVault 1Copyright (c) 2016-2017 Drew DeVault
2 2
3Permission is hereby granted, free of charge, to any person obtaining a copy of 3Permission is hereby granted, free of charge, to any person obtaining a copy of
4this software and associated documentation files (the "Software"), to deal in 4this software and associated documentation files (the "Software"), to deal in
diff --git a/assets/Sway_Logo+Text_Ver1_1500x716.png b/assets/Sway_Logo+Text_Ver1_1500x716.png
index 9eff243b..b84167cf 100644
--- a/assets/Sway_Logo+Text_Ver1_1500x716.png
+++ b/assets/Sway_Logo+Text_Ver1_1500x716.png
Binary files differ
diff --git a/assets/Sway_Logo+Text_Ver2.png b/assets/Sway_Logo+Text_Ver2.png
index bcaf4e53..d92b0461 100644
--- a/assets/Sway_Logo+Text_Ver2.png
+++ b/assets/Sway_Logo+Text_Ver2.png
Binary files differ
diff --git a/assets/Sway_Logo+Text_Ver3.png b/assets/Sway_Logo+Text_Ver3.png
index 6b87f706..3532ce40 100644
--- a/assets/Sway_Logo+Text_Ver3.png
+++ b/assets/Sway_Logo+Text_Ver3.png
Binary files differ
diff --git a/assets/Sway_Logo+Text_Ver4.png b/assets/Sway_Logo+Text_Ver4.png
index 4a090ad2..b1a9f49a 100644
--- a/assets/Sway_Logo+Text_Ver4.png
+++ b/assets/Sway_Logo+Text_Ver4.png
Binary files differ
diff --git a/assets/Sway_Tree.png b/assets/Sway_Tree.png
index 8cc0aa5b..2edc5841 100644
--- a/assets/Sway_Tree.png
+++ b/assets/Sway_Tree.png
Binary files differ
diff --git a/assets/Sway_Tree_1000x934.png b/assets/Sway_Tree_1000x934.png
index 51f1bf46..d982641c 100644
--- a/assets/Sway_Tree_1000x934.png
+++ b/assets/Sway_Tree_1000x934.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_1136x640.png b/assets/Sway_Wallpaper_Blue_1136x640.png
index 90a8436c..fdab9971 100644
--- a/assets/Sway_Wallpaper_Blue_1136x640.png
+++ b/assets/Sway_Wallpaper_Blue_1136x640.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png b/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png
index 1faf265e..669e76fd 100644
--- a/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png
+++ b/assets/Sway_Wallpaper_Blue_1136x640_Portrait.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_1366x768.png b/assets/Sway_Wallpaper_Blue_1366x768.png
index 014d0d39..9128406f 100644
--- a/assets/Sway_Wallpaper_Blue_1366x768.png
+++ b/assets/Sway_Wallpaper_Blue_1366x768.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_1920x1080.png b/assets/Sway_Wallpaper_Blue_1920x1080.png
index eae32931..034f0040 100644
--- a/assets/Sway_Wallpaper_Blue_1920x1080.png
+++ b/assets/Sway_Wallpaper_Blue_1920x1080.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_2048x1536.png b/assets/Sway_Wallpaper_Blue_2048x1536.png
index 5ea72642..bcb36c0d 100644
--- a/assets/Sway_Wallpaper_Blue_2048x1536.png
+++ b/assets/Sway_Wallpaper_Blue_2048x1536.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png b/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png
index b8a2c5b9..087d5d72 100644
--- a/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png
+++ b/assets/Sway_Wallpaper_Blue_2048x1536_Portrait.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_768x1024.png b/assets/Sway_Wallpaper_Blue_768x1024.png
index eb4d8612..cc05bb9e 100644
--- a/assets/Sway_Wallpaper_Blue_768x1024.png
+++ b/assets/Sway_Wallpaper_Blue_768x1024.png
Binary files differ
diff --git a/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png b/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png
index c5a0d396..6af90536 100644
--- a/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png
+++ b/assets/Sway_Wallpaper_Blue_768x1024_Portrait.png
Binary files differ
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
22 swaylock 22 swaylock
23) 23)
24 24
25WAYLAND_ADD_PROTOCOL_SERVER(proto-server-gamma-control
26 gamma-control.xml
27 gamma-control
28)
29
25add_library(sway-protocols STATIC 30add_library(sway-protocols STATIC
26 ${proto-client-xdg-shell} 31 ${proto-client-xdg-shell}
27 ${proto-client-desktop-shell} 32 ${proto-client-desktop-shell}
28 ${proto-server-desktop-shell} 33 ${proto-server-desktop-shell}
29 ${proto-client-swaylock} 34 ${proto-client-swaylock}
30 ${proto-server-swaylock} 35 ${proto-server-swaylock}
36 ${proto-server-gamma-control}
31 ) 37 )
32 38
33set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE) 39set(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 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="gamma_control">
3
4 <copyright>
5 Copyright © 2015 Giulio camuffo
6
7 Permission to use, copy, modify, distribute, and sell this
8 software and its documentation for any purpose is hereby granted
9 without fee, provided that the above copyright notice appear in
10 all copies and that both that copyright notice and this permission
11 notice appear in supporting documentation, and that the name of
12 the copyright holders not be used in advertising or publicity
13 pertaining to distribution of the software without specific,
14 written prior permission. The copyright holders make no
15 representations about the suitability of this software for any
16 purpose. It is provided "as is" without express or implied
17 warranty.
18
19 THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26 THIS SOFTWARE.
27 </copyright>
28
29 <interface name="gamma_control_manager" version="1">
30 <request name="destroy" type="destructor"/>
31
32 <request name="get_gamma_control">
33 <arg name="id" type="new_id" interface="gamma_control"/>
34 <arg name="output" type="object" interface="wl_output"/>
35 </request>
36 </interface>
37
38 <interface name="gamma_control" version="1">
39 <enum name="error">
40 <entry name="invalid_gamma" value="0"/>
41 </enum>
42
43 <request name="destroy" type="destructor"/>
44
45 <request name="set_gamma">
46 <arg name="red" type="array"/>
47 <arg name="green" type="array"/>
48 <arg name="blue" type="array"/>
49 </request>
50
51 <request name="reset_gamma"/>
52
53 <event name="gamma_size">
54 <arg name="size" type="uint"/>
55 </event>
56 </interface>
57</protocol>
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 @@
4#include <wlc/wlc-render.h> 4#include <wlc/wlc-render.h>
5#include "wayland-desktop-shell-server-protocol.h" 5#include "wayland-desktop-shell-server-protocol.h"
6#include "wayland-swaylock-server-protocol.h" 6#include "wayland-swaylock-server-protocol.h"
7#include "wayland-gamma-control-server-protocol.h"
7#include "sway/layout.h" 8#include "sway/layout.h"
8#include "sway/input_state.h" 9#include "sway/input_state.h"
9#include "sway/extensions.h" 10#include "sway/extensions.h"
@@ -140,6 +141,52 @@ static void desktop_unlock(struct wl_client *client, struct wl_resource *resourc
140 sway_log(L_ERROR, "desktop_unlock is not currently supported"); 141 sway_log(L_ERROR, "desktop_unlock is not currently supported");
141} 142}
142 143
144static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {
145 sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported");
146}
147
148static void desktop_ready(struct wl_client *client, struct wl_resource *resource) {
149 // nop
150}
151
152static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) {
153 pid_t pid;
154 wl_client_get_credentials(client, &pid, NULL, NULL);
155 if (!(get_feature_policy(pid) & FEATURE_PANEL)) {
156 sway_log(L_INFO, "Denying panel feature to %d", pid);
157 return;
158 }
159 struct panel_config *config = find_or_create_panel_config(resource);
160 sway_log(L_DEBUG, "Panel position for wl_resource %p changed %d => %d", resource, config->panel_position, position);
161 config->panel_position = position;
162 arrange_windows(&root_container, -1, -1);
163}
164
165static struct desktop_shell_interface desktop_shell_implementation = {
166 .set_background = set_background,
167 .set_panel = set_panel,
168 .set_lock_surface = desktop_set_lock_surface,
169 .unlock = desktop_unlock,
170 .set_grab_surface = set_grab_surface,
171 .desktop_ready = desktop_ready,
172 .set_panel_position = set_panel_position
173};
174
175static void desktop_shell_bind(struct wl_client *client, void *data,
176 unsigned int version, unsigned int id) {
177 if (version > 3) {
178 // Unsupported version
179 return;
180 }
181
182 struct wl_resource *resource = wl_resource_create(client, &desktop_shell_interface, version, id);
183 if (!resource) {
184 wl_client_post_no_memory(client);
185 }
186
187 wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL);
188}
189
143static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, 190static void set_lock_surface(struct wl_client *client, struct wl_resource *resource,
144 struct wl_resource *_output, struct wl_resource *surface) { 191 struct wl_resource *_output, struct wl_resource *surface) {
145 pid_t pid; 192 pid_t pid;
@@ -179,70 +226,98 @@ static void unlock(struct wl_client *client, struct wl_resource *resource) {
179 // This isn't really necessary, we just unlock when the client exits. 226 // This isn't really necessary, we just unlock when the client exits.
180} 227}
181 228
182static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {
183 sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported");
184}
185
186static void desktop_ready(struct wl_client *client, struct wl_resource *resource) {
187 // nop
188}
189
190static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) {
191 pid_t pid;
192 wl_client_get_credentials(client, &pid, NULL, NULL);
193 if (!(get_feature_policy(pid) & FEATURE_PANEL)) {
194 sway_log(L_INFO, "Denying panel feature to %d", pid);
195 return;
196 }
197 struct panel_config *config = find_or_create_panel_config(resource);
198 sway_log(L_DEBUG, "Panel position for wl_resource %p changed %d => %d", resource, config->panel_position, position);
199 config->panel_position = position;
200 arrange_windows(&root_container, -1, -1);
201}
202
203static struct desktop_shell_interface desktop_shell_implementation = {
204 .set_background = set_background,
205 .set_panel = set_panel,
206 .set_lock_surface = desktop_set_lock_surface,
207 .unlock = desktop_unlock,
208 .set_grab_surface = set_grab_surface,
209 .desktop_ready = desktop_ready,
210 .set_panel_position = set_panel_position
211};
212
213static struct lock_interface swaylock_implementation = { 229static struct lock_interface swaylock_implementation = {
214 .set_lock_surface = set_lock_surface, 230 .set_lock_surface = set_lock_surface,
215 .unlock = unlock 231 .unlock = unlock
216}; 232};
217 233
218static void desktop_shell_bind(struct wl_client *client, void *data, 234static void swaylock_bind(struct wl_client *client, void *data,
219 unsigned int version, unsigned int id) { 235 unsigned int version, unsigned int id) {
220 if (version > 3) { 236 if (version > 1) {
221 // Unsupported version 237 // Unsupported version
222 return; 238 return;
223 } 239 }
224 240
225 struct wl_resource *resource = wl_resource_create(client, &desktop_shell_interface, version, id); 241 struct wl_resource *resource = wl_resource_create(client, &lock_interface, version, id);
226 if (!resource) { 242 if (!resource) {
227 wl_client_post_no_memory(client); 243 wl_client_post_no_memory(client);
228 } 244 }
229 245
230 wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL); 246 wl_resource_set_implementation(resource, &swaylock_implementation, NULL, NULL);
231} 247}
232 248
233static void swaylock_bind(struct wl_client *client, void *data, 249static void gamma_control_destroy(struct wl_client *client, struct wl_resource *res) {
234 unsigned int version, unsigned int id) { 250 wl_resource_destroy(res);
251}
252
253static void gamma_control_set_gamma(struct wl_client *client,
254 struct wl_resource *res, struct wl_array *red,
255 struct wl_array *green, struct wl_array *blue) {
256 if (red->size != green->size || red->size != blue->size) {
257 wl_resource_post_error(res, GAMMA_CONTROL_ERROR_INVALID_GAMMA,
258 "The gamma ramps don't have the same size");
259 return;
260 }
261 uint16_t *r = (uint16_t *)red->data;
262 uint16_t *g = (uint16_t *)green->data;
263 uint16_t *b = (uint16_t *)blue->data;
264 wlc_handle output = wlc_handle_from_wl_output_resource(
265 wl_resource_get_user_data(res));
266 if (!output) {
267 return;
268 }
269 sway_log(L_DEBUG, "Setting gamma for output");
270 wlc_output_set_gamma(output, red->size / sizeof(uint16_t), r, g, b);
271}
272
273static void gamma_control_reset_gamma(struct wl_client *client,
274 struct wl_resource *resource) {
275 // This space intentionally left blank
276}
277
278static struct gamma_control_interface gamma_control_implementation = {
279 .destroy = gamma_control_destroy,
280 .set_gamma = gamma_control_set_gamma,
281 .reset_gamma = gamma_control_reset_gamma
282};
283
284static void gamma_control_manager_destroy(struct wl_client *client,
285 struct wl_resource *res) {
286 wl_resource_destroy(res);
287}
288
289static void gamma_control_manager_get(struct wl_client *client,
290 struct wl_resource *res, uint32_t id, struct wl_resource *_output) {
291 struct wl_resource *manager_res = wl_resource_create(client,
292 &gamma_control_interface, wl_resource_get_version(res), id);
293 wlc_handle output = wlc_handle_from_wl_output_resource(_output);
294 if (!output) {
295 return;
296 }
297 wl_resource_set_implementation(manager_res, &gamma_control_implementation,
298 _output, NULL);
299 gamma_control_send_gamma_size(manager_res, wlc_output_get_gamma_size(output));
300}
301
302static struct gamma_control_manager_interface gamma_manager_implementation = {
303 .destroy = gamma_control_manager_destroy,
304 .get_gamma_control = gamma_control_manager_get
305};
306
307static void gamma_control_manager_bind(struct wl_client *client, void *data,
308 unsigned int version, unsigned int fd) {
235 if (version > 1) { 309 if (version > 1) {
236 // Unsupported version 310 // Unsupported version
237 return; 311 return;
238 } 312 }
239 313
240 struct wl_resource *resource = wl_resource_create(client, &lock_interface, version, id); 314 struct wl_resource *resource = wl_resource_create(client,
315 &gamma_control_manager_interface, version, fd);
241 if (!resource) { 316 if (!resource) {
242 wl_client_post_no_memory(client); 317 wl_client_post_no_memory(client);
243 } 318 }
244 319
245 wl_resource_set_implementation(resource, &swaylock_implementation, NULL, NULL); 320 wl_resource_set_implementation(resource, &gamma_manager_implementation, NULL, NULL);
246} 321}
247 322
248void register_extensions(void) { 323void register_extensions(void) {
@@ -252,4 +327,6 @@ void register_extensions(void) {
252 desktop_shell.lock_surfaces = create_list(); 327 desktop_shell.lock_surfaces = create_list();
253 desktop_shell.is_locked = false; 328 desktop_shell.is_locked = false;
254 wl_global_create(wlc_get_wl_display(), &lock_interface, 1, NULL, swaylock_bind); 329 wl_global_create(wlc_get_wl_display(), &lock_interface, 1, NULL, swaylock_bind);
330 wl_global_create(wlc_get_wl_display(), &gamma_control_manager_interface, 1,
331 NULL, gamma_control_manager_bind);
255} 332}
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) {
132 132
133static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { 133static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) {
134 int num = (isdigit(workspace->name[0])) ? atoi(workspace->name) : -1; 134 int num = (isdigit(workspace->name[0])) ? atoi(workspace->name) : -1;
135 const char *layout = ipc_json_layout_description(workspace->layout); 135 const char *layout = ipc_json_layout_description(workspace->workspace_layout);
136 136
137 json_object_object_add(object, "num", json_object_new_int(num)); 137 json_object_object_add(object, "num", json_object_new_int(num));
138 json_object_object_add(object, "output", (workspace->parent) ? json_object_new_string(workspace->parent->name) : NULL); 138 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) {
173 json_object_object_add(object, "last_split_layout", 173 json_object_object_add(object, "last_split_layout",
174 (strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout)); 174 (strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout));
175 json_object_object_add(object, "workspace_layout", 175 json_object_object_add(object, "workspace_layout",
176 json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->layout))); 176 json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->workspace_layout)));
177 177
178 json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(c))); 178 json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(c)));
179 json_object_object_add(object, "current_border_width", json_object_new_int(c->border_thickness)); 179 json_object_object_add(object, "current_border_width", json_object_new_int(c->border_thickness));