10985a948SNamhyung Kim #include <pthread.h> 20985a948SNamhyung Kim 3*ea251d51SNamhyung Kim #include "../util/cache.h" 4*ea251d51SNamhyung Kim #include "../util/debug.h" 5*ea251d51SNamhyung Kim #include "../util/hist.h" 6aca7a94dSNamhyung Kim 70985a948SNamhyung Kim pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; 80985a948SNamhyung Kim 9aca7a94dSNamhyung Kim void setup_browser(bool fallback_to_pager) 10aca7a94dSNamhyung Kim { 11281ef544SNamhyung Kim if (!isatty(1) || dump_trace) 12aca7a94dSNamhyung Kim use_browser = 0; 13281ef544SNamhyung Kim 14281ef544SNamhyung Kim /* default to TUI */ 15281ef544SNamhyung Kim if (use_browser < 0) 16281ef544SNamhyung Kim use_browser = 1; 17281ef544SNamhyung Kim 18281ef544SNamhyung Kim switch (use_browser) { 19281ef544SNamhyung Kim case 2: 20dc41b9b8SNamhyung Kim if (perf_gtk__init() == 0) 21281ef544SNamhyung Kim break; 22dc41b9b8SNamhyung Kim /* fall through */ 23281ef544SNamhyung Kim case 1: 24dc41b9b8SNamhyung Kim use_browser = 1; 25dc41b9b8SNamhyung Kim if (ui__init() == 0) 26281ef544SNamhyung Kim break; 27dc41b9b8SNamhyung Kim /* fall through */ 28281ef544SNamhyung Kim default: 2921f0d423SNamhyung Kim use_browser = 0; 30aca7a94dSNamhyung Kim if (fallback_to_pager) 31aca7a94dSNamhyung Kim setup_pager(); 32*ea251d51SNamhyung Kim 33*ea251d51SNamhyung Kim perf_hpp__init(false, false); 34281ef544SNamhyung Kim break; 35aca7a94dSNamhyung Kim } 36aca7a94dSNamhyung Kim } 37aca7a94dSNamhyung Kim 38aca7a94dSNamhyung Kim void exit_browser(bool wait_for_ok) 39aca7a94dSNamhyung Kim { 40281ef544SNamhyung Kim switch (use_browser) { 41281ef544SNamhyung Kim case 2: 42281ef544SNamhyung Kim perf_gtk__exit(wait_for_ok); 43281ef544SNamhyung Kim break; 44281ef544SNamhyung Kim 45281ef544SNamhyung Kim case 1: 46281ef544SNamhyung Kim ui__exit(wait_for_ok); 47281ef544SNamhyung Kim break; 48281ef544SNamhyung Kim 49281ef544SNamhyung Kim default: 50281ef544SNamhyung Kim break; 51aca7a94dSNamhyung Kim } 52aca7a94dSNamhyung Kim } 53