]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Restore focus when exiting debugger
authorToni Wilen <twilen@winuae.net>
Fri, 14 Feb 2025 15:57:46 +0000 (17:57 +0200)
committerToni Wilen <twilen@winuae.net>
Fri, 14 Feb 2025 15:57:46 +0000 (17:57 +0200)
debug.cpp
include/sysdeps.h
od-win32/writelog.cpp

index 8cdb129836fbe2028f336470c2d8371c96159649..af2f366eb5558d9982c41b91d95f6c960e396bd5 100644 (file)
--- a/debug.cpp
+++ b/debug.cpp
@@ -110,6 +110,7 @@ void deactivate_debugger (void)
        debugmem_enable();
        debug_pc = 0xffffffff;
        keybuf_ignore_next_release();
+       deactivate_console();
 }
 
 void activate_debugger (void)
index 97f24335f0d30cab18eba906129a451d5422f13d..dae18aabbc285ccecd41071890bb9e8e0a39a9de 100644 (file)
@@ -458,7 +458,8 @@ extern TCHAR *setconsolemode (TCHAR *buffer, int maxlen);
 extern void close_console (void);
 extern void open_console(void);
 extern void reopen_console(void);
-extern void activate_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);
index 19b423e98f6951dbd8e62dc55f5288d3f59690f6..7e34b4dcd33e15ac5ba64801617503e628adf836 100644 (file)
@@ -72,6 +72,7 @@ static int console_input_linemode = -1;
 int always_flush_log = 0;
 TCHAR *conlogfile = NULL;
 static FILE *conlogfilehandle;
+static HWND previousactivewindow;
 
 #define WRITE_LOG_BUF_SIZE 4096
 
@@ -134,11 +135,21 @@ static void flushmsgpump(void)
        }
 }
 
-void activate_console (void)
+void deactivate_console(void)
 {
+       if (previousactivewindow) {
+               SetForegroundWindow(previousactivewindow);
+               previousactivewindow = NULL;
+       }
+}
+
+void activate_console(void)
+{
+       previousactivewindow = NULL;
        if (!consoleopen)
                return;
-       SetForegroundWindow (GetConsoleWindow ());
+       previousactivewindow = GetForegroundWindow();
+       SetForegroundWindow(GetConsoleWindow());
 }
 
 static void open_console_window (void)