mirror of
https://github.com/swaywm/sway.git
synced 2025-11-17 06:59:48 -05:00
Make focus part of transactions
Rather than maintain copies of the entire focus stack, this PR transactionises the focus by introducing two new properties to the container state and using those when rendering. * `bool focused` means this container has actual focus. Only one container should have this equalling true in its current state. * `struct sway_container *focus_inactive_child` points to the immediate child that was most recently focused (eg. for tabbed and stacked containers).
This commit is contained in:
parent
53e3f35ba3
commit
a120d4c79f
10 changed files with 55 additions and 73 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include <wlr/types/wlr_idle.h>
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "sway/desktop/transaction.h"
|
||||
#include "sway/input/cursor.h"
|
||||
#include "sway/layers.h"
|
||||
#include "sway/output.h"
|
||||
|
|
@ -219,6 +220,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
|||
struct sway_drag_icon *drag_icon = wlr_drag_icon->data;
|
||||
drag_icon_update_position(drag_icon);
|
||||
}
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
||||
|
|
@ -278,6 +280,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
|
|||
|
||||
wlr_seat_pointer_notify_button(cursor->seat->wlr_seat,
|
||||
time_msec, button, state);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <wlr/backend/multi.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include "sway/desktop/transaction.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/input/keyboard.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
|
|
@ -126,6 +127,7 @@ static void keyboard_execute_command(struct sway_keyboard *keyboard,
|
|||
binding->command);
|
||||
config->handler_context.seat = keyboard->seat_device->sway_seat;
|
||||
struct cmd_results *results = execute_command(binding->command, NULL);
|
||||
transaction_commit_dirty();
|
||||
if (results->status != CMD_SUCCESS) {
|
||||
wlr_log(WLR_DEBUG, "could not run command for binding: %s (%s)",
|
||||
binding->command, results->error);
|
||||
|
|
|
|||
|
|
@ -661,9 +661,13 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
|||
if (last_focus) {
|
||||
seat_send_unfocus(last_focus, seat);
|
||||
}
|
||||
|
||||
seat_send_focus(container, seat);
|
||||
container_damage_whole(container->parent);
|
||||
|
||||
container_set_dirty(container);
|
||||
container_set_dirty(container->parent); // for focused_inactive_child
|
||||
if (last_focus) {
|
||||
container_set_dirty(last_focus);
|
||||
}
|
||||
}
|
||||
|
||||
// If we've focused a floating container, bring it to the front.
|
||||
|
|
@ -717,10 +721,6 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
|||
}
|
||||
}
|
||||
|
||||
if (last_focus) {
|
||||
container_damage_whole(last_focus);
|
||||
}
|
||||
|
||||
if (last_workspace && last_workspace != new_workspace) {
|
||||
cursor_send_pointer_motion(seat->cursor, 0, true);
|
||||
}
|
||||
|
|
@ -840,18 +840,6 @@ struct sway_container *seat_get_active_child(struct sway_seat *seat,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct sway_container *seat_get_active_current_child(struct sway_seat *seat,
|
||||
struct sway_container *container) {
|
||||
struct sway_seat_container *current = NULL;
|
||||
wl_list_for_each(current, &seat->focus_stack, link) {
|
||||
if (current->container->current.parent == container &&
|
||||
current->container->current.layout != L_FLOATING) {
|
||||
return current->container;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct sway_container *seat_get_focus(struct sway_seat *seat) {
|
||||
if (!seat->has_focus) {
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue