Skip to content

Commit

Permalink
fix tmux bug and be const correct
Browse files Browse the repository at this point in the history
  • Loading branch information
jstkdng committed Feb 24, 2024
1 parent 5dea85e commit 73b057a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/canvas/x11/x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ void X11Canvas::get_tmux_window_ids(std::unordered_set<xcb_window_t> &windows)
continue;
}
windows.insert(win->second);
break; // prevent multiple windows being created
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ auto os::exec(const std::string &cmd) -> std::string
const int bufsize = 128;
std::array<char, bufsize> buffer;
std::string result;
c_unique_ptr<FILE, pclose> pipe{popen(cmd.c_str(), "r")};
const c_unique_ptr<FILE, pclose> pipe{popen(cmd.c_str(), "r")};
if (!pipe) {
throw std::system_error(errno, std::generic_category());
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ void Terminal::get_terminal_size()

padding_horizontal = static_cast<uint16_t>(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;
Expand Down

0 comments on commit 73b057a

Please sign in to comment.