diff --git a/src/canvas/x11/x11.cpp b/src/canvas/x11/x11.cpp index a308f70..f7b7f02 100644 --- a/src/canvas/x11/x11.cpp +++ b/src/canvas/x11/x11.cpp @@ -218,6 +218,7 @@ void X11Canvas::get_tmux_window_ids(std::unordered_set &windows) continue; } windows.insert(win->second); + break; // prevent multiple windows being created } } } diff --git a/src/os.cpp b/src/os.cpp index 8aefc3a..677a5dd 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -33,7 +33,7 @@ auto os::exec(const std::string &cmd) -> std::string const int bufsize = 128; std::array buffer; std::string result; - c_unique_ptr pipe{popen(cmd.c_str(), "r")}; + const c_unique_ptr pipe{popen(cmd.c_str(), "r")}; if (!pipe) { throw std::system_error(errno, std::generic_category()); } @@ -84,7 +84,7 @@ auto os::wait_for_data_on_fd(int filde, int waitms) -> bool poll(&fds, 1, waitms); if ((fds.revents & (POLLERR | POLLNVAL | POLLHUP)) != 0) { - throw std::system_error(errno, std::generic_category()); + throw std::system_error(EIO, std::generic_category()); } return (fds.revents & POLLIN) != 0; @@ -116,14 +116,14 @@ auto os::get_ppid() -> int void os::daemonize() { - int pid = fork(); + const int pid = fork(); if (pid < 0) { std::exit(EXIT_FAILURE); // NOLINT } if (pid > 0) { std::exit(EXIT_SUCCESS); // NOLINT } - int status = setsid(); + const int status = setsid(); if (status < 0) { std::exit(EXIT_FAILURE); // NOLINT } diff --git a/src/terminal.cpp b/src/terminal.cpp index d564918..84c52fe 100644 --- a/src/terminal.cpp +++ b/src/terminal.cpp @@ -101,8 +101,8 @@ void Terminal::get_terminal_size() padding_horizontal = static_cast(std::max(padding_horiz, padding_vert)); padding_vertical = padding_horizontal; - font_width = std::ceil(guess_font_size(cols, xpixel, padding_horizontal)); - font_height = std::ceil(guess_font_size(rows, ypixel, padding_vertical)); + font_width = std::floor(guess_font_size(cols, xpixel, padding_horizontal)); + font_height = std::floor(guess_font_size(rows, ypixel, padding_vertical)); if (xpixel < fallback_xpixel && ypixel < fallback_ypixel) { padding_horizontal = (fallback_xpixel - xpixel) / 2;