From ad4e1ab7e1c0fa585d0e137e5b97e1849b58676a Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 9 Jul 2023 23:56:34 +0200 Subject: [PATCH] Code cleanup --- libs/draw.c | 23 +++++++++++++++++++---- libs/stream.c | 9 +++++---- libs/x11/event.c | 16 ---------------- spmenu.c | 4 ++-- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/libs/draw.c b/libs/draw.c index 2e57639..98ca8e5 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -538,9 +538,9 @@ void drawmenu(void) { drawimage(); #endif if (listfile) { - readfile(); + readstdin(); - if (listchanged) { + if (sp.listchanged) { resizeclient(); match(); @@ -559,10 +559,25 @@ void drawmenu(void) { wl_surface_damage(state.surface, 0, 0, state.width, state.height); wl_surface_commit(state.surface); } else { +#endif +#if USEX + if (listfile) { + readstdin(); + + if (sp.listchanged) { + match(); + + for (int i = 0; i < sp.itemnumber; i++) { + if (sel && sel->right && (sel = sel->right) == next) { + curr = next; + } + } + } + } drawmenu_layer(); +#endif +#if USEWAYLAND } -#elif USEX - drawmenu_layer(); #endif } diff --git a/libs/stream.c b/libs/stream.c index 5d52ae5..084860b 100644 --- a/libs/stream.c +++ b/libs/stream.c @@ -132,11 +132,12 @@ void readfile(void) { if (!o) img.longestedge = img.imagegaps = 0; #endif - if (i == listcount) { - listchanged = 0; + if (i == sp.listcount) { + sp.listchanged = 0; + sp.listcount = i; } else { - listcount = i; - listchanged = 1; + sp.listcount = i; + sp.listchanged = 1; // prevents state->buffer from being NULL if (!protocol) { diff --git a/libs/x11/event.c b/libs/x11/event.c index 12baa50..5cdbae6 100644 --- a/libs/x11/event.c +++ b/libs/x11/event.c @@ -42,21 +42,5 @@ void eventloop_x11(void) { drawmenu(); break; } - - if (listfile) { - readfile(); - - if (listchanged) { - match(); - - for (int i = 0; i < sp.itemnumber; i++) { - if (sel && sel->right && (sel = sel->right) == next) { - curr = next; - } - } - - drawmenu(); - } - } } } diff --git a/spmenu.c b/spmenu.c index eba95d0..ff4d2db 100644 --- a/spmenu.c +++ b/spmenu.c @@ -137,6 +137,8 @@ struct sp { int plw; // powerline width int itemnumber; // item number + int listcount; + int listchanged; size_t cursor; // cursor width @@ -251,8 +253,6 @@ static void grabfocus(void); static char **list; static size_t listsize; -static int listcount; -static int listchanged = 0; // user configuration #include "libs/options.h"