NextActiveWindowID to fix the bug where ctrl+q would trigger for 2 registered commands and it would work on 2 different active windows

This commit is contained in:
Krzosa Karol
2025-12-27 12:46:46 +01:00
parent 9ae73e5c04
commit b6f3a1ebec
5 changed files with 38 additions and 38 deletions

View File

@@ -275,7 +275,7 @@ void OnCommand(Event event) {
}
bool mouse_in_document = AreOverlapping(mouse, it->document_rect);
if (mouse_in_document) {
ActiveWindowID = it->id;
NextActiveWindowID = ActiveWindowID = it->id;
break;
}
}
@@ -525,6 +525,12 @@ void Update(Event event) {
UpdateProcesses();
CoUpdate(&event);
For(IterateInReverse(&order)) {
if (!it->visible) continue;
View *view = GetView(it->active_view);
UpdateScroll(it, !AreEqual(view->main_caret_on_begin_frame, view->carets[0]) && view->update_scroll);
}
// We update it here despite the name to make it sure that all the possible changes are
// included albeit with delayed response. If we did this at the beginning of the frame
// and the DebugWindowUpdated we wouldnt get to know that in the OnCommand.
@@ -533,7 +539,7 @@ void Update(Event event) {
}
{
ProfileScope(WindowEndOfFrameVisibilityAndLastActive);
ProfileScope(UpdateWindows);
For (Windows) {
if (it->jump_history) {
View *view = GetView(it->active_view);
@@ -556,7 +562,7 @@ void Update(Event event) {
}
if (it->sync_visibility_with_focus) {
if (it->id == ActiveWindowID) {
if (it->id == NextActiveWindowID) {
it->visible = true;
} else {
it->visible = false;
@@ -564,22 +570,20 @@ void Update(Event event) {
}
}
Window *window = GetWindow(ActiveWindowID);
if (ActiveWindowID.id != LastActiveLayoutWindowID.id) {
ActiveWindowID = NextActiveWindowID;
Window *window = GetWindow(ActiveWindowID, NULL);
if (window == NULL || window->visible == false) {
ActiveWindowID = NextActiveWindowID = LastActiveLayoutWindowID;
window = GetWindow(ActiveWindowID);
}
if (ActiveWindowID != LastActiveLayoutWindowID) {
if (window->layout) {
LastActiveLayoutWindowID = ActiveWindowID;
}
}
}
For(IterateInReverse(&order)) {
if (!it->visible) continue;
View *view = GetView(it->active_view);
UpdateScroll(it, !AreEqual(view->main_caret_on_begin_frame, view->carets[0]) && view->update_scroll);
}
GarbageCollect();
}