mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 18:01:29 +00:00
Focus containers only on entry.
This commit is contained in:
parent
fea654a6ce
commit
06098bef98
|
@ -29,8 +29,8 @@ struct sway_cursor {
|
||||||
|
|
||||||
void sway_cursor_destroy(struct sway_cursor *cursor);
|
void sway_cursor_destroy(struct sway_cursor *cursor);
|
||||||
struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
|
struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
|
||||||
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
void cursor_send_pointer_motion(struct sway_cursor *cursor,
|
||||||
bool allow_refocusing);
|
double delta_x, double delta_y, uint32_t time_msec, bool allow_refocusing);
|
||||||
void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
|
void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
|
||||||
uint32_t button, enum wlr_button_state state);
|
uint32_t button, enum wlr_button_state state);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
|
||||||
|
|
||||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
if (seat->cursor) {
|
if (seat->cursor) {
|
||||||
cursor_send_pointer_motion(seat->cursor, 0, false);
|
cursor_send_pointer_motion(seat->cursor, 0, 0, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
||||||
int delta_x = strtol(argv[1], NULL, 10);
|
int delta_x = strtol(argv[1], NULL, 10);
|
||||||
int delta_y = strtol(argv[2], NULL, 10);
|
int delta_y = strtol(argv[2], NULL, 10);
|
||||||
wlr_cursor_move(cursor->cursor, NULL, delta_x, delta_y);
|
wlr_cursor_move(cursor->cursor, NULL, delta_x, delta_y);
|
||||||
cursor_send_pointer_motion(cursor, 0, true);
|
cursor_send_pointer_motion(cursor, 0, 0, 0, true);
|
||||||
} else if (strcasecmp(argv[0], "set") == 0) {
|
} else if (strcasecmp(argv[0], "set") == 0) {
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||||
|
@ -45,7 +45,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
||||||
float x = strtof(argv[1], NULL) / root_container.width;
|
float x = strtof(argv[1], NULL) / root_container.width;
|
||||||
float y = strtof(argv[2], NULL) / root_container.height;
|
float y = strtof(argv[2], NULL) / root_container.height;
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, NULL, x, y);
|
wlr_cursor_warp_absolute(cursor->cursor, NULL, x, y);
|
||||||
cursor_send_pointer_motion(cursor, 0, true);
|
cursor_send_pointer_motion(cursor, 0, 0, 0, true);
|
||||||
} else {
|
} else {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||||
|
|
|
@ -135,15 +135,25 @@ static struct sway_container *container_at_coords(
|
||||||
return output->swayc;
|
return output->swayc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
void cursor_send_pointer_motion(struct sway_cursor *cursor,
|
||||||
bool allow_refocusing) {
|
double delta_x, double delta_y, uint32_t time_msec, bool allow_refocusing) {
|
||||||
|
struct sway_container *prev_c = NULL;
|
||||||
|
struct wlr_surface *surface = NULL;
|
||||||
|
double sx, sy;
|
||||||
|
|
||||||
|
if (delta_x != 0 || delta_y != 0) {
|
||||||
|
// Use the motion delta to find the container the pointer was previously
|
||||||
|
// over.
|
||||||
|
prev_c = container_at_coords(cursor->seat,
|
||||||
|
cursor->cursor->x - delta_x, cursor->cursor->y - delta_y,
|
||||||
|
&surface, &sx, &sy);
|
||||||
|
}
|
||||||
|
|
||||||
if (time_msec == 0) {
|
if (time_msec == 0) {
|
||||||
time_msec = get_current_time_msec();
|
time_msec = get_current_time_msec();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_seat *seat = cursor->seat->wlr_seat;
|
struct wlr_seat *seat = cursor->seat->wlr_seat;
|
||||||
struct wlr_surface *surface = NULL;
|
|
||||||
double sx, sy;
|
|
||||||
struct sway_container *c = container_at_coords(cursor->seat,
|
struct sway_container *c = container_at_coords(cursor->seat,
|
||||||
cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
||||||
if (c && config->focus_follows_mouse && allow_refocusing) {
|
if (c && config->focus_follows_mouse && allow_refocusing) {
|
||||||
|
@ -162,20 +172,27 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
||||||
seat_set_focus_warp(cursor->seat, c, false);
|
seat_set_focus_warp(cursor->seat, c, false);
|
||||||
}
|
}
|
||||||
} else if (c->type == C_VIEW) {
|
} else if (c->type == C_VIEW) {
|
||||||
// Don't switch focus on title mouseover for
|
|
||||||
// stacked and tabbed layouts
|
|
||||||
// If pointed container is in nested containers which are
|
|
||||||
// inside tabbed/stacked layout we should skip them
|
|
||||||
bool do_mouse_focus = true;
|
bool do_mouse_focus = true;
|
||||||
bool is_visible = view_is_visible(c->sway_view);
|
|
||||||
struct sway_container *p = c->parent;
|
struct sway_container *p = c->parent;
|
||||||
while (p) {
|
// Don't switch focus unless we have moved from one container to another.
|
||||||
if ((p->layout == L_TABBED || p->layout == L_STACKED)
|
if (c && prev_c && c == prev_c) {
|
||||||
&& !is_visible) {
|
do_mouse_focus = false;
|
||||||
do_mouse_focus = false;
|
}
|
||||||
break;
|
// Skip check if we already know not to focus.
|
||||||
|
if (do_mouse_focus) {
|
||||||
|
// Don't switch focus on title mouseover for
|
||||||
|
// stacked and tabbed layouts
|
||||||
|
// If pointed container is in nested containers which are
|
||||||
|
// inside tabbed/stacked layout we should skip them
|
||||||
|
bool is_visible = view_is_visible(c->sway_view);
|
||||||
|
while (p) {
|
||||||
|
if ((p->layout == L_TABBED || p->layout == L_STACKED)
|
||||||
|
&& !is_visible) {
|
||||||
|
do_mouse_focus = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p = p->parent;
|
||||||
}
|
}
|
||||||
p = p->parent;
|
|
||||||
}
|
}
|
||||||
if (!do_mouse_focus) {
|
if (!do_mouse_focus) {
|
||||||
struct sway_container *next_focus = seat_get_focus_inactive(
|
struct sway_container *next_focus = seat_get_focus_inactive(
|
||||||
|
@ -221,7 +238,8 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_event_pointer_motion *event = data;
|
struct wlr_event_pointer_motion *event = data;
|
||||||
wlr_cursor_move(cursor->cursor, event->device,
|
wlr_cursor_move(cursor->cursor, event->device,
|
||||||
event->delta_x, event->delta_y);
|
event->delta_x, event->delta_y);
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec, true);
|
cursor_send_pointer_motion(cursor, event->delta_x, event->delta_y,
|
||||||
|
event->time_msec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_cursor_motion_absolute(
|
static void handle_cursor_motion_absolute(
|
||||||
|
@ -231,7 +249,7 @@ static void handle_cursor_motion_absolute(
|
||||||
wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
|
wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
|
||||||
struct wlr_event_pointer_motion_absolute *event = data;
|
struct wlr_event_pointer_motion_absolute *event = data;
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
|
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec, true);
|
cursor_send_pointer_motion(cursor, 0, 0, event->time_msec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatch_cursor_button(struct sway_cursor *cursor,
|
void dispatch_cursor_button(struct sway_cursor *cursor,
|
||||||
|
@ -401,7 +419,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y);
|
wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y);
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec, true);
|
cursor_send_pointer_motion(cursor, 0, 0, event->time_msec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tool_tip(struct wl_listener *listener, void *data) {
|
static void handle_tool_tip(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -602,7 +602,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
||||||
wlr_output, seat->cursor->cursor->x,
|
wlr_output, seat->cursor->cursor->x,
|
||||||
seat->cursor->cursor->y)) {
|
seat->cursor->cursor->y)) {
|
||||||
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
|
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
|
||||||
cursor_send_pointer_motion(seat->cursor, 0, true);
|
cursor_send_pointer_motion(seat->cursor, 0, 0, 0, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_workspace && last_workspace != new_workspace) {
|
if (last_workspace && last_workspace != new_workspace) {
|
||||||
cursor_send_pointer_motion(seat->cursor, 0, true);
|
cursor_send_pointer_motion(seat->cursor, 0, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
seat->has_focus = (container != NULL);
|
seat->has_focus = (container != NULL);
|
||||||
|
|
Loading…
Reference in a new issue