aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-08 18:19:05 +0200
committeremersion <contact@emersion.fr>2017-10-08 18:19:05 +0200
commit518ef46ef2c15bdfd2a1e0274fe2bf628639a310 (patch)
tree8db05bf590f1e459b7879a4d57a5da8ef631fb54
parente66e18f4de6996a5c8d923668834096b61b60110 (diff)
Activate new views
-rw-r--r--include/rootston/input.h3
-rw-r--r--include/rootston/view.h1
-rw-r--r--rootston/cursor.c7
-rw-r--r--rootston/desktop.c10
-rw-r--r--rootston/wl_shell.c5
-rw-r--r--rootston/xdg_shell_v6.c5
6 files changed, 19 insertions, 12 deletions
diff --git a/include/rootston/input.h b/include/rootston/input.h
index e20446ea..9caf66c0 100644
--- a/include/rootston/input.h
+++ b/include/rootston/input.h
@@ -132,4 +132,7 @@ void view_begin_move(struct roots_input *input, struct wlr_cursor *cursor,
void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor,
struct roots_view *view, uint32_t edges);
+void set_view_focus(struct roots_input *input, struct roots_desktop *desktop,
+ struct roots_view *view);
+
#endif
diff --git a/include/rootston/view.h b/include/rootston/view.h
index f8a828cd..ccc934d4 100644
--- a/include/rootston/view.h
+++ b/include/rootston/view.h
@@ -83,5 +83,6 @@ void view_activate(struct roots_view *view, bool active);
void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
void view_close(struct roots_view *view);
bool view_center(struct roots_view *view);
+bool view_initialize(struct roots_view *view);
#endif
diff --git a/rootston/cursor.c b/rootston/cursor.c
index 8eb22459..605920cc 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -123,8 +123,8 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
}
}
-static void set_view_focus(struct roots_input *input,
- struct roots_desktop *desktop, struct roots_view *view) {
+void set_view_focus(struct roots_input *input, struct roots_desktop *desktop,
+ struct roots_view *view) {
if (input->active_view == view) {
return;
}
@@ -140,8 +140,7 @@ static void set_view_focus(struct roots_input *input,
struct roots_view *_view = desktop->views->items[i];
if (_view != view) {
view_activate(_view, false);
- }
- if (view == _view) {
+ } else {
index = i;
}
}
diff --git a/rootston/desktop.c b/rootston/desktop.c
index ee813130..75030ad2 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -103,6 +103,16 @@ bool view_center(struct roots_view *view) {
return true;
}
+bool view_initialize(struct roots_view *view) {
+ bool centered = view_center(view);
+ if (centered) {
+ 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);
+ }
+ return centered;
+}
+
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/wl_shell.c b/rootston/wl_shell.c
index 81c41f76..eb977367 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -56,10 +56,7 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
if (view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL &&
!roots_surface->initialized) {
- bool centered = view_center(view);
- if (centered) {
- roots_surface->initialized = true;
- }
+ roots_surface->initialized = view_initialize(view);
}
}
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index 2471b3ee..44acab4e 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -73,10 +73,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_xdg_surface->view;
if (!roots_xdg_surface->initialized) {
- bool centered = view_center(view);
- if (centered) {
- roots_xdg_surface->initialized = true;
- }
+ roots_xdg_surface->initialized = view_initialize(view);
}
}