Skip to content

Commit

Permalink
enhancement: Restore focus when exiting debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Feb 16, 2025
1 parent 995b1de commit 50195da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void deactivate_debugger (void)
debugmem_enable();
debug_pc = 0xffffffff;
keybuf_ignore_next_release();
deactivate_console();
}

void activate_debugger (void)
Expand Down
1 change: 1 addition & 0 deletions src/include/sysdeps.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ extern void close_console (void);
extern void open_console(void);
extern void reopen_console(void);
extern void activate_console (void);
extern void deactivate_console(void);
extern void console_out (const TCHAR *);
extern void console_out_f (const TCHAR *, ...);
extern void console_flush (void);
Expand Down
11 changes: 11 additions & 0 deletions src/osdep/writelog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extern int lof_store;
static int console_input_linemode = -1;
int always_flush_log = 1;
TCHAR* conlogfile = nullptr;
static HWND previousactivewindow;

#define WRITE_LOG_BUF_SIZE 4096

Expand Down Expand Up @@ -74,10 +75,20 @@ static void getconsole()
}
}

void deactivate_console(void)
{
if (previousactivewindow) {
SDL_RaiseWindow(previousactivewindow);
previousactivewindow = NULL;
}
}

void activate_console()
{
previousactivewindow = NULL;
if (!consoleopen)
return;
previousactivewindow = SDL_GetWindowFromID(SDL_GetWindowID(SDL_GetKeyboardFocus()));
//SetForegroundWindow(GetConsoleWindow());
}

Expand Down

0 comments on commit 50195da

Please sign in to comment.