Commit 357da79563a597762f7cf8b1a714054ff72fbbe2 Parent: 9757af28cb92a1d0d5be44137bf24024a8da73d4 Author: mcol <mcol@posteo.net> Date: 2021-02-11 23:21:41 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-02-11 23:22:11 +0000 focus_view will get surface from view if not provided
src/shell.c Modified
@@ -19,6 +19,8 @@ void focus_view(struct view *view, struct wlr_surface *surface) { + /* view can be NULL. In that case focus is removed from any focussed surface. */ + /* surface can be NULL. In that case focus goes to view->surface->surface. */ struct wlr_surface *prev_surface = wimp.seat->keyboard_state.focused_surface; if (prev_surface == surface) { return; @@ -39,9 +41,12 @@ wl_list_remove(&view->link); wl_list_insert(&wimp.current_desk->views, &view->link); } - - wlr_xdg_toplevel_set_activated(view->surface, true); - + if (!surface) { + surface = view->surface->surface; + } + if (wlr_surface_is_xdg_surface(surface)) { + wlr_xdg_toplevel_set_activated(view->surface, true); + } struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(wimp.seat); wlr_seat_keyboard_notify_enter( wimp.seat, view->surface->surface, keyboard->keycodes, @@ -172,7 +177,7 @@ scratchpad->is_mapped = true; } - focus_view(view, view->surface->surface); + focus_view(view, NULL); } @@ -197,7 +202,7 @@ wl_list_for_each(scratchpad, &wimp.scratchpads, link) { if (scratchpad->is_mapped) { - focus_view(scratchpad->view, scratchpad->view->surface->surface); + focus_view(scratchpad->view, NULL); return; } } @@ -205,7 +210,7 @@ if (!wl_list_empty(&wimp.current_desk->views)) { struct view *next = wl_container_of(wimp.current_desk->views.next, view, link); if (view != next) { - focus_view(next, next->surface->surface); + focus_view(next, NULL); return; } };
src/desk.c Modified
@@ -75,7 +75,7 @@ focus_view(NULL, NULL); } else { struct view *view = wl_container_of(desk->views.next, view, link); - focus_view(view, view->surface->surface); + focus_view(view, NULL); } } @@ -98,7 +98,7 @@ wl_list_insert(&desk->views, &view->link); if (!wl_list_empty(&wimp.current_desk->views)) { struct view *next_view = wl_container_of(wimp.current_desk->views.next, view, link); - focus_view(next_view, next_view->surface->surface); + focus_view(next_view, NULL); } } }
src/action.c Modified
@@ -106,7 +106,7 @@ if (next) { unfullscreen(); pan_to_view(next); - focus_view(next, next->surface->surface); + focus_view(next, NULL); } } @@ -302,7 +302,7 @@ ) { continue; } - focus_view(view, view->surface->surface); + focus_view(view, NULL); return; } }