aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-15 15:20:21 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-15 22:08:26 +1000
commita120d4c79f9406a2f7cc38c60069d3183c98ea87 (patch)
tree87a568ff97fc94ca82b9ceb4abacb02ea86a9f71 /sway/input
parentMerge pull request #2272 from RyanDwyer/simplify-transactions (diff)
downloadsway-a120d4c79f9406a2f7cc38c60069d3183c98ea87.tar.gz
sway-a120d4c79f9406a2f7cc38c60069d3183c98ea87.tar.zst
sway-a120d4c79f9406a2f7cc38c60069d3183c98ea87.zip
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).
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c3
-rw-r--r--sway/input/keyboard.c2
-rw-r--r--sway/input/seat.c24
3 files changed, 11 insertions, 18 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 307eedd4..7a9f3ed7 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -10,6 +10,7 @@
10#include <wlr/types/wlr_idle.h> 10#include <wlr/types/wlr_idle.h>
11#include "list.h" 11#include "list.h"
12#include "log.h" 12#include "log.h"
13#include "sway/desktop/transaction.h"
13#include "sway/input/cursor.h" 14#include "sway/input/cursor.h"
14#include "sway/layers.h" 15#include "sway/layers.h"
15#include "sway/output.h" 16#include "sway/output.h"
@@ -219,6 +220,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
219 struct sway_drag_icon *drag_icon = wlr_drag_icon->data; 220 struct sway_drag_icon *drag_icon = wlr_drag_icon->data;
220 drag_icon_update_position(drag_icon); 221 drag_icon_update_position(drag_icon);
221 } 222 }
223 transaction_commit_dirty();
222} 224}
223 225
224static void handle_cursor_motion(struct wl_listener *listener, void *data) { 226static void handle_cursor_motion(struct wl_listener *listener, void *data) {
@@ -278,6 +280,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
278 280
279 wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, 281 wlr_seat_pointer_notify_button(cursor->seat->wlr_seat,
280 time_msec, button, state); 282 time_msec, button, state);
283 transaction_commit_dirty();
281} 284}
282 285
283static void handle_cursor_button(struct wl_listener *listener, void *data) { 286static void handle_cursor_button(struct wl_listener *listener, void *data) {
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 580c0d4b..ede38519 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -3,6 +3,7 @@
3#include <wlr/backend/multi.h> 3#include <wlr/backend/multi.h>
4#include <wlr/backend/session.h> 4#include <wlr/backend/session.h>
5#include <wlr/types/wlr_idle.h> 5#include <wlr/types/wlr_idle.h>
6#include "sway/desktop/transaction.h"
6#include "sway/input/seat.h" 7#include "sway/input/seat.h"
7#include "sway/input/keyboard.h" 8#include "sway/input/keyboard.h"
8#include "sway/input/input-manager.h" 9#include "sway/input/input-manager.h"
@@ -126,6 +127,7 @@ static void keyboard_execute_command(struct sway_keyboard *keyboard,
126 binding->command); 127 binding->command);
127 config->handler_context.seat = keyboard->seat_device->sway_seat; 128 config->handler_context.seat = keyboard->seat_device->sway_seat;
128 struct cmd_results *results = execute_command(binding->command, NULL); 129 struct cmd_results *results = execute_command(binding->command, NULL);
130 transaction_commit_dirty();
129 if (results->status != CMD_SUCCESS) { 131 if (results->status != CMD_SUCCESS) {
130 wlr_log(WLR_DEBUG, "could not run command for binding: %s (%s)", 132 wlr_log(WLR_DEBUG, "could not run command for binding: %s (%s)",
131 binding->command, results->error); 133 binding->command, results->error);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 5e65ca70..74f1375e 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -661,9 +661,13 @@ void seat_set_focus_warp(struct sway_seat *seat,
661 if (last_focus) { 661 if (last_focus) {
662 seat_send_unfocus(last_focus, seat); 662 seat_send_unfocus(last_focus, seat);
663 } 663 }
664
665 seat_send_focus(container, seat); 664 seat_send_focus(container, seat);
666 container_damage_whole(container->parent); 665
666 container_set_dirty(container);
667 container_set_dirty(container->parent); // for focused_inactive_child
668 if (last_focus) {
669 container_set_dirty(last_focus);
670 }
667 } 671 }
668 672
669 // If we've focused a floating container, bring it to the front. 673 // 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,
717 } 721 }
718 } 722 }
719 723
720 if (last_focus) {
721 container_damage_whole(last_focus);
722 }
723
724 if (last_workspace && last_workspace != new_workspace) { 724 if (last_workspace && last_workspace != new_workspace) {
725 cursor_send_pointer_motion(seat->cursor, 0, true); 725 cursor_send_pointer_motion(seat->cursor, 0, true);
726 } 726 }
@@ -840,18 +840,6 @@ struct sway_container *seat_get_active_child(struct sway_seat *seat,
840 return NULL; 840 return NULL;
841} 841}
842 842
843struct sway_container *seat_get_active_current_child(struct sway_seat *seat,
844 struct sway_container *container) {
845 struct sway_seat_container *current = NULL;
846 wl_list_for_each(current, &seat->focus_stack, link) {
847 if (current->container->current.parent == container &&
848 current->container->current.layout != L_FLOATING) {
849 return current->container;
850 }
851 }
852 return NULL;
853}
854
855struct sway_container *seat_get_focus(struct sway_seat *seat) { 843struct sway_container *seat_get_focus(struct sway_seat *seat) {
856 if (!seat->has_focus) { 844 if (!seat->has_focus) {
857 return NULL; 845 return NULL;