aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/browser.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-10-25 11:45:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-26 11:05:23 -0400
commit71172ed97cd4cd45c6ae70e594ba351798d11909 (patch)
treec94ffc88b9ebf64b71531adf6c0028dcc24b9217 /tools/perf/util/ui/browser.c
parentca59bcbceeb7fd412faa35871ec0bd21bdd69229 (diff)
perf ui: Improve handling sigwinch a bit
No need to unblock it at each ui__getch() and also allow other users to check if a resize is needed, or force an refresh of terminal dimensions. The 'force' one shouldn't be needed, but its in a slow path, so leave it like that for now, I'll revisit this another day. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-aujchu6yx3bfy64non1rky0w@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/ui/browser.c')
-rw-r--r--tools/perf/util/ui/browser.c49
1 files changed, 2 insertions, 47 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index 5359f371d30..370c4703cec 100644
--- a/tools/perf/util/ui/browser.c
+++ b/tools/perf/util/ui/browser.c
@@ -4,6 +4,7 @@
4#include "libslang.h" 4#include "libslang.h"
5#include <newt.h> 5#include <newt.h>
6#include "ui.h" 6#include "ui.h"
7#include "util.h"
7#include <linux/compiler.h> 8#include <linux/compiler.h>
8#include <linux/list.h> 9#include <linux/list.h>
9#include <linux/rbtree.h> 10#include <linux/rbtree.h>
@@ -291,53 +292,10 @@ void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries)
291 browser->seek(browser, browser->top_idx, SEEK_SET); 292 browser->seek(browser, browser->top_idx, SEEK_SET);
292} 293}
293 294
294static int ui__getch(int delay_secs)
295{
296 struct timeval timeout, *ptimeout = delay_secs ? &timeout : NULL;
297 fd_set read_set;
298 int err, key;
299
300 FD_ZERO(&read_set);
301 FD_SET(0, &read_set);
302
303 if (delay_secs) {
304 timeout.tv_sec = delay_secs;
305 timeout.tv_usec = 0;
306 }
307
308 err = select(1, &read_set, NULL, NULL, ptimeout);
309
310 if (err == 0)
311 return K_TIMER;
312
313 if (err == -1) {
314 if (errno == EINTR)
315 return K_RESIZE;
316 return K_ERROR;
317 }
318
319 key = SLang_getkey();
320 if (key != K_ESC)
321 return key;
322
323 FD_ZERO(&read_set);
324 FD_SET(0, &read_set);
325 timeout.tv_sec = 0;
326 timeout.tv_usec = 20;
327 err = select(1, &read_set, NULL, NULL, &timeout);
328 if (err == 0)
329 return K_ESC;
330
331 SLang_ungetkey(key);
332 return SLkp_getkey();
333}
334
335int ui_browser__run(struct ui_browser *self, int delay_secs) 295int ui_browser__run(struct ui_browser *self, int delay_secs)
336{ 296{
337 int err, key; 297 int err, key;
338 298
339 pthread__unblock_sigwinch();
340
341 while (1) { 299 while (1) {
342 off_t offset; 300 off_t offset;
343 301
@@ -351,10 +309,7 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
351 key = ui__getch(delay_secs); 309 key = ui__getch(delay_secs);
352 310
353 if (key == K_RESIZE) { 311 if (key == K_RESIZE) {
354 pthread_mutex_lock(&ui__lock); 312 ui__refresh_dimensions(false);
355 SLtt_get_screen_size();
356 SLsmg_reinit_smg();
357 pthread_mutex_unlock(&ui__lock);
358 ui_browser__refresh_dimensions(self); 313 ui_browser__refresh_dimensions(self);
359 __ui_browser__show_title(self, self->title); 314 __ui_browser__show_title(self, self->title);
360 ui_helpline__puts(self->helpline); 315 ui_helpline__puts(self->helpline);