Activate new views

This commit is contained in:
emersion 2017-10-08 18:19:05 +02:00
parent e66e18f4de
commit 518ef46ef2
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
6 changed files with 19 additions and 12 deletions

View File

@ -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, void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor,
struct roots_view *view, uint32_t edges); struct roots_view *view, uint32_t edges);
void set_view_focus(struct roots_input *input, struct roots_desktop *desktop,
struct roots_view *view);
#endif #endif

View File

@ -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_resize(struct roots_view *view, uint32_t width, uint32_t height);
void view_close(struct roots_view *view); void view_close(struct roots_view *view);
bool view_center(struct roots_view *view); bool view_center(struct roots_view *view);
bool view_initialize(struct roots_view *view);
#endif #endif

View File

@ -123,8 +123,8 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
} }
} }
static void set_view_focus(struct roots_input *input, void set_view_focus(struct roots_input *input, struct roots_desktop *desktop,
struct roots_desktop *desktop, struct roots_view *view) { struct roots_view *view) {
if (input->active_view == view) { if (input->active_view == view) {
return; return;
} }
@ -140,8 +140,7 @@ static void set_view_focus(struct roots_input *input,
struct roots_view *_view = desktop->views->items[i]; struct roots_view *_view = desktop->views->items[i];
if (_view != view) { if (_view != view) {
view_activate(_view, false); view_activate(_view, false);
} } else {
if (view == _view) {
index = i; index = i;
} }
} }

View File

@ -103,6 +103,16 @@ bool view_center(struct roots_view *view) {
return true; 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, static struct wlr_subsurface *subsurface_at(struct wlr_surface *surface,
double sx, double sy, double *sub_x, double *sub_y) { double sx, double sy, double *sub_x, double *sub_y) {
struct wlr_subsurface *subsurface; struct wlr_subsurface *subsurface;

View File

@ -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 && if (view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL &&
!roots_surface->initialized) { !roots_surface->initialized) {
bool centered = view_center(view); roots_surface->initialized = view_initialize(view);
if (centered) {
roots_surface->initialized = true;
}
} }
} }

View File

@ -73,10 +73,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_xdg_surface->view; struct roots_view *view = roots_xdg_surface->view;
if (!roots_xdg_surface->initialized) { if (!roots_xdg_surface->initialized) {
bool centered = view_center(view); roots_xdg_surface->initialized = view_initialize(view);
if (centered) {
roots_xdg_surface->initialized = true;
}
} }
} }