Skip to content

Commit d8f75e2

Browse files
author
s.kushnirenko
committed
ui: reset ui state before frame
1 parent 15f66f5 commit d8f75e2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/graphics/window.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "graphics/elements/warning.h"
77
#include "input/cursor.h"
88
#include "input/scroll.h"
9+
#include "graphics/elements/ui.h"
910

1011
#define MAX_QUEUE 6
1112

@@ -25,11 +26,13 @@ static void noop(void) {
2526
}
2627
static void noop_input(const mouse* m, const hotkeys* h) {
2728
}
29+
2830
static void reset_input() {
2931
mouse_reset_button_state();
3032
reset_touches(1);
3133
scroll_stop();
3234
}
35+
3336
static void increase_queue_index() {
3437
auto& data = g_window;
3538
data.queue_index++;
@@ -78,15 +81,20 @@ void window_show(const window_type* window) {
7881
auto& data = g_window;
7982
// push window into queue of screens to render
8083
reset_input();
84+
ui::begin_frame();
8185
increase_queue_index();
8286
data.window_queue[data.queue_index] = *window;
8387
data.current_window = &data.window_queue[data.queue_index];
8488
if (!data.current_window->draw_background)
8589
data.current_window->draw_background = noop;
90+
8691
if (!data.current_window->draw_foreground)
8792
data.current_window->draw_foreground = noop;
88-
if (!data.current_window->handle_input)
93+
94+
if (!data.current_window->handle_input) {
8995
data.current_window->handle_input = noop_input;
96+
}
97+
9098
window_invalidate();
9199
}
92100

@@ -97,20 +105,23 @@ void window_go_back() {
97105
data.current_window = &data.window_queue[data.queue_index];
98106
window_invalidate();
99107
}
108+
100109
static void update_input_before() {
101110
if (!touch_to_mouse()) {
102111
mouse_determine_button_state(); // touch overrides mouse
103112
}
104113

105114
hotkey_handle_global_keys();
106115
}
116+
107117
void window_update_input_after() {
108118
auto& data = g_window;
109119
reset_touches(0);
110120
mouse_reset_scroll();
111121
input_cursor_update(data.current_window->id);
112122
hotkey_reset_state();
113123
}
124+
114125
void window_draw(int force) {
115126
auto& data = g_window;
116127
// draw the current (top) window in the queue

0 commit comments

Comments
 (0)