mirror of https://github.com/xzeldon/htop.git
Keep panel structure up-to-date as process list changes when headers are updated during the screen manager. Hopefully closes #3444533.
This commit is contained in:
parent
dfad0afb36
commit
bfd86a60cc
|
@ -67,7 +67,7 @@ static HandlerResult ColorsPanel_EventHandler(Panel* super, int ch) {
|
||||||
this->settings->changed = true;
|
this->settings->changed = true;
|
||||||
Header* header = this->settings->header;
|
Header* header = this->settings->header;
|
||||||
CRT_setColors(mark);
|
CRT_setColors(mark);
|
||||||
Panel* menu = (Panel*) Vector_get(this->scr->items, 0);
|
Panel* menu = (Panel*) Vector_get(this->scr->panels, 0);
|
||||||
Header_draw(header);
|
Header_draw(header);
|
||||||
RichString_setAttr(&(super->header), CRT_colors[PANEL_HEADER_FOCUS]);
|
RichString_setAttr(&(super->header), CRT_colors[PANEL_HEADER_FOCUS]);
|
||||||
RichString_setAttr(&(menu->header), CRT_colors[PANEL_HEADER_UNFOCUS]);
|
RichString_setAttr(&(menu->header), CRT_colors[PANEL_HEADER_UNFOCUS]);
|
||||||
|
|
|
@ -16,6 +16,7 @@ in the source distribution for its full text.
|
||||||
#include "UsersTable.h"
|
#include "UsersTable.h"
|
||||||
#include "Hashtable.h"
|
#include "Hashtable.h"
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
|
#include "Panel.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -109,6 +110,13 @@ typedef struct ProcessList_ {
|
||||||
Hashtable* processTable;
|
Hashtable* processTable;
|
||||||
UsersTable* usersTable;
|
UsersTable* usersTable;
|
||||||
|
|
||||||
|
Panel* panel;
|
||||||
|
bool follow;
|
||||||
|
bool userOnly;
|
||||||
|
uid_t userId;
|
||||||
|
bool filtering;
|
||||||
|
const char* incFilter;
|
||||||
|
|
||||||
int cpuCount;
|
int cpuCount;
|
||||||
int totalTasks;
|
int totalTasks;
|
||||||
int userlandThreads;
|
int userlandThreads;
|
||||||
|
@ -243,6 +251,10 @@ void ProcessList_delete(ProcessList* this) {
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcessList_setPanel(ProcessList* this, Panel* panel) {
|
||||||
|
this->panel = panel;
|
||||||
|
}
|
||||||
|
|
||||||
void ProcessList_invertSortOrder(ProcessList* this) {
|
void ProcessList_invertSortOrder(ProcessList* this) {
|
||||||
if (this->direction == 1)
|
if (this->direction == 1)
|
||||||
this->direction = -1;
|
this->direction = -1;
|
||||||
|
@ -888,3 +900,47 @@ void ProcessList_expandTree(ProcessList* this) {
|
||||||
process->showChildren = true;
|
process->showChildren = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcessList_rebuildPanel(ProcessList* this, bool flags, bool follow, bool userOnly, uid_t userId, bool filtering, const char* incFilter) {
|
||||||
|
if (!flags) {
|
||||||
|
follow = this->follow;
|
||||||
|
userOnly = this->userOnly;
|
||||||
|
userId = this->userId;
|
||||||
|
filtering = this->filtering;
|
||||||
|
incFilter = this->incFilter;
|
||||||
|
} else {
|
||||||
|
this->follow = follow;
|
||||||
|
this->userOnly = userOnly;
|
||||||
|
this->userId = userId;
|
||||||
|
this->filtering = filtering;
|
||||||
|
this->incFilter = incFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currPos = Panel_getSelectedIndex(this->panel);
|
||||||
|
pid_t currPid = 0;
|
||||||
|
int currScrollV = this->panel->scrollV;
|
||||||
|
if (follow)
|
||||||
|
currPid = ProcessList_get(this, currPos)->pid;
|
||||||
|
|
||||||
|
Panel_prune(this->panel);
|
||||||
|
int size = ProcessList_size(this);
|
||||||
|
int idx = 0;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
bool hidden = false;
|
||||||
|
Process* p = ProcessList_get(this, i);
|
||||||
|
|
||||||
|
if ( (!p->show)
|
||||||
|
|| (userOnly && (p->st_uid != userId))
|
||||||
|
|| (filtering && !(String_contains_i(p->comm, incFilter))) )
|
||||||
|
hidden = true;
|
||||||
|
|
||||||
|
if (!hidden) {
|
||||||
|
Panel_set(this->panel, idx, (Object*)p);
|
||||||
|
if ((!follow && idx == currPos) || (follow && p->pid == currPid)) {
|
||||||
|
Panel_setSelected(this->panel, idx);
|
||||||
|
this->panel->scrollV = currScrollV;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ in the source distribution for its full text.
|
||||||
#include "UsersTable.h"
|
#include "UsersTable.h"
|
||||||
#include "Hashtable.h"
|
#include "Hashtable.h"
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
|
#include "Panel.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -111,6 +112,13 @@ typedef struct ProcessList_ {
|
||||||
Hashtable* processTable;
|
Hashtable* processTable;
|
||||||
UsersTable* usersTable;
|
UsersTable* usersTable;
|
||||||
|
|
||||||
|
Panel* panel;
|
||||||
|
bool follow;
|
||||||
|
bool userOnly;
|
||||||
|
uid_t userId;
|
||||||
|
bool filtering;
|
||||||
|
const char* incFilter;
|
||||||
|
|
||||||
int cpuCount;
|
int cpuCount;
|
||||||
int totalTasks;
|
int totalTasks;
|
||||||
int userlandThreads;
|
int userlandThreads;
|
||||||
|
@ -161,6 +169,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable);
|
||||||
|
|
||||||
void ProcessList_delete(ProcessList* this);
|
void ProcessList_delete(ProcessList* this);
|
||||||
|
|
||||||
|
void ProcessList_setPanel(ProcessList* this, Panel* panel);
|
||||||
|
|
||||||
void ProcessList_invertSortOrder(ProcessList* this);
|
void ProcessList_invertSortOrder(ProcessList* this);
|
||||||
|
|
||||||
void ProcessList_printHeader(ProcessList* this, RichString* header);
|
void ProcessList_printHeader(ProcessList* this, RichString* header);
|
||||||
|
@ -194,4 +204,6 @@ ProcessField ProcessList_keyAt(ProcessList* this, int at);
|
||||||
|
|
||||||
void ProcessList_expandTree(ProcessList* this);
|
void ProcessList_expandTree(ProcessList* this);
|
||||||
|
|
||||||
|
void ProcessList_rebuildPanel(ProcessList* this, bool flags, bool follow, bool userOnly, uid_t userId, bool filtering, const char* incFilter);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,13 +31,14 @@ typedef struct ScreenManager_ {
|
||||||
int x2;
|
int x2;
|
||||||
int y2;
|
int y2;
|
||||||
Orientation orientation;
|
Orientation orientation;
|
||||||
Vector* items;
|
Vector* panels;
|
||||||
Vector* fuBars;
|
Vector* fuBars;
|
||||||
int itemCount;
|
int panelCount;
|
||||||
const FunctionBar* fuBar;
|
const FunctionBar* fuBar;
|
||||||
const Header* header;
|
const Header* header;
|
||||||
time_t lastScan;
|
time_t lastScan;
|
||||||
bool owner;
|
bool owner;
|
||||||
|
bool allowFocusChange;
|
||||||
} ScreenManager;
|
} ScreenManager;
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
@ -51,29 +52,30 @@ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation ori
|
||||||
this->y2 = y2;
|
this->y2 = y2;
|
||||||
this->fuBar = NULL;
|
this->fuBar = NULL;
|
||||||
this->orientation = orientation;
|
this->orientation = orientation;
|
||||||
this->items = Vector_new(PANEL_CLASS, owner, DEFAULT_SIZE, NULL);
|
this->panels = Vector_new(PANEL_CLASS, owner, DEFAULT_SIZE, NULL);
|
||||||
this->fuBars = Vector_new(FUNCTIONBAR_CLASS, true, DEFAULT_SIZE, NULL);
|
this->fuBars = Vector_new(FUNCTIONBAR_CLASS, true, DEFAULT_SIZE, NULL);
|
||||||
this->itemCount = 0;
|
this->panelCount = 0;
|
||||||
this->header = header;
|
this->header = header;
|
||||||
this->owner = owner;
|
this->owner = owner;
|
||||||
|
this->allowFocusChange = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenManager_delete(ScreenManager* this) {
|
void ScreenManager_delete(ScreenManager* this) {
|
||||||
Vector_delete(this->items);
|
Vector_delete(this->panels);
|
||||||
Vector_delete(this->fuBars);
|
Vector_delete(this->fuBars);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int ScreenManager_size(ScreenManager* this) {
|
inline int ScreenManager_size(ScreenManager* this) {
|
||||||
return this->itemCount;
|
return this->panelCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size) {
|
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size) {
|
||||||
if (this->orientation == HORIZONTAL) {
|
if (this->orientation == HORIZONTAL) {
|
||||||
int lastX = 0;
|
int lastX = 0;
|
||||||
if (this->itemCount > 0) {
|
if (this->panelCount > 0) {
|
||||||
Panel* last = (Panel*) Vector_get(this->items, this->itemCount - 1);
|
Panel* last = (Panel*) Vector_get(this->panels, this->panelCount - 1);
|
||||||
lastX = last->x + last->w + 1;
|
lastX = last->x + last->w + 1;
|
||||||
}
|
}
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
|
@ -84,22 +86,22 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int
|
||||||
Panel_move(item, lastX, this->y1);
|
Panel_move(item, lastX, this->y1);
|
||||||
}
|
}
|
||||||
// TODO: VERTICAL
|
// TODO: VERTICAL
|
||||||
Vector_add(this->items, item);
|
Vector_add(this->panels, item);
|
||||||
if (fuBar)
|
if (fuBar)
|
||||||
Vector_add(this->fuBars, fuBar);
|
Vector_add(this->fuBars, fuBar);
|
||||||
else
|
else
|
||||||
Vector_add(this->fuBars, FunctionBar_new(NULL, NULL, NULL));
|
Vector_add(this->fuBars, FunctionBar_new(NULL, NULL, NULL));
|
||||||
if (!this->fuBar && fuBar) this->fuBar = fuBar;
|
if (!this->fuBar && fuBar) this->fuBar = fuBar;
|
||||||
item->needsRedraw = true;
|
item->needsRedraw = true;
|
||||||
this->itemCount++;
|
this->panelCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Panel* ScreenManager_remove(ScreenManager* this, int idx) {
|
Panel* ScreenManager_remove(ScreenManager* this, int idx) {
|
||||||
assert(this->itemCount > idx);
|
assert(this->panelCount > idx);
|
||||||
Panel* panel = (Panel*) Vector_remove(this->items, idx);
|
Panel* panel = (Panel*) Vector_remove(this->panels, idx);
|
||||||
Vector_remove(this->fuBars, idx);
|
Vector_remove(this->fuBars, idx);
|
||||||
this->fuBar = NULL;
|
this->fuBar = NULL;
|
||||||
this->itemCount--;
|
this->panelCount--;
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,15 +110,15 @@ void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
|
||||||
this->y1 = y1;
|
this->y1 = y1;
|
||||||
this->x2 = x2;
|
this->x2 = x2;
|
||||||
this->y2 = y2;
|
this->y2 = y2;
|
||||||
int items = this->itemCount;
|
int panels = this->panelCount;
|
||||||
int lastX = 0;
|
int lastX = 0;
|
||||||
for (int i = 0; i < items - 1; i++) {
|
for (int i = 0; i < panels - 1; i++) {
|
||||||
Panel* panel = (Panel*) Vector_get(this->items, i);
|
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
||||||
Panel_resize(panel, panel->w, LINES-y1+y2);
|
Panel_resize(panel, panel->w, LINES-y1+y2);
|
||||||
Panel_move(panel, lastX, y1);
|
Panel_move(panel, lastX, y1);
|
||||||
lastX = panel->x + panel->w + 1;
|
lastX = panel->x + panel->w + 1;
|
||||||
}
|
}
|
||||||
Panel* panel = (Panel*) Vector_get(this->items, items-1);
|
Panel* panel = (Panel*) Vector_get(this->panels, panels-1);
|
||||||
Panel_resize(panel, COLS-x1+x2-lastX, LINES-y1+y2);
|
Panel_resize(panel, COLS-x1+x2-lastX, LINES-y1+y2);
|
||||||
Panel_move(panel, lastX, y1);
|
Panel_move(panel, lastX, y1);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +127,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
int focus = 0;
|
int focus = 0;
|
||||||
|
|
||||||
Panel* panelFocus = (Panel*) Vector_get(this->items, focus);
|
Panel* panelFocus = (Panel*) Vector_get(this->panels, focus);
|
||||||
if (this->fuBar)
|
if (this->fuBar)
|
||||||
FunctionBar_draw(this->fuBar, NULL);
|
FunctionBar_draw(this->fuBar, NULL);
|
||||||
|
|
||||||
|
@ -133,19 +135,21 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
|
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
int items = this->itemCount;
|
int panels = this->panelCount;
|
||||||
if (this->header) {
|
if (this->header) {
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
if (now > this->lastScan) {
|
if (now > this->lastScan) {
|
||||||
ProcessList_scan(this->header->pl);
|
ProcessList_scan(this->header->pl);
|
||||||
|
ProcessList_sort(this->header->pl);
|
||||||
this->lastScan = now;
|
this->lastScan = now;
|
||||||
}
|
}
|
||||||
Header_draw(this->header);
|
Header_draw(this->header);
|
||||||
|
ProcessList_rebuildPanel(this->header->pl, false, false, false, false, false, NULL);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < items; i++) {
|
for (int i = 0; i < panels; i++) {
|
||||||
Panel* panel = (Panel*) Vector_get(this->items, i);
|
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
||||||
Panel_draw(panel, i == focus);
|
Panel_draw(panel, i == focus);
|
||||||
if (i < items) {
|
if (i < panels) {
|
||||||
if (this->orientation == HORIZONTAL) {
|
if (this->orientation == HORIZONTAL) {
|
||||||
mvvline(panel->y, panel->x+panel->w, ' ', panel->h+1);
|
mvvline(panel->y, panel->x+panel->w, ' ', panel->h+1);
|
||||||
}
|
}
|
||||||
|
@ -166,8 +170,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
if (mevent.y == LINES - 1) {
|
if (mevent.y == LINES - 1) {
|
||||||
ch = FunctionBar_synthesizeEvent(this->fuBar, mevent.x);
|
ch = FunctionBar_synthesizeEvent(this->fuBar, mevent.x);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < this->itemCount; i++) {
|
for (int i = 0; i < this->panelCount; i++) {
|
||||||
Panel* panel = (Panel*) Vector_get(this->items, i);
|
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
||||||
if (mevent.x > panel->x && mevent.x <= panel->x+panel->w &&
|
if (mevent.x > panel->x && mevent.x <= panel->x+panel->w &&
|
||||||
mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
|
mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
|
||||||
focus = i;
|
focus = i;
|
||||||
|
@ -200,21 +204,25 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
}
|
}
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
case KEY_CTRLB:
|
case KEY_CTRLB:
|
||||||
|
if (!this->allowFocusChange)
|
||||||
|
break;
|
||||||
tryLeft:
|
tryLeft:
|
||||||
if (focus > 0)
|
if (focus > 0)
|
||||||
focus--;
|
focus--;
|
||||||
panelFocus = (Panel*) Vector_get(this->items, focus);
|
panelFocus = (Panel*) Vector_get(this->panels, focus);
|
||||||
if (Panel_size(panelFocus) == 0 && focus > 0)
|
if (Panel_size(panelFocus) == 0 && focus > 0)
|
||||||
goto tryLeft;
|
goto tryLeft;
|
||||||
break;
|
break;
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
case KEY_CTRLF:
|
case KEY_CTRLF:
|
||||||
case 9:
|
case 9:
|
||||||
|
if (!this->allowFocusChange)
|
||||||
|
break;
|
||||||
tryRight:
|
tryRight:
|
||||||
if (focus < this->itemCount - 1)
|
if (focus < this->panelCount - 1)
|
||||||
focus++;
|
focus++;
|
||||||
panelFocus = (Panel*) Vector_get(this->items, focus);
|
panelFocus = (Panel*) Vector_get(this->panels, focus);
|
||||||
if (Panel_size(panelFocus) == 0 && focus < this->itemCount - 1)
|
if (Panel_size(panelFocus) == 0 && focus < this->panelCount - 1)
|
||||||
goto tryRight;
|
goto tryRight;
|
||||||
break;
|
break;
|
||||||
case KEY_F(10):
|
case KEY_F(10):
|
||||||
|
|
|
@ -33,13 +33,14 @@ typedef struct ScreenManager_ {
|
||||||
int x2;
|
int x2;
|
||||||
int y2;
|
int y2;
|
||||||
Orientation orientation;
|
Orientation orientation;
|
||||||
Vector* items;
|
Vector* panels;
|
||||||
Vector* fuBars;
|
Vector* fuBars;
|
||||||
int itemCount;
|
int panelCount;
|
||||||
const FunctionBar* fuBar;
|
const FunctionBar* fuBar;
|
||||||
const Header* header;
|
const Header* header;
|
||||||
time_t lastScan;
|
time_t lastScan;
|
||||||
bool owner;
|
bool owner;
|
||||||
|
bool allowFocusChange;
|
||||||
} ScreenManager;
|
} ScreenManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
67
htop.c
67
htop.c
|
@ -199,6 +199,7 @@ static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const cha
|
||||||
if (!list->eventHandler)
|
if (!list->eventHandler)
|
||||||
Panel_setEventHandler(list, Panel_selectByTyping);
|
Panel_setEventHandler(list, Panel_selectByTyping);
|
||||||
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, header, false);
|
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, header, false);
|
||||||
|
scr->allowFocusChange = false;
|
||||||
ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1);
|
ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1);
|
||||||
ScreenManager_add(scr, panel, NULL, -1);
|
ScreenManager_add(scr, panel, NULL, -1);
|
||||||
Panel* panelFocus;
|
Panel* panelFocus;
|
||||||
|
@ -331,7 +332,6 @@ int main(int argc, char** argv) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Panel* panel;
|
|
||||||
int quit = 0;
|
int quit = 0;
|
||||||
int refreshTimeout = 0;
|
int refreshTimeout = 0;
|
||||||
int resetRefreshTimeout = 5;
|
int resetRefreshTimeout = 5;
|
||||||
|
@ -384,10 +384,11 @@ int main(int argc, char** argv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CRT_init(settings->delay, settings->colorScheme);
|
CRT_init(settings->delay, settings->colorScheme);
|
||||||
|
|
||||||
|
Panel* panel = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false, NULL);
|
||||||
|
ProcessList_setPanel(pl, panel);
|
||||||
|
|
||||||
panel = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false, NULL);
|
|
||||||
if (sortKey > 0) {
|
if (sortKey > 0) {
|
||||||
pl->sortKey = sortKey;
|
pl->sortKey = sortKey;
|
||||||
pl->treeView = false;
|
pl->treeView = false;
|
||||||
|
@ -439,12 +440,6 @@ int main(int argc, char** argv) {
|
||||||
if (recalculate)
|
if (recalculate)
|
||||||
oldTime = newTime;
|
oldTime = newTime;
|
||||||
if (doRefresh) {
|
if (doRefresh) {
|
||||||
|
|
||||||
int currPos = Panel_getSelectedIndex(panel);
|
|
||||||
pid_t currPid = 0;
|
|
||||||
int currScrollV = panel->scrollV;
|
|
||||||
if (follow)
|
|
||||||
currPid = ProcessList_get(pl, currPos)->pid;
|
|
||||||
if (recalculate || doRecalculate) {
|
if (recalculate || doRecalculate) {
|
||||||
ProcessList_scan(pl);
|
ProcessList_scan(pl);
|
||||||
doRecalculate = false;
|
doRecalculate = false;
|
||||||
|
@ -453,27 +448,7 @@ int main(int argc, char** argv) {
|
||||||
ProcessList_sort(pl);
|
ProcessList_sort(pl);
|
||||||
refreshTimeout = 1;
|
refreshTimeout = 1;
|
||||||
}
|
}
|
||||||
Panel_prune(panel);
|
ProcessList_rebuildPanel(pl, true, follow, userOnly, userId, filtering, incFilter.buffer);
|
||||||
int size = ProcessList_size(pl);
|
|
||||||
int idx = 0;
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
bool hidden = false;
|
|
||||||
Process* p = ProcessList_get(pl, i);
|
|
||||||
|
|
||||||
if ( (!p->show)
|
|
||||||
|| (userOnly && (p->st_uid != userId))
|
|
||||||
|| (filtering && !(String_contains_i(p->comm, incFilter.buffer))) )
|
|
||||||
hidden = true;
|
|
||||||
|
|
||||||
if (!hidden) {
|
|
||||||
Panel_set(panel, idx, (Object*)p);
|
|
||||||
if ((!follow && idx == currPos) || (follow && p->pid == currPid)) {
|
|
||||||
Panel_setSelected(panel, idx);
|
|
||||||
panel->scrollV = currScrollV;
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
doRefresh = true;
|
doRefresh = true;
|
||||||
|
|
||||||
|
@ -746,6 +721,19 @@ int main(int argc, char** argv) {
|
||||||
if (!killPanel) {
|
if (!killPanel) {
|
||||||
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
|
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
bool anyTagged = false;
|
||||||
|
pid_t selectedPid;
|
||||||
|
for (int i = 0; i < Panel_size(panel); i++) {
|
||||||
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
|
if (p->tag) {
|
||||||
|
anyTagged = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!anyTagged) {
|
||||||
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
|
selectedPid = p->pid;
|
||||||
|
}
|
||||||
SignalsPanel_reset((SignalsPanel*) killPanel);
|
SignalsPanel_reset((SignalsPanel*) killPanel);
|
||||||
const char* fuFunctions[] = {"Send ", "Cancel ", NULL};
|
const char* fuFunctions[] = {"Send ", "Cancel ", NULL};
|
||||||
ListItem* sgn = (ListItem*) pickFromVector(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar, header);
|
ListItem* sgn = (ListItem*) pickFromVector(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar, header);
|
||||||
|
@ -754,17 +742,18 @@ int main(int argc, char** argv) {
|
||||||
Panel_setHeader(panel, "Sending...");
|
Panel_setHeader(panel, "Sending...");
|
||||||
Panel_draw(panel, true);
|
Panel_draw(panel, true);
|
||||||
refresh();
|
refresh();
|
||||||
bool anyTagged = false;
|
if (anyTagged) {
|
||||||
for (int i = 0; i < Panel_size(panel); i++) {
|
for (int i = 0; i < Panel_size(panel); i++) {
|
||||||
Process* p = (Process*) Panel_get(panel, i);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
Process_sendSignal(p, sgn->key);
|
Process_sendSignal(p, sgn->key);
|
||||||
anyTagged = true;
|
anyTagged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (!anyTagged) {
|
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
Process_sendSignal(p, sgn->key);
|
if (p->pid == selectedPid)
|
||||||
|
Process_sendSignal(p, sgn->key);
|
||||||
}
|
}
|
||||||
napms(500);
|
napms(500);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue