From patchwork Wed Jun 15 13:50:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1940 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0DFB523DE6 for ; Wed, 15 Jun 2011 13:52:48 +0000 (UTC) Received: from mail-vw0-f52.google.com (mail-vw0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id D11D0A1894A for ; Wed, 15 Jun 2011 13:52:47 +0000 (UTC) Received: by mail-vw0-f52.google.com with SMTP id 16so416308vws.11 for ; Wed, 15 Jun 2011 06:52:47 -0700 (PDT) Received: by 10.52.75.4 with SMTP id y4mr790673vdv.167.1308145967663; Wed, 15 Jun 2011 06:52:47 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs126646vdc; Wed, 15 Jun 2011 06:52:47 -0700 (PDT) Received: by 10.227.199.21 with SMTP id eq21mr611362wbb.101.1308145964285; Wed, 15 Jun 2011 06:52:44 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by mx.google.com with ESMTP id e7si1373562wbh.102.2011.06.15.06.52.43; Wed, 15 Jun 2011 06:52:44 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.127 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.127; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.127 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([92.134.76.78]) by mwinf5d28 with ME id wDsa1g00D1hMfSL03DsjDx; Wed, 15 Jun 2011 15:52:43 +0200 From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linaro-dev@lists.linaro.org, patches@linaro.org Subject: [powerdebug 16/22] Encapsulate the display (9) Date: Wed, 15 Jun 2011 15:50:50 +0200 Message-Id: <1308145856-6112-16-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308145856-6112-1-git-send-email-daniel.lezcano@linaro.org> References: <1308145856-6112-1-git-send-email-daniel.lezcano@linaro.org> Remove unused parameter for the keystroke callback. Signed-off-by: Daniel Lezcano --- powerdebug.c | 28 ++++++++++------------------ 1 files changed, 10 insertions(+), 18 deletions(-) diff --git a/powerdebug.c b/powerdebug.c index 28b23b4..fccc08b 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -153,7 +153,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) return 0; } -int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) +int keystroke_callback(struct powerdebug_options *options) { char keychar; int keystroke = getch(); @@ -162,10 +162,10 @@ int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) exit(0); if (keystroke == KEY_RIGHT || keystroke == '\t') - options->selectedwindow = display_next_panel(); + display_next_panel(); if (keystroke == KEY_LEFT || keystroke == KEY_BTAB) - options->selectedwindow = display_prev_panel(); + display_prev_panel(); if (keystroke == KEY_DOWN) display_next_line(); @@ -176,13 +176,13 @@ int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) keychar = toupper(keystroke); if (keystroke == '\r') - *enter_hit = true; + display_select(); if (keychar == 'Q') return 1; if (keychar == 'R') { - /* TODO refresh window */ + display_refresh(); options->ticktime = 3; } @@ -191,23 +191,11 @@ int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) int mainloop(struct powerdebug_options *options) { - bool enter_hit = false; - while (1) { int key = 0; struct timeval tval; fd_set readfds; - - if (options->selectedwindow == CLOCK) { - if (enter_hit) - display_select(); - enter_hit = false; - } - - display_refresh(); - - FD_ZERO(&readfds); FD_SET(0, &readfds); tval.tv_sec = options->ticktime; @@ -224,9 +212,10 @@ int mainloop(struct powerdebug_options *options) break; } - if (keystroke_callback(&enter_hit, options)) + if (keystroke_callback(options)) break; + display_refresh(); } return 0; @@ -253,6 +242,9 @@ static int powerdebug_display(struct powerdebug_options *options) return -1; } + if (display_refresh()) + return -1; + if (mainloop(options)) return -1;