From f125e1b9a4e05a5282765b0b699f8a097ea65783 Mon Sep 17 00:00:00 2001 From: Stivvo Date: Sat, 5 Sep 2020 11:22:24 +0200 Subject: Toggle fullscreen on all clients mod+e allows to toggle fullscreen any client, even those who don't support it themselves --- config.def.h | 1 + 1 file changed, 1 insertion(+) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index 53021cf..d821a96 100644 --- a/config.def.h +++ b/config.def.h @@ -75,6 +75,7 @@ static const Key keys[] = { { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, + { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = -1} }, -- cgit v1.2.3 From c89de53de3e0867157730026a333e16430e71e5a Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sat, 19 Dec 2020 18:23:23 +0100 Subject: remove togglefullscreen keybinding Distribute it as a patch like in dwm since graphical applications usually provide their own keybinding; I guess it's only for terminals. Note that even though these commits don't let you open multiple windows in fullscreen and cycle between them like in dwm, with just fullscreennotify spawning new windows or changing tag would still exit fullscreen automatically, but you would have to toggle fullscreen twice when switching back to the fullscreen window to enter fullscreen again, so this is better since it avoids that. --- config.def.h | 1 - dwl.c | 8 -------- 2 files changed, 9 deletions(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index d821a96..53021cf 100644 --- a/config.def.h +++ b/config.def.h @@ -75,7 +75,6 @@ static const Key keys[] = { { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, - { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = -1} }, diff --git a/dwl.c b/dwl.c index 4c03717..6d51236 100644 --- a/dwl.c +++ b/dwl.c @@ -278,7 +278,6 @@ static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglefloating(const Arg *arg); -static void togglefullscreen(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unmaplayersurface(LayerSurface *layersurface); @@ -1053,13 +1052,6 @@ destroyxdeco(struct wl_listener *listener, void *data) free(d); } -void -togglefullscreen(const Arg *arg) -{ - Client *sel = selclient(); - setfullscreen(sel, !sel->isfullscreen); -} - void setfullscreen(Client *c, int fullscreen) { -- cgit v1.2.3 From 4f1e557d3d26ee8359750dce8f370d404513a1ca Mon Sep 17 00:00:00 2001 From: will Date: Sat, 17 Oct 2020 13:52:53 +0200 Subject: Added basic tap-to-click for touchpad users --- Makefile | 2 +- config.def.h | 4 ++++ dwl.c | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'config.def.h') diff --git a/Makefile b/Makefile index abbbe39..bf0b957 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 -Werror=declaration-after-statement WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols) WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner) -PKGS = wlroots wayland-server xcb xkbcommon +PKGS = wlroots wayland-server xcb xkbcommon libinput CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p))) LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p))) diff --git a/config.def.h b/config.def.h index 53021cf..c1ad7d6 100644 --- a/config.def.h +++ b/config.def.h @@ -41,6 +41,10 @@ static const struct xkb_rule_names xkb_rules = { .options = "ctrl:nocaps", */ }; + +/* Trackpad */ +int tap_to_click = 1; + static const int repeat_rate = 25; static const int repeat_delay = 600; diff --git a/dwl.c b/dwl.c index 2257222..2907c5f 100644 --- a/dwl.c +++ b/dwl.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include #ifdef XWAYLAND @@ -970,6 +972,10 @@ createlayersurface(struct wl_listener *listener, void *data) void createpointer(struct wlr_input_device *device) { + struct libinput_device *libinput_device = (struct libinput_device*) + wlr_libinput_get_device_handle(device); + if (tap_to_click && libinput_device_config_tap_get_finger_count(libinput_device)) + libinput_device_config_tap_set_enabled(libinput_device, LIBINPUT_CONFIG_TAP_ENABLED); /* We don't do anything special with pointers. All of our pointer handling * is proxied through wlr_cursor. On another compositor, you might take this * opportunity to do libinput configuration on the device to set -- cgit v1.2.3 From aa679c4f29fd386e0bb89dd95ec2093f9c998ba8 Mon Sep 17 00:00:00 2001 From: will Date: Sat, 17 Oct 2020 16:18:44 +0200 Subject: Added support for natural scrolling --- config.def.h | 1 + dwl.c | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index c1ad7d6..2c11fd3 100644 --- a/config.def.h +++ b/config.def.h @@ -44,6 +44,7 @@ static const struct xkb_rule_names xkb_rules = { /* Trackpad */ int tap_to_click = 1; +int natural_scrolling = 1; static const int repeat_rate = 25; static const int repeat_delay = 600; diff --git a/dwl.c b/dwl.c index 2907c5f..188639e 100644 --- a/dwl.c +++ b/dwl.c @@ -974,8 +974,13 @@ createpointer(struct wlr_input_device *device) { struct libinput_device *libinput_device = (struct libinput_device*) wlr_libinput_get_device_handle(device); + if (tap_to_click && libinput_device_config_tap_get_finger_count(libinput_device)) libinput_device_config_tap_set_enabled(libinput_device, LIBINPUT_CONFIG_TAP_ENABLED); + + if (libinput_device_config_scroll_has_natural_scroll(libinput_device)) + libinput_device_config_scroll_set_natural_scroll_enabled(libinput_device, natural_scrolling); + /* We don't do anything special with pointers. All of our pointer handling * is proxied through wlr_cursor. On another compositor, you might take this * opportunity to do libinput configuration on the device to set -- cgit v1.2.3 From feeacc88c41653937a2698fcb39a455cd41c44d8 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sat, 19 Dec 2020 18:39:30 +0100 Subject: tweak trackpad variables Add static const and move them below in order to group the keyboard options. --- config.def.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index 2c11fd3..fc30ba8 100644 --- a/config.def.h +++ b/config.def.h @@ -42,13 +42,13 @@ static const struct xkb_rule_names xkb_rules = { */ }; -/* Trackpad */ -int tap_to_click = 1; -int natural_scrolling = 1; - static const int repeat_rate = 25; static const int repeat_delay = 600; +/* Trackpad */ +static const int tap_to_click = 1; +static const int natural_scrolling = 1; + #define MODKEY WLR_MODIFIER_ALT #define TAGKEYS(KEY,SKEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ -- cgit v1.2.3 From 6b47e2bb621dfba333fb9bd9839b8128c88e58c2 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sun, 20 Dec 2020 13:51:40 +0100 Subject: use bool Because it's 2020. Passing integers to wlroots variables and functions with bool in their signature is silly. --- config.def.h | 6 ++-- dwl.c | 104 ++++++++++++++++++++++++++++++----------------------------- 2 files changed, 56 insertions(+), 54 deletions(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index fc30ba8..5e33204 100644 --- a/config.def.h +++ b/config.def.h @@ -1,5 +1,5 @@ /* appearance */ -static const int sloppyfocus = 1; /* focus follows mouse */ +static const bool sloppyfocus = true; /* focus follows mouse */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const float rootcolor[] = {0.3, 0.3, 0.3, 1.0}; static const float bordercolor[] = {0.5, 0.5, 0.5, 1.0}; @@ -46,8 +46,8 @@ static const int repeat_rate = 25; static const int repeat_delay = 600; /* Trackpad */ -static const int tap_to_click = 1; -static const int natural_scrolling = 1; +static const bool tap_to_click = true; +static const bool natural_scrolling = true; #define MODKEY WLR_MODIFIER_ALT #define TAGKEYS(KEY,SKEY,TAG) \ diff --git a/dwl.c b/dwl.c index a4f8b6d..39c2bf1 100644 --- a/dwl.c +++ b/dwl.c @@ -113,13 +113,13 @@ typedef struct { #endif int bw; unsigned int tags; - int isfloating; + bool isfloating; uint32_t resize; /* configure serial of a pending resize */ int oldx; int oldy; int oldwidth; int oldheight; - int isfullscreen; + bool isfullscreen; } Client; typedef struct { @@ -190,7 +190,7 @@ typedef struct { const char *id; const char *title; unsigned int tags; - int isfloating; + bool isfloating; int monitor; } Rule; @@ -232,7 +232,7 @@ static void destroylayersurfacenotify(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data); static void destroyxdeco(struct wl_listener *listener, void *data); static Monitor *dirtomon(int dir); -static void focusclient(Client *c, int lift); +static void focusclient(Client *c, bool lift); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static void fullscreennotify(struct wl_listener *listener, void *data); @@ -240,7 +240,7 @@ static Client *focustop(Monitor *m); static void getxdecomode(struct wl_listener *listener, void *data); static void incnmaster(const Arg *arg); static void inputdevice(struct wl_listener *listener, void *data); -static int keybinding(uint32_t mods, xkb_keysym_t sym); +static bool keybinding(uint32_t mods, xkb_keysym_t sym); static void keypress(struct wl_listener *listener, void *data); static void keypressmod(struct wl_listener *listener, void *data); static void killclient(const Arg *arg); @@ -261,15 +261,15 @@ static void render(struct wlr_surface *surface, int sx, int sy, void *data); static void renderclients(Monitor *m, struct timespec *now); static void renderlayer(struct wl_list *layer_surfaces, struct timespec *now); static void rendermon(struct wl_listener *listener, void *data); -static void resize(Client *c, int x, int y, int w, int h, int interact); +static void resize(Client *c, int x, int y, int w, int h, bool interact); static void run(char *startup_cmd); static void scalebox(struct wlr_box *box, float scale); static Client *selclient(void); static void setcursor(struct wl_listener *listener, void *data); static void setpsel(struct wl_listener *listener, void *data); static void setsel(struct wl_listener *listener, void *data); -static void setfloating(Client *c, int floating); -static void setfullscreen(Client *c, int fullscreen); +static void setfloating(Client *c, bool floating); +static void setfullscreen(Client *c, bool fullscreen); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setmon(Client *c, Monitor *m, unsigned int newtags); @@ -655,7 +655,7 @@ buttonpress(struct wl_listener *listener, void *data) /* Change focus if the button was _pressed_ over a client */ Client *c; if ((c = xytoclient(cursor->x, cursor->y))) - focusclient(c, 1); + focusclient(c, true); struct wlr_keyboard* keyboard = wlr_seat_get_keyboard(seat); uint32_t mods = wlr_keyboard_get_modifiers(keyboard); @@ -737,7 +737,7 @@ cleanupmon(struct wl_listener *listener, void *data) do // don't switch to disabled mons selmon = wl_container_of(mons.prev, selmon, link); while (!selmon->wlr_output->enabled && i++ < nmons); - focusclient(focustop(selmon), 1); + focusclient(focustop(selmon), true); closemon(m); free(m); } @@ -751,7 +751,7 @@ closemon(Monitor *m) wl_list_for_each(c, &clients, link) { if (c->isfloating && c->geom.x > m->m.width) resize(c, c->geom.x - m->w.width, c->geom.y, - c->geom.width, c->geom.height, 0); + c->geom.width, c->geom.height, false); if (c->mon == m) setmon(c, selmon, c->tags); } @@ -856,7 +856,7 @@ createmon(struct wl_listener *listener, void *data) wl_list_insert(&mons, &m->link); - wlr_output_enable(wlr_output, 1); + wlr_output_enable(wlr_output, true); if (!wlr_output_commit(wlr_output)) return; @@ -883,7 +883,7 @@ createmon(struct wl_listener *listener, void *data) wl_list_for_each(c, &clients, link) { if (c->isfloating) resize(c, c->geom.x + m->w.width, c->geom.y, - c->geom.width, c->geom.height, 0); + c->geom.width, c->geom.height, false); } return; } @@ -901,7 +901,7 @@ createnotify(struct wl_listener *listener, void *data) return; wl_list_for_each(c, &clients, link) if (c->isfullscreen && VISIBLEON(c, c->mon)) - setfullscreen(c, 0); + setfullscreen(c, false); /* Allocate a Client for this surface */ c = xdg_surface->data = calloc(1, sizeof(*c)); @@ -924,7 +924,7 @@ createnotify(struct wl_listener *listener, void *data) c->fullscreen.notify = fullscreennotify; wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, &c->fullscreen); - c->isfullscreen = 0; + c->isfullscreen = false; } void @@ -1059,7 +1059,7 @@ destroyxdeco(struct wl_listener *listener, void *data) } void -setfullscreen(Client *c, int fullscreen) +setfullscreen(Client *c, bool fullscreen) { c->isfullscreen = fullscreen; c->bw = (1 - fullscreen) * borderpx; @@ -1077,9 +1077,10 @@ setfullscreen(Client *c, int fullscreen) c->oldy = c->geom.y; c->oldheight = c->geom.height; c->oldwidth = c->geom.width; - resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0); + resize(c, c->mon->m.x, c->mon->m.y, + c->mon->m.width, c->mon->m.height, false); } else { - resize(c, c->oldx, c->oldy, c->oldwidth, c->oldheight, 0); + resize(c, c->oldx, c->oldy, c->oldwidth, c->oldheight, false); } } @@ -1107,7 +1108,7 @@ dirtomon(int dir) } void -focusclient(Client *c, int lift) +focusclient(Client *c, bool lift) { /* Raise client in stacking order if requested */ if (c && lift) { @@ -1154,10 +1155,10 @@ focusclient(Client *c, int lift) /* Activate the new client */ #ifdef XWAYLAND if (c->type != XDGShell) - wlr_xwayland_surface_activate(c->surface.xwayland, 1); + wlr_xwayland_surface_activate(c->surface.xwayland, true); else #endif - wlr_xdg_toplevel_set_activated(c->surface.xdg, 1); + wlr_xdg_toplevel_set_activated(c->surface.xdg, true); } void @@ -1166,7 +1167,7 @@ focusmon(const Arg *arg) do selmon = dirtomon(arg->i); while (!selmon->wlr_output->enabled); - focusclient(focustop(selmon), 1); + focusclient(focustop(selmon), true); } void @@ -1192,7 +1193,7 @@ focusstack(const Arg *arg) } } /* If only one client is visible on selmon, then c == sel */ - focusclient(c, 1); + focusclient(c, true); } Client * @@ -1247,7 +1248,7 @@ inputdevice(struct wl_listener *listener, void *data) wlr_seat_set_capabilities(seat, caps); } -int +bool keybinding(uint32_t mods, xkb_keysym_t sym) { /* @@ -1255,13 +1256,13 @@ keybinding(uint32_t mods, xkb_keysym_t sym) * processing keys, rather than passing them on to the client for its own * processing. */ - int handled = 0; + bool handled = false; const Key *k; for (k = keys; k < END(keys); k++) { if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func) { k->func(&k->arg); - handled = 1; + handled = true; } } return handled; @@ -1281,7 +1282,7 @@ keypress(struct wl_listener *listener, void *data) int nsyms = xkb_state_key_get_syms( kb->device->keyboard->xkb_state, keycode, &syms); - int handled = 0; + bool handled = false; uint32_t mods = wlr_keyboard_get_modifiers(kb->device->keyboard); wlr_idle_notify_activity(idle, seat); @@ -1386,10 +1387,10 @@ monocle(Monitor *m) if (!VISIBLEON(c, m) || c->isfloating) continue; if (c->isfullscreen) { - resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0); + resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, false); return; } - resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0); + resize(c, m->w.x, m->w.y, m->w.width, m->w.height, false); } } @@ -1426,12 +1427,12 @@ motionnotify(uint32_t time) if (cursor_mode == CurMove) { /* Move the grabbed client to the new position. */ resize(grabc, cursor->x - grabcx, cursor->y - grabcy, - grabc->geom.width, grabc->geom.height, 1); + grabc->geom.width, grabc->geom.height, true); return; } else if (cursor_mode == CurResize) { resize(grabc, grabc->geom.x, grabc->geom.y, cursor->x - grabc->geom.x, - cursor->y - grabc->geom.y, 1); + cursor->y - grabc->geom.y, true); return; } @@ -1507,7 +1508,7 @@ moveresize(const Arg *arg) return; /* Float the window and tell motionnotify to grab it */ - setfloating(grabc, 1); + setfloating(grabc, true); switch (cursor_mode = arg->ui) { case CurMove: grabcx = cursor->x - grabc->geom.x; @@ -1625,7 +1626,7 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, #endif if (sloppyfocus) - focusclient(c, 0); + focusclient(c, false); } void @@ -1773,11 +1774,11 @@ rendermon(struct wl_listener *listener, void *data) /* Do not render if any XDG clients have an outstanding resize. */ Client *c; - int render = 1; + bool render = true; wl_list_for_each(c, &stack, slink) { if (c->resize) { wlr_surface_send_frame_done(WLR_SURFACE(c), &now); - render = 0; + render = false; } } @@ -1816,7 +1817,7 @@ rendermon(struct wl_listener *listener, void *data) } void -resize(Client *c, int x, int y, int w, int h, int interact) +resize(Client *c, int x, int y, int w, int h, bool interact) { /* * Note that I took some shortcuts here. In a more fleshed-out @@ -1930,7 +1931,7 @@ setcursor(struct wl_listener *listener, void *data) } void -setfloating(Client *c, int floating) +setfloating(Client *c, bool floating) { if (c->isfloating == floating) return; @@ -1983,7 +1984,7 @@ setmon(Client *c, Monitor *m, unsigned int newtags) c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */ arrange(m); } - focusclient(focustop(selmon), 1); + focusclient(focustop(selmon), true); } void @@ -2196,7 +2197,7 @@ tag(const Arg *arg) Client *sel = selclient(); if (sel && arg->ui & TAGMASK) { sel->tags = arg->ui & TAGMASK; - focusclient(focustop(selmon), 1); + focusclient(focustop(selmon), true); arrange(selmon); } } @@ -2231,16 +2232,17 @@ tile(Monitor *m) if (!VISIBLEON(c, m) || c->isfloating) continue; if (c->isfullscreen) { - resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0); + resize(c, c->mon->m.x, c->mon->m.y, + c->mon->m.width, c->mon->m.height, false); return; } if (i < m->nmaster) { h = (m->w.height - my) / (MIN(n, m->nmaster) - i); - resize(c, m->w.x, m->w.y + my, mw, h, 0); + resize(c, m->w.x, m->w.y + my, mw, h, false); my += c->geom.height; } else { h = (m->w.height - ty) / (n - i); - resize(c, m->w.x + mw, m->w.y + ty, m->w.width - mw, h, 0); + resize(c, m->w.x + mw, m->w.y + ty, m->w.width - mw, h, false); ty += c->geom.height; } i++; @@ -2266,7 +2268,7 @@ toggletag(const Arg *arg) unsigned int newtags = sel->tags ^ (arg->ui & TAGMASK); if (newtags) { sel->tags = newtags; - focusclient(focustop(selmon), 1); + focusclient(focustop(selmon), true); arrange(selmon); } } @@ -2278,7 +2280,7 @@ toggleview(const Arg *arg) if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; - focusclient(focustop(selmon), 1); + focusclient(focustop(selmon), true); arrange(selmon); } } @@ -2289,7 +2291,7 @@ unmaplayersurface(LayerSurface *layersurface) layersurface->layer_surface->mapped = false; if (layersurface->layer_surface->surface == seat->keyboard_state.focused_surface) - focusclient(selclient(), 1); + focusclient(selclient(), true); motionnotify(0); } @@ -2350,7 +2352,7 @@ view(const Arg *arg) selmon->seltags ^= 1; /* toggle sel tagset */ if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; - focusclient(focustop(selmon), 1); + focusclient(focustop(selmon), true); arrange(selmon); } @@ -2430,7 +2432,7 @@ zoom(const Arg *arg) wl_list_remove(&sel->link); wl_list_insert(&clients, &sel->link); - focusclient(sel, 1); + focusclient(sel, true); arrange(selmon); } @@ -2442,7 +2444,7 @@ activatex11(struct wl_listener *listener, void *data) /* Only "managed" windows can be activated */ if (c->type == X11Managed) - wlr_xwayland_surface_activate(c->surface.xwayland, 1); + wlr_xwayland_surface_activate(c->surface.xwayland, true); } void @@ -2460,7 +2462,7 @@ createnotifyx11(struct wl_listener *listener, void *data) Client *c; wl_list_for_each(c, &clients, link) if (c->isfullscreen && VISIBLEON(c, c->mon)) - setfullscreen(c, 0); + setfullscreen(c, false); /* Allocate a Client for this surface */ struct wlr_xwayland_surface *xwayland_surface = data; @@ -2483,7 +2485,7 @@ createnotifyx11(struct wl_listener *listener, void *data) c->fullscreen.notify = fullscreennotify; wl_signal_add(&xwayland_surface->events.request_fullscreen, &c->fullscreen); - c->isfullscreen = 0; + c->isfullscreen = false; } Atom @@ -2535,7 +2537,7 @@ updatewindowtype(Client *c) c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeSplash] || c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeToolbar] || c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeUtility]) - c->isfloating = 1; + c->isfloating = true; } void -- cgit v1.2.3 From 5668c616161d451e6f20be29b31bbf03f0f398a5 Mon Sep 17 00:00:00 2001 From: Stivvo Date: Fri, 18 Sep 2020 21:45:35 +0200 Subject: Define monitor order with monrules[] The order in which monitors are defined in monrules[] actually matters. Monotors that aren't configured in monrules[], it will always be the leftmost. --- config.def.h | 3 +++ dwl.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index 5e33204..8d76be4 100644 --- a/config.def.h +++ b/config.def.h @@ -32,6 +32,9 @@ static const MonitorRule monrules[] = { */ /* defaults */ { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, + /* with the outputOder patch, the order in which every monitor is defined + * defines its actual position. Non configured monitor, are always added to + * the left */ }; /* keyboard */ diff --git a/dwl.c b/dwl.c index 16f0a88..d54311d 100644 --- a/dwl.c +++ b/dwl.c @@ -175,6 +175,7 @@ struct Monitor { unsigned int tagset[2]; double mfact; int nmaster; + int position; }; typedef struct { @@ -836,8 +837,8 @@ createmon(struct wl_listener *listener, void *data) Monitor *m = wlr_output->data = calloc(1, sizeof(*m)); m->wlr_output = wlr_output; m->tagset[0] = m->tagset[1] = 1; - const MonitorRule *r; - for (r = monrules; r < END(monrules); r++) { + m->position = -1; + for (const MonitorRule *r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { m->mfact = r->mfact; m->nmaster = r->nmaster; @@ -846,6 +847,7 @@ createmon(struct wl_listener *listener, void *data) m->lt[0] = r->lt; m->lt[1] = &layouts[LENGTH(layouts) > 1 && r->lt != &layouts[1]]; wlr_output_set_transform(wlr_output, r->rr); + m->position = r - monrules; break; } } @@ -856,7 +858,19 @@ createmon(struct wl_listener *listener, void *data) m->destroy.notify = cleanupmon; wl_signal_add(&wlr_output->events.destroy, &m->destroy); - wl_list_insert(&mons, &m->link); + Monitor *moni, *insertmon = NULL; + int x = 0; + wl_list_for_each(moni, &mons, link) + if (m->position > moni->position) + insertmon = moni; + if (insertmon) { + x = insertmon->w.x + insertmon->w.width; + wl_list_insert(&insertmon->link, &m->link); + fprintf(stderr, "%s inserted in pos %d\n", m->wlr_output->name, m->position); + } else { + wl_list_insert(&mons, &m->link); + fprintf(stderr, "%s defaulting\n", m->wlr_output->name); + } wlr_output_enable(wlr_output, true); if (!wlr_output_commit(wlr_output)) @@ -871,7 +885,15 @@ createmon(struct wl_listener *listener, void *data) * display, which Wayland clients can see to find out information about the * output (such as DPI, scale factor, manufacturer, etc). */ - wlr_output_layout_add_auto(output_layout, wlr_output); + wlr_output_layout_add(output_layout, wlr_output, x, 0); + wl_list_for_each_reverse(moni, &mons, link) { + /* all monitors that on the right of the new one must be moved */ + if (moni == m) + break; + wlr_output_layout_move(output_layout, moni->wlr_output, moni->w.x + m->wlr_output->width, 0); + fprintf(stderr, "moved %s to %d", moni->wlr_output->name, moni->w.x + m->wlr_output->width); + } + sgeom = *wlr_output_layout_get_box(output_layout, NULL); size_t nlayers = LENGTH(m->layers); for (size_t i = 0; i < nlayers; ++i) -- cgit v1.2.3 From 33e8a3f1f3382322180c6b80bc48cb2ab4965bcf Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Mon, 21 Dec 2020 11:21:59 +0100 Subject: update comments and remove debugging printf --- config.def.h | 7 +++---- dwl.c | 12 +++--------- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index 8d76be4..4ab746b 100644 --- a/config.def.h +++ b/config.def.h @@ -24,7 +24,9 @@ static const Layout layouts[] = { { "[M]", monocle }, }; -/* monitors */ +/* monitors + * The order in which monitors are defined determines their position. + * Non-configured monitors are always added to the left. */ static const MonitorRule monrules[] = { /* name mfact nmaster scale layout rotate/reflect */ /* example of a HiDPI laptop monitor: @@ -32,9 +34,6 @@ static const MonitorRule monrules[] = { */ /* defaults */ { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, - /* with the outputOder patch, the order in which every monitor is defined - * defines its actual position. Non configured monitor, are always added to - * the left */ }; /* keyboard */ diff --git a/dwl.c b/dwl.c index d54311d..2128751 100644 --- a/dwl.c +++ b/dwl.c @@ -866,20 +866,15 @@ createmon(struct wl_listener *listener, void *data) if (insertmon) { x = insertmon->w.x + insertmon->w.width; wl_list_insert(&insertmon->link, &m->link); - fprintf(stderr, "%s inserted in pos %d\n", m->wlr_output->name, m->position); } else { wl_list_insert(&mons, &m->link); - fprintf(stderr, "%s defaulting\n", m->wlr_output->name); } wlr_output_enable(wlr_output, true); if (!wlr_output_commit(wlr_output)) return; - /* 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 - * layout. + /* Adds this to the output layout in the order it was configured in. * * The output layout utility automatically adds a wl_output global to the * display, which Wayland clients can see to find out information about the @@ -887,11 +882,10 @@ createmon(struct wl_listener *listener, void *data) */ wlr_output_layout_add(output_layout, wlr_output, x, 0); wl_list_for_each_reverse(moni, &mons, link) { - /* all monitors that on the right of the new one must be moved */ + /* All monitors to the right of the new one must be moved */ if (moni == m) break; wlr_output_layout_move(output_layout, moni->wlr_output, moni->w.x + m->wlr_output->width, 0); - fprintf(stderr, "moved %s to %d", moni->wlr_output->name, moni->w.x + m->wlr_output->width); } sgeom = *wlr_output_layout_get_box(output_layout, NULL); @@ -902,7 +896,7 @@ createmon(struct wl_listener *listener, void *data) /* When adding monitors, the geometries of all monitors must be updated */ updatemons(); wl_list_for_each(m, &mons, link) { - /* the first monitor in the list is the most recently added */ + /* The first monitor in the list is the most recently added */ Client *c; wl_list_for_each(c, &clients, link) { if (c->isfloating) -- cgit v1.2.3 From bcf9d8fb9a2f30e5fc0283637ee63350bf78e696 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Mon, 21 Dec 2020 13:06:06 +0100 Subject: disable natural scrolling by default This inverts the scroll even on regular mice. --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index 4ab746b..b7e067d 100644 --- a/config.def.h +++ b/config.def.h @@ -49,7 +49,7 @@ static const int repeat_delay = 600; /* Trackpad */ static const bool tap_to_click = true; -static const bool natural_scrolling = true; +static const bool natural_scrolling = false; #define MODKEY WLR_MODIFIER_ALT #define TAGKEYS(KEY,SKEY,TAG) \ -- cgit v1.2.3