aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authorRyan Dwyer <RyanDwyer@users.noreply.github.com>2018-07-18 09:32:03 +1000
committerGitHub <noreply@github.com>2018-07-18 09:32:03 +1000
commit8ce7e3b44eea0a270ecc35a9da2ae801aaf6bce1 (patch)
tree6badffb0c6ee33b4e23e914c4c9f9b39a625b5f3 /sway/input
parent621d2666b1ac214c63628bbe0ac8f5d6485cb501 (diff)
parent48b911a4596f50b585a1073d32413236d9defb60 (diff)
Merge branch 'master' into destroy-output-destroy-empty-workspaces
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c5
-rw-r--r--sway/input/input-manager.c50
-rw-r--r--sway/input/keyboard.c10
-rw-r--r--sway/input/seat.c73
4 files changed, 85 insertions, 53 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index a2f11557..7a9f3ed7 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -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) {
@@ -474,7 +477,7 @@ static void handle_request_set_cursor(struct wl_listener *listener,
// TODO: check cursor mode
if (focused_client == NULL ||
event->seat_client->client != focused_client) {
- wlr_log(L_DEBUG, "denying request to set cursor from unfocused client");
+ wlr_log(WLR_DEBUG, "denying request to set cursor from unfocused client");
return;
}
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 98f7d7cf..0b7cb766 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -61,7 +61,7 @@ static char *get_device_identifier(struct wlr_input_device *device) {
int len = snprintf(NULL, 0, fmt, vendor, product, name) + 1;
char *identifier = malloc(len);
if (!identifier) {
- wlr_log(L_ERROR, "Unable to allocate unique input device name");
+ wlr_log(WLR_ERROR, "Unable to allocate unique input device name");
return NULL;
}
@@ -104,77 +104,89 @@ static void input_manager_libinput_config_pointer(
}
libinput_device = wlr_libinput_get_device_handle(wlr_device);
- wlr_log(L_DEBUG, "input_manager_libinput_config_pointer(%s)",
+ wlr_log(WLR_DEBUG, "input_manager_libinput_config_pointer(%s)",
ic->identifier);
if (ic->accel_profile != INT_MIN) {
- wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)",
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)",
ic->identifier, ic->accel_profile);
libinput_device_config_accel_set_profile(libinput_device,
ic->accel_profile);
}
if (ic->click_method != INT_MIN) {
- wlr_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)",
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)",
ic->identifier, ic->click_method);
libinput_device_config_click_set_method(libinput_device,
ic->click_method);
}
if (ic->drag_lock != INT_MIN) {
- wlr_log(L_DEBUG,
+ wlr_log(WLR_DEBUG,
"libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)",
ic->identifier, ic->click_method);
libinput_device_config_tap_set_drag_lock_enabled(libinput_device,
ic->drag_lock);
}
if (ic->dwt != INT_MIN) {
- wlr_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)",
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)",
ic->identifier, ic->dwt);
libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt);
}
if (ic->left_handed != INT_MIN) {
- wlr_log(L_DEBUG,
+ wlr_log(WLR_DEBUG,
"libinput_config_pointer(%s) left_handed_set_enabled(%d)",
ic->identifier, ic->left_handed);
libinput_device_config_left_handed_set(libinput_device,
ic->left_handed);
}
if (ic->middle_emulation != INT_MIN) {
- wlr_log(L_DEBUG,
+ wlr_log(WLR_DEBUG,
"libinput_config_pointer(%s) middle_emulation_set_enabled(%d)",
ic->identifier, ic->middle_emulation);
libinput_device_config_middle_emulation_set_enabled(libinput_device,
ic->middle_emulation);
}
if (ic->natural_scroll != INT_MIN) {
- wlr_log(L_DEBUG,
+ wlr_log(WLR_DEBUG,
"libinput_config_pointer(%s) natural_scroll_set_enabled(%d)",
ic->identifier, ic->natural_scroll);
libinput_device_config_scroll_set_natural_scroll_enabled(
libinput_device, ic->natural_scroll);
}
if (ic->pointer_accel != FLT_MIN) {
- wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)",
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)",
ic->identifier, ic->pointer_accel);
libinput_device_config_accel_set_speed(libinput_device,
ic->pointer_accel);
}
+ if (ic->scroll_button != INT_MIN) {
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) scroll_set_button(%d)",
+ ic->identifier, ic->scroll_button);
+ libinput_device_config_scroll_set_button(libinput_device,
+ ic->scroll_button);
+ }
if (ic->scroll_method != INT_MIN) {
- wlr_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)",
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)",
ic->identifier, ic->scroll_method);
libinput_device_config_scroll_set_method(libinput_device,
ic->scroll_method);
}
if (ic->send_events != INT_MIN) {
- wlr_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)",
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)",
ic->identifier, ic->send_events);
libinput_device_config_send_events_set_mode(libinput_device,
ic->send_events);
}
if (ic->tap != INT_MIN) {
- wlr_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)",
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)",
ic->identifier, ic->tap);
libinput_device_config_tap_set_enabled(libinput_device, ic->tap);
}
+ if (ic->tap_button_map != INT_MIN) {
+ wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_button_map(%d)",
+ ic->identifier, ic->tap);
+ libinput_device_config_tap_set_button_map(libinput_device,
+ ic->tap_button_map);
+ }
}
static void handle_device_destroy(struct wl_listener *listener, void *data) {
@@ -187,7 +199,7 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) {
return;
}
- wlr_log(L_DEBUG, "removing device: '%s'",
+ wlr_log(WLR_DEBUG, "removing device: '%s'",
input_device->identifier);
struct sway_seat *seat = NULL;
@@ -217,7 +229,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
input_device->identifier = get_device_identifier(device);
wl_list_insert(&input->devices, &input_device->link);
- wlr_log(L_DEBUG, "adding device: '%s'",
+ wlr_log(WLR_DEBUG, "adding device: '%s'",
input_device->identifier);
if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
@@ -229,7 +241,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
struct sway_seat *seat = NULL;
if (!input_has_seat_configuration(input)) {
- wlr_log(L_DEBUG, "no seat configuration, using default seat");
+ wlr_log(WLR_DEBUG, "no seat configuration, using default seat");
seat = input_manager_get_seat(input, default_seat);
seat_add_device(seat, input_device);
return;
@@ -259,7 +271,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
}
if (!added) {
- wlr_log(L_DEBUG,
+ wlr_log(WLR_DEBUG,
"device '%s' is not configured on any seats",
input_device->identifier);
}
@@ -282,7 +294,7 @@ static void handle_inhibit_deactivate(struct wl_listener *listener, void *data)
seat_set_exclusive_client(seat, NULL);
struct sway_container *previous = seat_get_focus(seat);
if (previous) {
- wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous,
+ wlr_log(WLR_DEBUG, "Returning focus to %p %s '%s'", previous,
container_type_to_str(previous->type), previous->name);
// Hack to get seat to re-focus the return value of get_focus
seat_set_focus(seat, previous->parent);
@@ -359,7 +371,7 @@ void input_manager_apply_input_config(struct sway_input_manager *input,
void input_manager_apply_seat_config(struct sway_input_manager *input,
struct seat_config *seat_config) {
- wlr_log(L_DEBUG, "applying new seat config for seat %s",
+ wlr_log(WLR_DEBUG, "applying new seat config for seat %s",
seat_config->name);
struct sway_seat *seat = input_manager_get_seat(input, seat_config->name);
if (!seat) {
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 182536de..ede38519 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -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"
@@ -108,7 +109,7 @@ static void get_active_binding(const struct sway_shortcut_state *state,
}
if (*current_binding && *current_binding != binding) {
- wlr_log(L_DEBUG, "encountered duplicate bindings %d and %d",
+ wlr_log(WLR_DEBUG, "encountered duplicate bindings %d and %d",
(*current_binding)->order, binding->order);
} else {
*current_binding = binding;
@@ -122,12 +123,13 @@ static void get_active_binding(const struct sway_shortcut_state *state,
*/
static void keyboard_execute_command(struct sway_keyboard *keyboard,
struct sway_binding *binding) {
- wlr_log(L_DEBUG, "running command for binding: %s",
+ wlr_log(WLR_DEBUG, "running command for binding: %s",
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(L_DEBUG, "could not run command for binding: %s (%s)",
+ wlr_log(WLR_DEBUG, "could not run command for binding: %s (%s)",
binding->command, results->error);
}
free_cmd_results(results);
@@ -386,7 +388,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
xkb_keymap_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
if (!keymap) {
- wlr_log(L_DEBUG, "cannot configure keyboard: keymap does not exist");
+ wlr_log(WLR_DEBUG, "cannot configure keyboard: keymap does not exist");
xkb_context_unref(context);
return;
}
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 6c5abcd8..12b1fab5 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -75,7 +75,7 @@ static void seat_send_activate(struct sway_container *con,
struct sway_seat *seat) {
if (con->type == C_VIEW) {
if (!seat_is_input_allowed(seat, con->sway_view->surface)) {
- wlr_log(L_DEBUG, "Refusing to set focus, input is inhibited");
+ wlr_log(WLR_DEBUG, "Refusing to set focus, input is inhibited");
return;
}
view_set_activated(con->sway_view, true);
@@ -219,7 +219,7 @@ static struct sway_seat_container *seat_container_from_container(
seat_con = calloc(1, sizeof(struct sway_seat_container));
if (seat_con == NULL) {
- wlr_log(L_ERROR, "could not allocate seat container");
+ wlr_log(WLR_ERROR, "could not allocate seat container");
return NULL;
}
@@ -301,7 +301,7 @@ static void handle_new_drag_icon(struct wl_listener *listener, void *data) {
struct sway_drag_icon *icon = calloc(1, sizeof(struct sway_drag_icon));
if (icon == NULL) {
- wlr_log(L_ERROR, "Allocation failed");
+ wlr_log(WLR_ERROR, "Allocation failed");
return;
}
icon->seat = seat;
@@ -391,7 +391,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
struct input_config *ic = input_device_get_config(
sway_device->input_device);
if (ic != NULL) {
- wlr_log(L_DEBUG, "Applying input config to %s",
+ wlr_log(WLR_DEBUG, "Applying input config to %s",
sway_device->input_device->identifier);
mapped_to_output = ic->mapped_to_output;
@@ -401,7 +401,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
mapped_to_output = sway_device->input_device->wlr_device->output_name;
}
if (mapped_to_output != NULL) {
- wlr_log(L_DEBUG, "Mapping input device %s to output %s",
+ wlr_log(WLR_DEBUG, "Mapping input device %s to output %s",
sway_device->input_device->identifier, mapped_to_output);
struct sway_container *output = NULL;
for (int i = 0; i < root_container.children->length; ++i) {
@@ -415,7 +415,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
wlr_cursor_map_input_to_output(seat->cursor->cursor,
sway_device->input_device->wlr_device,
output->sway_output->wlr_output);
- wlr_log(L_DEBUG, "Mapped to output %s", output->name);
+ wlr_log(WLR_DEBUG, "Mapped to output %s", output->name);
}
}
}
@@ -495,7 +495,7 @@ void seat_configure_device(struct sway_seat *seat,
seat_configure_tablet_tool(seat, seat_device);
break;
case WLR_INPUT_DEVICE_TABLET_PAD:
- wlr_log(L_DEBUG, "TODO: configure tablet pad");
+ wlr_log(WLR_DEBUG, "TODO: configure tablet pad");
break;
}
}
@@ -510,11 +510,11 @@ void seat_add_device(struct sway_seat *seat,
struct sway_seat_device *seat_device =
calloc(1, sizeof(struct sway_seat_device));
if (!seat_device) {
- wlr_log(L_DEBUG, "could not allocate seat device");
+ wlr_log(WLR_DEBUG, "could not allocate seat device");
return;
}
- wlr_log(L_DEBUG, "adding device %s to seat %s",
+ wlr_log(WLR_DEBUG, "adding device %s to seat %s",
input_device->identifier, seat->wlr_seat->name);
seat_device->sway_seat = seat;
@@ -533,7 +533,7 @@ void seat_remove_device(struct sway_seat *seat,
return;
}
- wlr_log(L_DEBUG, "removing device %s from seat %s",
+ wlr_log(WLR_DEBUG, "removing device %s from seat %s",
input_device->identifier, seat->wlr_seat->name);
seat_device_destroy(seat_device);
@@ -594,6 +594,12 @@ static void seat_send_unfocus(struct sway_container *container,
}
}
+static int handle_urgent_timeout(void *data) {
+ struct sway_view *view = data;
+ view_set_urgent(view, false);
+ return 0;
+}
+
void seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *container, bool warp) {
if (seat->focused_layer) {
@@ -649,6 +655,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
while (parent) {
wl_list_remove(&parent->link);
wl_list_insert(&seat->focus_stack, &parent->link);
+ container_set_dirty(parent->container);
parent =
seat_container_from_container(seat,
@@ -661,9 +668,33 @@ 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 urgent, start a timer to unset it
+ if (container && container->type == C_VIEW &&
+ view_is_urgent(container->sway_view) &&
+ !container->sway_view->urgent_timer) {
+ struct sway_view *view = container->sway_view;
+ view->urgent_timer = wl_event_loop_add_timer(server.wl_event_loop,
+ handle_urgent_timeout, view);
+ wl_event_source_timer_update(view->urgent_timer, 1000);
+ }
+
+ // If we've focused a floating container, bring it to the front.
+ // We do this by putting it at the end of the floating list.
+ // This must happen for both the pending and current children lists.
+ if (container && container_is_floating(container)) {
+ list_move_to_end(container->parent->children, container);
+ if (container_has_ancestor(container, container->current.parent)) {
+ list_move_to_end(container->parent->current.children, container);
+ }
}
// clean up unfocused empty workspace on new output
@@ -707,10 +738,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);
}
@@ -752,7 +779,7 @@ void seat_set_focus_layer(struct sway_seat *seat,
struct sway_container *previous =
seat_get_focus_inactive(seat, &root_container);
if (previous) {
- wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous,
+ wlr_log(WLR_DEBUG, "Returning focus to %p %s '%s'", previous,
container_type_to_str(previous->type), previous->name);
// Hack to get seat to re-focus the return value of get_focus
seat_set_focus(seat, previous->parent);
@@ -830,18 +857,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;