mirror of
https://github.com/aristocratos/btop.git
synced 2024-05-21 04:43:36 +12:00
Changed: Stop second thread before updating terminal size variables
This commit is contained in:
parent
9233b3cffc
commit
65c62cef47
|
@ -152,7 +152,7 @@ void argumentParser(const int& argc, char **argv) {
|
|||
void term_resize(bool force) {
|
||||
if (Global::resizing) return;
|
||||
atomic_lock lck(Global::resizing);
|
||||
if (auto refreshed = Term::refresh(); refreshed or force) {
|
||||
if (auto refreshed = Term::refresh(true); refreshed or force) {
|
||||
if (force and refreshed) force = false;
|
||||
}
|
||||
else return;
|
||||
|
@ -160,6 +160,7 @@ void term_resize(bool force) {
|
|||
static const array<string, 4> all_boxes = {"cpu", "mem", "net", "proc"};
|
||||
Global::resized = true;
|
||||
if (Runner::active) Runner::stop();
|
||||
Term::refresh();
|
||||
Config::unlock();
|
||||
|
||||
auto boxes = Config::getS("shown_boxes");
|
||||
|
|
|
@ -73,12 +73,14 @@ namespace Term {
|
|||
}
|
||||
}
|
||||
|
||||
bool refresh() {
|
||||
bool refresh(bool only_check) {
|
||||
struct winsize w;
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) < 0) return false;
|
||||
if (width != w.ws_col or height != w.ws_row) {
|
||||
width = w.ws_col;
|
||||
height = w.ws_row;
|
||||
if (not only_check) {
|
||||
width = w.ws_col;
|
||||
height = w.ws_row;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Term {
|
|||
const string sync_end = Fx::e + "?2026l"; //? End of terminal synchronized output
|
||||
|
||||
//* Returns true if terminal has been resized and updates width and height
|
||||
bool refresh();
|
||||
bool refresh(bool only_check=false);
|
||||
|
||||
//* Returns an array with the lowest possible width, height with current box config
|
||||
auto get_min_size(const string& boxes) -> array<int, 2>;
|
||||
|
|
Loading…
Reference in a new issue