mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 01:41:30 +00:00
input_state: Remove mouse_origin (x&y). Query wlc instead.
This commit is contained in:
parent
78ca619769
commit
5ba47d4a44
|
@ -48,11 +48,6 @@ extern struct pointer_state {
|
|||
struct pointer_button_state right;
|
||||
struct pointer_button_state scroll;
|
||||
|
||||
// pointer position
|
||||
struct mouse_origin{
|
||||
int x, y;
|
||||
} origin;
|
||||
|
||||
// change in pointer position
|
||||
struct {
|
||||
int x, y;
|
||||
|
|
|
@ -510,7 +510,7 @@ swayc_t *swayc_active_workspace_for(swayc_t *cont) {
|
|||
}
|
||||
|
||||
static bool pointer_test(swayc_t *view, void *_origin) {
|
||||
const struct mouse_origin *origin = _origin;
|
||||
const struct wlc_origin *origin = _origin;
|
||||
// Determine the output that the view is under
|
||||
swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT);
|
||||
if (origin->x >= view->x && origin->y >= view->y
|
||||
|
@ -531,6 +531,8 @@ swayc_t *container_under_pointer(void) {
|
|||
if (lookup->children == 0) {
|
||||
return NULL;
|
||||
}
|
||||
struct wlc_origin origin;
|
||||
wlc_pointer_get_origin(&origin);
|
||||
while (lookup->type != C_VIEW) {
|
||||
int i;
|
||||
int len;
|
||||
|
@ -545,7 +547,7 @@ swayc_t *container_under_pointer(void) {
|
|||
i = len = lookup->floating->length;
|
||||
bool got_floating = false;
|
||||
while (--i > -1) {
|
||||
if (pointer_test(lookup->floating->items[i], &pointer_state.origin)) {
|
||||
if (pointer_test(lookup->floating->items[i], &origin)) {
|
||||
lookup = lookup->floating->items[i];
|
||||
got_floating = true;
|
||||
break;
|
||||
|
@ -558,7 +560,7 @@ swayc_t *container_under_pointer(void) {
|
|||
// search children
|
||||
len = lookup->children->length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (pointer_test(lookup->children->items[i], &pointer_state.origin)) {
|
||||
if (pointer_test(lookup->children->items[i], &origin)) {
|
||||
lookup = lookup->children->items[i];
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -343,10 +343,6 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
|
|||
// Update view pointer is on
|
||||
pointer_state.view = container_under_pointer();
|
||||
|
||||
// Update pointer origin
|
||||
pointer_state.origin.x = origin->x;
|
||||
pointer_state.origin.y = origin->y;
|
||||
|
||||
// Update pointer_state
|
||||
switch (button) {
|
||||
case M_LEFT_CLICK:
|
||||
|
|
|
@ -163,10 +163,10 @@ static void reset_initial_sibling(void) {
|
|||
}
|
||||
|
||||
void pointer_position_set(struct wlc_origin *new_origin, bool force_focus) {
|
||||
pointer_state.delta.x = new_origin->x - pointer_state.origin.x;
|
||||
pointer_state.delta.y = new_origin->y - pointer_state.origin.y;
|
||||
pointer_state.origin.x = new_origin->x;
|
||||
pointer_state.origin.y = new_origin->y;
|
||||
struct wlc_origin origin;
|
||||
wlc_pointer_get_origin(&origin);
|
||||
pointer_state.delta.x = new_origin->x - origin.x;
|
||||
pointer_state.delta.y = new_origin->y - origin.y;
|
||||
|
||||
// Update view under pointer
|
||||
swayc_t *prev_view = pointer_state.view;
|
||||
|
@ -214,8 +214,10 @@ static void pointer_mode_set_right(void) {
|
|||
int midway_x = initial.ptr->x + initial.ptr->width/2;
|
||||
int midway_y = initial.ptr->y + initial.ptr->height/2;
|
||||
|
||||
lock.left = pointer_state.origin.x > midway_x;
|
||||
lock.top = pointer_state.origin.y > midway_y;
|
||||
struct wlc_origin origin;
|
||||
wlc_pointer_get_origin(&origin);
|
||||
lock.left = origin.x > midway_x;
|
||||
lock.top = origin.y > midway_y;
|
||||
|
||||
if (initial.ptr->is_floating) {
|
||||
pointer_state.mode = M_RESIZING | M_FLOATING;
|
||||
|
@ -277,8 +279,10 @@ void pointer_mode_update(void) {
|
|||
pointer_state.mode = 0;
|
||||
return;
|
||||
}
|
||||
int dx = pointer_state.origin.x;
|
||||
int dy = pointer_state.origin.y;
|
||||
struct wlc_origin origin;
|
||||
wlc_pointer_get_origin(&origin);
|
||||
int dx = origin.x;
|
||||
int dy = origin.y;
|
||||
|
||||
switch (pointer_state.mode) {
|
||||
case M_FLOATING | M_DRAGGING:
|
||||
|
|
Loading…
Reference in a new issue