Skip to content

Commit

Permalink
Revert mouse warp
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl-github-acc committed Sep 4, 2023
1 parent f05ec29 commit c5eb4c9
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions dwl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1574,27 +1574,7 @@ focusmon(const Arg *arg)
c = focustop(selmon);
focusclient(c, 1);

int max_x = 0, max_y = 0;
Monitor *m;
struct wlr_box m_area;
wl_list_for_each(m, &mons, link) {
m_area = m->m;
if ((m_area.x + m_area.width) > max_x) {
max_x = (m_area.x + m_area.width);
}
if ((m_area.y + m_area.height) > max_y) {
max_y = (m_area.y + m_area.height);
}
}
if (mousefollowsfocus) {
if (c) {
warpcursortoclient(c);
} else {
wlr_cursor_warp_absolute(cursor, NULL,
((double)selmon->m.x + ((double)selmon->m.width) / 2.0) / (double)max_x,
((double)selmon->m.y + ((double)selmon->m.height) / 2.0) / (double)max_y);
}
}
if (mousefollowsfocus) warpcursortoclient(c);
}

void
Expand Down Expand Up @@ -3147,26 +3127,12 @@ virtualkeyboard(struct wl_listener *listener, void *data)

void
warpcursortoclient(Client *c) {
if (!c) return;

int max_x = 0, max_y = 0;
Monitor *m;
struct wlr_box m_area;
wl_list_for_each(m, &mons, link) {
m_area = m->m;
if ((m_area.x + m_area.width) > max_x) {
max_x = (m_area.x + m_area.width);
}
if ((m_area.y + m_area.height) > max_y) {
max_y = (m_area.y + m_area.height);
}
}

struct wlr_box mg = c->mon->m;
struct wlr_box cg = c->geom;
if (!VISIBLEON(c, selmon)) return;
wlr_cursor_warp_absolute(cursor, NULL,
((double)cg.x + (double)cg.width / 2.0) / (double)max_x,
((double)cg.y + (double)cg.height / 2.0) / (double)max_y);
((double)cg.x + (double)cg.width / 2.0) / (double)mg.width,
((double)cg.y + (double)cg.height / 2.0) / (double)mg.height);
}

Monitor *
Expand Down

0 comments on commit c5eb4c9

Please sign in to comment.