forked from mirror/dwl
focus follows mouse
This commit is contained in:
parent
4eabe48fed
commit
a87adfd77c
2 changed files with 25 additions and 20 deletions
|
@ -1,4 +1,5 @@
|
||||||
/* appearance */
|
/* appearance */
|
||||||
|
static const int sloppyfocus = 1; /* focus follows mouse */
|
||||||
static const float rootcolor[] = {0.3, 0.3, 0.3, 1.0};
|
static const float rootcolor[] = {0.3, 0.3, 0.3, 1.0};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
|
|
24
dwl.c
24
dwl.c
|
@ -203,6 +203,7 @@ arrange(Monitor *m)
|
||||||
{
|
{
|
||||||
if (m->lt[m->sellt]->arrange)
|
if (m->lt[m->sellt]->arrange)
|
||||||
m->lt[m->sellt]->arrange(m);
|
m->lt[m->sellt]->arrange(m);
|
||||||
|
/* XXX recheck pointer focus here... or in resize()? */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -606,6 +607,7 @@ void
|
||||||
motionnotify(uint32_t time)
|
motionnotify(uint32_t time)
|
||||||
{
|
{
|
||||||
/* Update selmon (even while dragging a window) */
|
/* Update selmon (even while dragging a window) */
|
||||||
|
if (sloppyfocus)
|
||||||
selmon = xytomon(cursor->x, cursor->y);
|
selmon = xytomon(cursor->x, cursor->y);
|
||||||
|
|
||||||
/* If we are currently grabbing the mouse, handle and return */
|
/* If we are currently grabbing the mouse, handle and return */
|
||||||
|
@ -628,8 +630,7 @@ motionnotify(uint32_t time)
|
||||||
/* Otherwise, find the client under the pointer and send the event along. */
|
/* Otherwise, find the client under the pointer and send the event along. */
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
struct wlr_surface *surface = NULL;
|
struct wlr_surface *surface = NULL;
|
||||||
Client *c = xytoclient(cursor->x, cursor->y,
|
Client *c = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
|
||||||
&surface, &sx, &sy);
|
|
||||||
if (!c) {
|
if (!c) {
|
||||||
/* If there's no client under the cursor, set the cursor image to a
|
/* If there's no client under the cursor, set the cursor image to a
|
||||||
* default. This is what makes the cursor image appear when you move it
|
* default. This is what makes the cursor image appear when you move it
|
||||||
|
@ -637,8 +638,13 @@ motionnotify(uint32_t time)
|
||||||
wlr_xcursor_manager_set_cursor_image(
|
wlr_xcursor_manager_set_cursor_image(
|
||||||
cursor_mgr, "left_ptr", cursor);
|
cursor_mgr, "left_ptr", cursor);
|
||||||
}
|
}
|
||||||
if (surface) {
|
if (!surface) {
|
||||||
bool focus_changed = seat->pointer_state.focused_surface != surface;
|
/* Clear pointer focus so future button events and such are not sent to
|
||||||
|
* the last client to have the cursor over it. */
|
||||||
|
wlr_seat_pointer_clear_focus(seat);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "Enter" the surface if necessary. This lets the client know that the
|
* "Enter" the surface if necessary. This lets the client know that the
|
||||||
* cursor has entered one of its surfaces.
|
* cursor has entered one of its surfaces.
|
||||||
|
@ -647,17 +653,15 @@ motionnotify(uint32_t time)
|
||||||
* from keyboard focus. You get pointer focus by moving the pointer over
|
* from keyboard focus. You get pointer focus by moving the pointer over
|
||||||
* a window.
|
* a window.
|
||||||
*/
|
*/
|
||||||
|
if (surface != seat->pointer_state.focused_surface) {
|
||||||
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
|
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
|
||||||
if (!focus_changed) {
|
if (sloppyfocus)
|
||||||
|
focus(c, surface);
|
||||||
|
} else {
|
||||||
/* The enter event contains coordinates, so we only need to notify
|
/* The enter event contains coordinates, so we only need to notify
|
||||||
* on motion if the focus did not change. */
|
* on motion if the focus did not change. */
|
||||||
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
|
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/* Clear pointer focus so future button events and such are not sent to
|
|
||||||
* the last client to have the cursor over it. */
|
|
||||||
wlr_seat_pointer_clear_focus(seat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue