From 7b31d4cc54c4b6aaae746a26acb455876e1c5399 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Sat, 30 Oct 2021 11:20:27 +0200 Subject: [PATCH] bugfixes --- src/common.hpp | 5 ----- src/main.cpp | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/common.hpp b/src/common.hpp index 2fba11b..2170103 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -39,11 +39,6 @@ extern wl_compositor* compositor; extern wl_shm* shm; extern zwlr_layer_shell_v1* wlrLayerShell; -void view(Monitor& m, const Arg& arg); -void toggleview(Monitor& m, const Arg& arg); -void setlayout(Monitor& m, const Arg& arg); -void tag(Monitor& m, const Arg& arg); -void toggletag(Monitor& m, const Arg& arg); void spawn(Monitor&, const Arg& arg); [[noreturn]] void die(const char* why); diff --git a/src/main.cpp b/src/main.cpp index 12ab2cd..bab86fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,7 +52,7 @@ static void updatemon(Monitor &mon); static void setupStatusFifo(); static void onStatus(); static void onStdin(); -static void handleStdin(); +static void handleStdin(const std::string& line); static void cleanup(); static void requireGlobal(const void* p, const char* name); static void waylandFlush(); @@ -208,14 +208,6 @@ static void onReady() setupStatusFifo(); wl_display_roundtrip(display); // roundtrip so we receive all dwl tags etc. - epoll_event epollEv = {0}; - epollEv.events = EPOLLIN; - epollEv.data.fd = 0; - fcntl(0, F_SETFL, O_NONBLOCK); - if (epoll_ctl(epoll, EPOLL_CTL_ADD, 0, &epollEv) < 0) { - diesys("epoll_ctl add stdin"); - } - ready = true; for (auto& monitor : monitors) { setupMonitor(monitor); @@ -297,7 +289,7 @@ static void handleStdin(const std::string& line) state |= TagState::Active; if (urgent & tagMask) state |= TagState::Urgent; - mon->bar->setTag(i, state, occupied & tagMask ? 1 : 0, clientTags ? 1 : 0); + mon->bar->setTag(i, state, occupied & tagMask ? 1 : 0, clientTags & tagMask ? 0 : -1); } mon->tags = tags; } else if (command == "layout") { @@ -485,6 +477,13 @@ int main(int argc, char* argv[]) diesys("epoll_ctl add wayland_display"); } + epollEv.events = EPOLLIN; + epollEv.data.fd = STDIN_FILENO; + if (epoll_ctl(epoll, EPOLL_CTL_ADD, STDIN_FILENO, &epollEv) < 0) { + diesys("epoll_ctl add stdin"); + } + fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); + while (!quitting) { waylandFlush(); auto res = epoll_wait(epoll, epollEvents.data(), epollEvents.size(), -1); @@ -508,7 +507,7 @@ int main(int argc, char* argv[]) } waylandFlush(); } - } else if (ev.data.fd == 0) { + } else if (ev.data.fd == STDIN_FILENO) { onStdin(); } else if (ev.data.fd == statusFifoFd) { onStatus();