aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-10-25 21:30:05 -0400
committerGitHub <noreply@github.com>2017-10-25 21:30:05 -0400
commitb3eec47d57514390de6c934090cebb1c44068594 (patch)
tree5da0c72de78b165ac99a1819149a08288c69937a
parent70cc87078ee64c465ea8cd032a51ac2e8571be37 (diff)
parent7c85709de19e2cb03209b414ce91039d363972ff (diff)
Merge pull request #335 from emersion/focus-on-close
Focus last view on close in rootston
-rw-r--r--include/rootston/view.h3
-rw-r--r--rootston/desktop.c16
-rw-r--r--rootston/wl_shell.c3
-rw-r--r--rootston/xdg_shell_v6.c3
-rw-r--r--rootston/xwayland.c3
5 files changed, 22 insertions, 6 deletions
diff --git a/include/rootston/view.h b/include/rootston/view.h
index 7d297329..9eb7065d 100644
--- a/include/rootston/view.h
+++ b/include/rootston/view.h
@@ -80,6 +80,7 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
void view_set_position(struct roots_view *view, double x, double y);
void view_close(struct roots_view *view);
bool view_center(struct roots_view *view);
-void view_initialize(struct roots_view *view);
+void view_setup(struct roots_view *view);
+void view_teardown(struct roots_view *view);
#endif
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 40d088b8..315db83a 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -107,14 +107,26 @@ bool view_center(struct roots_view *view) {
return true;
}
-void view_initialize(struct roots_view *view) {
+void view_setup(struct roots_view *view) {
view_center(view);
- struct roots_input *input = view->desktop->server->input;
+ struct roots_input *input = view->desktop->server->input;
set_view_focus(input, view->desktop, view);
wlr_seat_keyboard_notify_enter(input->wl_seat, view->wlr_surface);
}
+void view_teardown(struct roots_view *view) {
+ struct wlr_list *views = view->desktop->views;
+ if (views->length < 2 || views->items[views->length-1] != view) {
+ return;
+ }
+
+ struct roots_view *prev_view = views->items[views->length-2];
+ struct roots_input *input = prev_view->desktop->server->input;
+ set_view_focus(input, prev_view->desktop, prev_view);
+ wlr_seat_keyboard_notify_enter(input->wl_seat, prev_view->wlr_surface);
+}
+
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
for (int i = desktop->views->length - 1; i >= 0; --i) {
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 88397af8..e5366672 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -56,6 +56,7 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, destroy);
+ view_teardown(roots_surface->view);
wl_list_remove(&roots_surface->destroy.link);
wl_list_remove(&roots_surface->request_move.link);
wl_list_remove(&roots_surface->request_resize.link);
@@ -111,7 +112,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
view->desktop = desktop;
roots_surface->view = view;
wlr_list_add(desktop->views, view);
- view_initialize(view);
+ view_setup(view);
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
// we need to map it relative to the parent
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index 95b20a8b..85871144 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -74,6 +74,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, destroy);
+ view_teardown(roots_xdg_surface->view);
wl_list_remove(&roots_xdg_surface->commit.link);
wl_list_remove(&roots_xdg_surface->destroy.link);
wl_list_remove(&roots_xdg_surface->request_move.link);
@@ -126,5 +127,5 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
roots_surface->view = view;
wlr_list_add(desktop->views, view);
- view_initialize(view);
+ view_setup(view);
}
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 1149b966..8b7c32f4 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -43,6 +43,7 @@ static void close(struct roots_view *view) {
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, destroy);
+ view_teardown(roots_surface->view);
wl_list_remove(&roots_surface->destroy.link);
view_destroy(roots_surface->view);
free(roots_surface);
@@ -101,6 +102,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wlr_list_add(desktop->views, view);
if (!surface->override_redirect) {
- view_initialize(view);
+ view_setup(view);
}
}