mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
make alt+enter working with a resized window
This commit is contained in:
parent
d68cb86430
commit
72a86a9f78
@ -104,6 +104,7 @@ typedef struct IDirectDrawImpl
|
|||||||
BOOL wine;
|
BOOL wine;
|
||||||
LONG minimized;
|
LONG minimized;
|
||||||
DWORD ticklength;
|
DWORD ticklength;
|
||||||
|
BOOL altenter;
|
||||||
|
|
||||||
} IDirectDrawImpl;
|
} IDirectDrawImpl;
|
||||||
|
|
||||||
|
70
src/main.c
70
src/main.c
@ -368,6 +368,9 @@ void InitDirect3D9()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LastSetWindowPosTick = Workaround for a wine+gnome bug where each SetWindowPos call triggers a WA_INACTIVE message
|
||||||
|
DWORD LastSetWindowPosTick;
|
||||||
|
|
||||||
HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD height, DWORD bpp)
|
HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD height, DWORD bpp)
|
||||||
{
|
{
|
||||||
printf("DirectDraw::SetDisplayMode(This=%p, width=%d, height=%d, bpp=%d)\n", This, (unsigned int)width, (unsigned int)height, (unsigned int)bpp);
|
printf("DirectDraw::SetDisplayMode(This=%p, width=%d, height=%d, bpp=%d)\n", This, (unsigned int)width, (unsigned int)height, (unsigned int)bpp);
|
||||||
@ -407,8 +410,17 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
|||||||
SendMessage(This->hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hsicon);
|
SendMessage(This->hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hsicon);
|
||||||
}
|
}
|
||||||
|
|
||||||
This->render.width = WindowRect.right;
|
if (ddraw->altenter)
|
||||||
This->render.height = WindowRect.bottom;
|
{
|
||||||
|
ddraw->altenter = FALSE;
|
||||||
|
This->render.width = ddraw->width;
|
||||||
|
This->render.height = ddraw->height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
This->render.width = WindowRect.right;
|
||||||
|
This->render.height = WindowRect.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
This->width = width;
|
This->width = width;
|
||||||
This->height = height;
|
This->height = height;
|
||||||
@ -601,7 +613,8 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
|||||||
SetWindowLong(This->hWnd, GWL_STYLE, GetWindowLong(This->hWnd, GWL_STYLE) | WS_MINIMIZEBOX);
|
SetWindowLong(This->hWnd, GWL_STYLE, GetWindowLong(This->hWnd, GWL_STYLE) | WS_MINIMIZEBOX);
|
||||||
|
|
||||||
SetWindowPos(This->hWnd, HWND_TOPMOST, 0, 0, This->render.width, This->render.height, SWP_SHOWWINDOW);
|
SetWindowPos(This->hWnd, HWND_TOPMOST, 0, 0, This->render.width, This->render.height, SWP_SHOWWINDOW);
|
||||||
|
LastSetWindowPosTick = timeGetTime();
|
||||||
|
|
||||||
mouse_lock();
|
mouse_lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,59 +642,28 @@ HRESULT __stdcall ddraw_SetDisplayMode2(IDirectDrawImpl *This, DWORD width, DWOR
|
|||||||
return ddraw_SetDisplayMode(This, width, height, bpp);
|
return ddraw_SetDisplayMode(This, width, height, bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LastSetWindowPosTick = Workaround for a wine+gnome bug where each SetWindowPos call triggers a WA_INACTIVE message
|
|
||||||
DWORD LastSetWindowPosTick;
|
|
||||||
|
|
||||||
void ToggleFullscreen()
|
void ToggleFullscreen()
|
||||||
{
|
{
|
||||||
if (ddraw->windowed)
|
if (ddraw->windowed)
|
||||||
{
|
{
|
||||||
mouse_unlock();
|
mouse_unlock();
|
||||||
if(ChangeDisplaySettings(&ddraw->render.mode, CDS_TEST) == DISP_CHANGE_SUCCESSFUL)
|
ddraw->windowed = FALSE;
|
||||||
{
|
SetWindowLong(ddraw->hWnd, GWL_STYLE, GetWindowLong(ddraw->hWnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU));
|
||||||
ddraw->windowed = FALSE;
|
ddraw->altenter = TRUE;
|
||||||
|
ddraw_SetDisplayMode(ddraw, ddraw->width, ddraw->height, 8);
|
||||||
SetWindowLong(ddraw->hWnd, GWL_STYLE, GetWindowLong(ddraw->hWnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU));
|
|
||||||
SetWindowPos(ddraw->hWnd, HWND_TOPMOST, 0, 0, ddraw->render.width, ddraw->render.height, SWP_SHOWWINDOW);
|
|
||||||
LastSetWindowPosTick = timeGetTime();
|
|
||||||
|
|
||||||
if (Direct3D9Active)
|
|
||||||
Direct3D9_Reset();
|
|
||||||
else
|
|
||||||
ChangeDisplaySettings(&ddraw->render.mode, CDS_FULLSCREEN);
|
|
||||||
}
|
|
||||||
mouse_lock();
|
mouse_lock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mouse_unlock();
|
mouse_unlock();
|
||||||
if(Direct3D9Active || ChangeDisplaySettings(&ddraw->mode, 0) == DISP_CHANGE_SUCCESSFUL)
|
ddraw->windowed = TRUE;
|
||||||
{
|
|
||||||
if (Direct3D9Active)
|
|
||||||
{
|
|
||||||
ddraw->windowed = TRUE;
|
|
||||||
Direct3D9_Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ddraw->border)
|
|
||||||
{
|
|
||||||
SetWindowLong(ddraw->hWnd, GWL_STYLE, GetWindowLong(ddraw->hWnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetWindowLong(ddraw->hWnd, GWL_STYLE, GetWindowLong(ddraw->hWnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
int x = (WindowRect.left != -32000) ? WindowRect.left : (ddraw->mode.dmPelsWidth / 2) - (ddraw->render.width / 2);
|
|
||||||
int y = (WindowRect.top != -32000) ? WindowRect.top : (ddraw->mode.dmPelsHeight / 2) - (ddraw->render.height / 2);
|
|
||||||
RECT dst = { x, y, ddraw->render.width+x, ddraw->render.height+y };
|
|
||||||
AdjustWindowRect(&dst, GetWindowLong(ddraw->hWnd, GWL_STYLE), FALSE);
|
|
||||||
|
|
||||||
SetWindowPos(ddraw->hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
if (Direct3D9Active)
|
||||||
MoveWindow(ddraw->hWnd, dst.left, dst.top, (dst.right - dst.left), (dst.bottom - dst.top), TRUE);
|
Direct3D9_Reset();
|
||||||
|
else
|
||||||
|
ChangeDisplaySettings(&ddraw->mode, 0);
|
||||||
|
|
||||||
ddraw->windowed = TRUE;
|
ddraw_SetDisplayMode(ddraw, ddraw->width, ddraw->height, 8);
|
||||||
}
|
|
||||||
mouse_lock();
|
mouse_lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user