From 22c5f5f866d967d3d41f651c14f3a2fd11da0038 Mon Sep 17 00:00:00 2001 From: Nikita Langer Date: Sun, 31 May 2026 09:57:10 +0200 Subject: Cliuck url --- x.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'x.c') diff --git a/x.c b/x.c index c8cac4b..57ca715 100644 --- a/x.c +++ b/x.c @@ -209,6 +209,7 @@ static void usage(void); static void (*handler[LASTEvent])(XEvent *) = { [KeyPress] = kpress, + [KeyRelease] = kpress, [ClientMessage] = cmessage, [ConfigureNotify] = resize, [VisibilityNotify] = visibility, @@ -473,6 +474,15 @@ mouseaction(XEvent *e, uint release) /* ignore Buttonmask for Button - it's set on release */ uint state = e->xbutton.state & ~buttonmask(e->xbutton.button); + if (release == 0 && + e->xbutton.button == Button1 && + (match(ControlMask, state) || + match(ControlMask, state & ~forcemousemod))) { + followurl(evrow(e), evcol(e)); + return 1; + } + + for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { if (ms->release == release && ms->button == e->xbutton.button && @@ -1715,7 +1725,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i } /* Render underline and strikethrough. */ - if (base.mode & ATTR_UNDERLINE) { + if (base.mode & ATTR_UNDERLINE || base.mode & ATTR_URL) { XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1, width, 1); } @@ -2123,6 +2133,18 @@ kpress(XEvent *ev) } else { len = XLookupString(e, buf, sizeof buf, &ksym, NULL); } + + /* 0. highlight URLs when control held */ + if (ksym == XK_Control_L) { + highlighturls(); + } else if (ev->type == KeyRelease && e->keycode == XKeysymToKeycode(e->display, XK_Control_L)) { + unhighlighturls(); + } + + /* KeyRelease not relevant to shortcuts */ + if (ev->type == KeyRelease) + return; + /* 1. shortcuts */ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if (ksym == bp->keysym && match(bp->mod, e->state)) { -- cgit