converted function wf_on_param_change to new PubSub_ system. The function was not called anymore, which caused a refresh problem when changing Smart Sizing during a session.

This commit is contained in:
Benoît LeBlanc 2013-10-07 13:46:13 -04:00
parent 173fede474
commit 46c06b5081
1 changed files with 20 additions and 18 deletions

View File

@ -10,7 +10,7 @@
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -332,7 +332,7 @@ BOOL wf_post_connect(freerdp* instance)
rdpContext* context; rdpContext* context;
WCHAR lpWindowName[64]; WCHAR lpWindowName[64];
rdpSettings* settings; rdpSettings* settings;
EmbedWindowEventArgs e; EmbedWindowEventArgs e;
settings = instance->settings; settings = instance->settings;
context = instance->context; context = instance->context;
@ -390,9 +390,9 @@ BOOL wf_post_connect(freerdp* instance)
else else
_snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S:%d", settings->ServerHostname, settings->ServerPort); _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S:%d", settings->ServerHostname, settings->ServerPort);
if (settings->EmbeddedWindow) if (settings->EmbeddedWindow)
settings->Decorations = FALSE; settings->Decorations = FALSE;
if (!settings->Decorations) if (!settings->Decorations)
dwStyle = WS_CHILD | WS_BORDER; dwStyle = WS_CHILD | WS_BORDER;
else else
@ -403,7 +403,7 @@ BOOL wf_post_connect(freerdp* instance)
wfc->hwnd = CreateWindowEx((DWORD) NULL, wfc->wndClassName, lpWindowName, dwStyle, wfc->hwnd = CreateWindowEx((DWORD) NULL, wfc->wndClassName, lpWindowName, dwStyle,
0, 0, 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL); 0, 0, 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL);
SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR) wfc); SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR) wfc);
} }
wf_resize_window(wfc); wf_resize_window(wfc);
@ -413,11 +413,11 @@ BOOL wf_post_connect(freerdp* instance)
BitBlt(wfc->primary->hdc, 0, 0, wfc->width, wfc->height, NULL, 0, 0, BLACKNESS); BitBlt(wfc->primary->hdc, 0, 0, wfc->width, wfc->height, NULL, 0, 0, BLACKNESS);
wfc->drawing = wfc->primary; wfc->drawing = wfc->primary;
EventArgsInit(&e, "wfreerdp"); EventArgsInit(&e, "wfreerdp");
e.embed = FALSE; e.embed = FALSE;
e.handle = (void*) wfc->hwnd; e.handle = (void*) wfc->hwnd;
PubSub_OnEmbedWindow(context->pubSub, context, &e); PubSub_OnEmbedWindow(context->pubSub, context, &e);
ShowWindow(wfc->hwnd, SW_SHOWNORMAL); ShowWindow(wfc->hwnd, SW_SHOWNORMAL);
UpdateWindow(wfc->hwnd); UpdateWindow(wfc->hwnd);
@ -774,8 +774,8 @@ int freerdp_client_focus_out(wfContext* wfc)
int freerdp_client_set_window_size(wfContext* wfc, int width, int height) int freerdp_client_set_window_size(wfContext* wfc, int width, int height)
{ {
fprintf(stderr, "freerdp_client_set_window_size %d, %d", width, height); fprintf(stderr, "freerdp_client_set_window_size %d, %d", width, height);
if ((width != wfc->client_width) || (height != wfc->client_height)) if ((width != wfc->client_width) || (height != wfc->client_height))
{ {
PostThreadMessage(wfc->mainThreadId, WM_SIZE, SIZE_RESTORED, ((UINT) height << 16) | (UINT) width); PostThreadMessage(wfc->mainThreadId, WM_SIZE, SIZE_RESTORED, ((UINT) height << 16) | (UINT) width);
@ -784,19 +784,19 @@ int freerdp_client_set_window_size(wfContext* wfc, int width, int height)
return 0; return 0;
} }
void wf_on_param_change(freerdp* instance, int id) void wf_ParamChangeEventHandler(rdpContext* context, ParamChangeEventArgs* e)
{ {
RECT rect; RECT rect;
HMENU hMenu; HMENU hMenu;
wfContext* wfc = (wfContext*) instance->context; wfContext* wfc = (wfContext*) context;
// specific processing here // specific processing here
switch (id) switch (e->id)
{ {
case FreeRDP_SmartSizing: case FreeRDP_SmartSizing:
fprintf(stderr, "SmartSizing changed.\n"); fprintf(stderr, "SmartSizing changed.\n");
if (!instance->settings->SmartSizing && (wfc->client_width > instance->settings->DesktopWidth || wfc->client_height > instance->settings->DesktopHeight)) if (!context->settings->SmartSizing && (wfc->client_width > context->settings->DesktopWidth || wfc->client_height > context->settings->DesktopHeight))
{ {
GetWindowRect(wfc->hwnd, &rect); GetWindowRect(wfc->hwnd, &rect);
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, MIN(wfc->client_width + wfc->offset_x, rect.right - rect.left), MIN(wfc->client_height + wfc->offset_y, rect.bottom - rect.top), SWP_NOMOVE | SWP_FRAMECHANGED); SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, MIN(wfc->client_width + wfc->offset_x, rect.right - rect.left), MIN(wfc->client_height + wfc->offset_y, rect.bottom - rect.top), SWP_NOMOVE | SWP_FRAMECHANGED);
@ -804,7 +804,7 @@ void wf_on_param_change(freerdp* instance, int id)
} }
hMenu = GetSystemMenu(wfc->hwnd, FALSE); hMenu = GetSystemMenu(wfc->hwnd, FALSE);
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, instance->settings->SmartSizing); CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, context->settings->SmartSizing);
wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height); wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
GetClientRect(wfc->hwnd, &rect); GetClientRect(wfc->hwnd, &rect);
InvalidateRect(wfc->hwnd, &rect, TRUE); InvalidateRect(wfc->hwnd, &rect, TRUE);
@ -1034,6 +1034,8 @@ int wfreerdp_client_new(freerdp* instance, rdpContext* context)
wfc->instance = instance; wfc->instance = instance;
context->channels = freerdp_channels_new(); context->channels = freerdp_channels_new();
PubSub_SubscribeParamChange(context->pubSub, wf_ParamChangeEventHandler);
return 0; return 0;
} }