fixed fullscreen toggle positioning, smartsizing
Also: added maximum window size
This commit is contained in:
parent
a5bcb8bc21
commit
b91a7cd3a8
@ -160,6 +160,9 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
||||
rdpInput* input;
|
||||
BOOL processed;
|
||||
|
||||
RECT windowRect, clientRect;
|
||||
MINMAXINFO *minmax;
|
||||
|
||||
processed = TRUE;
|
||||
ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||
wfi = (wfInfo*) ptr;
|
||||
@ -171,7 +174,7 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
||||
switch (Msg)
|
||||
{
|
||||
case WM_MOVE:
|
||||
if (!wfi->fullscreen)
|
||||
if (!wfi->disablewindowtracking)
|
||||
{
|
||||
int x = LOWORD(lParam);
|
||||
int y = HIWORD(lParam);
|
||||
@ -180,6 +183,20 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_GETMINMAXINFO:
|
||||
// Set maximum window size for resizing
|
||||
|
||||
minmax = (MINMAXINFO*) lParam;
|
||||
wf_update_canvas_diff(wfi);
|
||||
if (!wfi->fullscreen)
|
||||
{
|
||||
// add window decoration
|
||||
minmax->ptMaxTrackSize.x = wfi->width + wfi->diff.x;
|
||||
minmax->ptMaxTrackSize.y = wfi->height + wfi->diff.y;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
int dwStyle = GetWindowLongPtr(wfi->hwnd, GWL_STYLE);
|
||||
@ -189,23 +206,6 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
||||
|
||||
if (!wfi->fullscreen)
|
||||
{
|
||||
//if (width > wfi->width || height > wfi->height)
|
||||
//{
|
||||
// // Calculate decoration size
|
||||
// RECT decoration;
|
||||
// GetWindowRect(wfi->hwnd, &decoration);
|
||||
// decoration.right = decoration.right - decoration.left - width;
|
||||
// decoration.left = 0;
|
||||
// decoration.bottom = decoration.bottom - decoration.top - height;
|
||||
// decoration.top = 0;
|
||||
|
||||
// width = min(wfi->width + decoration.right, width + decoration.right);
|
||||
// height = min(wfi->height + decoration.bottom, height + decoration.bottom);
|
||||
|
||||
// SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, width, height, SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||
|
||||
//}
|
||||
|
||||
((wfContext*) wfi->instance->context)->wfi->client_width = width;
|
||||
((wfContext*) wfi->instance->context)->wfi->client_height = height;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "wf_interface.h"
|
||||
#include "wf_graphics.h"
|
||||
#include "wf_gdi.h"
|
||||
|
||||
const BYTE wf_rop2_table[] =
|
||||
{
|
||||
@ -280,12 +281,8 @@ void wf_resize_window(wfInfo* wfi)
|
||||
|
||||
/* Now resize to get full canvas size and room for caption and borders */
|
||||
SetWindowPos(wfi->hwnd, HWND_TOP, 0, 0, wfi->width, wfi->height, SWP_FRAMECHANGED);
|
||||
GetClientRect(wfi->hwnd, &rc_client);
|
||||
GetWindowRect(wfi->hwnd, &rc_wnd);
|
||||
|
||||
wfi->diff.x = (rc_wnd.right - rc_wnd.left) - rc_client.right;
|
||||
wfi->diff.y = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
|
||||
|
||||
|
||||
wf_update_canvas_diff(wfi);
|
||||
SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, wfi->width + wfi->diff.x, wfi->height + wfi->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||
}
|
||||
else
|
||||
@ -293,7 +290,7 @@ void wf_resize_window(wfInfo* wfi)
|
||||
RECT rc_wnd;
|
||||
RECT rc_client;
|
||||
|
||||
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX);
|
||||
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX);
|
||||
|
||||
if (!wfi->client_height)
|
||||
wfi->client_height = wfi->height;
|
||||
@ -307,15 +304,10 @@ void wf_resize_window(wfInfo* wfi)
|
||||
if (!wfi->client_y)
|
||||
wfi->client_y = 10;
|
||||
|
||||
/* Now resize to get full canvas size and room for caption and borders */
|
||||
SetWindowPos(wfi->hwnd, HWND_TOP, wfi->client_x, wfi->client_y, wfi->client_width, wfi->client_height, SWP_FRAMECHANGED);
|
||||
GetClientRect(wfi->hwnd, &rc_client);
|
||||
GetWindowRect(wfi->hwnd, &rc_wnd);
|
||||
wf_update_canvas_diff(wfi);
|
||||
|
||||
wfi->diff.x = (rc_wnd.right - rc_wnd.left) - rc_client.right;
|
||||
wfi->diff.y = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
|
||||
|
||||
SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, wfi->client_width + wfi->diff.x, wfi->client_height + wfi->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||
/* Now resize to get full canvas size and room for caption and borders */
|
||||
SetWindowPos(wfi->hwnd, HWND_TOP, wfi->client_x, wfi->client_y, wfi->client_width + wfi->diff.x, wfi->client_height + wfi->diff.y, SWP_FRAMECHANGED);
|
||||
}
|
||||
wf_update_offset(wfi);
|
||||
}
|
||||
@ -324,10 +316,22 @@ void wf_toggle_fullscreen(wfInfo* wfi)
|
||||
{
|
||||
ShowWindow(wfi->hwnd, SW_HIDE);
|
||||
wfi->fullscreen = !wfi->fullscreen;
|
||||
|
||||
if (wfi->fullscreen)
|
||||
{
|
||||
wfi->disablewindowtracking = TRUE;
|
||||
}
|
||||
|
||||
SetParent(wfi->hwnd, wfi->fullscreen ? NULL : wfi->hWndParent);
|
||||
wf_resize_window(wfi);
|
||||
ShowWindow(wfi->hwnd, SW_SHOW);
|
||||
SetForegroundWindow(wfi->hwnd);
|
||||
|
||||
if (!wfi->fullscreen)
|
||||
{
|
||||
// Reenable window tracking AFTER resizing it back, otherwise it can lean to repositioning errors.
|
||||
wfi->disablewindowtracking = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void wf_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
|
||||
@ -694,3 +698,21 @@ void wf_gdi_register_update_callbacks(rdpUpdate* update)
|
||||
update->SurfaceBits = wf_gdi_surface_bits;
|
||||
update->SurfaceFrameMarker = wf_gdi_surface_frame_marker;
|
||||
}
|
||||
|
||||
void wf_update_canvas_diff(wfInfo* wfi)
|
||||
{
|
||||
RECT rc_client, rc_wnd;
|
||||
int dx, dy;
|
||||
|
||||
GetClientRect(wfi->hwnd, &rc_client);
|
||||
GetWindowRect(wfi->hwnd, &rc_wnd);
|
||||
|
||||
dx = (rc_wnd.right - rc_wnd.left) - rc_client.right;
|
||||
dy = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
|
||||
|
||||
if (!wfi->disablewindowtracking)
|
||||
{
|
||||
wfi->diff.x = dx;
|
||||
wfi->diff.y = dy;
|
||||
}
|
||||
}
|
@ -33,4 +33,6 @@ void wf_toggle_fullscreen(wfInfo* wfi);
|
||||
|
||||
void wf_gdi_register_update_callbacks(rdpUpdate* update);
|
||||
|
||||
void wf_update_canvas_diff(wfInfo* wfi);
|
||||
|
||||
#endif /* __WF_GDI_H */
|
||||
|
@ -129,6 +129,9 @@ struct wf_info
|
||||
callbackFunc client_callback_func;
|
||||
|
||||
rdpFile* connectionRdpFile;
|
||||
|
||||
// Keep track of window size and position, disable when in fullscreen mode.
|
||||
BOOL disablewindowtracking;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user