Add roots_seat_cycle_focus

master
emersion 7 years ago
parent bf41e7a794
commit 97ddd2d1df
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -71,7 +71,9 @@ bool roots_seat_has_meta_pressed(struct roots_seat *seat);
struct roots_view *roots_seat_get_focus(struct roots_seat *seat); struct roots_view *roots_seat_get_focus(struct roots_seat *seat);
void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view); void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view);
void roots_seat_cycle_focus(struct roots_seat *seat);
void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view); void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view);

@ -142,7 +142,7 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
if (state == WLR_BUTTON_PRESSED && if (state == WLR_BUTTON_PRESSED &&
view && view &&
roots_seat_has_meta_pressed(seat)) { roots_seat_has_meta_pressed(seat)) {
roots_seat_focus_view(seat, view); roots_seat_set_focus(seat, view);
uint32_t edges; uint32_t edges;
switch (button) { switch (button) {
@ -193,7 +193,7 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
cursor->input_events[i].device = device; cursor->input_events[i].device = device;
cursor->input_events_idx = (i + 1) cursor->input_events_idx = (i + 1)
% (sizeof(cursor->input_events) / sizeof(cursor->input_events[0])); % (sizeof(cursor->input_events) / sizeof(cursor->input_events[0]));
roots_seat_focus_view(seat, view); roots_seat_set_focus(seat, view);
break; break;
} }
} }

@ -197,7 +197,7 @@ void view_setup(struct roots_view *view) {
// TODO what seat gets focus? the one with the last input event? // TODO what seat gets focus? the one with the last input event?
struct roots_seat *seat; struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) { wl_list_for_each(seat, &input->seats, link) {
roots_seat_focus_view(seat, view); roots_seat_set_focus(seat, view);
} }
view_center(view); view_center(view);

@ -96,11 +96,7 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard,
view_close(focus); view_close(focus);
} }
} else if (strcmp(command, "next_window") == 0) { } else if (strcmp(command, "next_window") == 0) {
if (!wl_list_empty(&seat->views)) { roots_seat_cycle_focus(seat);
struct roots_seat_view *last_seat_view = wl_container_of(
seat->views.prev, last_seat_view, link);
roots_seat_focus_view(seat, last_seat_view->view);
}
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) { } else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
const char *shell_cmd = command + strlen(exec_prefix); const char *shell_cmd = command + strlen(exec_prefix);
pid_t pid = fork(); pid_t pid = fork();

@ -510,7 +510,7 @@ static void seat_view_destroy(struct roots_seat_view *seat_view) {
if (!wl_list_empty(&seat->views)) { if (!wl_list_empty(&seat->views)) {
struct roots_seat_view *first_seat_view = wl_container_of( struct roots_seat_view *first_seat_view = wl_container_of(
seat->views.next, first_seat_view, link); seat->views.next, first_seat_view, link);
roots_seat_focus_view(seat, first_seat_view->view); roots_seat_set_focus(seat, first_seat_view->view);
} }
} }
@ -538,7 +538,7 @@ static struct roots_seat_view *seat_add_view(struct roots_seat *seat,
return seat_view; return seat_view;
} }
void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) { void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
struct roots_view *prev_focus = roots_seat_get_focus(seat); struct roots_view *prev_focus = roots_seat_get_focus(seat);
if (view == prev_focus) { if (view == prev_focus) {
return; return;
@ -590,6 +590,15 @@ void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) {
wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface); wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface);
} }
void roots_seat_cycle_focus(struct roots_seat *seat) {
if (wl_list_empty(&seat->views)) {
return;
}
struct roots_seat_view *last_seat_view = wl_container_of(
seat->views.prev, last_seat_view, link);
roots_seat_set_focus(seat, last_seat_view->view);
}
void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) { void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {
struct roots_cursor *cursor = seat->cursor; struct roots_cursor *cursor = seat->cursor;
cursor->mode = ROOTS_CURSOR_MOVE; cursor->mode = ROOTS_CURSOR_MOVE;

Loading…
Cancel
Save