This commit is contained in:
speediegq 2022-08-28 01:47:41 +02:00
parent 79718a1e13
commit 794e63060c
5 changed files with 122 additions and 21 deletions

View file

@ -162,7 +162,7 @@ Below is a list of all speedwm keybinds.
- Email button | Open your defined email client
- System button | Open your defined status viewer in a terminal
-- Mouse --
### Mouse
These binds can be activated using your mouse

View file

@ -126,6 +126,7 @@
- Focused window (Super+Alt+Middle click) | Make the focused window floating
- Focused window title (Middle click) | Rotate stack
- Dragging (Super+Right click) | Increase/decrease size of each window
- Dragging (Super+Middle click) | Increase/decrease cfact
There are also keybinds for statuscmd, but you must implement it into your own status bar.
See mouse.h for more information.

View file

@ -12,6 +12,7 @@ static Button buttons[] = {
{ ClkLtSymbol, 0, Button1, cyclelayout, {.i = +1 } },
{ ClkLtSymbol, 0, Button2, cyclelayout, {.i = -1 } },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkClientWin, MODKEY, Button2, dragcfact, {0} },
{ ClkClientWin, MODKEY, Button1, moveorplace, {.i = 1} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },

View file

@ -377,6 +377,7 @@ static void incrogaps(const Arg *arg);
static void togglegaps(const Arg *arg);
static void defaultgaps(const Arg *arg);
static void setlayout(const Arg *arg);
static void dragcfact(const Arg *arg);
#if USEIPC
static void setlayoutsafe(const Arg *arg);
#endif
@ -1432,6 +1433,81 @@ dirtomon(int dir)
return m;
}
void
dragcfact(const Arg *arg)
{
int prev_x, prev_y, dist_x, dist_y;
float fact;
Client *c;
XEvent ev;
Time lasttime = 0;
if (!(c = selmon->sel))
return;
if (c->isfloating) {
resizemouse(arg);
return;
}
#if !FAKEFULLSCREEN_PATCH
#if FAKEFULLSCREEN_CLIENT_PATCH
if (c->isfullscreen && !c->fakefullscreen) /* no support resizing fullscreen windows by mouse */
return;
#else
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
return;
#endif // FAKEFULLSCREEN_CLIENT_PATCH
#endif // !FAKEFULLSCREEN_PATCH
restack(selmon);
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
return;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
prev_x = prev_y = -999999;
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
case ConfigureRequest:
case Expose:
case MapRequest:
handler[ev.type](&ev);
break;
case MotionNotify:
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
continue;
lasttime = ev.xmotion.time;
if (prev_x == -999999) {
prev_x = ev.xmotion.x_root;
prev_y = ev.xmotion.y_root;
}
dist_x = ev.xmotion.x - prev_x;
dist_y = ev.xmotion.y - prev_y;
if (abs(dist_x) > abs(dist_y)) {
fact = (float) 4.0 * dist_x / c->mon->ww;
} else {
fact = (float) -4.0 * dist_y / c->mon->wh;
}
if (fact)
setcfact(&((Arg) { .f = fact }));
prev_x = ev.xmotion.x;
prev_y = ev.xmotion.y;
break;
}
} while (ev.type != ButtonRelease);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
Bool
isHexDigit(char digit) {
return (digit >= '0' && digit <= '9') || (digit >= 'A' && digit <= 'F') || (digit >= 'a' && digit <= 'f');
@ -3732,19 +3808,27 @@ setlayout(const Arg *arg)
}
void
setcfact(const Arg *arg) {
setcfact(const Arg *arg)
{
float f;
Client *c;
c = selmon->sel;
if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
if (!arg || !c || !selmon->lt[selmon->sellt]->arrange)
return;
f = arg->f + c->cfact;
if(arg->f == 0.0)
//f = arg->f + c->cfact;
//if(arg->f == 0.0)
if (!arg->f)
f = 1.0;
else if(f < 0.25 || f > 4.0)
return;
else if (arg->f > 4.0) // set fact absolutely
f = arg->f - 4.0;
else
f = arg->f + c->cfact;
if (f < 0.25)
f = 0.25;
else if (f > 4.0)
f = 4.0;
c->cfact = f;
arrange(selmon);
}

41
status
View file

@ -96,43 +96,43 @@ STATUS_WHEN_HIDDEN="" # Status to print when status is hidden (char)
# Order of colors and items in the status bar
PRINT() {
$SETMETHOD "\
$SETMETHOD "$(printf "\
$FSETCOLORCMD11\
$BSETCOLORCMD11\
$(ITEM2) \
$ITEMCMD2 \
$FSETCOLORCMD10\
$BSETCOLORCMD10\
$(ITEM3) \
$ITEMCMD3 \
$FSETCOLORCMD13\
$BSETCOLORCMD13\
$(ITEM11) \
$ITEMCMD11 \
$FSETCOLORCMD8\
$BSETCOLORCMD8\
$(ITEM4) \
$ITEMCMD4 \
$FSETCOLORCMD7\
$BSETCOLORCMD7\
$(ITEM1) \
$ITEMCMD1 \
$FSETCOLORCMD6\
$BSETCOLORCMD6\
$(ITEM6) \
$ITEMCMD6 \
$FSETCOLORCMD4\
$BSETCOLORCMD4\
$(ITEM8) \
$ITEMCMD8 \
$FSETCOLORCMD3\
$BSETCOLORCMD3\
$(ITEM5) \
$ITEMCMD5 \
$FSETCOLORCMD2\
$BSETCOLORCMD2\
$(ITEM9) \
$ITEMCMD9 \
$FSETCOLORCMD5\
$BSETCOLORCMD5\
$(ITEM7) \
$ITEMCMD7 \
$FSETCOLORCMD9\
$BSETCOLORCMD9\
$(ITEM10) \
$ITEMCMD10 \
$FSETCOLORCMD14\
$BSETCOLORCMD14\
$(ITEM12)"
$ITEMCMD12")"
}
# Colors
@ -382,6 +382,21 @@ PRINT_SYSTRAY() {
esac
fi
# Output of commands
# We're doing this so we can manipulate them easily for various reasons.
ITEMCMD1="$(printf "$(ITEM1)")"
ITEMCMD2="$(printf "$(ITEM2)")"
ITEMCMD3="$(printf "$(ITEM3)")"
ITEMCMD4="$(printf "$(ITEM4)")"
ITEMCMD5="$(printf "$(ITEM5)")"
ITEMCMD6="$(printf "$(ITEM6)")"
ITEMCMD7="$(printf "$(ITEM7)")"
ITEMCMD8="$(printf "$(ITEM8)")"
ITEMCMD9="$(printf "$(ITEM9)")"
ITEMCMD10="$(printf "$(ITEM10)")"
ITEMCMD11="$(printf "$(ITEM11)")"
ITEMCMD12="$(printf "$(ITEM12)")"
if [ "$HIDE_SYSTEM_SYSTRAY" = "true" ]; then
if [ "$SYSTRAYRUNNING" != "true" ]; then
PRINT