mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
shellwindow: use time_monotonic_ms()
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
Implementation:
|
Implementation:
|
||||||
Copyright (C) 2013 martii
|
Copyright (C) 2013 martii
|
||||||
gitorious.org/neutrino-mp/martiis-neutrino-mp
|
gitorious.org/neutrino-mp/martiis-neutrino-mp
|
||||||
Copyright (C) 2015 Stefan Seyfried
|
Copyright (C) 2015-2017 Stefan Seyfried
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <driver/abstime.h>
|
||||||
#include <driver/framebuffer.h>
|
#include <driver/framebuffer.h>
|
||||||
#include <gui/widget/textbox.h>
|
#include <gui/widget/textbox.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -103,22 +104,19 @@ void CShellWindow::exec()
|
|||||||
fds.events = POLLIN | POLLHUP | POLLERR;
|
fds.events = POLLIN | POLLHUP | POLLERR;
|
||||||
fcntl(fds.fd, F_SETFL, fcntl(fds.fd, F_GETFL, 0) | O_NONBLOCK);
|
fcntl(fds.fd, F_SETFL, fcntl(fds.fd, F_GETFL, 0) | O_NONBLOCK);
|
||||||
|
|
||||||
struct timeval tv;
|
time_t lastPaint = time_monotonic_ms();
|
||||||
gettimeofday(&tv,NULL);
|
|
||||||
uint64_t lastPaint = (uint64_t) tv.tv_usec + (uint64_t)((uint64_t) tv.tv_sec * (uint64_t) 1000000);
|
|
||||||
bool ok = true, nlseen = false, dirty = false, incomplete = false;
|
bool ok = true, nlseen = false, dirty = false, incomplete = false;
|
||||||
char output[1024];
|
char output[1024];
|
||||||
std::string txt = "";
|
std::string txt = "";
|
||||||
std::string line = "";
|
std::string line = "";
|
||||||
|
|
||||||
do {
|
do {
|
||||||
uint64_t now;
|
time_t now;
|
||||||
fds.revents = 0;
|
fds.revents = 0;
|
||||||
int r = poll(&fds, 1, 300);
|
int r = poll(&fds, 1, 300);
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
if (!feof(f)) {
|
if (!feof(f)) {
|
||||||
gettimeofday(&tv,NULL);
|
now = time_monotonic_ms();
|
||||||
now = (uint64_t) tv.tv_usec + (uint64_t)((uint64_t) tv.tv_sec * (uint64_t) 1000000);
|
|
||||||
|
|
||||||
unsigned int lines_read = 0;
|
unsigned int lines_read = 0;
|
||||||
while (fgets(output, sizeof(output), f)) {
|
while (fgets(output, sizeof(output), f)) {
|
||||||
@@ -178,7 +176,7 @@ void CShellWindow::exec()
|
|||||||
first = false;
|
first = false;
|
||||||
txt += *it;
|
txt += *it;
|
||||||
}
|
}
|
||||||
if (((lines_read == lines_max) && (lastPaint + 100000 < now)) || (lastPaint + 250000 < now)) {
|
if (((lines_read >= lines_max) && (lastPaint + 100 < now)) || (lastPaint + 250 < now)) {
|
||||||
textBox->setText(&txt, textBox->getWindowsPos().iWidth, false);
|
textBox->setText(&txt, textBox->getWindowsPos().iWidth, false);
|
||||||
if (!textBox->isPainted())
|
if (!textBox->isPainted())
|
||||||
if (mode & VERBOSE) textBox->paint();
|
if (mode & VERBOSE) textBox->paint();
|
||||||
@@ -192,9 +190,8 @@ void CShellWindow::exec()
|
|||||||
} else if (r < 0)
|
} else if (r < 0)
|
||||||
ok = false;
|
ok = false;
|
||||||
|
|
||||||
gettimeofday(&tv,NULL);
|
now = time_monotonic_ms();
|
||||||
now = (uint64_t) tv.tv_usec + (uint64_t)((uint64_t) tv.tv_sec * (uint64_t) 1000000);
|
if (!ok || (r < 1 && dirty && lastPaint + 250 < now)) {
|
||||||
if (!ok || (r < 1 && dirty && lastPaint + 250000 < now)) {
|
|
||||||
textBox->setText(&txt, textBox->getWindowsPos().iWidth, false);
|
textBox->setText(&txt, textBox->getWindowsPos().iWidth, false);
|
||||||
if (!textBox->isPainted())
|
if (!textBox->isPainted())
|
||||||
if (mode & VERBOSE) textBox->paint();
|
if (mode & VERBOSE) textBox->paint();
|
||||||
|
Reference in New Issue
Block a user