Skip to content

Commit

Permalink
Partially revert Kenix3#341 (Kenix3#372) (Kenix3#379)
Browse files Browse the repository at this point in the history
This seems to have caused a discrepancy in DPI awareness and therefore ImGUI does not use the whole window.

Co-authored-by: Spodi <[email protected]>
  • Loading branch information
briaguya-ai and Spodi authored Nov 19, 2023
1 parent d9b1a2d commit ff156b0
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/graphic/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ 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 @@ -382,6 +384,24 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par
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_ACTIVATEAPP:
if (dxgi.on_all_keys_up != nullptr) {
dxgi.on_all_keys_up();
Expand Down Expand Up @@ -541,9 +561,15 @@ 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);
}
/* dxgi.run_one_game_iter = run_one_game_iter;
while (dxgi.is_running) {
dxgi.run_one_game_iter();
}
}*/
}

static void gfx_dxgi_get_dimensions(uint32_t* width, uint32_t* height, int32_t* posX, int32_t* posY) {
Expand All @@ -554,15 +580,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

0 comments on commit ff156b0

Please sign in to comment.