From 6c62901ae5e218db6ef570929299b2dcf1d7101a Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 10 Jan 2017 23:46:12 -0500 Subject: [PATCH] GDI: fix window not responding, but menu corruption still happens if set_gdi_pixel_format is called --- gfx/common/win32_common.cpp | 17 +++++++++-------- gfx/drivers/gdi_gfx.c | 21 +++++++++++++++++++-- gfx/drivers_context/gdi_ctx.cpp | 2 +- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index d283b72f69..8e609e3463 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -521,19 +521,20 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, switch (message) { - case WM_PAINT: - { - PAINTSTRUCT ps; + //case WM_PAINT: + //{ + /*PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); // All painting occurs here, between BeginPaint and EndPaint. - //FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1)); + FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1)); - EndPaint(hwnd, &ps); - return 0; - break; - } + EndPaint(hwnd, &ps);*/ + //return DefWindowProc(hwnd, message, wparam, lparam); + //return 0; + //break; + //} case WM_DROPFILES: case WM_SYSCOMMAND: case WM_CHAR: diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index af297d301a..ef59184017 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -354,8 +354,25 @@ static void gdi_gfx_set_nonblock_state(void *data, bool toggle) static bool gdi_gfx_alive(void *data) { - (void)data; - video_driver_set_size(&gdi_video_width, &gdi_video_height); + gfx_ctx_size_t size_data; + unsigned temp_width = 0; + unsigned temp_height = 0; + bool quit = false; + bool resize = false; + + /* Needed because some context drivers don't track their sizes */ + video_driver_get_size(&temp_width, &temp_height); + + size_data.quit = &quit; + size_data.resize = &resize; + size_data.width = &temp_width; + size_data.height = &temp_height; + + video_context_driver_check_window(&size_data); + + if (temp_width != 0 && temp_height != 0) + video_driver_set_size(&temp_width, &temp_height); + return true; } diff --git a/gfx/drivers_context/gdi_ctx.cpp b/gfx/drivers_context/gdi_ctx.cpp index a2a8c12abb..d7a5d95b98 100644 --- a/gfx/drivers_context/gdi_ctx.cpp +++ b/gfx/drivers_context/gdi_ctx.cpp @@ -298,7 +298,7 @@ void create_gdi_context(HWND hwnd, bool *quit) (void)quit; win32_gdi_hdc = GetDC(hwnd); - setup_gdi_pixel_format(win32_gdi_hdc); + //setup_gdi_pixel_format(win32_gdi_hdc); g_inited = true; }