diff options
Diffstat (limited to 'src/osd/windows/drawd3d.c')
-rw-r--r-- | src/osd/windows/drawd3d.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index e819bf7f0e2..b082c54a43c 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -207,6 +207,33 @@ static const line_aa_step line_aa_4step[] = // INLINES //============================================================ +INLINE BOOL GetClientRectExceptMenu(HWND hWnd, PRECT pRect, BOOL fullscreen) +{ + static HMENU last_menu; + static RECT last_rect; + static RECT cached_rect; + HMENU menu = GetMenu(hWnd); + BOOL result = GetClientRect(hWnd, pRect); + + if (!fullscreen || !menu) + return result; + + // to avoid flicker use cache if we can use + if (last_menu != menu || memcmp(&last_rect, pRect, sizeof *pRect) != 0) + { + last_menu = menu; + last_rect = *pRect; + + SetMenu(hWnd, NULL); + result = GetClientRect(hWnd, &cached_rect); + SetMenu(hWnd, menu); + } + + *pRect = cached_rect; + return result; +} + + INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr) { /* original equations: @@ -535,7 +562,7 @@ static const render_primitive_list *drawd3d_window_get_primitives(win_window_inf d3d_info *d3d = window->drawdata; RECT client; - GetClientRect(window->hwnd, &client); + GetClientRectExceptMenu(window->hwnd, &client, window->fullscreen); if (rect_width(&client) > 0 && rect_height(&client) > 0) { render_target_set_bounds(window->target, rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor)); @@ -706,7 +733,7 @@ try_again: d3d->presentation.MultiSampleType = D3DMULTISAMPLE_NONE; d3d->presentation.SwapEffect = D3DSWAPEFFECT_DISCARD; d3d->presentation.hDeviceWindow = window->hwnd; - d3d->presentation.Windowed = !window->fullscreen || HAS_WINDOW_MENU; + d3d->presentation.Windowed = (!video_config.switchres || !window->fullscreen) || HAS_WINDOW_MENU; d3d->presentation.EnableAutoDepthStencil = FALSE; d3d->presentation.AutoDepthStencilFormat = D3DFMT_D16; d3d->presentation.Flags = 0; @@ -1112,7 +1139,7 @@ static int config_adapter_mode(win_window_info *window) RECT client; // bounds are from the window client rect - GetClientRect(window->hwnd, &client); + GetClientRectExceptMenu(window->hwnd, &client, window->fullscreen); d3d->width = client.right - client.left; d3d->height = client.bottom - client.top; @@ -1291,7 +1318,7 @@ static int update_window_size(win_window_info *window) RECT client; // get the current window bounds - GetClientRect(window->hwnd, &client); + GetClientRectExceptMenu(window->hwnd, &client, window->fullscreen); // if we have a device and matching width/height, nothing to do if (d3d->device != NULL && rect_width(&client) == d3d->width && rect_height(&client) == d3d->height) |