Merge pull request #2617 from wmww/cursor-enter-on-focus-change

Give windows pointer focus immediately
master
Drew DeVault 6 years ago committed by GitHub
commit 822b45f483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,6 +3,7 @@
#include "log.h" #include "log.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/input/cursor.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/output.h" #include "sway/output.h"
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
@ -180,6 +181,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
} }
if (new_focus) { if (new_focus) {
seat_set_focus_container(seat, new_focus); seat_set_focus_container(seat, new_focus);
cursor_send_pointer_motion(seat->cursor, 0, true);
} else { } else {
return cmd_results_new(CMD_FAILURE, "focus", return cmd_results_new(CMD_FAILURE, "focus",
"Failed to find a %s container in workspace", "Failed to find a %s container in workspace",
@ -212,6 +214,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
free(identifier); free(identifier);
if (output) { if (output) {
seat_set_focus(seat, seat_get_focus_inactive(seat, &output->node)); seat_set_focus(seat, seat_get_focus_inactive(seat, &output->node));
cursor_send_pointer_motion(seat->cursor, 0, true);
} }
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
@ -232,6 +235,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
if (argc == 0 && container) { if (argc == 0 && container) {
seat_set_focus_container(seat, container); seat_set_focus_container(seat, container);
cursor_send_pointer_motion(seat->cursor, 0, true);
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }
@ -260,6 +264,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
struct sway_node *focus = seat_get_active_child(seat, node); struct sway_node *focus = seat_get_active_child(seat, node);
if (focus) { if (focus) {
seat_set_focus(seat, focus); seat_set_focus(seat, focus);
cursor_send_pointer_motion(seat->cursor, 0, true);
} }
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }
@ -279,6 +284,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
struct sway_node *node = struct sway_node *node =
get_node_in_output_direction(new_output, direction); get_node_in_output_direction(new_output, direction);
seat_set_focus(seat, node); seat_set_focus(seat, node);
cursor_send_pointer_motion(seat->cursor, 0, true);
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }
@ -286,6 +292,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
node_get_in_direction(container, seat, direction); node_get_in_direction(container, seat, direction);
if (next_focus) { if (next_focus) {
seat_set_focus(seat, next_focus); seat_set_focus(seat, next_focus);
cursor_send_pointer_motion(seat->cursor, 0, true);
} }
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);

@ -218,7 +218,7 @@ static struct sway_container *container_at_tabbed(struct sway_node *parent,
// Surfaces // Surfaces
struct sway_node *current = seat_get_active_child(seat, parent); struct sway_node *current = seat_get_active_child(seat, parent);
return tiling_container_at(current, lx, ly, surface, sx, sy); return current ? tiling_container_at(current, lx, ly, surface, sx, sy) : NULL;
} }
/** /**
@ -246,7 +246,7 @@ static struct sway_container *container_at_stacked(struct sway_node *parent,
// Surfaces // Surfaces
struct sway_node *current = seat_get_active_child(seat, parent); struct sway_node *current = seat_get_active_child(seat, parent);
return tiling_container_at(current, lx, ly, surface, sx, sy); return current ? tiling_container_at(current, lx, ly, surface, sx, sy) : NULL;
} }
/** /**

@ -14,6 +14,7 @@
#include "sway/criteria.h" #include "sway/criteria.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/desktop/transaction.h" #include "sway/desktop/transaction.h"
#include "sway/input/cursor.h"
#include "sway/ipc-server.h" #include "sway/ipc-server.h"
#include "sway/output.h" #include "sway/output.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
@ -582,6 +583,8 @@ void view_unmap(struct sway_view *view) {
workspace_detect_urgent(ws); workspace_detect_urgent(ws);
} }
cursor_send_pointer_motion(config->handler_context.seat->cursor, 0, true);
transaction_commit_dirty(); transaction_commit_dirty();
view->surface = NULL; view->surface = NULL;
} }

@ -7,6 +7,7 @@
#include <strings.h> #include <strings.h>
#include "stringop.h" #include "stringop.h"
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/input/cursor.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/ipc-server.h" #include "sway/ipc-server.h"
#include "sway/output.h" #include "sway/output.h"
@ -400,6 +401,7 @@ bool workspace_switch(struct sway_workspace *workspace,
if (&floater->node == focus) { if (&floater->node == focus) {
seat_set_focus(seat, NULL); seat_set_focus(seat, NULL);
seat_set_focus_container(seat, floater); seat_set_focus_container(seat, floater);
cursor_send_pointer_motion(seat->cursor, 0, true);
} }
--i; --i;
} }
@ -422,6 +424,7 @@ bool workspace_switch(struct sway_workspace *workspace,
} }
seat_set_focus(seat, next); seat_set_focus(seat, next);
arrange_workspace(workspace); arrange_workspace(workspace);
cursor_send_pointer_motion(seat->cursor, 0, true);
return true; return true;
} }

Loading…
Cancel
Save