aboutsummaryrefslogtreecommitdiff
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
install_manifest.txt
*.swp
*.o
+*.a
bin/
test/
build/
diff --git a/README.md b/README.md
index 3f15ef35..394dfc80 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# sway
+# 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)
"**S**irCmpwn's **Way**land window manager" is a **work in progress**
i3-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 @@
#ifndef _SWAY_EXTENSIONS_H
#define _SWAY_EXTENSIONS_H
+#include <wayland-server-core.h>
+#include <wlc/wlc-wayland.h>
#include "wayland-desktop-shell-server-protocol.h"
#include "list.h"
-#include "wlc/wlc-wayland.h"
struct background_config {
wlc_handle output;
wlc_resource surface;
+ struct wl_resource *resource;
};
struct panel_config {
wlc_handle output;
wlc_resource surface;
+ struct wl_resource *resource;
};
struct desktop_shell_state {
@@ -22,6 +25,12 @@ struct desktop_shell_state {
struct wlc_size panel_size;
};
+struct swaylock_state {
+ bool active;
+ wlc_handle output;
+ wlc_resource surface;
+};
+
extern struct desktop_shell_state desktop_shell;
void 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
desktop-shell
)
+WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-swaylock
+ swaylock.xml
+ swaylock
+)
+WAYLAND_ADD_PROTOCOL_SERVER(proto-server-swaylock
+ swaylock.xml
+ swaylock
+)
+
add_library(sway-protocols
${proto-client-xdg-shell}
${proto-client-desktop-shell}
${proto-server-desktop-shell}
+ ${proto-client-swaylock}
+ ${proto-server-swaylock}
)
set(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 @@
+<protocol name="lock">
+
+ <interface name="lock" version="1">
+ <description summary="create lock screen UIs">
+ The Weston desktop-shell protocol's locking functionality depends more
+ on the behavior of the compositor than of a screen locking client, so
+ another protocol is necessary.
+ </description>
+
+ <request name="set_lock_surface">
+ <arg name="output" type="object" interface="wl_output"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <request name="unlock"/>
+
+ </interface>
+</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) {
struct output_config *oc = NULL;
int i;
for (i = 0; i < config->output_configs->length; ++i) {
- oc = config->output_configs->items[i];
- if (strcasecmp(name, oc->name) == 0) {
+ struct output_config *cur = config->output_configs->items[i];
+ if (strcasecmp(name, cur->name) == 0) {
sway_log(L_DEBUG, "Matched output config for %s", name);
+ oc = cur;
break;
}
- if (strcasecmp("*", oc->name) == 0) {
+ if (strcasecmp("*", cur->name) == 0) {
sway_log(L_DEBUG, "Matched wildcard output config for %s", name);
+ oc = cur;
break;
}
}
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 @@
struct desktop_shell_state desktop_shell;
+void background_surface_destructor(struct wl_resource *resource) {
+ sway_log(L_DEBUG, "Background surface killed");
+ int i;
+ for (i = 0; i < desktop_shell.backgrounds->length; ++i) {
+ struct background_config *config = desktop_shell.backgrounds->items[i];
+ if (config->resource == resource) {
+ list_del(desktop_shell.backgrounds, i);
+ break;
+ }
+ }
+}
+
+void panel_surface_destructor(struct wl_resource *resource) {
+ sway_log(L_DEBUG, "Panel surface killed");
+ int i;
+ for (i = 0; i < desktop_shell.panels->length; ++i) {
+ struct panel_config *config = desktop_shell.panels->items[i];
+ if (config->resource == resource) {
+ list_del(desktop_shell.panels, i);
+ arrange_windows(&root_container, -1, -1);
+ break;
+ }
+ }
+}
+
static void set_background(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *_output, struct wl_resource *surface) {
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
struct background_config *config = malloc(sizeof(struct background_config));
config->output = output;
config->surface = wlc_resource_from_wl_surface_resource(surface);
+ config->resource = surface;
list_add(desktop_shell.backgrounds, config);
+ wl_resource_set_destructor(surface, background_surface_destructor);
}
static 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,
struct panel_config *config = malloc(sizeof(struct panel_config));
config->output = output;
config->surface = wlc_resource_from_wl_surface_resource(surface);
+ config->resource = surface;
list_add(desktop_shell.panels, config);
+ wl_resource_set_destructor(surface, panel_surface_destructor);
desktop_shell.panel_size = *wlc_surface_get_size(config->surface);
arrange_windows(&root_container, -1, -1);
}
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) {
uint32_t len = strlen(command);
char *resp = ipc_single_command(socketfd, type, command, &len);
if (!quiet) {
- printf("%s", resp);
+ printf("%s\n", resp);
}
close(socketfd);
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 @@
#include <string.h>
#include "wayland-desktop-shell-client-protocol.h"
#include "client/registry.h"
+#include "stringop.h"
#include "log.h"
static void display_handle_mode(void *data, struct wl_output *wl_output,
@@ -110,7 +111,6 @@ void registry_teardown(struct registry *registry) {
wl_display_disconnect(registry->display);
}
if (registry->outputs) {
- // TODO: Free the outputs themselves
- list_free(registry->outputs);
+ free_flat_list(registry->outputs);
}
}