perf ui browser: Allow overriding refresh_dimensions method
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 1 Jul 2014 19:34:42 +0000 (16:34 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 7 Jul 2014 15:36:54 +0000 (12:36 -0300)
Some browsers, like the hist_browser, may want to be notified everytime
a refresh_dimensions is needed, so that it can reset ui_browser->rows,
for instance, or do some other related reaction to screen resizings.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
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-ielvluuemzn30bneh0zk3twi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browser.c
tools/perf/ui/browser.h

index adb294a3ec08b1072b207d64ce93d8f06e007259..6680fa5cb9dd9bda53617b0bf25214a343c0bd27 100644 (file)
@@ -250,7 +250,10 @@ int ui_browser__show(struct ui_browser *browser, const char *title,
        int err;
        va_list ap;
 
-       ui_browser__refresh_dimensions(browser);
+       if (browser->refresh_dimensions == NULL)
+               browser->refresh_dimensions = ui_browser__refresh_dimensions;
+
+       browser->refresh_dimensions(browser);
 
        pthread_mutex_lock(&ui__lock);
        __ui_browser__show_title(browser, title);
@@ -367,7 +370,7 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs)
 
                if (key == K_RESIZE) {
                        ui__refresh_dimensions(false);
-                       ui_browser__refresh_dimensions(browser);
+                       browser->refresh_dimensions(browser);
                        __ui_browser__show_title(browser, browser->title);
                        ui_helpline__puts(browser->helpline);
                        continue;
index cb8f39a1646fb1ee94bf3fff0574aa78d96a670f..92ae7211396555c8f0f2435d369ad0436b1562b2 100644 (file)
@@ -19,6 +19,7 @@ struct ui_browser {
        void          *priv;
        const char    *title;
        char          *helpline;
+       void          (*refresh_dimensions)(struct ui_browser *browser);
        unsigned int  (*refresh)(struct ui_browser *browser);
        void          (*write)(struct ui_browser *browser, void *entry, int row);
        void          (*seek)(struct ui_browser *browser, off_t offset, int whence);