From 534a727b7ca16d4bf1214e8192b97461e04e348c Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Mon, 7 Oct 2024 17:33:10 -0700 Subject: [PATCH] unminimize on exception hit --- src/os/gfx/linux/os_gfx_linux.c | 8 ++- src/os/gfx/os_gfx.h | 3 +- src/os/gfx/stub/os_gfx_stub.c | 8 ++- src/os/gfx/win32/os_gfx_win32.c | 21 +++++- src/raddbg/raddbg_core.c | 3 +- src/scratch/ryan_scratch.c | 110 ++++++++++---------------------- 6 files changed, 70 insertions(+), 83 deletions(-) diff --git a/src/os/gfx/linux/os_gfx_linux.c b/src/os/gfx/linux/os_gfx_linux.c index c8a588c0..a771727c 100644 --- a/src/os/gfx/linux/os_gfx_linux.c +++ b/src/os/gfx/linux/os_gfx_linux.c @@ -181,8 +181,14 @@ os_window_set_maximized(OS_Handle handle, B32 maximized) if(os_handle_match(handle, os_handle_zero())) {return;} } +internal B32 +os_window_is_minimized(OS_Handle window) +{ + if(os_handle_match(handle, os_handle_zero())) {return 0;} +} + internal void -os_window_minimize(OS_Handle handle) +os_window_set_minimized(OS_Handle window, B32 minimized) { if(os_handle_match(handle, os_handle_zero())) {return;} } diff --git a/src/os/gfx/os_gfx.h b/src/os/gfx/os_gfx.h index cd56a6ba..2a593336 100644 --- a/src/os/gfx/os_gfx.h +++ b/src/os/gfx/os_gfx.h @@ -148,7 +148,8 @@ internal B32 os_window_is_fullscreen(OS_Handle window); internal void os_window_set_fullscreen(OS_Handle window, B32 fullscreen); internal B32 os_window_is_maximized(OS_Handle window); internal void os_window_set_maximized(OS_Handle window, B32 maximized); -internal void os_window_minimize(OS_Handle window); +internal B32 os_window_is_minimized(OS_Handle window); +internal void os_window_set_minimized(OS_Handle window, B32 minimized); internal void os_window_bring_to_front(OS_Handle window); internal void os_window_set_monitor(OS_Handle window, OS_Handle monitor); internal void os_window_clear_custom_border_data(OS_Handle handle); diff --git a/src/os/gfx/stub/os_gfx_stub.c b/src/os/gfx/stub/os_gfx_stub.c index 356e7d47..2be9677d 100644 --- a/src/os/gfx/stub/os_gfx_stub.c +++ b/src/os/gfx/stub/os_gfx_stub.c @@ -83,8 +83,14 @@ os_window_set_maximized(OS_Handle window, B32 maximized) { } +internal B32 +os_window_is_minimized(OS_Handle window) +{ + return 0; +} + internal void -os_window_minimize(OS_Handle window) +os_window_set_minimized(OS_Handle window, B32 minimized) { } diff --git a/src/os/gfx/win32/os_gfx_win32.c b/src/os/gfx/win32/os_gfx_win32.c index 17620cb3..f3a8ead5 100644 --- a/src/os/gfx/win32/os_gfx_win32.c +++ b/src/os/gfx/win32/os_gfx_win32.c @@ -1177,13 +1177,30 @@ os_window_set_maximized(OS_Handle handle, B32 maximized) } } +internal B32 +os_window_is_minimized(OS_Handle handle) +{ + B32 result = 0; + OS_W32_Window *window = os_w32_window_from_handle(handle); + if(window) + { + result = !!(IsIconic(window->hwnd)); + } + return result; +} + internal void -os_window_minimize(OS_Handle handle) +os_window_set_minimized(OS_Handle handle, B32 minimized) { OS_W32_Window *window = os_w32_window_from_handle(handle); if(window != 0) { - ShowWindow(window->hwnd, SW_MINIMIZE); + switch(minimized) + { + default: + case 0:{ShowWindow(window->hwnd, SW_RESTORE);}break; + case 1:{ShowWindow(window->hwnd, SW_MINIMIZE);}break; + } } } diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index c75417cc..92a5e76c 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -5549,7 +5549,7 @@ rd_window_frame(RD_Window *ws) } if(ui_clicked(min_sig)) { - os_window_minimize(ws->os); + os_window_set_minimized(ws->os, 1); } if(ui_clicked(max_sig)) { @@ -15311,6 +15311,7 @@ rd_frame(void) } if(window != 0) { + os_window_set_minimized(window->os, 0); os_window_bring_to_front(window->os); os_window_focus(window->os); } diff --git a/src/scratch/ryan_scratch.c b/src/scratch/ryan_scratch.c index 3b1899a7..162fe89c 100644 --- a/src/scratch/ryan_scratch.c +++ b/src/scratch/ryan_scratch.c @@ -5,7 +5,7 @@ //~ rjf: Build Options #define BUILD_TITLE "ryan_scratch" -// #define OS_FEATURE_GRAPHICAL 1 +#define OS_FEATURE_GRAPHICAL 1 //////////////////////////////// //~ rjf: Includes @@ -41,88 +41,44 @@ #include "pdb/pdb_stringize.c" //////////////////////////////// -//~ rjf: Entry Point +//~ rjf: Entry Points -typedef struct FooBar FooBar; -struct FooBar +internal B32 +frame(void) { - U64 x; - U64 y; - U64 z; - String8 name; -}; - -Member FooBar__members[] = -{ - {str8_lit_comp("x"), type(U64), OffsetOf(FooBar, x)}, - {str8_lit_comp("y"), type(U64), OffsetOf(FooBar, y)}, - {str8_lit_comp("z"), type(U64), OffsetOf(FooBar, z)}, - {str8_lit_comp("name"), type(String8), OffsetOf(FooBar, name)}, -}; - -Type FooBar__type = -{ - TypeKind_Struct, - sizeof(FooBar), - &type_nil, - str8_lit_comp("FooBar"), - {0}, - ArrayCount(FooBar__members), - FooBar__members, -}; + B32 quit = 0; + Temp scratch = scratch_begin(0, 0); + OS_EventList events = os_get_events(scratch.arena, 0); + for(OS_Event *ev = events.first; ev != 0; ev = ev->next) + { + if(ev->kind != OS_EventKind_MouseMove) + { + String8 string = push_str8f(scratch.arena, "%S (%S)\n", os_string_from_event_kind(ev->kind), os_g_key_display_string_table[ev->key]); + printf("%.*s", str8_varg(string)); + OutputDebugStringA((char *)string.str); + fflush(stdout); + } + if(ev->kind == OS_EventKind_Press && ev->key == OS_Key_X) + { + *(int *)0 = 0; + } + } + for(OS_Event *ev = events.first; ev != 0; ev = ev->next) + { + if(ev->kind == OS_EventKind_WindowClose) + { + quit = 1; + break; + } + } + scratch_end(scratch); + return quit; +} internal void entry_point(CmdLine *cmdline) { - Arena *arena = arena_alloc(); - - FooBar foobar_in = {1, 2, 3, str8_lit("foobar 123 hello world")}; - String8 foobar_srlz = serialized_from_struct(arena, FooBar, &foobar_in); - FooBar foobar_out = *struct_from_serialized(arena, FooBar, foobar_srlz); - - String8List strs_in = {0}; - str8_list_pushf(arena, &strs_in, "foobar: %i", 123); - str8_list_pushf(arena, &strs_in, "xyzxyzxyz"); - str8_list_pushf(arena, &strs_in, "abc abc abc"); - str8_list_pushf(arena, &strs_in, "123"); - str8_list_pushf(arena, &strs_in, "456"); - str8_list_pushf(arena, &strs_in, "789"); - str8_list_pushf(arena, &strs_in, "111"); - str8_list_pushf(arena, &strs_in, "222"); - str8_list_pushf(arena, &strs_in, "333"); - String8 strs_serialized = serialized_from_struct(arena, String8List, &strs_in); - String8List strs_out = *struct_from_serialized(arena, String8List, strs_serialized); - - String8 test_name_in = str8_lit("foobar 123"); - String8 test_name_srlz = serialized_from_struct(arena, String8, &test_name_in); - String8 test_name_out = *struct_from_serialized(arena, String8, test_name_srlz); - - int x = 0; - -#if 0 OS_Handle window = os_window_open(v2f32(1280, 720), 0, str8_lit("Window")); os_window_first_paint(window); - for(B32 quit = 0; !quit;) - { - Temp scratch = scratch_begin(0, 0); - OS_EventList events = os_get_events(scratch.arena, 0); - for(OS_Event *ev = events.first; ev != 0; ev = ev->next) - { - if(ev->kind != OS_EventKind_MouseMove) - { - printf("%.*s (%.*s)\n", str8_varg(os_string_from_event_kind(ev->kind)), str8_varg(os_g_key_display_string_table[ev->key])); - fflush(stdout); - } - } - for(OS_Event *ev = events.first; ev != 0; ev = ev->next) - { - if(ev->kind == OS_EventKind_WindowClose) - { - quit = 1; - break; - } - } - scratch_end(scratch); - } -#endif + for(;!update();); }