Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard resize fix #341

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions src/graphic/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ using namespace Microsoft::WRL; // For ComPtr

static struct {
HWND h_wnd;
bool in_paint;
bool recursive_paint_detected;

// These four only apply in windowed mode.
uint32_t current_width, current_height; // Width and height of client areas
Expand Down Expand Up @@ -375,24 +373,13 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par
GetMonitorHzPeriod(dxgi.h_Monitor, dxgi.detected_hz, dxgi.display_period);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
case WM_CLOSE:
dxgi.is_running = false;
break;
case WM_PAINT:
if (dxgi.in_paint) {
dxgi.recursive_paint_detected = true;
return DefWindowProcW(h_wnd, message, w_param, l_param);
} else {
if (dxgi.run_one_game_iter != nullptr) {
dxgi.in_paint = true;
dxgi.run_one_game_iter();
dxgi.in_paint = false;
if (dxgi.recursive_paint_detected) {
dxgi.recursive_paint_detected = false;
InvalidateRect(h_wnd, nullptr, false);
UpdateWindow(h_wnd);
}
}
case WM_ENDSESSION:
// This hopefully gives the game a chance to shut down, before windows kills it.
if (w_param == TRUE) {
dxgi.is_running = false;
}
break;
case WM_ACTIVATEAPP:
Expand Down Expand Up @@ -554,11 +541,8 @@ static void gfx_dxgi_set_keyboard_callbacks(bool (*on_key_down)(int scancode), b

static void gfx_dxgi_main_loop(void (*run_one_game_iter)(void)) {
dxgi.run_one_game_iter = run_one_game_iter;

MSG msg;
while (GetMessage(&msg, nullptr, 0, 0) && dxgi.is_running) {
TranslateMessage(&msg);
DispatchMessage(&msg);
while (dxgi.is_running) {
dxgi.run_one_game_iter();
}
}

Expand All @@ -570,11 +554,15 @@ static void gfx_dxgi_get_dimensions(uint32_t* width, uint32_t* height, int32_t*
}

static void gfx_dxgi_handle_events(void) {
/*MSG msg;
MSG msg;
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
dxgi.is_running = false;
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}*/
}
}

static uint64_t qpc_to_ns(uint64_t qpc) {
Expand Down
Loading