mirror of https://github.com/xzeldon/htop.git
ScreenManager: reduce ScreenManager_resize
The main change is the header hight being not included in y1. This is important if a sub-manager gets resized, e.g. a resize while editing the Settings or in a pickFromVector selection, and afterwards, then the sub-manager is closed, the super-ScreenManager gets resized, it uses the correct header hight. The header hight might have been changed since the last resize of the super-manager in the Settings by adding/removing some meters. This fixes new meters being hidden after added at runtime after a resize in the main window.
This commit is contained in:
parent
edc3de7cb5
commit
b9e69223d0
|
@ -81,7 +81,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
|
||||||
Header_calculateHeight(header);
|
Header_calculateHeight(header);
|
||||||
Header_updateData(header);
|
Header_updateData(header);
|
||||||
Header_draw(header);
|
Header_draw(header);
|
||||||
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
|
ScreenManager_resize(this->scr);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
|
||||||
Header_reinit(header);
|
Header_reinit(header);
|
||||||
Header_updateData(header);
|
Header_updateData(header);
|
||||||
Header_draw(header);
|
Header_draw(header);
|
||||||
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
|
ScreenManager_resize(this->scr);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
|
||||||
this->settings->changed = true;
|
this->settings->changed = true;
|
||||||
Header_calculateHeight(header);
|
Header_calculateHeight(header);
|
||||||
Header_draw(header);
|
Header_draw(header);
|
||||||
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
|
ScreenManager_resize(this->scr);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ ScreenManager* ScreenManager_new(Header* header, const Settings* settings, const
|
||||||
ScreenManager* this;
|
ScreenManager* this;
|
||||||
this = xMalloc(sizeof(ScreenManager));
|
this = xMalloc(sizeof(ScreenManager));
|
||||||
this->x1 = 0;
|
this->x1 = 0;
|
||||||
this->y1 = header->height;
|
this->y1 = 0;
|
||||||
this->x2 = 0;
|
this->x2 = 0;
|
||||||
this->y2 = -1;
|
this->y2 = -1;
|
||||||
this->panels = Vector_new(Class(Panel), owner, DEFAULT_SIZE);
|
this->panels = Vector_new(Class(Panel), owner, DEFAULT_SIZE);
|
||||||
|
@ -54,13 +54,13 @@ void ScreenManager_add(ScreenManager* this, Panel* item, int size) {
|
||||||
const Panel* last = (const Panel*) Vector_get(this->panels, this->panelCount - 1);
|
const Panel* last = (const Panel*) Vector_get(this->panels, this->panelCount - 1);
|
||||||
lastX = last->x + last->w + 1;
|
lastX = last->x + last->w + 1;
|
||||||
}
|
}
|
||||||
int height = LINES - this->y1 + this->y2;
|
int height = LINES - this->y1 - (this->header ? this->header->height : 0) + this->y2;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
Panel_resize(item, size, height);
|
Panel_resize(item, size, height);
|
||||||
} else {
|
} else {
|
||||||
Panel_resize(item, COLS - this->x1 + this->x2 - lastX, height);
|
Panel_resize(item, COLS - this->x1 + this->x2 - lastX, height);
|
||||||
}
|
}
|
||||||
Panel_move(item, lastX, this->y1);
|
Panel_move(item, lastX, this->y1 + (this->header ? this->header->height : 0));
|
||||||
Vector_add(this->panels, item);
|
Vector_add(this->panels, item);
|
||||||
item->needsRedraw = true;
|
item->needsRedraw = true;
|
||||||
this->panelCount++;
|
this->panelCount++;
|
||||||
|
@ -73,22 +73,19 @@ Panel* ScreenManager_remove(ScreenManager* this, int idx) {
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
|
void ScreenManager_resize(ScreenManager* this) {
|
||||||
this->x1 = x1;
|
int y1_header = this->y1 + (this->header ? this->header->height : 0);
|
||||||
this->y1 = y1;
|
|
||||||
this->x2 = x2;
|
|
||||||
this->y2 = y2;
|
|
||||||
int panels = this->panelCount;
|
int panels = this->panelCount;
|
||||||
int lastX = 0;
|
int lastX = 0;
|
||||||
for (int i = 0; i < panels - 1; i++) {
|
for (int i = 0; i < panels - 1; i++) {
|
||||||
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
||||||
Panel_resize(panel, panel->w, LINES - y1 + y2);
|
Panel_resize(panel, panel->w, LINES - y1_header + this->y2);
|
||||||
Panel_move(panel, lastX, y1);
|
Panel_move(panel, lastX, y1_header);
|
||||||
lastX = panel->x + panel->w + 1;
|
lastX = panel->x + panel->w + 1;
|
||||||
}
|
}
|
||||||
Panel* panel = (Panel*) Vector_get(this->panels, panels - 1);
|
Panel* panel = (Panel*) Vector_get(this->panels, panels - 1);
|
||||||
Panel_resize(panel, COLS - x1 + x2 - lastX, LINES - y1 + y2);
|
Panel_resize(panel, COLS - this->x1 + this->x2 - lastX, LINES - y1_header + this->y2);
|
||||||
Panel_move(panel, lastX, y1);
|
Panel_move(panel, lastX, y1_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut) {
|
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut) {
|
||||||
|
@ -260,7 +257,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case KEY_RESIZE:
|
case KEY_RESIZE:
|
||||||
{
|
{
|
||||||
ScreenManager_resize(this, this->x1, this->y1, this->x2, this->y2);
|
ScreenManager_resize(this);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
|
|
|
@ -39,7 +39,7 @@ void ScreenManager_add(ScreenManager* this, Panel* item, int size);
|
||||||
|
|
||||||
Panel* ScreenManager_remove(ScreenManager* this, int idx);
|
Panel* ScreenManager_remove(ScreenManager* this, int idx);
|
||||||
|
|
||||||
void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2);
|
void ScreenManager_resize(ScreenManager* this);
|
||||||
|
|
||||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);
|
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue