From 04f823a5969b71a4187bc2f32b5370438694261a Mon Sep 17 00:00:00 2001 From: speediegq Date: Sat, 1 Oct 2022 15:37:35 +0200 Subject: [PATCH] Update: Toggle for autoresizing --- docs/example.Xresources | 15 ++++++------ options.h | 3 +-- options.mk | 2 +- scripts/speedwm-compatcheck | 20 ++++++---------- scripts/speedwm-dm | 46 +++++++++++++++++++------------------ speedwm.c | 18 ++++----------- xresources.h | 2 +- 7 files changed, 46 insertions(+), 60 deletions(-) diff --git a/docs/example.Xresources b/docs/example.Xresources index 5f837c9..9ac7503 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -158,6 +158,13 @@ !! - speedwm.attachdirection: 3 !! +!! Auto resizing windows +!! +!! If set to 1, windows that want to be moved will be moved automatically. +!! Otherwise they will not be moved automatically. +!! + - speedwm.autoresize: 1 +!! !! Window icon size in pixels: !! - speedwm.iconsize: 10 @@ -268,18 +275,10 @@ !! - speedwm.hidetitle: 0 !! -!! Hide title text. If set to 0, the task names will be shown. Otherwise the text will not be printed. (1/0) -!! - - speedwm.hidetitletext: 0 -!! !! Hide status bar. If set to 0, the status bar will be shown. Otherwise the status bar will not be shown. (1/0) !! - speedwm.hidestatus: 0 !! -!! Hide status bar text. If set to 0, the status bar text will be printed. Otherwise the status bar text will not be shown. (1/0) -!! - - speedwm.hidestatustext: 0 -!! !! Hide window icons. If set to 0, the window icons will be used. Otherwise the window icons will not be drawn. (1/0) !! - speedwm.hideicon: 0 diff --git a/options.h b/options.h index 1bce0f3..bb3df67 100644 --- a/options.h +++ b/options.h @@ -159,6 +159,7 @@ static int centerfloating = 1; /* Center floating windows by static int startontag = 1; /* Start on a tag or not? */ static int floatscratchpad = 0; /* Float the scratchpad window on hide (1/0) */ static int focusspawn = 0; /* Automatically focus the next spawned window. If warp is enabled, this is useless and will be disabled. (1/0) */ +static int autoresize = 1; /* Allow resizing clients automatically when they request it. */ /* Font options */ static char font[] = { "NotoSans-Regular:size=8:antialiasing=true" }; /* What font should we use? */ @@ -225,9 +226,7 @@ static int underlinevoffset = 0; /* How far above the bottom o static int hidebar = 0; /* Hide the bar (1) or show (0) */ static int hidelayout = 0; /* Hide layout indicator (1) or show (0) */ static int hidetitle = 0; /* Hide title (1) or show (0) */ -static int hidetitletext = 0; /* Hide title text (1) or show (0) */ static int hidestatus = 0; /* Hide status bar (1) or show (0) */ -static int hidestatustext = 0; /* Hide status bar text (1) or show (0) */ static int hideicon = 0; /* Hide icon (1) or show (0) */ static int hidetags = 0; /* Hide status bar (1) or show (0) */ static int hideemptytags = 1; /* Hide empty tags (1) or show (0) */ diff --git a/options.mk b/options.mk index 0df9b6d..4dc65ce 100644 --- a/options.mk +++ b/options.mk @@ -43,7 +43,7 @@ FREETYPEINC = /usr/include/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -I${YAJLINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender ${IMLIB2LIBS} -lX11-xcb -lxcb -lxcb-res -lXext ${YAJLLIBS} +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender ${IMLIB2LIBS} -lX11-xcb -lxcb -lxcb-res -lXext ${YAJLLIBS} -lXrdb # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/scripts/speedwm-compatcheck b/scripts/speedwm-compatcheck index 7bdb4a1..c7cf050 100755 --- a/scripts/speedwm-compatcheck +++ b/scripts/speedwm-compatcheck @@ -8,35 +8,35 @@ BINDIR=$(cat /usr/share/speedwm/bindir) if [ -e "${BINDIR}xrdb" ]; then xrdb_exists=true else - printf "\nWARNING: xrdb was not found. .Xresources and Pywal support will not work." + printf "WARNING: xrdb was not found. .Xresources and Pywal support will not work.\n" fi # Check if wmctrl exists if [ -e "${BINDIR}wmctrl" ]; then wmctrl_exists=true else - printf "\nWARNING: wmctrl was not found. Window management using 'Alt+Tab' will not work." + printf "WARNING: wmctrl was not found. Window management using 'Alt+Tab' will not work.\n" fi # Check if xsetroot exists if [ -e "${BINDIR}xsetroot" ]; then xsetroot_exists=true else - printf "\nerror: ${BINDIR}xsetroot was not found\n" && exit 1 + printf "\nError: ${BINDIR}xsetroot was not found\n" && exit 1 fi # Check if xwallpaper exists if [ -e "${BINDIR}xwallpaper" ]; then xwallpaper_exists=true else - printf "\nWARNING: xwallpaper was not found. This means setting your wallpaper and Pywal support won't work." + printf "WARNING: xwallpaper was not found. This means setting your wallpaper and Pywal support won't work.\n" fi # Check if xmodmap exists if [ -e "${BINDIR}xmodmap" ]; then xmodmap_exists=true else - printf "\nWARNING: xmodmap was not found. This means the Alt+Tab script will not be able to remap Alt+hjkl temporarily." + printf "WARNING: xmodmap was not found. This means the Alt+Tab script will not be able to remap Alt+hjkl temporarily.\n" fi # Check if trayer exists @@ -49,9 +49,9 @@ fi # Check if srg or not. if [ "$trayer_exists" = "false" ]; then - printf "\nWARNING: trayer was not found. This means the systray will not be available.\n" + printf "WARNING: trayer was not found. This means the systray will not be available.\n" elif [ "$trayer_srg" = "true" ]; then - printf "\nWARNING: Before trayer-srg can be used instead of trayer, you must edit ~/.config/speedwm-de/systray/config and set USE_SRG to true.\n" + printf "WARNING: Before trayer-srg can be used instead of trayer, you must edit ~/.config/speedwm-de/systray/config and set USE_SRG to true.\n" fi # Check if dmenu exists @@ -59,10 +59,4 @@ command -v dmenu > /dev/null || printf "\nWARNING: dmenu was not found. This mea # Check if slock exists command -v slock > /dev/null || printf "\nWARNING: slock was not found. This means the shutdown menu can't lock your screen." - result="$(echo "$xrdb_exists$wmctrl_exists$xsetroot_exists$xwallpaper_exists$xmodmap_exists$trayer_exists")" - -case "$result" in -"truetruetruetruetruetrue") printf "\nAll dependencies were found.\n\n" ;; -"") printf "\nSome dependencies could not be found." ;; -esac diff --git a/scripts/speedwm-dm b/scripts/speedwm-dm index ea0887b..04c3dc8 100755 --- a/scripts/speedwm-dm +++ b/scripts/speedwm-dm @@ -24,107 +24,109 @@ PADDING=$(grep "barpaddingv" options.h | grep "0" | awk '{ print $5 }') COMPOSITOR=$(grep "define COMPOSITOR " options.h | awk '{ print $3 }' | sed 's/"//g') # Print all of it -echo $TOPBAR | grep "1" && touch /usr/share/speedwm/topbar -echo $PADDING | grep "0" && touch /usr/share/speedwm/nopadding +echo $TOPBAR | grep -q "1" && touch /usr/share/speedwm/topbar +echo $PADDING | grep -q "0" && touch /usr/share/speedwm/nopadding echo $COMPOSITOR > /usr/share/speedwm/compositor echo $(pwd) > /usr/share/speedwm/sourcedir sed "s/#define //g" toggle.h | grep LAYOUT | sed "s|/[*]|#|g; s|[*]/||g; s/ //g; s/1/=1/g; s/0/=0/g; s/#/ # /g" > /usr/share/speedwm/layouts . /usr/share/speedwm/layouts -AVAILABLE_LAYOUTS="$(printf "$AVAILABLE_LAYOUTS")" +AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS}Floating")" # Tile if [ "$LAYOUT_TILE" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Tiling\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tiling" fi # Tile (5:4) if [ "$LAYOUT_TILE54" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Tiling 5:4\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tiling 5:4" fi # Monocle if [ "$LAYOUT_MONOCLE" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Monocle\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Monocle" fi # Grid if [ "$LAYOUT_GRID" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Grid\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Grid" fi # Dwindle if [ "$LAYOUT_DWINDLE" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Dwindle\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Dwindle" fi # Spiral if [ "$LAYOUT_SPIRAL" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Spiral\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Spiral" fi # Three Columns if [ "$LAYOUT_TCL" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Three Columns\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Three Columns" fi # Bottom Stack if [ "$LAYOUT_BSTACK" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Bottom Stack\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Bottom Stack" fi # Horizontal Bottom Stack if [ "$LAYOUT_BSTACKH" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Horizontal Bottom Stack\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Horizontal Bottom Stack" fi # Horizontal Grid if [ "$LAYOUT_HGRID" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Horizontal Grid\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Horizontal Grid" fi # Dynamic Grid if [ "$LAYOUT_DGRID" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Dynamic Grid\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Dynamic Grid" fi # Tatami if [ "$LAYOUT_TATAMI" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Tatami\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tatami" fi # Tilewide if [ "$LAYOUT_TW" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Tilewide\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tilewide" fi # Centered Master if [ "$LAYOUT_CM" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Centered Master\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Centered Master" fi # Centered Floating Master if [ "$LAYOUT_CFM" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Centered Floating Master\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Centered Floating Master" fi # Deck if [ "$LAYOUT_DECK" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Deck\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Deck" fi # Columns if [ "$LAYOUT_COL" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Columns\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Columns" fi # Stairs if [ "$LAYOUT_STAIRS" = "1" ]; then - AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS} Stairs\n")" + AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Stairs" fi -printf "\n\nAvailable layouts: $AVAILABLE_LAYOUTS\n\n" +AVAILABLE_LAYOUTS="$(printf "$AVAILABLE_LAYOUTS" | sed "s/ /, /g")" + +printf "Available layouts: $AVAILABLE_LAYOUTS\n" # Copy .Xresources file cp docs/example.Xresources /usr/share/speedwm/example.Xresources diff --git a/speedwm.c b/speedwm.c index ab925a4..ded2b1b 100644 --- a/speedwm.c +++ b/speedwm.c @@ -527,7 +527,6 @@ static pid_t winpid(Window w); /* variables */ static const char broken[] = "speedwm"; -static const char empty[] = ""; #if USEMOUSE static const char *layoutmenu_cmd = "speedwm-utils layout"; #endif @@ -1356,7 +1355,7 @@ configurerequest(XEvent *e) configure(c); if (ISVISIBLE(c)) XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); - else + else if (autoresize) c->needresize = 1; } else configure(c); @@ -2493,12 +2492,14 @@ showhide(Client *c) if (ISVISIBLE(c)) { /* show clients top down */ XMoveWindow(dpy, c->win, c->x, c->y); - if (c->needresize) { + + if (c->needresize && autoresize) { c->needresize = 0; XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); - } else { + } else if (autoresize) { XMoveWindow(dpy, c->win, c->x, c->y); } + if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) resize(c, c->x, c->y, c->w, c->h, 0); showhide(c->snext); @@ -4921,11 +4922,6 @@ updatestatus(void) Monitor* m; if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext)) && !hidestatus) { strcpy(stext, defaultstatus); - - // Hide status text - if (hidestatustext) - strcpy(stext, defaultstatus); - statusw = TEXTW(stext) - lrpad + 2; } else { if (!hidestatus) { @@ -5016,10 +5012,6 @@ updatetitle(Client *c) if (c->name[0] == '\0') strcpy(c->name, broken); - // Hide title by setting it to nothing - if (hidetitletext) - strcpy(c->name, empty); - #if USEIPC for (Monitor *m = mons; m; m = m->next) { if (m->sel == c && strcmp(oldname, c->name) != 0) diff --git a/xresources.h b/xresources.h index 9138c47..4420928 100644 --- a/xresources.h +++ b/xresources.h @@ -156,7 +156,6 @@ ResourcePref resources[] = { { "leftlayout", INTEGER, &leftlayout }, { "hidelayout", INTEGER, &hidelayout }, { "hidetitle", INTEGER, &hidetitle }, - { "hidetitletext", INTEGER, &hidetitletext }, { "hideicon", INTEGER, &hideicon }, { "hidetags", INTEGER, &hidetags }, { "hideemptytags", INTEGER, &hideemptytags }, @@ -194,6 +193,7 @@ ResourcePref resources[] = { { "focusspawn", INTEGER, &focusspawn }, { "floatscratchpad", INTEGER, &floatscratchpad }, { "altbar", INTEGER, &altbar }, + { "autoresize", INTEGER, &autoresize }, { "mfact", FLOAT, &mfact }, { "lowestmfact", FLOAT, &lowestmfact }, /* value in .Xresources type value in speedwm */