From 367bbc735fc9ad822890707acff1e1b8881befb7 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 10 Sep 2022 00:37:35 +0400 Subject: [PATCH] Remove unnecessary code (layouts) --- Makefile | 1 - src/dwm.c | 16 +++---- src/layouts.c | 115 -------------------------------------------------- src/layouts.h | 63 --------------------------- 4 files changed, 7 insertions(+), 188 deletions(-) delete mode 100644 src/layouts.c delete mode 100644 src/layouts.h diff --git a/Makefile b/Makefile index ebe2acf..398222b 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,6 @@ MODULES_SRC = \ src/drw.c \ src/dwm.c \ src/geom.c \ - src/layouts.c \ src/logger.c \ src/spawn.c \ src/state.c \ diff --git a/src/dwm.c b/src/dwm.c index d89203e..5ff9ce7 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -1,7 +1,6 @@ #include "dwm.h" #include "helpers.h" -#include "layouts.h" #include "logger.h" #include "main.h" #include "settings.h" @@ -122,7 +121,6 @@ typedef struct { } Key; typedef struct { - LayoutsSymbolFunc symbol_func; void (*arrange)(Monitor *); } Layout; @@ -250,12 +248,12 @@ static const char *colors[][3] = { }; const Layout layouts[] = { - /* symbol function, arrange function */ - { layouts_symbol_monocle, monocle }, /* first entry is default */ - { layouts_symbol_floating, NULL }, /* no layout function means floating behavior */ - { layouts_symbol_tile, tile }, - { layouts_symbol_horizontile, horizontile }, - { layouts_symbol_centeredmaster, centeredmaster }, + /* arrange function */ + { monocle }, /* first entry is default */ + { NULL }, /* no layout function means floating behavior */ + { tile }, + { horizontile }, + { centeredmaster }, }; /************************************ @@ -344,7 +342,7 @@ int dwm_main(const char *const new_program_title) // Cleanup start - Layout foo = { NULL, NULL }; + Layout foo = { NULL }; selmon->lt[selmon->sellt] = &foo; for (Monitor *m = mons; m; m = m->next) { diff --git a/src/layouts.c b/src/layouts.c deleted file mode 100644 index 4d9af84..0000000 --- a/src/layouts.c +++ /dev/null @@ -1,115 +0,0 @@ -#include "layouts.h" - -#include -#include - -#define TMP_BUFFER_SIZE 128 - -void layouts_symbol_func( - LayoutsSymbolFunc func, - char *const buffer, - const size_t buffer_size, - const unsigned int clients_in_master, - const unsigned int visible_clients -) { - if (func == NULL) { - func = layouts_symbol_unknown; - } - - func( - buffer, - buffer_size, - clients_in_master, - visible_clients - ); -} - -void layouts_symbol_unknown( - char *const buffer, - const size_t buffer_size, - const unsigned int clients_in_master, - const unsigned int visible_clients -) { - // TODO: maybe we should assert - if (buffer == NULL) return; - - char tmp[TMP_BUFFER_SIZE]; - sprintf(tmp, "?%u/%u?", clients_in_master, visible_clients); - tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0'; - strncpy(buffer, tmp, buffer_size); -} - -void layouts_symbol_monocle( - char *const buffer, - const size_t buffer_size, - const unsigned int clients_in_master, - const unsigned int visible_clients -) { - // TODO: maybe we should assert - if (buffer == NULL) return; - - char tmp[TMP_BUFFER_SIZE]; - sprintf(tmp, "[%u/%u]", clients_in_master, visible_clients); - tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0'; - strncpy(buffer, tmp, buffer_size); -} - -void layouts_symbol_floating( - char *const buffer, - const size_t buffer_size, - const unsigned int clients_in_master, - const unsigned int visible_clients -) { - // TODO: maybe we should assert - if (buffer == NULL) return; - - char tmp[TMP_BUFFER_SIZE]; - sprintf(tmp, "<%u/%u>", clients_in_master, visible_clients); - tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0'; - strncpy(buffer, tmp, buffer_size); -} - -void layouts_symbol_tile( - char *const buffer, - const size_t buffer_size, - const unsigned int clients_in_master, - const unsigned int visible_clients -) { - // TODO: maybe we should assert - if (buffer == NULL) return; - - char tmp[TMP_BUFFER_SIZE]; - sprintf(tmp, "{%u/%u}=", clients_in_master, visible_clients); - tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0'; - strncpy(buffer, tmp, buffer_size); -} - -void layouts_symbol_horizontile( - char *const buffer, - const size_t buffer_size, - const unsigned int clients_in_master, - const unsigned int visible_clients -) { - // TODO: maybe we should assert - if (buffer == NULL) return; - - char tmp[TMP_BUFFER_SIZE]; - sprintf(tmp, "v{%u/%u}v", clients_in_master, visible_clients); - tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0'; - strncpy(buffer, tmp, buffer_size); -} - -void layouts_symbol_centeredmaster( - char *const buffer, - const size_t buffer_size, - const unsigned int clients_in_master, - const unsigned int visible_clients -) { - // TODO: maybe we should assert - if (buffer == NULL) return; - - char tmp[TMP_BUFFER_SIZE]; - sprintf(tmp, "={%u/%u}=", clients_in_master, visible_clients); - tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0'; - strncpy(buffer, tmp, buffer_size); -} diff --git a/src/layouts.h b/src/layouts.h deleted file mode 100644 index d0efaa6..0000000 --- a/src/layouts.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _LAYOUTS_H -#define _LAYOUTS_H - -#include - -typedef void (*LayoutsSymbolFunc)( - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -void layouts_symbol_func( - LayoutsSymbolFunc func, - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -void layouts_symbol_unknown( - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -void layouts_symbol_monocle( - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -void layouts_symbol_floating( - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -void layouts_symbol_tile( - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -void layouts_symbol_horizontile( - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -void layouts_symbol_centeredmaster( - char *buffer, - size_t buffer_size, - unsigned int clients_in_master, - unsigned int visible_clients -); - -#endif // _LAYOUTS_H