aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-06 15:39:39 +0200
committeremersion <contact@emersion.fr>2017-10-06 16:03:35 +0200
commit972e9dbd1b2eb2853a60632d279bd754daf7c440 (patch)
tree8005b87e755b170794842d597d206bafc07fd6a5 /rootston
parent8ff548cdbaf5ea4e20758d6ee58d6db0c4daf8cd (diff)
Add close command, add close for xwayland
Diffstat (limited to 'rootston')
-rw-r--r--rootston/cursor.c1
-rw-r--r--rootston/desktop.c6
-rw-r--r--rootston/keyboard.c4
-rw-r--r--rootston/xwayland.c21
4 files changed, 25 insertions, 7 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c
index 0ca45f16..9c4b0dd8 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -133,6 +133,7 @@ static void set_view_focus(struct roots_input *input,
if (!view) {
return;
}
+ input->last_active_view = view;
size_t index = 0;
for (size_t i = 0; i < desktop->views->length; ++i) {
diff --git a/rootston/desktop.c b/rootston/desktop.c
index f99afaf5..d214e280 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -58,6 +58,12 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
}
}
+void view_close(struct roots_view *view) {
+ if (view->close) {
+ view->close(view);
+ }
+}
+
static struct wlr_subsurface *subsurface_at(struct wlr_surface *surface,
double sx, double sy, double *sub_x, double *sub_y) {
struct wlr_subsurface *subsurface;
diff --git a/rootston/keyboard.c b/rootston/keyboard.c
index 8488e208..6f4334af 100644
--- a/rootston/keyboard.c
+++ b/rootston/keyboard.c
@@ -28,6 +28,10 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard,
struct roots_server *server = keyboard->input->server;
if (strcmp(command, "exit") == 0) {
wl_display_terminate(server->wl_display);
+ } else if (strcmp(command, "close") == 0) {
+ if (keyboard->input->last_active_view != NULL) {
+ view_close(keyboard->input->last_active_view);
+ }
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
const char *shell_cmd = command + strlen(exec_prefix);
pid_t pid = fork();
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index bb8ced8e..4b833ef1 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -9,13 +9,6 @@
#include "rootston/desktop.h"
#include "rootston/server.h"
-static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
- assert(view->type == ROOTS_XWAYLAND_VIEW);
- struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
- wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
- xwayland_surface->x, xwayland_surface->y, width, height);
-}
-
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, destroy);
@@ -39,6 +32,7 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
}
static void activate(struct roots_view *view, bool active) {
+ assert(view->type == ROOTS_XWAYLAND_VIEW);
if (active) {
wlr_xwayland_surface_activate(view->desktop->xwayland,
view->xwayland_surface);
@@ -47,6 +41,18 @@ static void activate(struct roots_view *view, bool active) {
}
}
+static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
+ assert(view->type == ROOTS_XWAYLAND_VIEW);
+ struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
+ wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
+ xwayland_surface->x, xwayland_surface->y, width, height);
+}
+
+static void close(struct roots_view *view) {
+ assert(view->type == ROOTS_XWAYLAND_VIEW);
+ wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
+}
+
void handle_xwayland_surface(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop =
wl_container_of(listener, desktop, xwayland_surface);
@@ -82,6 +88,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->desktop = desktop;
view->activate = activate;
view->resize = resize;
+ view->close = close;
roots_surface->view = view;
list_add(desktop->views, view);
}