Address review feedback

This commit is contained in:
Drew DeVault 2018-03-31 15:13:27 -04:00
parent b9d2983324
commit f2332dc75c
3 changed files with 12 additions and 9 deletions

View file

@ -56,6 +56,9 @@ void sway_seat_configure_xcursor(struct sway_seat *seat);
void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container); void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container);
void sway_seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *container, bool warp);
struct sway_container *sway_seat_get_focus(struct sway_seat *seat); struct sway_container *sway_seat_get_focus(struct sway_seat *seat);
/** /**

View file

@ -120,9 +120,6 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
return NULL; return NULL;
} }
void _sway_seat_set_focus(struct sway_seat *seat,
struct sway_container *container, bool warp);
static void cursor_send_pointer_motion(struct sway_cursor *cursor, static void cursor_send_pointer_motion(struct sway_cursor *cursor,
uint32_t time) { uint32_t time) {
struct wlr_seat *seat = cursor->seat->wlr_seat; struct wlr_seat *seat = cursor->seat->wlr_seat;
@ -130,7 +127,7 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor,
double sx, sy; double sx, sy;
struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy); struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy);
if (c && config->focus_follows_mouse) { if (c && config->focus_follows_mouse) {
_sway_seat_set_focus(cursor->seat, c, false); sway_seat_set_focus_warp(cursor->seat, c, false);
} }
// reset cursor if switching between clients // reset cursor if switching between clients

View file

@ -1,5 +1,6 @@
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xcursor_manager.h>
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
@ -291,7 +292,7 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
seat->cursor->cursor->y); seat->cursor->cursor->y);
} }
void _sway_seat_set_focus(struct sway_seat *seat, void sway_seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *container, bool warp) { struct sway_container *container, bool warp) {
struct sway_container *last_focus = sway_seat_get_focus(seat); struct sway_container *last_focus = sway_seat_get_focus(seat);
@ -351,12 +352,14 @@ void _sway_seat_set_focus(struct sway_seat *seat,
} }
if (new_output && last_output && new_output != last_output if (new_output && last_output && new_output != last_output
&& config->mouse_warping && warp) { && config->mouse_warping && warp) {
wlr_log(L_DEBUG, "warpin the mouse baby");
struct wlr_output *output = new_output->sway_output->wlr_output; struct wlr_output *output = new_output->sway_output->wlr_output;
// TODO: Change container coords to layout coords
double x = container->x + output->lx + container->width / 2.0; double x = container->x + output->lx + container->width / 2.0;
double y = container->y + output->ly + container->height / 2.0; double y = container->y + output->ly + container->height / 2.0;
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); if (!wlr_output_layout_contains_point(
root_container.sway_root->output_layout,
output, seat->cursor->cursor->x, seat->cursor->cursor->y)) {
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
}
} }
} }
@ -371,7 +374,7 @@ void _sway_seat_set_focus(struct sway_seat *seat,
void sway_seat_set_focus(struct sway_seat *seat, void sway_seat_set_focus(struct sway_seat *seat,
struct sway_container *container) { struct sway_container *container) {
_sway_seat_set_focus(seat, container, true); sway_seat_set_focus_warp(seat, container, true);
} }
struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) { struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) {