forked from mirror/dwl
focus monitor under mouse cursor initially
This commit is contained in:
parent
f88a98327e
commit
240be1af19
1 changed files with 16 additions and 3 deletions
19
dwl.c
19
dwl.c
|
@ -149,6 +149,7 @@ static void tile(Monitor *m);
|
||||||
static void unmapnotify(struct wl_listener *listener, void *data);
|
static void unmapnotify(struct wl_listener *listener, void *data);
|
||||||
static Client * xytoclient(double x, double y,
|
static Client * xytoclient(double x, double y,
|
||||||
struct wlr_surface **surface, double *sx, double *sy);
|
struct wlr_surface **surface, double *sx, double *sy);
|
||||||
|
static Monitor *xytomon(double x, double y);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static struct wl_display *wl_display;
|
static struct wl_display *wl_display;
|
||||||
|
@ -302,9 +303,6 @@ createmon(struct wl_listener *listener, void *data)
|
||||||
wl_signal_add(&wlr_output->events.frame, &m->frame);
|
wl_signal_add(&wlr_output->events.frame, &m->frame);
|
||||||
wl_list_insert(&mons, &m->link);
|
wl_list_insert(&mons, &m->link);
|
||||||
|
|
||||||
if (!selmon)
|
|
||||||
selmon = m;
|
|
||||||
|
|
||||||
/* Adds this to the output layout. The add_auto function arranges outputs
|
/* Adds this to the output layout. The add_auto function arranges outputs
|
||||||
* from left-to-right in the order they appear. A more sophisticated
|
* from left-to-right in the order they appear. A more sophisticated
|
||||||
* compositor would let the user configure the arrangement of outputs in the
|
* compositor would let the user configure the arrangement of outputs in the
|
||||||
|
@ -813,6 +811,10 @@ run(char *startup_cmd)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now that outputs are initialized, choose initial selmon based on
|
||||||
|
* cursor position */
|
||||||
|
selmon = xytomon(cursor->x, cursor->y);
|
||||||
|
|
||||||
/* Set the WAYLAND_DISPLAY environment variable to our socket and run the
|
/* Set the WAYLAND_DISPLAY environment variable to our socket and run the
|
||||||
* startup command if requested. */
|
* startup command if requested. */
|
||||||
setenv("WAYLAND_DISPLAY", socket, true);
|
setenv("WAYLAND_DISPLAY", socket, true);
|
||||||
|
@ -1063,6 +1065,17 @@ xytoclient(double x, double y,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Monitor *
|
||||||
|
xytomon(double x, double y)
|
||||||
|
{
|
||||||
|
struct wlr_output *o = wlr_output_layout_output_at(output_layout, x, y);
|
||||||
|
Monitor *m;
|
||||||
|
wl_list_for_each(m, &mons, link)
|
||||||
|
if (m->wlr_output == o)
|
||||||
|
return m;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue