Add tabbed patches not included in upstream

This commit is contained in:
Alexis Jhon Gaspar 2023-11-01 23:07:38 +08:00
parent 57a05555f3
commit 813717224b
7 changed files with 91 additions and 5 deletions

View file

@ -18,6 +18,9 @@ static const int tabwidth = 200;
#endif // AWESOMEBAR_PATCH
static const Bool foreground = True;
static Bool urgentswitch = False;
#if SEPERATOR_PATCH
static const int separator = 1;
#endif // SEPERATOR_PATCH
#if BAR_HEIGHT_PATCH
static const int barheight = 0; /* 0 means derive by font (default), otherwise absolute height */

View file

@ -0,0 +1,34 @@
void
motionnotify(const XEvent *e)
{
const XMotionEvent *ev = &e->xmotion;
int i, fc;
Arg arg;
if (ev->y < 0 || ev->y > bh)
return;
if (! (ev->state & Button1Mask)) {
return;
}
if (((fc = getfirsttab()) > 0 && ev->x < TEXTW(before)) || ev->x < 0)
return;
if (sel < 0)
return;
for (i = fc; i < nclients; i++) {
if (clients[i]->tabx > ev->x) {
if (i == sel+1) {
arg.i = 1;
movetab(&arg);
}
if (i == sel-1) {
arg.i = -1;
movetab(&arg);
}
break;
}
}
}

View file

@ -0,0 +1 @@
static void motionnotify(const XEvent *e);

View file

@ -1,4 +1,7 @@
/* Patches */
#if DRAG_PATCH
#include "drag.c"
#endif
#if HIDETABS_PATCH
#include "hidebar.c"
#endif
@ -10,4 +13,4 @@
#endif
#if XRESOURCES_PATCH
#include "xresources.c"
#endif
#endif

View file

@ -1,4 +1,7 @@
/* Patches */
#if DRAG_PATCH
#include "drag.h"
#endif
#if HIDETABS_PATCH
#include "hidebar.h"
#endif
@ -10,4 +13,4 @@
#endif
#if XRESOURCES_PATCH
#include "xresources.h"
#endif
#endif

View file

@ -42,11 +42,22 @@
*/
#define CENTER_PATCH 1
/* With this patch, tabbed interprets large position numbers as the largest known position.
* This allows Ctrl-9, for example, to always select the rightmost tab, even if there are only 4 tabs.
* https://tools.suckless.org/tabbed/patches/move-clamped/
*/
#define CLAMPEDMOVE_PATCH 1
/* This patch prints the position number of the client before the window title.
* https://tools.suckless.org/tabbed/patches/clientnumber/
*/
#define CLIENTNUMBER_PATCH 1
/* Support dragging tabs left and right with the mouse.
* https://tools.suckless.org/tabbed/patches/drag/
*/
#define DRAG_PATCH 1
/* This patch hides all the tabs and only shows them when Mod+Shift is pressed. All functions
* with switching, rotating, and creating tabs involve Mod+Shift. When not doing one of these
* functions, visibility of the tabs is not needed.
@ -85,6 +96,12 @@
*/
#define REPARENT_PATCH 1
/* Add a decorative separator bar to the beginning of each tab.
* Configure the width via the separator property in config.h.
* https://tools.suckless.org/tabbed/patches/separator/
*/
#define SEPERATOR_PATCH 0
/* This patch allows tabbed colors to be defined via Xresources.
* https://tools.suckless.org/tabbed/patches/xresources/
*/

View file

@ -172,6 +172,9 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
#endif // KEYRELEASE_PATCH
[MapRequest] = maprequest,
[PropertyNotify] = propertynotify,
#if DRAG_PATCH
[MotionNotify] = motionnotify,
#endif // DRAG_PATCH
};
static int bh, obh, wx, wy, ww, wh;
#if AUTOHIDE_PATCH || HIDETABS_PATCH
@ -476,10 +479,20 @@ drawtext(const char *text, XftColor col[ColLast])
int i, j, x, y, h, len, olen;
char buf[256];
XftDraw *d;
#if SEPERATOR_PATCH
XRectangle tab = { dc.x+separator, dc.y, dc.w-separator, dc.h };
XRectangle sep = { dc.x, dc.y, separator, dc.h };
#else
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
#endif // SEPERATOR_PATCH
XSetForeground(dpy, dc.gc, col[ColBG].pixel);
#if SEPERATOR_PATCH
XFillRectangles(dpy, dc.drawable, dc.gc, &tab, 1);
#else
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
#endif // SEPERATOR_PATCH
if (!text)
return;
@ -928,8 +941,15 @@ maprequest(const XEvent *e)
void
move(const Arg *arg)
{
if (arg->i >= 0 && arg->i < nclients)
focus(arg->i);
#if CLAMPEDMOVE_PATCH
int i;
i = arg->i < nclients ? arg->i : nclients - 1;
if (i >= 0)
focus(i);
#else
if (arg->i >= 0 && arg->i < nclients)
focus(arg->i);
#endif // CLAMPEDMOVE_PATCH
}
void
@ -1264,7 +1284,12 @@ setup(void)
KeyReleaseMask |
#endif // KEYRELEASE_PATCH
PropertyChangeMask | StructureNotifyMask |
SubstructureRedirectMask);
#if DRAG_PATCH
SubstructureRedirectMask | ButtonMotionMask
#else
SubstructureRedirectMask
#endif // DRAG_PATCH
);
xerrorxlib = XSetErrorHandler(xerror);
class_hint.res_name = wmname;