win-stats: Handle app commands, support back keybind in flame graph
See #1658
This commit is contained in:
parent
7b02aa7026
commit
a632365b88
|
|
@ -127,7 +127,21 @@ set_time_units(int unit_mask) {
|
|||
*/
|
||||
void WinStatsFlameGraph::
|
||||
on_click_label(int collector_index) {
|
||||
set_collector_index(collector_index);
|
||||
if (collector_index != get_collector_index()) {
|
||||
if (collector_index == -1) {
|
||||
clear_history();
|
||||
set_collector_index(-1);
|
||||
} else {
|
||||
push_collector_index(collector_index);
|
||||
}
|
||||
|
||||
if (is_title_unknown()) {
|
||||
std::string window_title = get_title_text();
|
||||
if (!is_title_unknown()) {
|
||||
SetWindowText(_window, window_title.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -159,22 +173,6 @@ on_leave_label(int collector_index) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the collector represented by this flame graph. This may force a
|
||||
* redraw.
|
||||
*/
|
||||
void WinStatsFlameGraph::
|
||||
set_collector_index(int collector_index) {
|
||||
PStatFlameGraph::set_collector_index(collector_index);
|
||||
|
||||
if (is_title_unknown()) {
|
||||
std::string window_title = get_title_text();
|
||||
if (!is_title_unknown()) {
|
||||
SetWindowText(_window, window_title.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls update_guide_bars with parameters suitable to this kind of graph.
|
||||
*/
|
||||
|
|
@ -373,7 +371,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||
break;
|
||||
|
||||
case 101:
|
||||
set_collector_index(_popup_index);
|
||||
on_click_label(_popup_index);
|
||||
return 0;
|
||||
|
||||
case 102:
|
||||
|
|
@ -419,6 +417,26 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||
}
|
||||
break;
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
if (((lparam >> 16) & KF_ALTDOWN) != 0 && wparam == VK_LEFT) {
|
||||
if (pop_collector_index()) {
|
||||
std::string window_title = get_title_text();
|
||||
SetWindowText(_window, window_title.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_APPCOMMAND:
|
||||
if (GET_APPCOMMAND_LPARAM(lparam) == APPCOMMAND_BROWSER_BACKWARD) {
|
||||
if (pop_collector_index()) {
|
||||
std::string window_title = get_title_text();
|
||||
SetWindowText(_window, window_title.c_str());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -506,7 +524,7 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||
// that collector.
|
||||
int16_t x = LOWORD(lparam);
|
||||
int16_t y = HIWORD(lparam);
|
||||
set_collector_index(get_bar_collector(pixel_to_depth(y), x));
|
||||
on_click_label(get_bar_collector(pixel_to_depth(y), x));
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ public:
|
|||
virtual void on_enter_label(int collector_index);
|
||||
virtual void on_leave_label(int collector_index);
|
||||
|
||||
void set_collector_index(int collector_index);
|
||||
|
||||
protected:
|
||||
virtual void normal_guide_bars();
|
||||
|
||||
|
|
|
|||
|
|
@ -413,6 +413,13 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||
close();
|
||||
break;
|
||||
|
||||
case WM_APPCOMMAND:
|
||||
if (GET_APPCOMMAND_LPARAM(lparam) == APPCOMMAND_CLOSE) {
|
||||
close();
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_GETMINMAXINFO:
|
||||
{
|
||||
WINDOWINFO winfo;
|
||||
|
|
|
|||
|
|
@ -858,6 +858,18 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||
}
|
||||
break;
|
||||
|
||||
case WM_APPCOMMAND:
|
||||
switch (GET_APPCOMMAND_LPARAM(lparam)) {
|
||||
case APPCOMMAND_OPEN:
|
||||
open_session();
|
||||
return TRUE;
|
||||
|
||||
case APPCOMMAND_SAVE:
|
||||
save_session();
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (HIWORD(wparam) <= 1) {
|
||||
int menu_id = LOWORD(wparam);
|
||||
|
|
|
|||
Loading…
Reference in New Issue