From ebbf927fc160f1fda47210c548306d2405345fac Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Mon, 15 Jul 2024 09:28:12 -0700 Subject: [PATCH] fix interaction register propagation rules on unfocused windows (still propagate if window was last focused) --- src/df/gfx/df_gfx.c | 9 ++++++++- src/raddbg/raddbg.c | 7 ++++++- src/raddbg/raddbg.h | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 6a2a4f68..aa3a919c 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -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); } diff --git a/src/raddbg/raddbg.c b/src/raddbg/raddbg.c index 5d74a2ee..abfdb4af 100644 --- a/src/raddbg/raddbg.c +++ b/src/raddbg/raddbg.c @@ -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); } diff --git a/src/raddbg/raddbg.h b/src/raddbg/raddbg.h index 67c19d74..8410b1da 100644 --- a/src/raddbg/raddbg.h +++ b/src/raddbg/raddbg.h @@ -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;