fix interaction register propagation rules on unfocused windows (still propagate if window was last focused)

This commit is contained in:
Ryan Fleury
2024-07-15 09:28:12 -07:00
parent 044e78bea2
commit ebbf927fc1
3 changed files with 17 additions and 2 deletions
+8 -1
View File
@@ -7282,9 +7282,16 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
build_view_ui_function(ws, panel, view, content_rect);
}
//- rjf: fill with per-view states, after the view has a chance to run
{
DF_View *view = df_selected_tab_from_panel(panel);
df_interact_regs()->cursor = view->cursor;
df_interact_regs()->mark = view->mark;
}
//- rjf: pop interaction registers; commit if this is the selected view
DF_InteractRegs *view_regs = df_pop_interact_regs();
if(panel_is_focused)
if(ws->focused_panel == panel)
{
MemoryCopyStruct(df_interact_regs(), view_regs);
}
+6 -1
View File
@@ -330,10 +330,15 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
d_begin_frame();
for(DF_Window *w = df_gfx_state->first_window; w != 0; w = w->next)
{
B32 window_is_focused = os_window_is_focused(w->os);
if(window_is_focused)
{
last_focused_window = df_handle_from_window(w);
}
df_push_interact_regs();
df_window_update_and_render(scratch.arena, w, &cmds);
DF_InteractRegs *window_regs = df_pop_interact_regs();
if(os_window_is_focused(w->os))
if(df_window_from_handle(last_focused_window) == w)
{
MemoryCopyStruct(df_interact_regs(), window_regs);
}
+3
View File
@@ -446,6 +446,9 @@ global U64 ipc_s2m_ring_read_pos = 0;
global OS_Handle ipc_s2m_ring_mutex = {0};
global OS_Handle ipc_s2m_ring_cv = {0};
//- rjf: last focused window
global DF_Handle last_focused_window = {0};
//- rjf: frame time history
global U64 frame_time_us_history[64] = {0};
global U64 frame_time_us_history_idx = 0;