diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2020-04-19 15:05:30 -0500 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2020-04-22 22:55:57 -0500 |
commit | 240be1af1917ae79797269f48b7128e285f263b8 (patch) | |
tree | bf6d00d722645df2b11aa4418789b0b746833cb9 | |
parent | f88a98327e717ae3fffd746f058b75eb37bc6563 (diff) |
focus monitor under mouse cursor initially
-rw-r--r-- | dwl.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -149,6 +149,7 @@ static void tile(Monitor *m); static void unmapnotify(struct wl_listener *listener, void *data); static Client * xytoclient(double x, double y, struct wlr_surface **surface, double *sx, double *sy); +static Monitor *xytomon(double x, double y); /* variables */ 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_list_insert(&mons, &m->link); - if (!selmon) - selmon = m; - /* Adds this to the output layout. The add_auto function arranges outputs * from left-to-right in the order they appear. A more sophisticated * compositor would let the user configure the arrangement of outputs in the @@ -813,6 +811,10 @@ run(char *startup_cmd) 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 * startup command if requested. */ setenv("WAYLAND_DISPLAY", socket, true); @@ -1063,6 +1065,17 @@ xytoclient(double x, double y, 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 main(int argc, char *argv[]) { |