aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--README.md2
-rw-r--r--include/extensions.h11
-rw-r--r--protocols/CMakeLists.txt11
-rw-r--r--protocols/swaylock.xml18
-rw-r--r--sway/container.c8
-rw-r--r--sway/extensions.c29
-rw-r--r--swaymsg/main.c2
-rw-r--r--wayland/registry.c4
9 files changed, 78 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index f1ac4010..48f8a0cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ cmake_install.cmake
5install_manifest.txt 5install_manifest.txt
6*.swp 6*.swp
7*.o 7*.o
8*.a
8bin/ 9bin/
9test/ 10test/
10build/ 11build/
diff --git a/README.md b/README.md
index 3f15ef35..394dfc80 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
1# sway 1# sway [![](https://api.travis-ci.org/SirCmpwn/sway.svg)](https://travis-ci.org/SirCmpwn/sway) [![Donate with fosspay](https://drewdevault.com/donate/static/donate-with-fosspay.png)](https://drewdevault.com/donate?project=4)
2 2
3"**S**irCmpwn's **Way**land window manager" is a **work in progress** 3"**S**irCmpwn's **Way**land window manager" is a **work in progress**
4i3-compatible window manager for [Wayland](http://wayland.freedesktop.org/). 4i3-compatible window manager for [Wayland](http://wayland.freedesktop.org/).
diff --git a/include/extensions.h b/include/extensions.h
index 1ef7d920..872fd3bd 100644
--- a/include/extensions.h
+++ b/include/extensions.h
@@ -1,18 +1,21 @@
1#ifndef _SWAY_EXTENSIONS_H 1#ifndef _SWAY_EXTENSIONS_H
2#define _SWAY_EXTENSIONS_H 2#define _SWAY_EXTENSIONS_H
3 3
4#include <wayland-server-core.h>
5#include <wlc/wlc-wayland.h>
4#include "wayland-desktop-shell-server-protocol.h" 6#include "wayland-desktop-shell-server-protocol.h"
5#include "list.h" 7#include "list.h"
6#include "wlc/wlc-wayland.h"
7 8
8struct background_config { 9struct background_config {
9 wlc_handle output; 10 wlc_handle output;
10 wlc_resource surface; 11 wlc_resource surface;
12 struct wl_resource *resource;
11}; 13};
12 14
13struct panel_config { 15struct panel_config {
14 wlc_handle output; 16 wlc_handle output;
15 wlc_resource surface; 17 wlc_resource surface;
18 struct wl_resource *resource;
16}; 19};
17 20
18struct desktop_shell_state { 21struct desktop_shell_state {
@@ -22,6 +25,12 @@ struct desktop_shell_state {
22 struct wlc_size panel_size; 25 struct wlc_size panel_size;
23}; 26};
24 27
28struct swaylock_state {
29 bool active;
30 wlc_handle output;
31 wlc_resource surface;
32};
33
25extern struct desktop_shell_state desktop_shell; 34extern struct desktop_shell_state desktop_shell;
26 35
27void register_extensions(void); 36void register_extensions(void);
diff --git a/protocols/CMakeLists.txt b/protocols/CMakeLists.txt
index 07becc36..d7516d0c 100644
--- a/protocols/CMakeLists.txt
+++ b/protocols/CMakeLists.txt
@@ -13,10 +13,21 @@ WAYLAND_ADD_PROTOCOL_SERVER(proto-server-desktop-shell
13 desktop-shell 13 desktop-shell
14) 14)
15 15
16WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-swaylock
17 swaylock.xml
18 swaylock
19)
20WAYLAND_ADD_PROTOCOL_SERVER(proto-server-swaylock
21 swaylock.xml
22 swaylock
23)
24
16add_library(sway-protocols 25add_library(sway-protocols
17 ${proto-client-xdg-shell} 26 ${proto-client-xdg-shell}
18 ${proto-client-desktop-shell} 27 ${proto-client-desktop-shell}
19 ${proto-server-desktop-shell} 28 ${proto-server-desktop-shell}
29 ${proto-client-swaylock}
30 ${proto-server-swaylock}
20 ) 31 )
21 32
22set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE) 33set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE)
diff --git a/protocols/swaylock.xml b/protocols/swaylock.xml
new file mode 100644
index 00000000..c7a102dd
--- /dev/null
+++ b/protocols/swaylock.xml
@@ -0,0 +1,18 @@
1<protocol name="lock">
2
3 <interface name="lock" version="1">
4 <description summary="create lock screen UIs">
5 The Weston desktop-shell protocol's locking functionality depends more
6 on the behavior of the compositor than of a screen locking client, so
7 another protocol is necessary.
8 </description>
9
10 <request name="set_lock_surface">
11 <arg name="output" type="object" interface="wl_output"/>
12 <arg name="surface" type="object" interface="wl_surface"/>
13 </request>
14
15 <request name="unlock"/>
16
17 </interface>
18</protocol>
diff --git a/sway/container.c b/sway/container.c
index 3315fd93..c260e01a 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -82,13 +82,15 @@ swayc_t *new_output(wlc_handle handle) {
82 struct output_config *oc = NULL; 82 struct output_config *oc = NULL;
83 int i; 83 int i;
84 for (i = 0; i < config->output_configs->length; ++i) { 84 for (i = 0; i < config->output_configs->length; ++i) {
85 oc = config->output_configs->items[i]; 85 struct output_config *cur = config->output_configs->items[i];
86 if (strcasecmp(name, oc->name) == 0) { 86 if (strcasecmp(name, cur->name) == 0) {
87 sway_log(L_DEBUG, "Matched output config for %s", name); 87 sway_log(L_DEBUG, "Matched output config for %s", name);
88 oc = cur;
88 break; 89 break;
89 } 90 }
90 if (strcasecmp("*", oc->name) == 0) { 91 if (strcasecmp("*", cur->name) == 0) {
91 sway_log(L_DEBUG, "Matched wildcard output config for %s", name); 92 sway_log(L_DEBUG, "Matched wildcard output config for %s", name);
93 oc = cur;
92 break; 94 break;
93 } 95 }
94 } 96 }
diff --git a/sway/extensions.c b/sway/extensions.c
index 1f8e9a7c..18621015 100644
--- a/sway/extensions.c
+++ b/sway/extensions.c
@@ -8,6 +8,31 @@
8 8
9struct desktop_shell_state desktop_shell; 9struct desktop_shell_state desktop_shell;
10 10
11void background_surface_destructor(struct wl_resource *resource) {
12 sway_log(L_DEBUG, "Background surface killed");
13 int i;
14 for (i = 0; i < desktop_shell.backgrounds->length; ++i) {
15 struct background_config *config = desktop_shell.backgrounds->items[i];
16 if (config->resource == resource) {
17 list_del(desktop_shell.backgrounds, i);
18 break;
19 }
20 }
21}
22
23void panel_surface_destructor(struct wl_resource *resource) {
24 sway_log(L_DEBUG, "Panel surface killed");
25 int i;
26 for (i = 0; i < desktop_shell.panels->length; ++i) {
27 struct panel_config *config = desktop_shell.panels->items[i];
28 if (config->resource == resource) {
29 list_del(desktop_shell.panels, i);
30 arrange_windows(&root_container, -1, -1);
31 break;
32 }
33 }
34}
35
11static void set_background(struct wl_client *client, struct wl_resource *resource, 36static void set_background(struct wl_client *client, struct wl_resource *resource,
12 struct wl_resource *_output, struct wl_resource *surface) { 37 struct wl_resource *_output, struct wl_resource *surface) {
13 wlc_handle output = wlc_handle_from_wl_output_resource(_output); 38 wlc_handle output = wlc_handle_from_wl_output_resource(_output);
@@ -18,7 +43,9 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc
18 struct background_config *config = malloc(sizeof(struct background_config)); 43 struct background_config *config = malloc(sizeof(struct background_config));
19 config->output = output; 44 config->output = output;
20 config->surface = wlc_resource_from_wl_surface_resource(surface); 45 config->surface = wlc_resource_from_wl_surface_resource(surface);
46 config->resource = surface;
21 list_add(desktop_shell.backgrounds, config); 47 list_add(desktop_shell.backgrounds, config);
48 wl_resource_set_destructor(surface, background_surface_destructor);
22} 49}
23 50
24static void set_panel(struct wl_client *client, struct wl_resource *resource, 51static void set_panel(struct wl_client *client, struct wl_resource *resource,
@@ -31,7 +58,9 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource,
31 struct panel_config *config = malloc(sizeof(struct panel_config)); 58 struct panel_config *config = malloc(sizeof(struct panel_config));
32 config->output = output; 59 config->output = output;
33 config->surface = wlc_resource_from_wl_surface_resource(surface); 60 config->surface = wlc_resource_from_wl_surface_resource(surface);
61 config->resource = surface;
34 list_add(desktop_shell.panels, config); 62 list_add(desktop_shell.panels, config);
63 wl_resource_set_destructor(surface, panel_surface_destructor);
35 desktop_shell.panel_size = *wlc_surface_get_size(config->surface); 64 desktop_shell.panel_size = *wlc_surface_get_size(config->surface);
36 arrange_windows(&root_container, -1, -1); 65 arrange_windows(&root_container, -1, -1);
37} 66}
diff --git a/swaymsg/main.c b/swaymsg/main.c
index f8c9e14c..dac84a9b 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -111,7 +111,7 @@ int main(int argc, char **argv) {
111 uint32_t len = strlen(command); 111 uint32_t len = strlen(command);
112 char *resp = ipc_single_command(socketfd, type, command, &len); 112 char *resp = ipc_single_command(socketfd, type, command, &len);
113 if (!quiet) { 113 if (!quiet) {
114 printf("%s", resp); 114 printf("%s\n", resp);
115 } 115 }
116 close(socketfd); 116 close(socketfd);
117 117
diff --git a/wayland/registry.c b/wayland/registry.c
index a7eb89d1..3c869d25 100644
--- a/wayland/registry.c
+++ b/wayland/registry.c
@@ -3,6 +3,7 @@
3#include <string.h> 3#include <string.h>
4#include "wayland-desktop-shell-client-protocol.h" 4#include "wayland-desktop-shell-client-protocol.h"
5#include "client/registry.h" 5#include "client/registry.h"
6#include "stringop.h"
6#include "log.h" 7#include "log.h"
7 8
8static void display_handle_mode(void *data, struct wl_output *wl_output, 9static void display_handle_mode(void *data, struct wl_output *wl_output,
@@ -110,7 +111,6 @@ void registry_teardown(struct registry *registry) {
110 wl_display_disconnect(registry->display); 111 wl_display_disconnect(registry->display);
111 } 112 }
112 if (registry->outputs) { 113 if (registry->outputs) {
113 // TODO: Free the outputs themselves 114 free_flat_list(registry->outputs);
114 list_free(registry->outputs);
115 } 115 }
116} 116}