Merge git://github.com/awakecoding/FreeRDP
Latest updates from master branch (PubSub)
This commit is contained in:
commit
a5c57e1bfb
@ -44,27 +44,53 @@
|
|||||||
|
|
||||||
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
|
int index;
|
||||||
int status;
|
int status;
|
||||||
wfInfo* wfi;
|
HANDLE thread;
|
||||||
|
wfContext* wfc;
|
||||||
|
DWORD dwExitCode;
|
||||||
|
rdpContext* context;
|
||||||
|
rdpSettings* settings;
|
||||||
|
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
|
||||||
|
|
||||||
freerdp_client_global_init();
|
ZeroMemory(&clientEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
|
||||||
|
clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
|
||||||
|
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
|
||||||
|
|
||||||
wfi = freerdp_client_new(__argc, __argv);
|
RdpClientEntry(&clientEntryPoints);
|
||||||
|
|
||||||
status = freerdp_client_start(wfi);
|
context = freerdp_client_context_new(&clientEntryPoints);
|
||||||
|
|
||||||
if (status < 0)
|
settings = context->settings;
|
||||||
|
wfc = (wfContext*) context;
|
||||||
|
|
||||||
|
context->argc = __argc;
|
||||||
|
context->argv = (char**) malloc(sizeof(char*) * __argc);
|
||||||
|
|
||||||
|
for (index = 0; index < context->argc; index++)
|
||||||
|
context->argv[index] = _strdup(__argv[index]);
|
||||||
|
|
||||||
|
status = freerdp_client_parse_command_line(context, context->argc, context->argv);
|
||||||
|
|
||||||
|
status = freerdp_client_command_line_status_print(context->argc, context->argv, settings, status);
|
||||||
|
|
||||||
|
if (status)
|
||||||
{
|
{
|
||||||
MessageBox(GetConsoleWindow(),
|
freerdp_client_context_free(context);
|
||||||
_T("Failed to start wfreerdp.\n\nPlease check the debug output."),
|
return 0;
|
||||||
_T("FreeRDP Error"), MB_ICONSTOP);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WaitForSingleObject(wfi->thread, INFINITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp_client_free(wfi);
|
freerdp_client_start(context);
|
||||||
|
|
||||||
|
thread = freerdp_client_get_thread(context);
|
||||||
|
|
||||||
|
WaitForSingleObject(thread, INFINITE);
|
||||||
|
|
||||||
|
GetExitCodeThread(thread, &dwExitCode);
|
||||||
|
|
||||||
|
freerdp_client_stop(context);
|
||||||
|
|
||||||
|
freerdp_client_context_free(context);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -29,54 +29,54 @@
|
|||||||
|
|
||||||
#include "wf_cliprdr.h"
|
#include "wf_cliprdr.h"
|
||||||
|
|
||||||
void wf_cliprdr_init(wfInfo* wfi, rdpChannels* chanman)
|
void wf_cliprdr_init(wfContext* wfc, rdpChannels* channels)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_cliprdr_uninit(wfInfo* wfi)
|
void wf_cliprdr_uninit(wfContext* wfc)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wf_cliprdr_process_cb_monitor_ready_event(wfInfo* wfi)
|
static void wf_cliprdr_process_cb_monitor_ready_event(wfContext* wfc)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wf_cliprdr_process_cb_data_request_event(wfInfo* wfi, RDP_CB_DATA_REQUEST_EVENT* event)
|
static void wf_cliprdr_process_cb_data_request_event(wfContext* wfc, RDP_CB_DATA_REQUEST_EVENT* event)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wf_cliprdr_process_cb_format_list_event(wfInfo* wfi, RDP_CB_FORMAT_LIST_EVENT* event)
|
static void wf_cliprdr_process_cb_format_list_event(wfContext* wfc, RDP_CB_FORMAT_LIST_EVENT* event)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wf_cliprdr_process_cb_data_response_event(wfInfo* wfi, RDP_CB_DATA_RESPONSE_EVENT* event)
|
static void wf_cliprdr_process_cb_data_response_event(wfContext* wfc, RDP_CB_DATA_RESPONSE_EVENT* event)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_process_cliprdr_event(wfInfo* wfi, wMessage* event)
|
void wf_process_cliprdr_event(wfContext* wfc, wMessage* event)
|
||||||
{
|
{
|
||||||
switch (GetMessageType(event->id))
|
switch (GetMessageType(event->id))
|
||||||
{
|
{
|
||||||
case CliprdrChannel_MonitorReady:
|
case CliprdrChannel_MonitorReady:
|
||||||
wf_cliprdr_process_cb_monitor_ready_event(wfi);
|
wf_cliprdr_process_cb_monitor_ready_event(wfc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CliprdrChannel_FormatList:
|
case CliprdrChannel_FormatList:
|
||||||
wf_cliprdr_process_cb_format_list_event(wfi, (RDP_CB_FORMAT_LIST_EVENT*) event);
|
wf_cliprdr_process_cb_format_list_event(wfc, (RDP_CB_FORMAT_LIST_EVENT*) event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CliprdrChannel_DataRequest:
|
case CliprdrChannel_DataRequest:
|
||||||
wf_cliprdr_process_cb_data_request_event(wfi, (RDP_CB_DATA_REQUEST_EVENT*) event);
|
wf_cliprdr_process_cb_data_request_event(wfc, (RDP_CB_DATA_REQUEST_EVENT*) event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CliprdrChannel_DataResponse:
|
case CliprdrChannel_DataResponse:
|
||||||
wf_cliprdr_process_cb_data_response_event(wfi, (RDP_CB_DATA_RESPONSE_EVENT*) event);
|
wf_cliprdr_process_cb_data_response_event(wfc, (RDP_CB_DATA_RESPONSE_EVENT*) event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -84,27 +84,27 @@ void wf_process_cliprdr_event(wfInfo* wfi, wMessage* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL wf_cliprdr_process_selection_notify(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
BOOL wf_cliprdr_process_selection_notify(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL wf_cliprdr_process_selection_request(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
BOOL wf_cliprdr_process_selection_request(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL wf_cliprdr_process_selection_clear(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
BOOL wf_cliprdr_process_selection_clear(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL wf_cliprdr_process_property_notify(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
BOOL wf_cliprdr_process_property_notify(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_cliprdr_check_owner(wfInfo* wfi)
|
void wf_cliprdr_check_owner(wfContext* wfc)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
#include "wf_interface.h"
|
#include "wf_interface.h"
|
||||||
|
|
||||||
void wf_cliprdr_init(wfInfo* wfi, rdpChannels* chanman);
|
void wf_cliprdr_init(wfContext* wfc, rdpChannels* channels);
|
||||||
void wf_cliprdr_uninit(wfInfo* wfi);
|
void wf_cliprdr_uninit(wfContext* wfc);
|
||||||
void wf_process_cliprdr_event(wfInfo* wfi, wMessage* event);
|
void wf_process_cliprdr_event(wfContext* wfc, wMessage* event);
|
||||||
BOOL wf_cliprdr_process_selection_notify(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
BOOL wf_cliprdr_process_selection_notify(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL wf_cliprdr_process_selection_request(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
BOOL wf_cliprdr_process_selection_request(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL wf_cliprdr_process_selection_clear(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
BOOL wf_cliprdr_process_selection_clear(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL wf_cliprdr_process_property_notify(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
BOOL wf_cliprdr_process_property_notify(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||||
void wf_cliprdr_check_owner(wfInfo* wfi);
|
void wf_cliprdr_check_owner(wfContext* wfc);
|
||||||
|
|
||||||
#endif /* __WF_CLIPRDR_H */
|
#endif /* __WF_CLIPRDR_H */
|
||||||
|
@ -37,12 +37,12 @@ static HWND g_focus_hWnd;
|
|||||||
#define X_POS(lParam) (lParam & 0xFFFF)
|
#define X_POS(lParam) (lParam & 0xFFFF)
|
||||||
#define Y_POS(lParam) ((lParam >> 16) & 0xFFFF)
|
#define Y_POS(lParam) ((lParam >> 16) & 0xFFFF)
|
||||||
|
|
||||||
BOOL wf_scale_blt(wfInfo* wfi, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop);
|
BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop);
|
||||||
void wf_scale_mouse_event(wfInfo* wfi, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
void wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||||
|
|
||||||
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
wfInfo* wfi;
|
wfContext* wfc;
|
||||||
DWORD rdp_scancode;
|
DWORD rdp_scancode;
|
||||||
rdpInput* input;
|
rdpInput* input;
|
||||||
PKBDLLHOOKSTRUCT p;
|
PKBDLLHOOKSTRUCT p;
|
||||||
@ -57,26 +57,26 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
wfi = (wfInfo*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
|
wfc = (wfContext*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
|
||||||
p = (PKBDLLHOOKSTRUCT) lParam;
|
p = (PKBDLLHOOKSTRUCT) lParam;
|
||||||
|
|
||||||
if (!wfi || !p)
|
if (!wfc || !p)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
input = wfi->instance->input;
|
input = wfc->instance->input;
|
||||||
rdp_scancode = MAKE_RDP_SCANCODE((BYTE) p->scanCode, p->flags & LLKHF_EXTENDED);
|
rdp_scancode = MAKE_RDP_SCANCODE((BYTE) p->scanCode, p->flags & LLKHF_EXTENDED);
|
||||||
|
|
||||||
DEBUG_KBD("keydown %d scanCode %04X flags %02X vkCode %02X",
|
DEBUG_KBD("keydown %d scanCode %04X flags %02X vkCode %02X",
|
||||||
(wParam == WM_KEYDOWN), (BYTE) p->scanCode, p->flags, p->vkCode);
|
(wParam == WM_KEYDOWN), (BYTE) p->scanCode, p->flags, p->vkCode);
|
||||||
|
|
||||||
if (wfi->fs_toggle &&
|
if (wfc->fs_toggle &&
|
||||||
((p->vkCode == VK_RETURN) || (p->vkCode == VK_CANCEL)) &&
|
((p->vkCode == VK_RETURN) || (p->vkCode == VK_CANCEL)) &&
|
||||||
(GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
|
(GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
|
||||||
(GetAsyncKeyState(VK_MENU) & 0x8000)) /* could also use flags & LLKHF_ALTDOWN */
|
(GetAsyncKeyState(VK_MENU) & 0x8000)) /* could also use flags & LLKHF_ALTDOWN */
|
||||||
{
|
{
|
||||||
if (wParam == WM_KEYDOWN)
|
if (wParam == WM_KEYDOWN)
|
||||||
{
|
{
|
||||||
wf_toggle_fullscreen(wfi);
|
wf_toggle_fullscreen(wfc);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,14 +126,14 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wf_event_process_WM_MOUSEWHEEL(wfInfo* wfi, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
static int wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
int flags;
|
int flags;
|
||||||
rdpInput* input;
|
rdpInput* input;
|
||||||
|
|
||||||
DefWindowProc(hWnd, Msg, wParam, lParam);
|
DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||||
input = wfi->instance->input;
|
input = wfc->instance->input;
|
||||||
delta = ((signed short) HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
|
delta = ((signed short) HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
|
||||||
|
|
||||||
if (delta > 0)
|
if (delta > 0)
|
||||||
@ -150,11 +150,12 @@ static int wf_event_process_WM_MOUSEWHEEL(wfInfo* wfi, HWND hWnd, UINT Msg, WPAR
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_sizing(wfInfo* wfi, WPARAM wParam, LPARAM lParam)
|
void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// Holding the CTRL key down while resizing the window will force the desktop aspect ratio.
|
// Holding the CTRL key down while resizing the window will force the desktop aspect ratio.
|
||||||
LPRECT rect;
|
LPRECT rect;
|
||||||
if (wfi->instance->settings->SmartSizing && (GetAsyncKeyState(VK_CONTROL) & 0x8000))
|
|
||||||
|
if (wfc->instance->settings->SmartSizing && (GetAsyncKeyState(VK_CONTROL) & 0x8000))
|
||||||
{
|
{
|
||||||
rect = (LPRECT) wParam;
|
rect = (LPRECT) wParam;
|
||||||
|
|
||||||
@ -164,20 +165,20 @@ void wf_sizing(wfInfo* wfi, WPARAM wParam, LPARAM lParam)
|
|||||||
case WMSZ_RIGHT:
|
case WMSZ_RIGHT:
|
||||||
case WMSZ_BOTTOMRIGHT:
|
case WMSZ_BOTTOMRIGHT:
|
||||||
// Adjust height
|
// Adjust height
|
||||||
rect->bottom = rect->top + wfi->height * (rect->right - rect->left) / wfi->instance->settings->DesktopWidth;
|
rect->bottom = rect->top + wfc->height * (rect->right - rect->left) / wfc->instance->settings->DesktopWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WMSZ_TOP:
|
case WMSZ_TOP:
|
||||||
case WMSZ_BOTTOM:
|
case WMSZ_BOTTOM:
|
||||||
case WMSZ_TOPRIGHT:
|
case WMSZ_TOPRIGHT:
|
||||||
// Adjust width
|
// Adjust width
|
||||||
rect->right = rect->left + wfi->width * (rect->bottom - rect->top) / wfi->instance->settings->DesktopHeight;
|
rect->right = rect->left + wfc->width * (rect->bottom - rect->top) / wfc->instance->settings->DesktopHeight;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WMSZ_BOTTOMLEFT:
|
case WMSZ_BOTTOMLEFT:
|
||||||
case WMSZ_TOPLEFT:
|
case WMSZ_TOPLEFT:
|
||||||
// adjust width
|
// adjust width
|
||||||
rect->left = rect->right - (wfi->width * (rect->bottom - rect->top) / wfi->instance->settings->DesktopHeight);
|
rect->left = rect->right - (wfc->width * (rect->bottom - rect->top) / wfc->instance->settings->DesktopHeight);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -189,38 +190,38 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
LONG ptr;
|
LONG ptr;
|
||||||
wfInfo* wfi;
|
wfContext* wfc;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
rdpInput* input;
|
rdpInput* input;
|
||||||
BOOL processed;
|
BOOL processed;
|
||||||
|
RECT windowRect;
|
||||||
RECT windowRect, clientRect;
|
RECT clientRect;
|
||||||
MINMAXINFO *minmax;
|
MINMAXINFO* minmax;
|
||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
|
|
||||||
processed = TRUE;
|
processed = TRUE;
|
||||||
ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||||
wfi = (wfInfo*) ptr;
|
wfc = (wfContext*) ptr;
|
||||||
|
|
||||||
if (wfi != NULL)
|
if (wfc != NULL)
|
||||||
{
|
{
|
||||||
input = wfi->instance->input;
|
input = wfc->instance->input;
|
||||||
|
|
||||||
switch (Msg)
|
switch (Msg)
|
||||||
{
|
{
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
if (!wfi->disablewindowtracking)
|
if (!wfc->disablewindowtracking)
|
||||||
{
|
{
|
||||||
int x = (int)(short) LOWORD(lParam);
|
int x = (int)(short) LOWORD(lParam);
|
||||||
int y = (int)(short) HIWORD(lParam);
|
int y = (int)(short) HIWORD(lParam);
|
||||||
((wfContext*) wfi->instance->context)->wfi->client_x = x;
|
wfc->client_x = x;
|
||||||
((wfContext*) wfi->instance->context)->wfi->client_y = y;
|
wfc->client_y = y;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
if (wfi->instance->settings->SmartSizing)
|
if (wfc->instance->settings->SmartSizing)
|
||||||
{
|
{
|
||||||
processed = FALSE;
|
processed = FALSE;
|
||||||
}
|
}
|
||||||
@ -229,41 +230,42 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
// Set maximum window size for resizing
|
// Set maximum window size for resizing
|
||||||
|
|
||||||
minmax = (MINMAXINFO*) lParam;
|
minmax = (MINMAXINFO*) lParam;
|
||||||
wf_update_canvas_diff(wfi);
|
wf_update_canvas_diff(wfc);
|
||||||
if (!wfi->fullscreen)
|
|
||||||
|
if (!wfc->fullscreen)
|
||||||
{
|
{
|
||||||
// add window decoration
|
// add window decoration
|
||||||
minmax->ptMaxTrackSize.x = wfi->width + wfi->diff.x;
|
minmax->ptMaxTrackSize.x = wfc->width + wfc->diff.x;
|
||||||
minmax->ptMaxTrackSize.y = wfi->height + wfi->diff.y;
|
minmax->ptMaxTrackSize.y = wfc->height + wfc->diff.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZING:
|
case WM_SIZING:
|
||||||
wf_sizing(wfi, lParam, wParam);
|
wf_sizing(wfc, lParam, wParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
GetWindowRect(wfi->hwnd, &windowRect);
|
GetWindowRect(wfc->hwnd, &windowRect);
|
||||||
|
|
||||||
if (!wfi->fullscreen)
|
if (!wfc->fullscreen)
|
||||||
{
|
{
|
||||||
wfi->client_width = LOWORD(lParam);
|
wfc->client_width = LOWORD(lParam);
|
||||||
wfi->client_height = HIWORD(lParam);
|
wfc->client_height = HIWORD(lParam);
|
||||||
wfi->client_x = windowRect.left;
|
wfc->client_x = windowRect.left;
|
||||||
wfi->client_y = windowRect.top;
|
wfc->client_y = windowRect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
wf_size_scrollbars(wfi, LOWORD(lParam), HIWORD(lParam));
|
wf_size_scrollbars(wfc, LOWORD(lParam), HIWORD(lParam));
|
||||||
|
|
||||||
// Workaround: when the window is maximized, the call to "ShowScrollBars" returns TRUE but has no effect.
|
// Workaround: when the window is maximized, the call to "ShowScrollBars" returns TRUE but has no effect.
|
||||||
if (wParam == SIZE_MAXIMIZED && !wfi->fullscreen)
|
if (wParam == SIZE_MAXIMIZED && !wfc->fullscreen)
|
||||||
SetWindowPos(wfi->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_FRAMECHANGED);
|
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_EXITSIZEMOVE:
|
case WM_EXITSIZEMOVE:
|
||||||
wf_size_scrollbars(wfi, wfi->client_width, wfi->client_height);
|
wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
@ -278,38 +280,38 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
w = ps.rcPaint.right - ps.rcPaint.left + 1;
|
w = ps.rcPaint.right - ps.rcPaint.left + 1;
|
||||||
h = ps.rcPaint.bottom - ps.rcPaint.top + 1;
|
h = ps.rcPaint.bottom - ps.rcPaint.top + 1;
|
||||||
|
|
||||||
wf_scale_blt(wfi, hdc, x, y, w, h, wfi->primary->hdc, x - wfi->offset_x + wfi->xCurrentScroll, y - wfi->offset_y + wfi->yCurrentScroll, SRCCOPY);
|
wf_scale_blt(wfc, hdc, x, y, w, h, wfc->primary->hdc, x - wfc->offset_x + wfc->xCurrentScroll, y - wfc->offset_y + wfc->yCurrentScroll, SRCCOPY);
|
||||||
|
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
wf_scale_mouse_event(wfi, input,PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, X_POS(lParam) - wfi->offset_x, Y_POS(lParam) - wfi->offset_y);
|
wf_scale_mouse_event(wfc, input,PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
wf_scale_mouse_event(wfi, input, PTR_FLAGS_BUTTON1, X_POS(lParam) - wfi->offset_x, Y_POS(lParam) - wfi->offset_y);
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
wf_scale_mouse_event(wfi, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, X_POS(lParam) - wfi->offset_x, Y_POS(lParam) - wfi->offset_y);
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
wf_scale_mouse_event(wfi, input, PTR_FLAGS_BUTTON2, X_POS(lParam) - wfi->offset_x, Y_POS(lParam) - wfi->offset_y);
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
wf_scale_mouse_event(wfi, input, PTR_FLAGS_MOVE, X_POS(lParam) - wfi->offset_x, Y_POS(lParam) - wfi->offset_y);
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_MOVE, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
wf_event_process_WM_MOUSEWHEEL(wfi, hWnd, Msg, wParam, lParam);
|
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
if (LOWORD(lParam) == HTCLIENT)
|
if (LOWORD(lParam) == HTCLIENT)
|
||||||
SetCursor(wfi->cursor);
|
SetCursor(wfc->cursor);
|
||||||
else
|
else
|
||||||
DefWindowProc(hWnd, Msg, wParam, lParam);
|
DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||||
break;
|
break;
|
||||||
@ -324,22 +326,22 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
{
|
{
|
||||||
// User clicked the scroll bar shaft left of the scroll box.
|
// User clicked the scroll bar shaft left of the scroll box.
|
||||||
case SB_PAGEUP:
|
case SB_PAGEUP:
|
||||||
xNewPos = wfi->xCurrentScroll - 50;
|
xNewPos = wfc->xCurrentScroll - 50;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User clicked the scroll bar shaft right of the scroll box.
|
// User clicked the scroll bar shaft right of the scroll box.
|
||||||
case SB_PAGEDOWN:
|
case SB_PAGEDOWN:
|
||||||
xNewPos = wfi->xCurrentScroll + 50;
|
xNewPos = wfc->xCurrentScroll + 50;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User clicked the left arrow.
|
// User clicked the left arrow.
|
||||||
case SB_LINEUP:
|
case SB_LINEUP:
|
||||||
xNewPos = wfi->xCurrentScroll - 5;
|
xNewPos = wfc->xCurrentScroll - 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User clicked the right arrow.
|
// User clicked the right arrow.
|
||||||
case SB_LINEDOWN:
|
case SB_LINEDOWN:
|
||||||
xNewPos = wfi->xCurrentScroll + 5;
|
xNewPos = wfc->xCurrentScroll + 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User dragged the scroll box.
|
// User dragged the scroll box.
|
||||||
@ -352,37 +354,37 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
xNewPos = wfi->xCurrentScroll;
|
xNewPos = wfc->xCurrentScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
// New position must be between 0 and the screen width.
|
// New position must be between 0 and the screen width.
|
||||||
xNewPos = MAX(0, xNewPos);
|
xNewPos = MAX(0, xNewPos);
|
||||||
xNewPos = MIN(wfi->xMaxScroll, xNewPos);
|
xNewPos = MIN(wfc->xMaxScroll, xNewPos);
|
||||||
|
|
||||||
// If the current position does not change, do not scroll.
|
// If the current position does not change, do not scroll.
|
||||||
if (xNewPos == wfi->xCurrentScroll)
|
if (xNewPos == wfc->xCurrentScroll)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Determine the amount scrolled (in pixels).
|
// Determine the amount scrolled (in pixels).
|
||||||
xDelta = xNewPos - wfi->xCurrentScroll;
|
xDelta = xNewPos - wfc->xCurrentScroll;
|
||||||
|
|
||||||
// Reset the current scroll position.
|
// Reset the current scroll position.
|
||||||
wfi->xCurrentScroll = xNewPos;
|
wfc->xCurrentScroll = xNewPos;
|
||||||
|
|
||||||
// Scroll the window. (The system repaints most of the
|
// Scroll the window. (The system repaints most of the
|
||||||
// client area when ScrollWindowEx is called; however, it is
|
// client area when ScrollWindowEx is called; however, it is
|
||||||
// necessary to call UpdateWindow in order to repaint the
|
// necessary to call UpdateWindow in order to repaint the
|
||||||
// rectangle of pixels that were invalidated.)
|
// rectangle of pixels that were invalidated.)
|
||||||
ScrollWindowEx(wfi->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
|
ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
|
||||||
(CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,
|
(CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,
|
||||||
SW_INVALIDATE);
|
SW_INVALIDATE);
|
||||||
UpdateWindow(wfi->hwnd);
|
UpdateWindow(wfc->hwnd);
|
||||||
|
|
||||||
// Reset the scroll bar.
|
// Reset the scroll bar.
|
||||||
si.cbSize = sizeof(si);
|
si.cbSize = sizeof(si);
|
||||||
si.fMask = SIF_POS;
|
si.fMask = SIF_POS;
|
||||||
si.nPos = wfi->xCurrentScroll;
|
si.nPos = wfc->xCurrentScroll;
|
||||||
SetScrollInfo(wfi->hwnd, SB_HORZ, &si, TRUE);
|
SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -396,22 +398,22 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
{
|
{
|
||||||
// User clicked the scroll bar shaft above the scroll box.
|
// User clicked the scroll bar shaft above the scroll box.
|
||||||
case SB_PAGEUP:
|
case SB_PAGEUP:
|
||||||
yNewPos = wfi->yCurrentScroll - 50;
|
yNewPos = wfc->yCurrentScroll - 50;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User clicked the scroll bar shaft below the scroll box.
|
// User clicked the scroll bar shaft below the scroll box.
|
||||||
case SB_PAGEDOWN:
|
case SB_PAGEDOWN:
|
||||||
yNewPos = wfi->yCurrentScroll + 50;
|
yNewPos = wfc->yCurrentScroll + 50;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User clicked the top arrow.
|
// User clicked the top arrow.
|
||||||
case SB_LINEUP:
|
case SB_LINEUP:
|
||||||
yNewPos = wfi->yCurrentScroll - 5;
|
yNewPos = wfc->yCurrentScroll - 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User clicked the bottom arrow.
|
// User clicked the bottom arrow.
|
||||||
case SB_LINEDOWN:
|
case SB_LINEDOWN:
|
||||||
yNewPos = wfi->yCurrentScroll + 5;
|
yNewPos = wfc->yCurrentScroll + 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// User dragged the scroll box.
|
// User dragged the scroll box.
|
||||||
@ -425,37 +427,37 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
yNewPos = wfi->yCurrentScroll;
|
yNewPos = wfc->yCurrentScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
// New position must be between 0 and the screen height.
|
// New position must be between 0 and the screen height.
|
||||||
yNewPos = MAX(0, yNewPos);
|
yNewPos = MAX(0, yNewPos);
|
||||||
yNewPos = MIN(wfi->yMaxScroll, yNewPos);
|
yNewPos = MIN(wfc->yMaxScroll, yNewPos);
|
||||||
|
|
||||||
// If the current position does not change, do not scroll.
|
// If the current position does not change, do not scroll.
|
||||||
if (yNewPos == wfi->yCurrentScroll)
|
if (yNewPos == wfc->yCurrentScroll)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Determine the amount scrolled (in pixels).
|
// Determine the amount scrolled (in pixels).
|
||||||
yDelta = yNewPos - wfi->yCurrentScroll;
|
yDelta = yNewPos - wfc->yCurrentScroll;
|
||||||
|
|
||||||
// Reset the current scroll position.
|
// Reset the current scroll position.
|
||||||
wfi->yCurrentScroll = yNewPos;
|
wfc->yCurrentScroll = yNewPos;
|
||||||
|
|
||||||
// Scroll the window. (The system repaints most of the
|
// Scroll the window. (The system repaints most of the
|
||||||
// client area when ScrollWindowEx is called; however, it is
|
// client area when ScrollWindowEx is called; however, it is
|
||||||
// necessary to call UpdateWindow in order to repaint the
|
// necessary to call UpdateWindow in order to repaint the
|
||||||
// rectangle of pixels that were invalidated.)
|
// rectangle of pixels that were invalidated.)
|
||||||
ScrollWindowEx(wfi->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
|
ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
|
||||||
(CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,
|
(CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,
|
||||||
SW_INVALIDATE);
|
SW_INVALIDATE);
|
||||||
UpdateWindow(wfi->hwnd);
|
UpdateWindow(wfc->hwnd);
|
||||||
|
|
||||||
// Reset the scroll bar.
|
// Reset the scroll bar.
|
||||||
si.cbSize = sizeof(si);
|
si.cbSize = sizeof(si);
|
||||||
si.fMask = SIF_POS;
|
si.fMask = SIF_POS;
|
||||||
si.nPos = wfi->yCurrentScroll;
|
si.nPos = wfc->yCurrentScroll;
|
||||||
SetScrollInfo(wfi->hwnd, SB_VERT, &si, TRUE);
|
SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -463,9 +465,9 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
{
|
{
|
||||||
if (wParam == SYSCOMMAND_ID_SMARTSIZING)
|
if (wParam == SYSCOMMAND_ID_SMARTSIZING)
|
||||||
{
|
{
|
||||||
HMENU hMenu = GetSystemMenu(wfi->hwnd, FALSE);
|
HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
|
||||||
freerdp_set_param_bool(wfi->instance->settings, FreeRDP_SmartSizing, !wfi->instance->settings->SmartSizing);
|
freerdp_set_param_bool(wfc->instance->settings, FreeRDP_SmartSizing, !wfc->instance->settings->SmartSizing);
|
||||||
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, wfi->instance->settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);
|
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, wfc->instance->settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -496,7 +498,7 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
if (LOWORD(lParam) == HTCLIENT)
|
if (LOWORD(lParam) == HTCLIENT)
|
||||||
SetCursor(wfi->hDefaultCursor);
|
SetCursor(wfc->hDefaultCursor);
|
||||||
else
|
else
|
||||||
DefWindowProc(hWnd, Msg, wParam, lParam);
|
DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||||
break;
|
break;
|
||||||
@ -507,7 +509,7 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
if (g_focus_hWnd == hWnd && wfi && !wfi->fullscreen)
|
if (g_focus_hWnd == hWnd && wfc && !wfc->fullscreen)
|
||||||
{
|
{
|
||||||
DEBUG_KBD("loosing focus %X", hWnd);
|
DEBUG_KBD("loosing focus %X", hWnd);
|
||||||
g_focus_hWnd = NULL;
|
g_focus_hWnd = NULL;
|
||||||
@ -535,20 +537,20 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL wf_scale_blt(wfInfo* wfi, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop)
|
BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop)
|
||||||
{
|
{
|
||||||
int ww, wh, dw, dh;
|
int ww, wh, dw, dh;
|
||||||
|
|
||||||
if (!wfi->client_width)
|
if (!wfc->client_width)
|
||||||
wfi->client_width = wfi->width;
|
wfc->client_width = wfc->width;
|
||||||
|
|
||||||
if (!wfi->client_height)
|
if (!wfc->client_height)
|
||||||
wfi->client_height = wfi->height;
|
wfc->client_height = wfc->height;
|
||||||
|
|
||||||
ww = wfi->client_width;
|
ww = wfc->client_width;
|
||||||
wh = wfi->client_height;
|
wh = wfc->client_height;
|
||||||
dw = wfi->instance->settings->DesktopWidth;
|
dw = wfc->instance->settings->DesktopWidth;
|
||||||
dh = wfi->instance->settings->DesktopHeight;
|
dh = wfc->instance->settings->DesktopHeight;
|
||||||
|
|
||||||
if (!ww)
|
if (!ww)
|
||||||
ww = dw;
|
ww = dw;
|
||||||
@ -556,38 +558,38 @@ BOOL wf_scale_blt(wfInfo* wfi, HDC hdc, int x, int y, int w, int h, HDC hdcSrc,
|
|||||||
if (!wh)
|
if (!wh)
|
||||||
wh = dh;
|
wh = dh;
|
||||||
|
|
||||||
if (wfi->fullscreen || !wfi->instance->settings->SmartSizing || (ww == dw && wh == dh))
|
if (wfc->fullscreen || !wfc->instance->settings->SmartSizing || (ww == dw && wh == dh))
|
||||||
{
|
{
|
||||||
return BitBlt(hdc, x, y, w, h, wfi->primary->hdc, x1, y1, SRCCOPY);
|
return BitBlt(hdc, x, y, w, h, wfc->primary->hdc, x1, y1, SRCCOPY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetStretchBltMode(hdc, HALFTONE);
|
SetStretchBltMode(hdc, HALFTONE);
|
||||||
SetBrushOrgEx(hdc, 0, 0, NULL);
|
SetBrushOrgEx(hdc, 0, 0, NULL);
|
||||||
|
|
||||||
return StretchBlt(hdc, 0, 0, ww, wh, wfi->primary->hdc, 0, 0, dw, dh, SRCCOPY);
|
return StretchBlt(hdc, 0, 0, ww, wh, wfc->primary->hdc, 0, 0, dw, dh, SRCCOPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_scale_mouse_event(wfInfo* wfi, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
void wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||||
{
|
{
|
||||||
int ww, wh, dw, dh;
|
int ww, wh, dw, dh;
|
||||||
|
|
||||||
if (!wfi->client_width)
|
if (!wfc->client_width)
|
||||||
wfi->client_width = wfi->width;
|
wfc->client_width = wfc->width;
|
||||||
|
|
||||||
if (!wfi->client_height)
|
if (!wfc->client_height)
|
||||||
wfi->client_height = wfi->height;
|
wfc->client_height = wfc->height;
|
||||||
|
|
||||||
ww = wfi->client_width;
|
ww = wfc->client_width;
|
||||||
wh = wfi->client_height;
|
wh = wfc->client_height;
|
||||||
dw = wfi->instance->settings->DesktopWidth;
|
dw = wfc->instance->settings->DesktopWidth;
|
||||||
dh = wfi->instance->settings->DesktopHeight;
|
dh = wfc->instance->settings->DesktopHeight;
|
||||||
|
|
||||||
if (!wfi->instance->settings->SmartSizing || (ww == dw) && (wh == dh))
|
if (!wfc->instance->settings->SmartSizing || (ww == dw) && (wh == dh))
|
||||||
input->MouseEvent(input, flags, x + wfi->xCurrentScroll, y + wfi->yCurrentScroll);
|
input->MouseEvent(input, flags, x + wfc->xCurrentScroll, y + wfc->yCurrentScroll);
|
||||||
else
|
else
|
||||||
input->MouseEvent(input, flags, x * dw / ww + wfi->xCurrentScroll, y * dh / wh + wfi->yCurrentScroll);
|
input->MouseEvent(input, flags, x * dw / ww + wfc->xCurrentScroll, y * dh / wh + wfc->yCurrentScroll);
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,10 @@ BOOL wf_set_rop2(HDC hdc, int rop2)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfBitmap* wf_glyph_new(wfInfo* wfi, GLYPH_DATA* glyph)
|
wfBitmap* wf_glyph_new(wfContext* wfc, GLYPH_DATA* glyph)
|
||||||
{
|
{
|
||||||
wfBitmap* glyph_bmp;
|
wfBitmap* glyph_bmp;
|
||||||
glyph_bmp = wf_image_new(wfi, glyph->cx, glyph->cy, 1, glyph->aj);
|
glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, 1, glyph->aj);
|
||||||
return glyph_bmp;
|
return glyph_bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ void wf_glyph_free(wfBitmap* glyph)
|
|||||||
wf_image_free(glyph);
|
wf_image_free(glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* wf_glyph_convert(wfInfo* wfi, int width, int height, BYTE* data)
|
BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data)
|
||||||
{
|
{
|
||||||
int indexx;
|
int indexx;
|
||||||
int indexy;
|
int indexy;
|
||||||
@ -115,7 +115,7 @@ BYTE* wf_glyph_convert(wfInfo* wfi, int width, int height, BYTE* data)
|
|||||||
return cdata;
|
return cdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
HBRUSH wf_create_brush(wfInfo * wfi, rdpBrush* brush, UINT32 color, int bpp)
|
HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, int bpp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
HBRUSH br;
|
HBRUSH br;
|
||||||
@ -135,7 +135,7 @@ HBRUSH wf_create_brush(wfInfo * wfi, rdpBrush* brush, UINT32 color, int bpp)
|
|||||||
{
|
{
|
||||||
if (brush->bpp > 1)
|
if (brush->bpp > 1)
|
||||||
{
|
{
|
||||||
pattern = wf_create_dib(wfi, 8, 8, bpp, brush->data, NULL);
|
pattern = wf_create_dib(wfc, 8, 8, bpp, brush->data, NULL);
|
||||||
lbr.lbHatch = (ULONG_PTR) pattern;
|
lbr.lbHatch = (ULONG_PTR) pattern;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -143,7 +143,7 @@ HBRUSH wf_create_brush(wfInfo * wfi, rdpBrush* brush, UINT32 color, int bpp)
|
|||||||
for (i = 0; i != 8; i++)
|
for (i = 0; i != 8; i++)
|
||||||
ipattern[7 - i] = brush->data[i];
|
ipattern[7 - i] = brush->data[i];
|
||||||
|
|
||||||
cdata = wf_glyph_convert(wfi, 8, 8, ipattern);
|
cdata = wf_glyph_convert(wfc, 8, 8, ipattern);
|
||||||
pattern = CreateBitmap(8, 8, 1, 1, cdata);
|
pattern = CreateBitmap(8, 8, 1, 1, cdata);
|
||||||
lbr.lbHatch = (ULONG_PTR) pattern;
|
lbr.lbHatch = (ULONG_PTR) pattern;
|
||||||
free(cdata);
|
free(cdata);
|
||||||
@ -159,7 +159,7 @@ HBRUSH wf_create_brush(wfInfo * wfi, rdpBrush* brush, UINT32 color, int bpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
br = CreateBrushIndirect(&lbr);
|
br = CreateBrushIndirect(&lbr);
|
||||||
SetBrushOrgEx(wfi->drawing->hdc, brush->x, brush->y, NULL);
|
SetBrushOrgEx(wfc->drawing->hdc, brush->x, brush->y, NULL);
|
||||||
|
|
||||||
if (pattern != NULL)
|
if (pattern != NULL)
|
||||||
DeleteObject(pattern);
|
DeleteObject(pattern);
|
||||||
@ -167,20 +167,20 @@ HBRUSH wf_create_brush(wfInfo * wfi, rdpBrush* brush, UINT32 color, int bpp)
|
|||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_scale_rect(wfInfo* wfi, RECT* source)
|
void wf_scale_rect(wfContext* wfc, RECT* source)
|
||||||
{
|
{
|
||||||
int ww, wh, dw, dh;
|
int ww, wh, dw, dh;
|
||||||
|
|
||||||
if (!wfi->client_width)
|
if (!wfc->client_width)
|
||||||
wfi->client_width = wfi->width;
|
wfc->client_width = wfc->width;
|
||||||
|
|
||||||
if (!wfi->client_height)
|
if (!wfc->client_height)
|
||||||
wfi->client_height = wfi->height;
|
wfc->client_height = wfc->height;
|
||||||
|
|
||||||
ww = wfi->client_width;
|
ww = wfc->client_width;
|
||||||
wh = wfi->client_height;
|
wh = wfc->client_height;
|
||||||
dw = wfi->instance->settings->DesktopWidth;
|
dw = wfc->instance->settings->DesktopWidth;
|
||||||
dh = wfi->instance->settings->DesktopHeight;
|
dh = wfc->instance->settings->DesktopHeight;
|
||||||
|
|
||||||
if (!ww)
|
if (!ww)
|
||||||
ww = dw;
|
ww = dw;
|
||||||
@ -188,7 +188,7 @@ void wf_scale_rect(wfInfo* wfi, RECT* source)
|
|||||||
if (!wh)
|
if (!wh)
|
||||||
wh = dh;
|
wh = dh;
|
||||||
|
|
||||||
if (wfi->instance->settings->SmartSizing && (ww != dw || wh != dh))
|
if (wfc->instance->settings->SmartSizing && (ww != dw || wh != dh))
|
||||||
{
|
{
|
||||||
source->bottom = source->bottom * wh / dh + 20;
|
source->bottom = source->bottom * wh / dh + 20;
|
||||||
source->top = source->top * wh / dh - 20;
|
source->top = source->top * wh / dh - 20;
|
||||||
@ -196,197 +196,194 @@ void wf_scale_rect(wfInfo* wfi, RECT* source)
|
|||||||
source->right = source->right * ww / dw + 20;
|
source->right = source->right * ww / dw + 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
source->bottom -= wfi->yCurrentScroll;
|
source->bottom -= wfc->yCurrentScroll;
|
||||||
source->top -= wfi->yCurrentScroll;
|
source->top -= wfc->yCurrentScroll;
|
||||||
source->left -= wfi->xCurrentScroll;
|
source->left -= wfc->xCurrentScroll;
|
||||||
source->right -= wfi->xCurrentScroll;
|
source->right -= wfc->xCurrentScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_invalidate_region(wfInfo* wfi, int x, int y, int width, int height)
|
void wf_invalidate_region(wfContext* wfc, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
wfi->update_rect.left = x + wfi->offset_x;
|
wfc->update_rect.left = x + wfc->offset_x;
|
||||||
wfi->update_rect.top = y + wfi->offset_y;
|
wfc->update_rect.top = y + wfc->offset_y;
|
||||||
wfi->update_rect.right = wfi->update_rect.left + width;
|
wfc->update_rect.right = wfc->update_rect.left + width;
|
||||||
wfi->update_rect.bottom = wfi->update_rect.top + height;
|
wfc->update_rect.bottom = wfc->update_rect.top + height;
|
||||||
|
|
||||||
wf_scale_rect(wfi, &(wfi->update_rect));
|
wf_scale_rect(wfc, &(wfc->update_rect));
|
||||||
InvalidateRect(wfi->hwnd, &(wfi->update_rect), FALSE);
|
InvalidateRect(wfc->hwnd, &(wfc->update_rect), FALSE);
|
||||||
|
|
||||||
rect.left = x;
|
rect.left = x;
|
||||||
rect.right = width;
|
rect.right = width;
|
||||||
rect.top = y;
|
rect.top = y;
|
||||||
rect.bottom = height;
|
rect.bottom = height;
|
||||||
wf_scale_rect(wfi, &rect);
|
wf_scale_rect(wfc, &rect);
|
||||||
gdi_InvalidateRegion(wfi->hdc, rect.left, rect.top, rect.right, rect.bottom);
|
gdi_InvalidateRegion(wfc->hdc, rect.left, rect.top, rect.right, rect.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_update_offset(wfInfo* wfi)
|
void wf_update_offset(wfContext* wfc)
|
||||||
{
|
{
|
||||||
if (wfi->fullscreen)
|
if (wfc->fullscreen)
|
||||||
{
|
{
|
||||||
if (wfi->instance->settings->UseMultimon)
|
if (wfc->instance->settings->UseMultimon)
|
||||||
{
|
{
|
||||||
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||||
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
|
|
||||||
wfi->offset_x = (w - wfi->width) / 2;
|
wfc->offset_x = (w - wfc->width) / 2;
|
||||||
if (wfi->offset_x < x)
|
if (wfc->offset_x < x)
|
||||||
wfi->offset_x = x;
|
wfc->offset_x = x;
|
||||||
wfi->offset_y = (h - wfi->height) / 2;
|
wfc->offset_y = (h - wfc->height) / 2;
|
||||||
if (wfi->offset_y < y)
|
if (wfc->offset_y < y)
|
||||||
wfi->offset_y = y;
|
wfc->offset_y = y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wfi->offset_x = (GetSystemMetrics(SM_CXSCREEN) - wfi->width) / 2;
|
wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) - wfc->width) / 2;
|
||||||
if (wfi->offset_x < 0)
|
if (wfc->offset_x < 0)
|
||||||
wfi->offset_x = 0;
|
wfc->offset_x = 0;
|
||||||
wfi->offset_y = (GetSystemMetrics(SM_CYSCREEN) - wfi->height) / 2;
|
wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) - wfc->height) / 2;
|
||||||
if (wfi->offset_y < 0)
|
if (wfc->offset_y < 0)
|
||||||
wfi->offset_y = 0;
|
wfc->offset_y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wfi->offset_x = 0;
|
wfc->offset_x = 0;
|
||||||
wfi->offset_y = 0;
|
wfc->offset_y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_resize_window(wfInfo* wfi)
|
void wf_resize_window(wfContext* wfc)
|
||||||
{
|
{
|
||||||
if (wfi->fullscreen)
|
if (wfc->fullscreen)
|
||||||
{
|
{
|
||||||
if(wfi->instance->settings->UseMultimon)
|
if(wfc->instance->settings->UseMultimon)
|
||||||
{
|
{
|
||||||
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||||
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
|
|
||||||
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_POPUP);
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_POPUP);
|
||||||
SetWindowPos(wfi->hwnd, HWND_TOP, x, y, w, h, SWP_FRAMECHANGED);
|
SetWindowPos(wfc->hwnd, HWND_TOP, x, y, w, h, SWP_FRAMECHANGED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_POPUP);
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_POPUP);
|
||||||
SetWindowPos(wfi->hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
|
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!wfi->instance->settings->Decorations)
|
else if (!wfc->instance->settings->Decorations)
|
||||||
{
|
{
|
||||||
RECT rc_wnd;
|
RECT rc_wnd;
|
||||||
RECT rc_client;
|
RECT rc_client;
|
||||||
|
|
||||||
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CHILD);
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CHILD);
|
||||||
|
|
||||||
/* Now resize to get full canvas size and room for caption and borders */
|
/* 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);
|
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, wfc->width, wfc->height, SWP_FRAMECHANGED);
|
||||||
|
|
||||||
wf_update_canvas_diff(wfi);
|
wf_update_canvas_diff(wfc);
|
||||||
SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, wfi->width + wfi->diff.x, wfi->height + wfi->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
|
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, wfc->width + wfc->diff.x, wfc->height + wfc->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RECT rc_wnd;
|
RECT rc_wnd;
|
||||||
RECT rc_client;
|
RECT rc_client;
|
||||||
|
|
||||||
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX);
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX);
|
||||||
|
|
||||||
if (!wfi->client_height)
|
if (!wfc->client_height)
|
||||||
wfi->client_height = wfi->height;
|
wfc->client_height = wfc->height;
|
||||||
|
|
||||||
if (!wfi->client_width)
|
if (!wfc->client_width)
|
||||||
wfi->client_width = wfi->width;
|
wfc->client_width = wfc->width;
|
||||||
|
|
||||||
if (!wfi->client_x)
|
if (!wfc->client_x)
|
||||||
wfi->client_x = 10;
|
wfc->client_x = 10;
|
||||||
|
|
||||||
if (!wfi->client_y)
|
if (!wfc->client_y)
|
||||||
wfi->client_y = 10;
|
wfc->client_y = 10;
|
||||||
|
|
||||||
wf_update_canvas_diff(wfi);
|
wf_update_canvas_diff(wfc);
|
||||||
|
|
||||||
/* Now resize to get full canvas size and room for caption and borders */
|
/* 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, 0 /*SWP_FRAMECHANGED*/);
|
SetWindowPos(wfc->hwnd, HWND_TOP, wfc->client_x, wfc->client_y, wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y, 0 /*SWP_FRAMECHANGED*/);
|
||||||
//wf_size_scrollbars(wfi, wfi->client_width, wfi->client_height);
|
//wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
|
||||||
}
|
}
|
||||||
wf_update_offset(wfi);
|
wf_update_offset(wfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_toggle_fullscreen(wfInfo* wfi)
|
void wf_toggle_fullscreen(wfContext* wfc)
|
||||||
{
|
{
|
||||||
ShowWindow(wfi->hwnd, SW_HIDE);
|
ShowWindow(wfc->hwnd, SW_HIDE);
|
||||||
wfi->fullscreen = !wfi->fullscreen;
|
wfc->fullscreen = !wfc->fullscreen;
|
||||||
|
|
||||||
if (wfi->fullscreen)
|
if (wfc->fullscreen)
|
||||||
{
|
{
|
||||||
wfi->disablewindowtracking = TRUE;
|
wfc->disablewindowtracking = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetParent(wfi->hwnd, wfi->fullscreen ? NULL : wfi->hWndParent);
|
SetParent(wfc->hwnd, wfc->fullscreen ? NULL : wfc->hWndParent);
|
||||||
wf_resize_window(wfi);
|
wf_resize_window(wfc);
|
||||||
ShowWindow(wfi->hwnd, SW_SHOW);
|
ShowWindow(wfc->hwnd, SW_SHOW);
|
||||||
SetForegroundWindow(wfi->hwnd);
|
SetForegroundWindow(wfc->hwnd);
|
||||||
|
|
||||||
if (!wfi->fullscreen)
|
if (!wfc->fullscreen)
|
||||||
{
|
{
|
||||||
// Reenable window tracking AFTER resizing it back, otherwise it can lean to repositioning errors.
|
// Reenable window tracking AFTER resizing it back, otherwise it can lean to repositioning errors.
|
||||||
wfi->disablewindowtracking = FALSE;
|
wfc->disablewindowtracking = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
|
void wf_gdi_palette_update(wfContext* wfc, PALETTE_UPDATE* palette)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_set_null_clip_rgn(wfInfo* wfi)
|
void wf_set_null_clip_rgn(wfContext* wfc)
|
||||||
{
|
{
|
||||||
SelectClipRgn(wfi->drawing->hdc, NULL);
|
SelectClipRgn(wfc->drawing->hdc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_set_clip_rgn(wfInfo* wfi, int x, int y, int width, int height)
|
void wf_set_clip_rgn(wfContext* wfc, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
HRGN clip;
|
HRGN clip;
|
||||||
clip = CreateRectRgn(x, y, x + width, y + height);
|
clip = CreateRectRgn(x, y, x + width, y + height);
|
||||||
SelectClipRgn(wfi->drawing->hdc, clip);
|
SelectClipRgn(wfc->drawing->hdc, clip);
|
||||||
DeleteObject(clip);
|
DeleteObject(clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_set_bounds(rdpContext* context, rdpBounds* bounds)
|
void wf_gdi_set_bounds(wfContext* wfc, rdpBounds* bounds)
|
||||||
{
|
{
|
||||||
HRGN hrgn;
|
HRGN hrgn;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
if (bounds != NULL)
|
if (bounds != NULL)
|
||||||
{
|
{
|
||||||
hrgn = CreateRectRgn(bounds->left, bounds->top, bounds->right + 1, bounds->bottom + 1);
|
hrgn = CreateRectRgn(bounds->left, bounds->top, bounds->right + 1, bounds->bottom + 1);
|
||||||
SelectClipRgn(wfi->drawing->hdc, hrgn);
|
SelectClipRgn(wfc->drawing->hdc, hrgn);
|
||||||
DeleteObject(hrgn);
|
DeleteObject(hrgn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SelectClipRgn(wfi->drawing->hdc, NULL);
|
SelectClipRgn(wfc->drawing->hdc, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
|
void wf_gdi_dstblt(wfContext* wfc, DSTBLT_ORDER* dstblt)
|
||||||
{
|
{
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
|
||||||
|
|
||||||
BitBlt(wfi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
|
|
||||||
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop));
|
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop));
|
||||||
|
|
||||||
wf_invalidate_region(wfi, dstblt->nLeftRect, dstblt->nTopRect,
|
wf_invalidate_region(wfc, dstblt->nLeftRect, dstblt->nTopRect,
|
||||||
dstblt->nWidth, dstblt->nHeight);
|
dstblt->nWidth, dstblt->nHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
|
void wf_gdi_patblt(wfContext* wfc, PATBLT_ORDER* patblt)
|
||||||
{
|
{
|
||||||
HBRUSH brush;
|
HBRUSH brush;
|
||||||
HBRUSH org_brush;
|
HBRUSH org_brush;
|
||||||
@ -395,78 +392,73 @@ void wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
|
|||||||
UINT32 bgcolor;
|
UINT32 bgcolor;
|
||||||
COLORREF org_bkcolor;
|
COLORREF org_bkcolor;
|
||||||
COLORREF org_textcolor;
|
COLORREF org_textcolor;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
fgcolor = freerdp_color_convert_bgr(patblt->foreColor, wfi->srcBpp, wfi->dstBpp, wfi->clrconv);
|
fgcolor = freerdp_color_convert_bgr(patblt->foreColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
|
||||||
bgcolor = freerdp_color_convert_bgr(patblt->backColor, wfi->srcBpp, wfi->dstBpp, wfi->clrconv);
|
bgcolor = freerdp_color_convert_bgr(patblt->backColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
|
||||||
|
|
||||||
brush = wf_create_brush(wfi, &patblt->brush, fgcolor, wfi->srcBpp);
|
brush = wf_create_brush(wfc, &patblt->brush, fgcolor, wfc->srcBpp);
|
||||||
org_bkmode = SetBkMode(wfi->drawing->hdc, OPAQUE);
|
org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE);
|
||||||
org_bkcolor = SetBkColor(wfi->drawing->hdc, bgcolor);
|
org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor);
|
||||||
org_textcolor = SetTextColor(wfi->drawing->hdc, fgcolor);
|
org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor);
|
||||||
org_brush = (HBRUSH)SelectObject(wfi->drawing->hdc, brush);
|
org_brush = (HBRUSH)SelectObject(wfc->drawing->hdc, brush);
|
||||||
|
|
||||||
PatBlt(wfi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
|
PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
|
||||||
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop));
|
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop));
|
||||||
|
|
||||||
SelectObject(wfi->drawing->hdc, org_brush);
|
SelectObject(wfc->drawing->hdc, org_brush);
|
||||||
DeleteObject(brush);
|
DeleteObject(brush);
|
||||||
|
|
||||||
SetBkMode(wfi->drawing->hdc, org_bkmode);
|
SetBkMode(wfc->drawing->hdc, org_bkmode);
|
||||||
SetBkColor(wfi->drawing->hdc, org_bkcolor);
|
SetBkColor(wfc->drawing->hdc, org_bkcolor);
|
||||||
SetTextColor(wfi->drawing->hdc, org_textcolor);
|
SetTextColor(wfc->drawing->hdc, org_textcolor);
|
||||||
|
|
||||||
if (wfi->drawing == wfi->primary)
|
if (wfc->drawing == wfc->primary)
|
||||||
wf_invalidate_region(wfi, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
|
wf_invalidate_region(wfc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
|
void wf_gdi_scrblt(wfContext* wfc, SCRBLT_ORDER* scrblt)
|
||||||
{
|
{
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
|
||||||
|
scrblt->nWidth, scrblt->nHeight, wfc->primary->hdc,
|
||||||
BitBlt(wfi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
|
|
||||||
scrblt->nWidth, scrblt->nHeight, wfi->primary->hdc,
|
|
||||||
scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop));
|
scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop));
|
||||||
|
|
||||||
wf_invalidate_region(wfi, scrblt->nLeftRect, scrblt->nTopRect,
|
wf_invalidate_region(wfc, scrblt->nLeftRect, scrblt->nTopRect,
|
||||||
scrblt->nWidth, scrblt->nHeight);
|
scrblt->nWidth, scrblt->nHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
|
void wf_gdi_opaque_rect(wfContext* wfc, OPAQUE_RECT_ORDER* opaque_rect)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
HBRUSH brush;
|
HBRUSH brush;
|
||||||
UINT32 brush_color;
|
UINT32 brush_color;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
brush_color = freerdp_color_convert_var_bgr(opaque_rect->color, wfi->srcBpp, wfi->dstBpp, wfi->clrconv);
|
brush_color = freerdp_color_convert_var_bgr(opaque_rect->color, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
|
||||||
|
|
||||||
rect.left = opaque_rect->nLeftRect;
|
rect.left = opaque_rect->nLeftRect;
|
||||||
rect.top = opaque_rect->nTopRect;
|
rect.top = opaque_rect->nTopRect;
|
||||||
rect.right = opaque_rect->nLeftRect + opaque_rect->nWidth;
|
rect.right = opaque_rect->nLeftRect + opaque_rect->nWidth;
|
||||||
rect.bottom = opaque_rect->nTopRect + opaque_rect->nHeight;
|
rect.bottom = opaque_rect->nTopRect + opaque_rect->nHeight;
|
||||||
brush = CreateSolidBrush(brush_color);
|
brush = CreateSolidBrush(brush_color);
|
||||||
FillRect(wfi->drawing->hdc, &rect, brush);
|
FillRect(wfc->drawing->hdc, &rect, brush);
|
||||||
DeleteObject(brush);
|
DeleteObject(brush);
|
||||||
|
|
||||||
if (wfi->drawing == wfi->primary)
|
if (wfc->drawing == wfc->primary)
|
||||||
wf_invalidate_region(wfi, rect.left, rect.top, rect.right - rect.left + 1, rect.bottom - rect.top + 1);
|
wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1, rect.bottom - rect.top + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
|
void wf_gdi_multi_opaque_rect(wfContext* wfc, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
HBRUSH brush;
|
HBRUSH brush;
|
||||||
UINT32 brush_color;
|
UINT32 brush_color;
|
||||||
DELTA_RECT* rectangle;
|
DELTA_RECT* rectangle;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
for (i = 1; i < (int) multi_opaque_rect->numRectangles + 1; i++)
|
for (i = 1; i < (int) multi_opaque_rect->numRectangles + 1; i++)
|
||||||
{
|
{
|
||||||
rectangle = &multi_opaque_rect->rectangles[i];
|
rectangle = &multi_opaque_rect->rectangles[i];
|
||||||
|
|
||||||
brush_color = freerdp_color_convert_var_bgr(multi_opaque_rect->color, wfi->srcBpp, wfi->dstBpp, wfi->clrconv);
|
brush_color = freerdp_color_convert_var_bgr(multi_opaque_rect->color, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
|
||||||
|
|
||||||
rect.left = rectangle->left;
|
rect.left = rectangle->left;
|
||||||
rect.top = rectangle->top;
|
rect.top = rectangle->top;
|
||||||
@ -475,46 +467,45 @@ void wf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* mult
|
|||||||
brush = CreateSolidBrush(brush_color);
|
brush = CreateSolidBrush(brush_color);
|
||||||
|
|
||||||
brush = CreateSolidBrush(brush_color);
|
brush = CreateSolidBrush(brush_color);
|
||||||
FillRect(wfi->drawing->hdc, &rect, brush);
|
FillRect(wfc->drawing->hdc, &rect, brush);
|
||||||
|
|
||||||
if (wfi->drawing == wfi->primary)
|
if (wfc->drawing == wfc->primary)
|
||||||
wf_invalidate_region(wfi, rect.left, rect.top, rect.right - rect.left + 1, rect.bottom - rect.top + 1);
|
wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1, rect.bottom - rect.top + 1);
|
||||||
|
|
||||||
DeleteObject(brush);
|
DeleteObject(brush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to)
|
void wf_gdi_line_to(wfContext* wfc, LINE_TO_ORDER* line_to)
|
||||||
{
|
{
|
||||||
HPEN pen;
|
HPEN pen;
|
||||||
HPEN org_pen;
|
HPEN org_pen;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
UINT32 pen_color;
|
UINT32 pen_color;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
pen_color = freerdp_color_convert_bgr(line_to->penColor, wfi->srcBpp, wfi->dstBpp, wfi->clrconv);
|
pen_color = freerdp_color_convert_bgr(line_to->penColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
|
||||||
|
|
||||||
pen = CreatePen(line_to->penStyle, line_to->penWidth, pen_color);
|
pen = CreatePen(line_to->penStyle, line_to->penWidth, pen_color);
|
||||||
|
|
||||||
wf_set_rop2(wfi->drawing->hdc, line_to->bRop2);
|
wf_set_rop2(wfc->drawing->hdc, line_to->bRop2);
|
||||||
org_pen = (HPEN) SelectObject(wfi->drawing->hdc, pen);
|
org_pen = (HPEN) SelectObject(wfc->drawing->hdc, pen);
|
||||||
|
|
||||||
MoveToEx(wfi->drawing->hdc, line_to->nXStart, line_to->nYStart, NULL);
|
MoveToEx(wfc->drawing->hdc, line_to->nXStart, line_to->nYStart, NULL);
|
||||||
LineTo(wfi->drawing->hdc, line_to->nXEnd, line_to->nYEnd);
|
LineTo(wfc->drawing->hdc, line_to->nXEnd, line_to->nYEnd);
|
||||||
|
|
||||||
x = (line_to->nXStart < line_to->nXEnd) ? line_to->nXStart : line_to->nXEnd;
|
x = (line_to->nXStart < line_to->nXEnd) ? line_to->nXStart : line_to->nXEnd;
|
||||||
y = (line_to->nYStart < line_to->nYEnd) ? line_to->nYStart : line_to->nYEnd;
|
y = (line_to->nYStart < line_to->nYEnd) ? line_to->nYStart : line_to->nYEnd;
|
||||||
w = (line_to->nXStart < line_to->nXEnd) ? (line_to->nXEnd - line_to->nXStart) : (line_to->nXStart - line_to->nXEnd);
|
w = (line_to->nXStart < line_to->nXEnd) ? (line_to->nXEnd - line_to->nXStart) : (line_to->nXStart - line_to->nXEnd);
|
||||||
h = (line_to->nYStart < line_to->nYEnd) ? (line_to->nYEnd - line_to->nYStart) : (line_to->nYStart - line_to->nYEnd);
|
h = (line_to->nYStart < line_to->nYEnd) ? (line_to->nYEnd - line_to->nYStart) : (line_to->nYStart - line_to->nYEnd);
|
||||||
|
|
||||||
if (wfi->drawing == wfi->primary)
|
if (wfc->drawing == wfc->primary)
|
||||||
wf_invalidate_region(wfi, x, y, w, h);
|
wf_invalidate_region(wfc, x, y, w, h);
|
||||||
|
|
||||||
SelectObject(wfi->drawing->hdc, org_pen);
|
SelectObject(wfc->drawing->hdc, org_pen);
|
||||||
DeleteObject(pen);
|
DeleteObject(pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
|
void wf_gdi_polyline(wfContext* wfc, POLYLINE_ORDER* polyline)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
POINT* pts;
|
POINT* pts;
|
||||||
@ -522,13 +513,12 @@ void wf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
|
|||||||
HPEN hpen;
|
HPEN hpen;
|
||||||
HPEN org_hpen;
|
HPEN org_hpen;
|
||||||
UINT32 pen_color;
|
UINT32 pen_color;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
pen_color = freerdp_color_convert_bgr(polyline->penColor, wfi->srcBpp, wfi->dstBpp, wfi->clrconv);
|
pen_color = freerdp_color_convert_bgr(polyline->penColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
|
||||||
|
|
||||||
hpen = CreatePen(0, 1, pen_color);
|
hpen = CreatePen(0, 1, pen_color);
|
||||||
org_rop2 = wf_set_rop2(wfi->drawing->hdc, polyline->bRop2);
|
org_rop2 = wf_set_rop2(wfc->drawing->hdc, polyline->bRop2);
|
||||||
org_hpen = (HPEN) SelectObject(wfi->drawing->hdc, hpen);
|
org_hpen = (HPEN) SelectObject(wfc->drawing->hdc, hpen);
|
||||||
|
|
||||||
if (polyline->numPoints > 0)
|
if (polyline->numPoints > 0)
|
||||||
{
|
{
|
||||||
@ -539,45 +529,43 @@ void wf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
|
|||||||
pts[i].x = polyline->points[i].x;
|
pts[i].x = polyline->points[i].x;
|
||||||
pts[i].y = polyline->points[i].y;
|
pts[i].y = polyline->points[i].y;
|
||||||
|
|
||||||
if (wfi->drawing == wfi->primary)
|
if (wfc->drawing == wfc->primary)
|
||||||
wf_invalidate_region(wfi, pts[i].x, pts[i].y, pts[i].x + 1, pts[i].y + 1);
|
wf_invalidate_region(wfc, pts[i].x, pts[i].y, pts[i].x + 1, pts[i].y + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyline(wfi->drawing->hdc, pts, polyline->numPoints);
|
Polyline(wfc->drawing->hdc, pts, polyline->numPoints);
|
||||||
free(pts);
|
free(pts);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectObject(wfi->drawing->hdc, org_hpen);
|
SelectObject(wfc->drawing->hdc, org_hpen);
|
||||||
wf_set_rop2(wfi->drawing->hdc, org_rop2);
|
wf_set_rop2(wfc->drawing->hdc, org_rop2);
|
||||||
DeleteObject(hpen);
|
DeleteObject(hpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
|
void wf_gdi_memblt(wfContext* wfc, MEMBLT_ORDER* memblt)
|
||||||
{
|
{
|
||||||
wfBitmap* bitmap;
|
wfBitmap* bitmap;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
bitmap = (wfBitmap*) memblt->bitmap;
|
bitmap = (wfBitmap*) memblt->bitmap;
|
||||||
|
|
||||||
BitBlt(wfi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
|
BitBlt(wfc->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
|
||||||
memblt->nWidth, memblt->nHeight, bitmap->hdc,
|
memblt->nWidth, memblt->nHeight, bitmap->hdc,
|
||||||
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop));
|
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop));
|
||||||
|
|
||||||
if (wfi->drawing == wfi->primary)
|
if (wfc->drawing == wfc->primary)
|
||||||
wf_invalidate_region(wfi, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight);
|
wf_invalidate_region(wfc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits_command)
|
void wf_gdi_surface_bits(wfContext* wfc, SURFACE_BITS_COMMAND* surface_bits_command)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int tx, ty;
|
int tx, ty;
|
||||||
char* tile_bitmap;
|
char* tile_bitmap;
|
||||||
RFX_MESSAGE* message;
|
RFX_MESSAGE* message;
|
||||||
BITMAPINFO bitmap_info;
|
BITMAPINFO bitmap_info;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) wfi->rfx_context;
|
RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) wfc->rfx_context;
|
||||||
NSC_CONTEXT* nsc_context = (NSC_CONTEXT*) wfi->nsc_context;
|
NSC_CONTEXT* nsc_context = (NSC_CONTEXT*) wfc->nsc_context;
|
||||||
|
|
||||||
tile_bitmap = (char*) malloc(32);
|
tile_bitmap = (char*) malloc(32);
|
||||||
ZeroMemory(tile_bitmap, 32);
|
ZeroMemory(tile_bitmap, 32);
|
||||||
@ -592,27 +580,27 @@ void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
|
|||||||
tx = message->tiles[i]->x + surface_bits_command->destLeft;
|
tx = message->tiles[i]->x + surface_bits_command->destLeft;
|
||||||
ty = message->tiles[i]->y + surface_bits_command->destTop;
|
ty = message->tiles[i]->y + surface_bits_command->destTop;
|
||||||
|
|
||||||
freerdp_image_convert(message->tiles[i]->data, wfi->tile->pdata, 64, 64, 32, 32, wfi->clrconv);
|
freerdp_image_convert(message->tiles[i]->data, wfc->tile->pdata, 64, 64, 32, 32, wfc->clrconv);
|
||||||
|
|
||||||
for (j = 0; j < message->num_rects; j++)
|
for (j = 0; j < message->num_rects; j++)
|
||||||
{
|
{
|
||||||
wf_set_clip_rgn(wfi,
|
wf_set_clip_rgn(wfc,
|
||||||
surface_bits_command->destLeft + message->rects[j].x,
|
surface_bits_command->destLeft + message->rects[j].x,
|
||||||
surface_bits_command->destTop + message->rects[j].y,
|
surface_bits_command->destTop + message->rects[j].y,
|
||||||
message->rects[j].width, message->rects[j].height);
|
message->rects[j].width, message->rects[j].height);
|
||||||
|
|
||||||
BitBlt(wfi->primary->hdc, tx, ty, 64, 64, wfi->tile->hdc, 0, 0, SRCCOPY);
|
BitBlt(wfc->primary->hdc, tx, ty, 64, 64, wfc->tile->hdc, 0, 0, SRCCOPY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wf_set_null_clip_rgn(wfi);
|
wf_set_null_clip_rgn(wfc);
|
||||||
|
|
||||||
/* invalidate regions */
|
/* invalidate regions */
|
||||||
for (i = 0; i < message->num_rects; i++)
|
for (i = 0; i < message->num_rects; i++)
|
||||||
{
|
{
|
||||||
tx = surface_bits_command->destLeft + message->rects[i].x;
|
tx = surface_bits_command->destLeft + message->rects[i].x;
|
||||||
ty = surface_bits_command->destTop + message->rects[i].y;
|
ty = surface_bits_command->destTop + message->rects[i].y;
|
||||||
wf_invalidate_region(wfi, tx, ty, message->rects[i].width, message->rects[i].height);
|
wf_invalidate_region(wfc, tx, ty, message->rects[i].width, message->rects[i].height);
|
||||||
}
|
}
|
||||||
|
|
||||||
rfx_message_free(rfx_context, message);
|
rfx_message_free(rfx_context, message);
|
||||||
@ -628,10 +616,10 @@ void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
|
|||||||
bitmap_info.bmiHeader.biPlanes = 1;
|
bitmap_info.bmiHeader.biPlanes = 1;
|
||||||
bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
|
bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
|
||||||
bitmap_info.bmiHeader.biCompression = BI_RGB;
|
bitmap_info.bmiHeader.biCompression = BI_RGB;
|
||||||
SetDIBitsToDevice(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
SetDIBitsToDevice(wfc->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||||
surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
|
surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
|
||||||
nsc_context->bmpdata, &bitmap_info, DIB_RGB_COLORS);
|
nsc_context->bmpdata, &bitmap_info, DIB_RGB_COLORS);
|
||||||
wf_invalidate_region(wfi, surface_bits_command->destLeft, surface_bits_command->destTop,
|
wf_invalidate_region(wfc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||||
surface_bits_command->width, surface_bits_command->height);
|
surface_bits_command->width, surface_bits_command->height);
|
||||||
}
|
}
|
||||||
else if (surface_bits_command->codecID == RDP_CODEC_ID_NONE)
|
else if (surface_bits_command->codecID == RDP_CODEC_ID_NONE)
|
||||||
@ -643,10 +631,10 @@ void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
|
|||||||
bitmap_info.bmiHeader.biPlanes = 1;
|
bitmap_info.bmiHeader.biPlanes = 1;
|
||||||
bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
|
bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
|
||||||
bitmap_info.bmiHeader.biCompression = BI_RGB;
|
bitmap_info.bmiHeader.biCompression = BI_RGB;
|
||||||
SetDIBitsToDevice(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
SetDIBitsToDevice(wfc->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||||
surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
|
surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
|
||||||
surface_bits_command->bitmapData, &bitmap_info, DIB_RGB_COLORS);
|
surface_bits_command->bitmapData, &bitmap_info, DIB_RGB_COLORS);
|
||||||
wf_invalidate_region(wfi, surface_bits_command->destLeft, surface_bits_command->destTop,
|
wf_invalidate_region(wfc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||||
surface_bits_command->width, surface_bits_command->height);
|
surface_bits_command->width, surface_bits_command->height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -658,16 +646,17 @@ void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
|
|||||||
free(tile_bitmap);
|
free(tile_bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surface_frame_marker)
|
void wf_gdi_surface_frame_marker(wfContext* wfc, SURFACE_FRAME_MARKER* surface_frame_marker)
|
||||||
{
|
{
|
||||||
wfInfo* wfi;
|
rdpContext* context;
|
||||||
rdpSettings* settings;
|
rdpSettings* settings;
|
||||||
|
|
||||||
wfi = ((wfContext*) context)->wfi;
|
context = (rdpContext*) wfc;
|
||||||
settings = wfi->instance->settings;
|
settings = wfc->instance->settings;
|
||||||
|
|
||||||
if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END && settings->FrameAcknowledge > 0)
|
if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END && settings->FrameAcknowledge > 0)
|
||||||
{
|
{
|
||||||
IFCALL(wfi->instance->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId);
|
IFCALL(context->instance->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,19 +667,19 @@ void wf_gdi_register_update_callbacks(rdpUpdate* update)
|
|||||||
update->Palette = wf_gdi_palette_update;
|
update->Palette = wf_gdi_palette_update;
|
||||||
update->SetBounds = wf_gdi_set_bounds;
|
update->SetBounds = wf_gdi_set_bounds;
|
||||||
|
|
||||||
primary->DstBlt = wf_gdi_dstblt;
|
primary->DstBlt = (pDstBlt) wf_gdi_dstblt;
|
||||||
primary->PatBlt = wf_gdi_patblt;
|
primary->PatBlt = (pPatBlt) wf_gdi_patblt;
|
||||||
primary->ScrBlt = wf_gdi_scrblt;
|
primary->ScrBlt = (pScrBlt) wf_gdi_scrblt;
|
||||||
primary->OpaqueRect = wf_gdi_opaque_rect;
|
primary->OpaqueRect = (pOpaqueRect) wf_gdi_opaque_rect;
|
||||||
primary->DrawNineGrid = NULL;
|
primary->DrawNineGrid = NULL;
|
||||||
primary->MultiDstBlt = NULL;
|
primary->MultiDstBlt = NULL;
|
||||||
primary->MultiPatBlt = NULL;
|
primary->MultiPatBlt = NULL;
|
||||||
primary->MultiScrBlt = NULL;
|
primary->MultiScrBlt = NULL;
|
||||||
primary->MultiOpaqueRect = wf_gdi_multi_opaque_rect;
|
primary->MultiOpaqueRect = (pMultiOpaqueRect) wf_gdi_multi_opaque_rect;
|
||||||
primary->MultiDrawNineGrid = NULL;
|
primary->MultiDrawNineGrid = NULL;
|
||||||
primary->LineTo = wf_gdi_line_to;
|
primary->LineTo = (pLineTo) wf_gdi_line_to;
|
||||||
primary->Polyline = wf_gdi_polyline;
|
primary->Polyline = (pPolyline) wf_gdi_polyline;
|
||||||
primary->MemBlt = wf_gdi_memblt;
|
primary->MemBlt = (pMemBlt) wf_gdi_memblt;
|
||||||
primary->Mem3Blt = NULL;
|
primary->Mem3Blt = NULL;
|
||||||
primary->SaveBitmap = NULL;
|
primary->SaveBitmap = NULL;
|
||||||
primary->GlyphIndex = NULL;
|
primary->GlyphIndex = NULL;
|
||||||
@ -705,20 +694,20 @@ void wf_gdi_register_update_callbacks(rdpUpdate* update)
|
|||||||
update->SurfaceFrameMarker = wf_gdi_surface_frame_marker;
|
update->SurfaceFrameMarker = wf_gdi_surface_frame_marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_update_canvas_diff(wfInfo* wfi)
|
void wf_update_canvas_diff(wfContext* wfc)
|
||||||
{
|
{
|
||||||
RECT rc_client, rc_wnd;
|
RECT rc_client, rc_wnd;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
|
||||||
GetClientRect(wfi->hwnd, &rc_client);
|
GetClientRect(wfc->hwnd, &rc_client);
|
||||||
GetWindowRect(wfi->hwnd, &rc_wnd);
|
GetWindowRect(wfc->hwnd, &rc_wnd);
|
||||||
|
|
||||||
dx = (rc_wnd.right - rc_wnd.left) - rc_client.right;
|
dx = (rc_wnd.right - rc_wnd.left) - rc_client.right;
|
||||||
dy = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
|
dy = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
|
||||||
|
|
||||||
if (!wfi->disablewindowtracking)
|
if (!wfc->disablewindowtracking)
|
||||||
{
|
{
|
||||||
wfi->diff.x = dx;
|
wfc->diff.x = dx;
|
||||||
wfi->diff.y = dy;
|
wfc->diff.y = dy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@
|
|||||||
|
|
||||||
#include "wf_interface.h"
|
#include "wf_interface.h"
|
||||||
|
|
||||||
void wf_invalidate_region(wfInfo* wfi, int x, int y, int width, int height);
|
void wf_invalidate_region(wfContext* wfc, int x, int y, int width, int height);
|
||||||
wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data);
|
wfBitmap* wf_image_new(wfContext* wfc, int width, int height, int bpp, BYTE* data);
|
||||||
void wf_image_free(wfBitmap* image);
|
void wf_image_free(wfBitmap* image);
|
||||||
void wf_update_offset(wfInfo* wfi);
|
void wf_update_offset(wfContext* wfc);
|
||||||
void wf_resize_window(wfInfo* wfi);
|
void wf_resize_window(wfContext* wfc);
|
||||||
void wf_toggle_fullscreen(wfInfo* wfi);
|
void wf_toggle_fullscreen(wfContext* wfc);
|
||||||
|
|
||||||
void wf_gdi_register_update_callbacks(rdpUpdate* update);
|
void wf_gdi_register_update_callbacks(rdpUpdate* update);
|
||||||
|
|
||||||
void wf_update_canvas_diff(wfInfo* wfi);
|
void wf_update_canvas_diff(wfContext* wfc);
|
||||||
|
|
||||||
#endif /* __WF_GDI_H */
|
#endif /* __WF_GDI_H */
|
||||||
|
@ -21,12 +21,14 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <winpr/crt.h>
|
||||||
|
|
||||||
#include <freerdp/codec/bitmap.h>
|
#include <freerdp/codec/bitmap.h>
|
||||||
|
|
||||||
#include "wf_gdi.h"
|
#include "wf_gdi.h"
|
||||||
#include "wf_graphics.h"
|
#include "wf_graphics.h"
|
||||||
|
|
||||||
HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, BYTE** pdata)
|
HBITMAP wf_create_dib(wfContext* wfc, int width, int height, int bpp, BYTE* data, BYTE** pdata)
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
int negHeight;
|
int negHeight;
|
||||||
@ -48,12 +50,12 @@ HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, B
|
|||||||
bmi.bmiHeader.biWidth = width;
|
bmi.bmiHeader.biWidth = width;
|
||||||
bmi.bmiHeader.biHeight = negHeight;
|
bmi.bmiHeader.biHeight = negHeight;
|
||||||
bmi.bmiHeader.biPlanes = 1;
|
bmi.bmiHeader.biPlanes = 1;
|
||||||
bmi.bmiHeader.biBitCount = wfi->dstBpp;
|
bmi.bmiHeader.biBitCount = wfc->dstBpp;
|
||||||
bmi.bmiHeader.biCompression = BI_RGB;
|
bmi.bmiHeader.biCompression = BI_RGB;
|
||||||
bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &cdata, NULL, 0);
|
bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &cdata, NULL, 0);
|
||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
freerdp_image_convert(data, cdata, width, height, bpp, wfi->dstBpp, wfi->clrconv);
|
freerdp_image_convert(data, cdata, width, height, bpp, wfc->dstBpp, wfc->clrconv);
|
||||||
|
|
||||||
if (pdata != NULL)
|
if (pdata != NULL)
|
||||||
*pdata = cdata;
|
*pdata = cdata;
|
||||||
@ -64,7 +66,7 @@ HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, B
|
|||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data)
|
wfBitmap* wf_image_new(wfContext* wfc, int width, int height, int bpp, BYTE* data)
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
wfBitmap* image;
|
wfBitmap* image;
|
||||||
@ -73,7 +75,7 @@ wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data)
|
|||||||
image = (wfBitmap*) malloc(sizeof(wfBitmap));
|
image = (wfBitmap*) malloc(sizeof(wfBitmap));
|
||||||
image->hdc = CreateCompatibleDC(hdc);
|
image->hdc = CreateCompatibleDC(hdc);
|
||||||
|
|
||||||
image->bitmap = wf_create_dib(wfi, width, height, bpp, data, &(image->pdata));
|
image->bitmap = wf_create_dib(wfc, width, height, bpp, data, &(image->pdata));
|
||||||
|
|
||||||
image->org_bitmap = (HBITMAP) SelectObject(image->hdc, image->bitmap);
|
image->org_bitmap = (HBITMAP) SelectObject(image->hdc, image->bitmap);
|
||||||
ReleaseDC(NULL, hdc);
|
ReleaseDC(NULL, hdc);
|
||||||
@ -94,27 +96,26 @@ void wf_image_free(wfBitmap* image)
|
|||||||
|
|
||||||
/* Bitmap Class */
|
/* Bitmap Class */
|
||||||
|
|
||||||
void wf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
|
void wf_Bitmap_New(wfContext* wfc, rdpBitmap* bitmap)
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
|
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
wf_bitmap = (wfBitmap*) bitmap;
|
wf_bitmap = (wfBitmap*) bitmap;
|
||||||
|
|
||||||
hdc = GetDC(NULL);
|
hdc = GetDC(NULL);
|
||||||
wf_bitmap->hdc = CreateCompatibleDC(hdc);
|
wf_bitmap->hdc = CreateCompatibleDC(hdc);
|
||||||
|
|
||||||
if (bitmap->data == NULL)
|
if (!bitmap->data)
|
||||||
wf_bitmap->bitmap = CreateCompatibleBitmap(hdc, bitmap->width, bitmap->height);
|
wf_bitmap->bitmap = CreateCompatibleBitmap(hdc, bitmap->width, bitmap->height);
|
||||||
else
|
else
|
||||||
wf_bitmap->bitmap = wf_create_dib(wfi, bitmap->width, bitmap->height, bitmap->bpp, bitmap->data, NULL);
|
wf_bitmap->bitmap = wf_create_dib(wfc, bitmap->width, bitmap->height, bitmap->bpp, bitmap->data, NULL);
|
||||||
|
|
||||||
wf_bitmap->org_bitmap = (HBITMAP) SelectObject(wf_bitmap->hdc, wf_bitmap->bitmap);
|
wf_bitmap->org_bitmap = (HBITMAP) SelectObject(wf_bitmap->hdc, wf_bitmap->bitmap);
|
||||||
ReleaseDC(NULL, hdc);
|
ReleaseDC(NULL, hdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
void wf_Bitmap_Free(wfContext* wfc, rdpBitmap* bitmap)
|
||||||
{
|
{
|
||||||
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
|
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
|
||||||
|
|
||||||
@ -126,22 +127,21 @@ void wf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
|
void wf_Bitmap_Paint(wfContext* wfc, rdpBitmap* bitmap)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
|
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
width = bitmap->right - bitmap->left + 1;
|
width = bitmap->right - bitmap->left + 1;
|
||||||
height = bitmap->bottom - bitmap->top + 1;
|
height = bitmap->bottom - bitmap->top + 1;
|
||||||
|
|
||||||
BitBlt(wfi->primary->hdc, bitmap->left, bitmap->top,
|
BitBlt(wfc->primary->hdc, bitmap->left, bitmap->top,
|
||||||
width, height, wf_bitmap->hdc, 0, 0, SRCCOPY);
|
width, height, wf_bitmap->hdc, 0, 0, SRCCOPY);
|
||||||
|
|
||||||
wf_invalidate_region(wfi, bitmap->left, bitmap->top, width, height);
|
wf_invalidate_region(wfc, bitmap->left, bitmap->top, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
void wf_Bitmap_Decompress(wfContext* wfc, rdpBitmap* bitmap,
|
||||||
BYTE* data, int width, int height, int bpp, int length, BOOL compressed, int codec_id)
|
BYTE* data, int width, int height, int bpp, int length, BOOL compressed, int codec_id)
|
||||||
{
|
{
|
||||||
UINT16 size;
|
UINT16 size;
|
||||||
@ -174,19 +174,17 @@ void wf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
|||||||
bitmap->bpp = bpp;
|
bitmap->bpp = bpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
|
void wf_Bitmap_SetSurface(wfContext* wfc, rdpBitmap* bitmap, BOOL primary)
|
||||||
{
|
{
|
||||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
|
||||||
|
|
||||||
if (primary)
|
if (primary)
|
||||||
wfi->drawing = wfi->primary;
|
wfc->drawing = wfc->primary;
|
||||||
else
|
else
|
||||||
wfi->drawing = (wfBitmap*) bitmap;
|
wfc->drawing = (wfBitmap*) bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pointer Class */
|
/* Pointer Class */
|
||||||
|
|
||||||
void wf_Pointer_New(rdpContext* context, rdpPointer* pointer)
|
void wf_Pointer_New(wfContext* wfc, rdpPointer* pointer)
|
||||||
{
|
{
|
||||||
HCURSOR hCur;
|
HCURSOR hCur;
|
||||||
ICONINFO info;
|
ICONINFO info;
|
||||||
@ -223,35 +221,35 @@ void wf_Pointer_New(rdpContext* context, rdpPointer* pointer)
|
|||||||
DeleteObject(info.hbmColor);
|
DeleteObject(info.hbmColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
|
void wf_Pointer_Free(wfContext* wfc, rdpPointer* pointer)
|
||||||
{
|
{
|
||||||
HCURSOR hCur;
|
HCURSOR hCur;
|
||||||
|
|
||||||
hCur = ((wfPointer*) pointer)->cursor;
|
hCur = ((wfPointer*) pointer)->cursor;
|
||||||
|
|
||||||
if (hCur != 0)
|
if (hCur != 0)
|
||||||
DestroyIcon(hCur);
|
DestroyIcon(hCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
|
void wf_Pointer_Set(wfContext* wfc, rdpPointer* pointer)
|
||||||
{
|
{
|
||||||
wfInfo* wfi;
|
|
||||||
HCURSOR hCur;
|
HCURSOR hCur;
|
||||||
|
|
||||||
wfi = ((wfContext*) context)->wfi;
|
|
||||||
hCur = ((wfPointer*) pointer)->cursor;
|
hCur = ((wfPointer*) pointer)->cursor;
|
||||||
|
|
||||||
if (hCur != NULL)
|
if (hCur != NULL)
|
||||||
{
|
{
|
||||||
SetCursor(hCur);
|
SetCursor(hCur);
|
||||||
wfi->cursor = hCur;
|
wfc->cursor = hCur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Pointer_SetNull(rdpContext* context)
|
void wf_Pointer_SetNull(wfContext* wfc)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_Pointer_SetDefault(rdpContext* context)
|
void wf_Pointer_SetDefault(wfContext* wfc)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -263,21 +261,21 @@ void wf_register_graphics(rdpGraphics* graphics)
|
|||||||
rdpBitmap bitmap;
|
rdpBitmap bitmap;
|
||||||
rdpPointer pointer;
|
rdpPointer pointer;
|
||||||
|
|
||||||
memset(&bitmap, 0, sizeof(rdpBitmap));
|
ZeroMemory(&bitmap, sizeof(rdpBitmap));
|
||||||
bitmap.size = sizeof(wfBitmap);
|
bitmap.size = sizeof(wfBitmap);
|
||||||
bitmap.New = wf_Bitmap_New;
|
bitmap.New = (pBitmap_New) wf_Bitmap_New;
|
||||||
bitmap.Free = wf_Bitmap_Free;
|
bitmap.Free = (pBitmap_Free) wf_Bitmap_Free;
|
||||||
bitmap.Paint = wf_Bitmap_Paint;
|
bitmap.Paint = (pBitmap_Paint) wf_Bitmap_Paint;
|
||||||
bitmap.Decompress = wf_Bitmap_Decompress;
|
bitmap.Decompress = (pBitmap_Decompress) wf_Bitmap_Decompress;
|
||||||
bitmap.SetSurface = wf_Bitmap_SetSurface;
|
bitmap.SetSurface = (pBitmap_SetSurface) wf_Bitmap_SetSurface;
|
||||||
|
|
||||||
memset(&pointer, 0, sizeof(rdpPointer));
|
ZeroMemory(&pointer, sizeof(rdpPointer));
|
||||||
pointer.size = sizeof(wfPointer);
|
pointer.size = sizeof(wfPointer);
|
||||||
pointer.New = wf_Pointer_New;
|
pointer.New = (pPointer_New) wf_Pointer_New;
|
||||||
pointer.Free = wf_Pointer_Free;
|
pointer.Free = (pPointer_Free) wf_Pointer_Free;
|
||||||
pointer.Set = wf_Pointer_Set;
|
pointer.Set = (pPointer_Set) wf_Pointer_Set;
|
||||||
pointer.SetNull = wf_Pointer_SetNull;
|
pointer.SetNull = (pPointer_SetNull) wf_Pointer_SetNull;
|
||||||
pointer.SetDefault = wf_Pointer_SetDefault;
|
pointer.SetDefault = (pPointer_SetDefault) wf_Pointer_SetDefault;
|
||||||
|
|
||||||
graphics_register_bitmap(graphics, &bitmap);
|
graphics_register_bitmap(graphics, &bitmap);
|
||||||
graphics_register_pointer(graphics, &pointer);
|
graphics_register_pointer(graphics, &pointer);
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
#include "wf_interface.h"
|
#include "wf_interface.h"
|
||||||
|
|
||||||
HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, BYTE** pdata);
|
HBITMAP wf_create_dib(wfContext* wfc, int width, int height, int bpp, BYTE* data, BYTE** pdata);
|
||||||
wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data);
|
wfBitmap* wf_image_new(wfContext* wfc, int width, int height, int bpp, BYTE* data);
|
||||||
void wf_image_free(wfBitmap* image);
|
void wf_image_free(wfBitmap* image);
|
||||||
|
|
||||||
void wf_register_graphics(rdpGraphics* graphics);
|
void wf_register_graphics(rdpGraphics* graphics);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -43,11 +43,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Callback type codes. Move elsewhere?
|
|
||||||
#define CALLBACK_TYPE_PARAM_CHANGE 0x01
|
|
||||||
#define CALLBACK_TYPE_CONNECTED 0x02
|
|
||||||
#define CALLBACK_TYPE_DISCONNECTED 0x03
|
|
||||||
|
|
||||||
// System menu constants
|
// System menu constants
|
||||||
#define SYSCOMMAND_ID_SMARTSIZING 1000
|
#define SYSCOMMAND_ID_SMARTSIZING 1000
|
||||||
|
|
||||||
@ -68,21 +63,10 @@ struct wf_pointer
|
|||||||
};
|
};
|
||||||
typedef struct wf_pointer wfPointer;
|
typedef struct wf_pointer wfPointer;
|
||||||
|
|
||||||
typedef struct wf_info wfInfo;
|
|
||||||
|
|
||||||
struct wf_context
|
struct wf_context
|
||||||
{
|
{
|
||||||
rdpContext _p;
|
rdpContext context;
|
||||||
|
DEFINE_RDP_CLIENT_COMMON();
|
||||||
wfInfo* wfi;
|
|
||||||
};
|
|
||||||
typedef struct wf_context wfContext;
|
|
||||||
|
|
||||||
typedef void (CALLBACK * callbackFunc)(wfInfo* wfi, int callback_type, DWORD param1, DWORD param2);
|
|
||||||
|
|
||||||
struct wf_info
|
|
||||||
{
|
|
||||||
rdpClient* client;
|
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@ -97,7 +81,6 @@ struct wf_info
|
|||||||
int client_width;
|
int client_width;
|
||||||
int client_height;
|
int client_height;
|
||||||
|
|
||||||
HANDLE thread;
|
|
||||||
HANDLE keyboardThread;
|
HANDLE keyboardThread;
|
||||||
|
|
||||||
HICON icon;
|
HICON icon;
|
||||||
@ -129,61 +112,33 @@ struct wf_info
|
|||||||
NSC_CONTEXT* nsc_context;
|
NSC_CONTEXT* nsc_context;
|
||||||
|
|
||||||
BOOL sw_gdi;
|
BOOL sw_gdi;
|
||||||
callbackFunc client_callback_func;
|
|
||||||
|
|
||||||
rdpFile* connectionRdpFile;
|
rdpFile* connectionRdpFile;
|
||||||
|
|
||||||
// Keep track of window size and position, disable when in fullscreen mode.
|
// Keep track of window size and position, disable when in fullscreen mode.
|
||||||
BOOL disablewindowtracking;
|
BOOL disablewindowtracking;
|
||||||
|
|
||||||
// These variables are required for horizontal scrolling.
|
// These variables are required for horizontal scrolling.
|
||||||
BOOL updating_scrollbars;
|
BOOL updating_scrollbars;
|
||||||
BOOL xScrollVisible;
|
BOOL xScrollVisible;
|
||||||
int xMinScroll; // minimum horizontal scroll value
|
int xMinScroll; // minimum horizontal scroll value
|
||||||
int xCurrentScroll; // current horizontal scroll value
|
int xCurrentScroll; // current horizontal scroll value
|
||||||
int xMaxScroll; // maximum horizontal scroll value
|
int xMaxScroll; // maximum horizontal scroll value
|
||||||
|
|
||||||
// These variables are required for vertical scrolling.
|
// These variables are required for vertical scrolling.
|
||||||
BOOL yScrollVisible;
|
BOOL yScrollVisible;
|
||||||
int yMinScroll; // minimum vertical scroll value
|
int yMinScroll; // minimum vertical scroll value
|
||||||
int yCurrentScroll; // current vertical scroll value
|
int yCurrentScroll; // current vertical scroll value
|
||||||
int yMaxScroll; // maximum vertical scroll value
|
int yMaxScroll; // maximum vertical scroll value
|
||||||
};
|
};
|
||||||
|
typedef struct wf_context wfContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client Interface
|
* Client Interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define cfInfo wfInfo
|
FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
|
||||||
|
|
||||||
void wf_on_param_change(freerdp* instance, int id);
|
|
||||||
void wf_size_scrollbars(wfInfo* wfi, int client_width, int client_height);
|
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_global_init();
|
|
||||||
FREERDP_API int freerdp_client_global_uninit();
|
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_start(wfInfo* cfi);
|
|
||||||
FREERDP_API int freerdp_client_stop(wfInfo* cfi);
|
|
||||||
|
|
||||||
FREERDP_API HANDLE freerdp_client_get_thread(wfInfo* cfi);
|
|
||||||
FREERDP_API freerdp* freerdp_client_get_instance(wfInfo* cfi);
|
|
||||||
FREERDP_API rdpClient* freerdp_client_get_interface(wfInfo* cfi);
|
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_focus_in(wfInfo* cfi);
|
|
||||||
FREERDP_API int freerdp_client_focus_out(wfInfo* cfi);
|
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_set_window_size(wfInfo* cfi, int width, int height);
|
|
||||||
|
|
||||||
FREERDP_API cfInfo* freerdp_client_new(int argc, char** argv);
|
|
||||||
FREERDP_API int freerdp_client_free(wfInfo* cfi);
|
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_set_client_callback_function(wfInfo* cfi, callbackFunc callbackFunc);
|
|
||||||
|
|
||||||
FREERDP_API rdpSettings* freerdp_client_get_settings(wfInfo* wfi);
|
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_load_settings_from_rdp_file(wfInfo* cfi, char* filename);
|
|
||||||
FREERDP_API int freerdp_client_save_settings_to_rdp_file(wfInfo* cfi, char* filename);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,30 +29,30 @@
|
|||||||
#include "wf_window.h"
|
#include "wf_window.h"
|
||||||
#include "wf_rail.h"
|
#include "wf_rail.h"
|
||||||
|
|
||||||
void wf_rail_paint(wfInfo* wfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom)
|
void wf_rail_paint(wfContext* wfc, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_rail_register_callbacks(wfInfo* wfi, rdpRail* rail)
|
void wf_rail_register_callbacks(wfContext* wfc, rdpRail* rail)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_rail_send_client_system_command(wfInfo* wfi, UINT32 windowId, UINT16 command)
|
void wf_rail_send_client_system_command(wfContext* wfc, UINT32 windowId, UINT16 command)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_rail_send_activate(wfInfo* wfi, HWND window, BOOL enabled)
|
void wf_rail_send_activate(wfContext* wfc, HWND window, BOOL enabled)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_process_rail_event(wfInfo* wfi, rdpChannels* chanman, wMessage* event)
|
void wf_process_rail_event(wfContext* wfc, rdpChannels* channels, wMessage* event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_rail_adjust_position(wfInfo* wfi, rdpWindow *window)
|
void wf_rail_adjust_position(wfContext* wfc, rdpWindow* window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_rail_end_local_move(wfInfo* wfi, rdpWindow *window)
|
void wf_rail_end_local_move(wfContext* wfc, rdpWindow* window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
|
|
||||||
#include "wf_interface.h"
|
#include "wf_interface.h"
|
||||||
|
|
||||||
void wf_rail_paint(wfInfo* wfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom);
|
void wf_rail_paint(wfContext* wfc, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom);
|
||||||
void wf_rail_register_callbacks(wfInfo* wfi, rdpRail* rail);
|
void wf_rail_register_callbacks(wfContext* wfc, rdpRail* rail);
|
||||||
void wf_rail_send_client_system_command(wfInfo* wfi, UINT32 windowId, UINT16 command);
|
void wf_rail_send_client_system_command(wfContext* wfc, UINT32 windowId, UINT16 command);
|
||||||
void wf_rail_send_activate(wfInfo* wfi, HWND window, BOOL enabled);
|
void wf_rail_send_activate(wfContext* wfc, HWND window, BOOL enabled);
|
||||||
void wf_process_rail_event(wfInfo* wfi, rdpChannels* chanman, wMessage* event);
|
void wf_process_rail_event(wfContext* wfc, rdpChannels* channels, wMessage* event);
|
||||||
void wf_rail_adjust_position(wfInfo* wfi, rdpWindow *window);
|
void wf_rail_adjust_position(wfContext* wfc, rdpWindow* window);
|
||||||
void wf_rail_end_local_move(wfInfo* wfi, rdpWindow *window);
|
void wf_rail_end_local_move(wfContext* wfc, rdpWindow* window);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,8 +44,8 @@ set(${MODULE_PREFIX}_SRCS
|
|||||||
xf_keyboard.h
|
xf_keyboard.h
|
||||||
xf_window.c
|
xf_window.c
|
||||||
xf_window.h
|
xf_window.h
|
||||||
xf_interface.c
|
xf_client.c
|
||||||
xf_interface.h)
|
xf_client.h)
|
||||||
|
|
||||||
if(WITH_CLIENT_INTERFACE)
|
if(WITH_CLIENT_INTERFACE)
|
||||||
if(CLIENT_INTERFACE_SHARED)
|
if(CLIENT_INTERFACE_SHARED)
|
||||||
|
@ -27,13 +27,14 @@
|
|||||||
#include <winpr/thread.h>
|
#include <winpr/thread.h>
|
||||||
|
|
||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
|
#include <freerdp/client/cmdline.h>
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
|
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
HANDLE thread;
|
HANDLE thread;
|
||||||
xfContext* xfc;
|
xfContext* xfc;
|
||||||
DWORD dwExitCode;
|
DWORD dwExitCode;
|
||||||
@ -52,20 +53,17 @@ int main(int argc, char* argv[])
|
|||||||
settings = context->settings;
|
settings = context->settings;
|
||||||
xfc = (xfContext*) context;
|
xfc = (xfContext*) context;
|
||||||
|
|
||||||
if (freerdp_client_parse_command_line(context, argc, argv) < 0)
|
status = freerdp_client_parse_command_line(context, argc, argv);
|
||||||
{
|
|
||||||
if (settings->ConnectionFile)
|
|
||||||
{
|
|
||||||
freerdp_client_parse_connection_file(context, settings->ConnectionFile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (settings->ListMonitors)
|
|
||||||
xf_list_monitors(xfc);
|
|
||||||
|
|
||||||
freerdp_client_context_free(context);
|
status = freerdp_client_command_line_status_print(argc, argv, settings, status);
|
||||||
return 0;
|
|
||||||
}
|
if (status)
|
||||||
|
{
|
||||||
|
if (settings->ListMonitors)
|
||||||
|
xf_list_monitors(xfc);
|
||||||
|
|
||||||
|
freerdp_client_context_free(context);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp_client_start(context);
|
freerdp_client_start(context);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "xf_channels.h"
|
#include "xf_channels.h"
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface)
|
int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface)
|
||||||
|
@ -480,6 +480,7 @@ void xf_create_window(xfContext* xfc)
|
|||||||
void xf_toggle_fullscreen(xfContext* xfc)
|
void xf_toggle_fullscreen(xfContext* xfc)
|
||||||
{
|
{
|
||||||
Pixmap contents = 0;
|
Pixmap contents = 0;
|
||||||
|
WindowStateChangeEventArgs e;
|
||||||
|
|
||||||
xf_lock_x11(xfc, TRUE);
|
xf_lock_x11(xfc, TRUE);
|
||||||
|
|
||||||
@ -495,8 +496,9 @@ void xf_toggle_fullscreen(xfContext* xfc)
|
|||||||
|
|
||||||
xf_unlock_x11(xfc, TRUE);
|
xf_unlock_x11(xfc, TRUE);
|
||||||
|
|
||||||
IFCALL(xfc->client->OnWindowStateChange, xfc->instance,
|
e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0;
|
||||||
xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0);
|
|
||||||
|
PubSub_OnEvent(((rdpContext*) xfc)->pubSub, "WindowStateChange", xfc, (wEventArgs*) &e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xf_lock_x11(xfContext* xfc, BOOL display)
|
void xf_lock_x11(xfContext* xfc, BOOL display)
|
||||||
@ -667,9 +669,6 @@ BOOL xf_pre_connect(freerdp* instance)
|
|||||||
instance->OnChannelConnected = xf_on_channel_connected;
|
instance->OnChannelConnected = xf_on_channel_connected;
|
||||||
instance->OnChannelDisconnected = xf_on_channel_disconnected;
|
instance->OnChannelDisconnected = xf_on_channel_disconnected;
|
||||||
|
|
||||||
//if (status < 0)
|
|
||||||
// exit(XF_EXIT_PARSE_ARGUMENTS);
|
|
||||||
|
|
||||||
freerdp_client_load_addins(channels, instance->settings);
|
freerdp_client_load_addins(channels, instance->settings);
|
||||||
|
|
||||||
freerdp_channels_pre_connect(channels, instance);
|
freerdp_channels_pre_connect(channels, instance);
|
||||||
@ -774,6 +773,7 @@ BOOL xf_post_connect(freerdp* instance)
|
|||||||
rdpCache* cache;
|
rdpCache* cache;
|
||||||
rdpChannels* channels;
|
rdpChannels* channels;
|
||||||
rdpSettings* settings;
|
rdpSettings* settings;
|
||||||
|
ResizeWindowEventArgs e;
|
||||||
RFX_CONTEXT* rfx_context = NULL;
|
RFX_CONTEXT* rfx_context = NULL;
|
||||||
NSC_CONTEXT* nsc_context = NULL;
|
NSC_CONTEXT* nsc_context = NULL;
|
||||||
xfContext* xfc = (xfContext*) instance->context;
|
xfContext* xfc = (xfContext*) instance->context;
|
||||||
@ -894,7 +894,10 @@ BOOL xf_post_connect(freerdp* instance)
|
|||||||
|
|
||||||
xf_cliprdr_init(xfc, channels);
|
xf_cliprdr_init(xfc, channels);
|
||||||
|
|
||||||
IFCALL(xfc->client->OnResizeWindow, instance, settings->DesktopWidth, settings->DesktopHeight);
|
e.width = settings->DesktopWidth;
|
||||||
|
e.height = settings->DesktopHeight;
|
||||||
|
|
||||||
|
PubSub_OnEvent(((rdpContext*) xfc)->pubSub, "ResizeWindow", xfc, (wEventArgs*) &e);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1550,11 +1553,6 @@ int xfreerdp_client_stop(rdpContext* context)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdpClient* freerdp_client_get_interface(rdpContext* context)
|
|
||||||
{
|
|
||||||
return context->client;
|
|
||||||
}
|
|
||||||
|
|
||||||
double freerdp_client_get_scale(rdpContext* context)
|
double freerdp_client_get_scale(rdpContext* context)
|
||||||
{
|
{
|
||||||
xfContext* xfc = (xfContext*) context;
|
xfContext* xfc = (xfContext*) context;
|
||||||
@ -1563,11 +1561,16 @@ double freerdp_client_get_scale(rdpContext* context)
|
|||||||
|
|
||||||
void freerdp_client_reset_scale(rdpContext* context)
|
void freerdp_client_reset_scale(rdpContext* context)
|
||||||
{
|
{
|
||||||
|
ResizeWindowEventArgs e;
|
||||||
xfContext* xfc = (xfContext*) context;
|
xfContext* xfc = (xfContext*) context;
|
||||||
|
|
||||||
xfc->scale = 1.0;
|
xfc->scale = 1.0;
|
||||||
XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
||||||
IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
|
||||||
|
e.width = (int) xfc->originalWidth * xfc->scale;
|
||||||
|
e.height = (int) xfc->originalHeight * xfc->scale;
|
||||||
|
PubSub_OnEvent(((rdpContext*) xfc)->pubSub, "ResizeWindow", xfc, (wEventArgs*) &e);
|
||||||
|
|
||||||
xf_draw_screen_scaled(xfc);
|
xf_draw_screen_scaled(xfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,7 +1591,6 @@ int xfreerdp_client_new(freerdp* instance, rdpContext* context)
|
|||||||
context->channels = freerdp_channels_new();
|
context->channels = freerdp_channels_new();
|
||||||
|
|
||||||
settings = instance->settings;
|
settings = instance->settings;
|
||||||
xfc->client = instance->context->client;
|
|
||||||
xfc->settings = instance->context->settings;
|
xfc->settings = instance->context->settings;
|
||||||
|
|
||||||
settings->OsMajorType = OSMAJORTYPE_UNIX;
|
settings->OsMajorType = OSMAJORTYPE_UNIX;
|
@ -17,11 +17,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XF_INTERFACE_H
|
#ifndef __XF_CLIENT_H
|
||||||
#define __XF_INTERFACE_H
|
#define __XF_CLIENT_H
|
||||||
|
|
||||||
#include <freerdp/api.h>
|
#include <freerdp/api.h>
|
||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
|
#include <freerdp/client.h>
|
||||||
|
|
||||||
#include <freerdp/gdi/gdi.h>
|
#include <freerdp/gdi/gdi.h>
|
||||||
#include <freerdp/gdi/dc.h>
|
#include <freerdp/gdi/dc.h>
|
||||||
@ -33,6 +34,7 @@
|
|||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
#include <winpr/synch.h>
|
#include <winpr/synch.h>
|
||||||
#include <winpr/thread.h>
|
#include <winpr/thread.h>
|
||||||
|
#include <winpr/collections.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -48,4 +50,4 @@ FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __XF_INTERFACE_H */
|
#endif /* __XF_CLIENT_H */
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __XF_CLIPRDR_H
|
#ifndef __XF_CLIPRDR_H
|
||||||
#define __XF_CLIPRDR_H
|
#define __XF_CLIPRDR_H
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
void xf_cliprdr_init(xfContext* xfc, rdpChannels* channels);
|
void xf_cliprdr_init(xfContext* xfc, rdpChannels* channels);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "xf_keyboard.h"
|
#include "xf_keyboard.h"
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
BOOL xf_event_process(freerdp* instance, XEvent* event);
|
BOOL xf_event_process(freerdp* instance, XEvent* event);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <freerdp/gdi/gdi.h>
|
#include <freerdp/gdi/gdi.h>
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
void xf_gdi_register_update_callbacks(rdpUpdate* update);
|
void xf_gdi_register_update_callbacks(rdpUpdate* update);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __XF_GRAPHICS_H
|
#ifndef __XF_GRAPHICS_H
|
||||||
#define __XF_GRAPHICS_H
|
#define __XF_GRAPHICS_H
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
void xf_register_graphics(rdpGraphics* graphics);
|
void xf_register_graphics(rdpGraphics* graphics);
|
||||||
|
@ -156,6 +156,7 @@ void xf_input_detect_pinch(xfContext* xfc)
|
|||||||
double dist;
|
double dist;
|
||||||
double zoom;
|
double zoom;
|
||||||
double delta;
|
double delta;
|
||||||
|
ResizeWindowEventArgs e;
|
||||||
|
|
||||||
if (active_contacts != 2)
|
if (active_contacts != 2)
|
||||||
{
|
{
|
||||||
@ -195,7 +196,10 @@ void xf_input_detect_pinch(xfContext* xfc)
|
|||||||
xfc->scale = 0.5;
|
xfc->scale = 0.5;
|
||||||
|
|
||||||
XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
||||||
IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
|
||||||
|
e.width = (int) xfc->originalWidth * xfc->scale;
|
||||||
|
e.height = (int) xfc->originalHeight * xfc->scale;
|
||||||
|
PubSub_OnEvent(((rdpContext*) xfc)->pubSub, "ResizeWindow", xfc, (wEventArgs*) &e);
|
||||||
|
|
||||||
z_vector = 0;
|
z_vector = 0;
|
||||||
}
|
}
|
||||||
@ -208,7 +212,10 @@ void xf_input_detect_pinch(xfContext* xfc)
|
|||||||
xfc->scale = 1.5;
|
xfc->scale = 1.5;
|
||||||
|
|
||||||
XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
XResizeWindow(xfc->display, xfc->window->handle, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
||||||
IFCALL(xfc->client->OnResizeWindow, xfc->instance, xfc->originalWidth * xfc->scale, xfc->originalHeight * xfc->scale);
|
|
||||||
|
e.width = (int) xfc->originalWidth * xfc->scale;
|
||||||
|
e.height = (int) xfc->originalHeight * xfc->scale;
|
||||||
|
PubSub_OnEvent(((rdpContext*) xfc)->pubSub, "ResizeWindow", xfc, (wEventArgs*) &e);
|
||||||
|
|
||||||
z_vector = 0;
|
z_vector = 0;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __XF_INPUT_H
|
#ifndef __XF_INPUT_H
|
||||||
#define __XF_INPUT_H
|
#define __XF_INPUT_H
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
#ifdef WITH_XI
|
#ifdef WITH_XI
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <freerdp/locale/keyboard.h>
|
#include <freerdp/locale/keyboard.h>
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
void xf_kbd_init(xfContext* xfc);
|
void xf_kbd_init(xfContext* xfc);
|
||||||
|
@ -40,7 +40,7 @@ struct _VIRTUAL_SCREEN
|
|||||||
};
|
};
|
||||||
typedef struct _VIRTUAL_SCREEN VIRTUAL_SCREEN;
|
typedef struct _VIRTUAL_SCREEN VIRTUAL_SCREEN;
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
int xf_list_monitors(xfContext* xfc);
|
int xf_list_monitors(xfContext* xfc);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __XF_RAIL_H
|
#ifndef __XF_RAIL_H
|
||||||
#define __XF_RAIL_H
|
#define __XF_RAIL_H
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
void xf_rail_paint(xfContext* xfc, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom);
|
void xf_rail_paint(xfContext* xfc, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __XF_TSMF_H
|
#ifndef __XF_TSMF_H
|
||||||
#define __XF_TSMF_H
|
#define __XF_TSMF_H
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
void xf_tsmf_init(xfContext* xfc, long xv_port);
|
void xf_tsmf_init(xfContext* xfc, long xv_port);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
typedef struct xf_localmove xfLocalMove;
|
typedef struct xf_localmove xfLocalMove;
|
||||||
typedef struct xf_window xfWindow;
|
typedef struct xf_window xfWindow;
|
||||||
|
|
||||||
#include "xf_interface.h"
|
#include "xf_client.h"
|
||||||
#include "xfreerdp.h"
|
#include "xfreerdp.h"
|
||||||
|
|
||||||
// Extended ICCM flags http://standards.freedesktop.org/wm-spec/wm-spec-latest.html
|
// Extended ICCM flags http://standards.freedesktop.org/wm-spec/wm-spec-latest.html
|
||||||
|
@ -62,7 +62,6 @@ struct xf_context
|
|||||||
DEFINE_RDP_CLIENT_COMMON();
|
DEFINE_RDP_CLIENT_COMMON();
|
||||||
|
|
||||||
freerdp* instance;
|
freerdp* instance;
|
||||||
rdpClient* client;
|
|
||||||
rdpSettings* settings;
|
rdpSettings* settings;
|
||||||
|
|
||||||
GC gc;
|
GC gc;
|
||||||
|
@ -26,6 +26,18 @@
|
|||||||
#include <freerdp/client/file.h>
|
#include <freerdp/client/file.h>
|
||||||
#include <freerdp/client/cmdline.h>
|
#include <freerdp/client/cmdline.h>
|
||||||
|
|
||||||
|
int freerdp_client_common_new(freerdp* instance, rdpContext* context)
|
||||||
|
{
|
||||||
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints = instance->pClientEntryPoints;
|
||||||
|
return pEntryPoints->ClientNew(instance, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void freerdp_client_common_free(freerdp* instance, rdpContext* context)
|
||||||
|
{
|
||||||
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints = instance->pClientEntryPoints;
|
||||||
|
pEntryPoints->ClientFree(instance, context);
|
||||||
|
}
|
||||||
|
|
||||||
/* Common API */
|
/* Common API */
|
||||||
|
|
||||||
rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
||||||
@ -37,15 +49,14 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
|||||||
|
|
||||||
instance = freerdp_new();
|
instance = freerdp_new();
|
||||||
instance->ContextSize = pEntryPoints->ContextSize;
|
instance->ContextSize = pEntryPoints->ContextSize;
|
||||||
instance->ContextNew = pEntryPoints->ClientNew;
|
instance->ContextNew = freerdp_client_common_new;
|
||||||
instance->ContextFree = pEntryPoints->ClientFree;
|
instance->ContextFree = freerdp_client_common_free;
|
||||||
|
instance->pClientEntryPoints = (RDP_CLIENT_ENTRY_POINTS*) malloc(pEntryPoints->Size);
|
||||||
|
CopyMemory(instance->pClientEntryPoints, pEntryPoints, pEntryPoints->Size);
|
||||||
freerdp_context_new(instance);
|
freerdp_context_new(instance);
|
||||||
|
|
||||||
context = instance->context;
|
context = instance->context;
|
||||||
|
|
||||||
context->client->pEntryPoints = (RDP_CLIENT_ENTRY_POINTS*) malloc(pEntryPoints->Size);
|
|
||||||
CopyMemory(context->client->pEntryPoints, pEntryPoints, pEntryPoints->Size);
|
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,14 +70,14 @@ void freerdp_client_context_free(rdpContext* context)
|
|||||||
|
|
||||||
int freerdp_client_start(rdpContext* context)
|
int freerdp_client_start(rdpContext* context)
|
||||||
{
|
{
|
||||||
rdpClient* client = context->client;
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints = context->instance->pClientEntryPoints;
|
||||||
return client->pEntryPoints->ClientStart(context);
|
return pEntryPoints->ClientStart(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
int freerdp_client_stop(rdpContext* context)
|
int freerdp_client_stop(rdpContext* context)
|
||||||
{
|
{
|
||||||
rdpClient* client = context->client;
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints = context->instance->pClientEntryPoints;
|
||||||
return client->pEntryPoints->ClientStop(context);
|
return pEntryPoints->ClientStop(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp* freerdp_client_get_instance(rdpContext* context)
|
freerdp* freerdp_client_get_instance(rdpContext* context)
|
||||||
|
@ -949,32 +949,10 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
|
|||||||
return compatibility;
|
return compatibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings)
|
int freerdp_client_command_line_status_print(int argc, char** argv, rdpSettings* settings, int status)
|
||||||
{
|
{
|
||||||
char* p;
|
|
||||||
char* str;
|
|
||||||
int length;
|
|
||||||
int status;
|
|
||||||
DWORD flags;
|
|
||||||
BOOL compatibility;
|
|
||||||
COMMAND_LINE_ARGUMENT_A* arg;
|
COMMAND_LINE_ARGUMENT_A* arg;
|
||||||
|
|
||||||
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0);
|
|
||||||
|
|
||||||
compatibility = freerdp_client_detect_command_line(argc, argv, &flags);
|
|
||||||
|
|
||||||
if (compatibility)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "WARNING: Using deprecated command-line interface!\n");
|
|
||||||
return freerdp_client_parse_old_command_line_arguments(argc, argv, settings);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CommandLineClearArgumentsA(args);
|
|
||||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
|
|
||||||
freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == COMMAND_LINE_STATUS_PRINT_HELP)
|
if (status == COMMAND_LINE_STATUS_PRINT_HELP)
|
||||||
{
|
{
|
||||||
freerdp_client_print_command_line_help(argc, argv);
|
freerdp_client_print_command_line_help(argc, argv);
|
||||||
@ -1025,13 +1003,36 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
|
|||||||
return COMMAND_LINE_STATUS_PRINT;
|
return COMMAND_LINE_STATUS_PRINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
arg = CommandLineFindArgumentA(args, "v");
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!settings->ConnectionFile && !(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
|
int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings)
|
||||||
|
{
|
||||||
|
char* p;
|
||||||
|
char* str;
|
||||||
|
int length;
|
||||||
|
int status;
|
||||||
|
DWORD flags;
|
||||||
|
BOOL compatibility;
|
||||||
|
COMMAND_LINE_ARGUMENT_A* arg;
|
||||||
|
|
||||||
|
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0);
|
||||||
|
|
||||||
|
compatibility = freerdp_client_detect_command_line(argc, argv, &flags);
|
||||||
|
|
||||||
|
if (compatibility)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "error: server hostname was not specified with /v:<server>[:port]\n");
|
fprintf(stderr, "WARNING: Using deprecated command-line interface!\n");
|
||||||
//return COMMAND_LINE_ERROR_MISSING_ARGUMENT;
|
return freerdp_client_parse_old_command_line_arguments(argc, argv, settings);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CommandLineClearArgumentsA(args);
|
||||||
|
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
|
||||||
|
freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
arg = CommandLineFindArgumentA(args, "v");
|
||||||
|
|
||||||
arg = args;
|
arg = args;
|
||||||
|
|
||||||
|
@ -55,37 +55,14 @@ struct rdp_client_entry_points_v1
|
|||||||
pRdpClientStart ClientStart;
|
pRdpClientStart ClientStart;
|
||||||
pRdpClientStop ClientStop;
|
pRdpClientStop ClientStop;
|
||||||
};
|
};
|
||||||
typedef struct rdp_client_entry_points_v1 RDP_CLIENT_ENTRY_POINTS_V1;
|
|
||||||
|
|
||||||
#define RDP_CLIENT_INTERFACE_VERSION 1
|
#define RDP_CLIENT_INTERFACE_VERSION 1
|
||||||
#define RDP_CLIENT_ENTRY_POINT_NAME "RdpClientEntry"
|
#define RDP_CLIENT_ENTRY_POINT_NAME "RdpClientEntry"
|
||||||
typedef RDP_CLIENT_ENTRY_POINTS_V1 RDP_CLIENT_ENTRY_POINTS;
|
|
||||||
|
|
||||||
typedef int (*pRdpClientEntry)(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
|
typedef int (*pRdpClientEntry)(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
|
||||||
|
|
||||||
/* Common Client Interface */
|
/* Common Client Interface */
|
||||||
|
|
||||||
#define FREERDP_WINDOW_STATE_NORMAL 0
|
|
||||||
#define FREERDP_WINDOW_STATE_MINIMIZED 1
|
|
||||||
#define FREERDP_WINDOW_STATE_MAXIMIZED 2
|
|
||||||
#define FREERDP_WINDOW_STATE_FULLSCREEN 3
|
|
||||||
#define FREERDP_WINDOW_STATE_ACTIVE 4
|
|
||||||
|
|
||||||
typedef void (*pOnResizeWindow)(freerdp* instance, int width, int height);
|
|
||||||
typedef void (*pOnWindowStateChange)(freerdp* instance, int state);
|
|
||||||
typedef void (*pOnErrorInfo)(freerdp* instance, UINT32 code);
|
|
||||||
typedef void (*pOnParamChange)(freerdp* instance, int id);
|
|
||||||
|
|
||||||
struct rdp_client
|
|
||||||
{
|
|
||||||
RDP_CLIENT_ENTRY_POINTS* pEntryPoints;
|
|
||||||
|
|
||||||
pOnResizeWindow OnResizeWindow;
|
|
||||||
pOnWindowStateChange OnWindowStateChange;
|
|
||||||
pOnErrorInfo OnErrorInfo;
|
|
||||||
pOnParamChange OnParamChange;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DEFINE_RDP_CLIENT_COMMON() \
|
#define DEFINE_RDP_CLIENT_COMMON() \
|
||||||
HANDLE thread
|
HANDLE thread
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings);
|
FREERDP_API int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings);
|
||||||
|
FREERDP_API int freerdp_client_command_line_status_print(int argc, char** argv, rdpSettings* settings, int status);
|
||||||
FREERDP_API int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings);
|
FREERDP_API int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings);
|
||||||
|
|
||||||
FREERDP_API int freerdp_client_print_version(void);
|
FREERDP_API int freerdp_client_print_version(void);
|
||||||
|
57
include/freerdp/event.h
Normal file
57
include/freerdp/event.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||||
|
* Event Definitions
|
||||||
|
*
|
||||||
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FREERDP_EVENT_H
|
||||||
|
#define FREERDP_EVENT_H
|
||||||
|
|
||||||
|
#include <freerdp/api.h>
|
||||||
|
#include <freerdp/freerdp.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FREERDP_WINDOW_STATE_NORMAL 0
|
||||||
|
#define FREERDP_WINDOW_STATE_MINIMIZED 1
|
||||||
|
#define FREERDP_WINDOW_STATE_MAXIMIZED 2
|
||||||
|
#define FREERDP_WINDOW_STATE_FULLSCREEN 3
|
||||||
|
#define FREERDP_WINDOW_STATE_ACTIVE 4
|
||||||
|
|
||||||
|
DEFINE_EVENT_BEGIN(WindowStateChange)
|
||||||
|
int state;
|
||||||
|
DEFINE_EVENT_END(WindowStateChange)
|
||||||
|
|
||||||
|
DEFINE_EVENT_BEGIN(ResizeWindow)
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
DEFINE_EVENT_END(ResizeWindow)
|
||||||
|
|
||||||
|
DEFINE_EVENT_BEGIN(ErrorInfo)
|
||||||
|
UINT32 code;
|
||||||
|
DEFINE_EVENT_END(ErrorInfo)
|
||||||
|
|
||||||
|
DEFINE_EVENT_BEGIN(ParamChange)
|
||||||
|
int id;
|
||||||
|
DEFINE_EVENT_END(ParamChange)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* FREERDP_EVENT_H */
|
@ -26,16 +26,19 @@ typedef struct rdp_rail rdpRail;
|
|||||||
typedef struct rdp_cache rdpCache;
|
typedef struct rdp_cache rdpCache;
|
||||||
typedef struct rdp_channels rdpChannels;
|
typedef struct rdp_channels rdpChannels;
|
||||||
typedef struct rdp_graphics rdpGraphics;
|
typedef struct rdp_graphics rdpGraphics;
|
||||||
typedef struct rdp_client rdpClient;
|
|
||||||
|
|
||||||
typedef struct rdp_freerdp freerdp;
|
typedef struct rdp_freerdp freerdp;
|
||||||
typedef struct rdp_context rdpContext;
|
typedef struct rdp_context rdpContext;
|
||||||
typedef struct rdp_freerdp_peer freerdp_peer;
|
typedef struct rdp_freerdp_peer freerdp_peer;
|
||||||
|
|
||||||
typedef struct rdp_client_context rdpClientContext;
|
typedef struct rdp_client_context rdpClientContext;
|
||||||
|
typedef struct rdp_client_entry_points_v1 RDP_CLIENT_ENTRY_POINTS_V1;
|
||||||
|
typedef RDP_CLIENT_ENTRY_POINTS_V1 RDP_CLIENT_ENTRY_POINTS;
|
||||||
|
|
||||||
#include <freerdp/api.h>
|
#include <freerdp/api.h>
|
||||||
#include <freerdp/types.h>
|
#include <freerdp/types.h>
|
||||||
#include <freerdp/error.h>
|
#include <freerdp/error.h>
|
||||||
|
#include <freerdp/event.h>
|
||||||
#include <freerdp/settings.h>
|
#include <freerdp/settings.h>
|
||||||
#include <freerdp/extension.h>
|
#include <freerdp/extension.h>
|
||||||
|
|
||||||
@ -92,7 +95,9 @@ struct rdp_context
|
|||||||
Used to keep this data available and used later on, typically just before connection initialization.
|
Used to keep this data available and used later on, typically just before connection initialization.
|
||||||
@see freerdp_parse_args() */
|
@see freerdp_parse_args() */
|
||||||
|
|
||||||
UINT64 paddingB[32 - 18]; /* 18 */
|
ALIGN64 wPubSub* pubSub; /* (offset 18) */
|
||||||
|
|
||||||
|
UINT64 paddingB[32 - 19]; /* 19 */
|
||||||
|
|
||||||
ALIGN64 rdpRdp* rdp; /**< (offset 32)
|
ALIGN64 rdpRdp* rdp; /**< (offset 32)
|
||||||
Pointer to a rdp_rdp structure used to keep the connection's parameters.
|
Pointer to a rdp_rdp structure used to keep the connection's parameters.
|
||||||
@ -109,8 +114,7 @@ struct rdp_context
|
|||||||
ALIGN64 rdpInput* input; /* 38 */
|
ALIGN64 rdpInput* input; /* 38 */
|
||||||
ALIGN64 rdpUpdate* update; /* 39 */
|
ALIGN64 rdpUpdate* update; /* 39 */
|
||||||
ALIGN64 rdpSettings* settings; /* 40 */
|
ALIGN64 rdpSettings* settings; /* 40 */
|
||||||
ALIGN64 rdpClient* client; /* 41 */
|
UINT64 paddingC[64 - 41]; /* 41 */
|
||||||
UINT64 paddingC[64 - 42]; /* 42 */
|
|
||||||
|
|
||||||
UINT64 paddingD[96 - 64]; /* 64 */
|
UINT64 paddingD[96 - 64]; /* 64 */
|
||||||
UINT64 paddingE[128 - 96]; /* 96 */
|
UINT64 paddingE[128 - 96]; /* 96 */
|
||||||
@ -135,7 +139,9 @@ struct rdp_freerdp
|
|||||||
Can be allocated by a call to freerdp_context_new().
|
Can be allocated by a call to freerdp_context_new().
|
||||||
Must be deallocated by a call to freerdp_context_free() before deallocating the current instance. */
|
Must be deallocated by a call to freerdp_context_free() before deallocating the current instance. */
|
||||||
|
|
||||||
UINT64 paddingA[16 - 1]; /* 1 */
|
ALIGN64 RDP_CLIENT_ENTRY_POINTS* pClientEntryPoints;
|
||||||
|
|
||||||
|
UINT64 paddingA[16 - 2]; /* 2 */
|
||||||
|
|
||||||
ALIGN64 rdpInput* input; /* (offset 16)
|
ALIGN64 rdpInput* input; /* (offset 16)
|
||||||
Input handle for the connection.
|
Input handle for the connection.
|
||||||
|
@ -744,6 +744,9 @@ BOOL freerdp_get_param_bool(rdpSettings* settings, int id)
|
|||||||
|
|
||||||
int freerdp_set_param_bool(rdpSettings* settings, int id, BOOL param)
|
int freerdp_set_param_bool(rdpSettings* settings, int id, BOOL param)
|
||||||
{
|
{
|
||||||
|
ParamChangeEventArgs e;
|
||||||
|
rdpContext* context = ((freerdp*) settings->instance)->context;
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case FreeRDP_ServerMode:
|
case FreeRDP_ServerMode:
|
||||||
@ -1185,7 +1188,9 @@ int freerdp_set_param_bool(rdpSettings* settings, int id, BOOL param)
|
|||||||
|
|
||||||
// Mark field as modified
|
// Mark field as modified
|
||||||
settings->settings_modified[id] = 1;
|
settings->settings_modified[id] = 1;
|
||||||
IFCALL(((freerdp*) settings->instance)->context->client->OnParamChange, ((freerdp*) settings->instance), id);
|
|
||||||
|
e.id = id;
|
||||||
|
PubSub_OnEvent(context->pubSub, "ParamChange", context->instance, (wEventArgs*) &e);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1508,6 +1513,9 @@ UINT32 freerdp_get_param_uint32(rdpSettings* settings, int id)
|
|||||||
|
|
||||||
int freerdp_set_param_uint32(rdpSettings* settings, int id, UINT32 param)
|
int freerdp_set_param_uint32(rdpSettings* settings, int id, UINT32 param)
|
||||||
{
|
{
|
||||||
|
ParamChangeEventArgs e;
|
||||||
|
rdpContext* context = ((freerdp*) settings->instance)->context;
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case FreeRDP_ShareId:
|
case FreeRDP_ShareId:
|
||||||
@ -1821,7 +1829,9 @@ int freerdp_set_param_uint32(rdpSettings* settings, int id, UINT32 param)
|
|||||||
|
|
||||||
// Mark field as modified
|
// Mark field as modified
|
||||||
settings->settings_modified[id] = 1;
|
settings->settings_modified[id] = 1;
|
||||||
IFCALL(((freerdp*) settings->instance)->context->client->OnParamChange, ((freerdp*) settings->instance), id);
|
|
||||||
|
e.id = id;
|
||||||
|
PubSub_OnEvent(context->pubSub, "ParamChange", context->instance, (wEventArgs*) &e);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1844,6 +1854,9 @@ UINT64 freerdp_get_param_uint64(rdpSettings* settings, int id)
|
|||||||
|
|
||||||
int freerdp_set_param_uint64(rdpSettings* settings, int id, UINT64 param)
|
int freerdp_set_param_uint64(rdpSettings* settings, int id, UINT64 param)
|
||||||
{
|
{
|
||||||
|
ParamChangeEventArgs e;
|
||||||
|
rdpContext* context = ((freerdp*) settings->instance)->context;
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case FreeRDP_ParentWindowId:
|
case FreeRDP_ParentWindowId:
|
||||||
@ -1857,7 +1870,9 @@ int freerdp_set_param_uint64(rdpSettings* settings, int id, UINT64 param)
|
|||||||
|
|
||||||
// Mark field as modified
|
// Mark field as modified
|
||||||
settings->settings_modified[id] = 1;
|
settings->settings_modified[id] = 1;
|
||||||
IFCALL(((freerdp*) settings->instance)->context->client->OnParamChange, ((freerdp*) settings->instance), id);
|
|
||||||
|
e.id = id;
|
||||||
|
PubSub_OnEvent(context->pubSub, "ParamChange", context->instance, (wEventArgs*) &e);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2028,6 +2043,9 @@ char* freerdp_get_param_string(rdpSettings* settings, int id)
|
|||||||
|
|
||||||
int freerdp_set_param_string(rdpSettings* settings, int id, char* param)
|
int freerdp_set_param_string(rdpSettings* settings, int id, char* param)
|
||||||
{
|
{
|
||||||
|
ParamChangeEventArgs e;
|
||||||
|
rdpContext* context = ((freerdp*) settings->instance)->context;
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case FreeRDP_ServerHostname:
|
case FreeRDP_ServerHostname:
|
||||||
@ -2189,7 +2207,9 @@ int freerdp_set_param_string(rdpSettings* settings, int id, char* param)
|
|||||||
|
|
||||||
// Mark field as modified
|
// Mark field as modified
|
||||||
settings->settings_modified[id] = 1;
|
settings->settings_modified[id] = 1;
|
||||||
IFCALL(((freerdp*) settings->instance)->context->client->OnParamChange, ((freerdp*) settings->instance), id);
|
|
||||||
|
e.id = id;
|
||||||
|
PubSub_OnEvent(context->pubSub, "ParamChange", context->instance, (wEventArgs*) &e);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -308,6 +308,14 @@ void freerdp_get_version(int* major, int* minor, int* revision)
|
|||||||
*revision = FREERDP_VERSION_REVISION;
|
*revision = FREERDP_VERSION_REVISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static wEvent FreeRDP_Events[] =
|
||||||
|
{
|
||||||
|
DEFINE_EVENT_ENTRY(WindowStateChange)
|
||||||
|
DEFINE_EVENT_ENTRY(ResizeWindow)
|
||||||
|
DEFINE_EVENT_ENTRY(ErrorInfo)
|
||||||
|
DEFINE_EVENT_ENTRY(ParamChange)
|
||||||
|
};
|
||||||
|
|
||||||
/** Allocator function for a rdp context.
|
/** Allocator function for a rdp context.
|
||||||
* The function will allocate a rdpRdp structure using rdp_new(), then copy
|
* The function will allocate a rdpRdp structure using rdp_new(), then copy
|
||||||
* its contents to the appropriate fields in the rdp_freerdp structure given in parameters.
|
* its contents to the appropriate fields in the rdp_freerdp structure given in parameters.
|
||||||
@ -339,8 +347,8 @@ int freerdp_context_new(freerdp* instance)
|
|||||||
context->update = instance->update;
|
context->update = instance->update;
|
||||||
context->settings = instance->settings;
|
context->settings = instance->settings;
|
||||||
|
|
||||||
context->client = (rdpClient*) malloc(sizeof(rdpClient));
|
context->pubSub = PubSub_New(TRUE);
|
||||||
ZeroMemory(context->client, sizeof(rdpClient));
|
PubSub_Publish(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEvent));
|
||||||
|
|
||||||
instance->update->context = instance->context;
|
instance->update->context = instance->context;
|
||||||
instance->update->pointer->context = instance->context;
|
instance->update->pointer->context = instance->context;
|
||||||
@ -375,11 +383,7 @@ void freerdp_context_free(freerdp* instance)
|
|||||||
rdp_free(instance->context->rdp);
|
rdp_free(instance->context->rdp);
|
||||||
graphics_free(instance->context->graphics);
|
graphics_free(instance->context->graphics);
|
||||||
|
|
||||||
if (instance->context->client)
|
PubSub_Free(instance->context->pubSub);
|
||||||
{
|
|
||||||
free(instance->context->client->pEntryPoints);
|
|
||||||
free(instance->context->client);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(instance->context);
|
free(instance->context);
|
||||||
instance->context = NULL;
|
instance->context = NULL;
|
||||||
|
@ -502,11 +502,13 @@ BOOL rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, wStream* s)
|
|||||||
|
|
||||||
if (rdp->errorInfo != ERRINFO_SUCCESS)
|
if (rdp->errorInfo != ERRINFO_SUCCESS)
|
||||||
{
|
{
|
||||||
rdpClient* client = rdp->instance->context->client;
|
ErrorInfoEventArgs e;
|
||||||
|
rdpContext* context = rdp->instance->context;
|
||||||
|
|
||||||
rdp_print_errinfo(rdp->errorInfo);
|
rdp_print_errinfo(rdp->errorInfo);
|
||||||
|
|
||||||
IFCALL(client->OnErrorInfo, rdp->instance, rdp->errorInfo);
|
e.code = rdp->errorInfo;
|
||||||
|
PubSub_OnEvent(context->pubSub, "ErrorInfo", context, (wEventArgs*) &e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -339,6 +339,72 @@ WINPR_API void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode);
|
|||||||
WINPR_API wMessagePipe* MessagePipe_New(void);
|
WINPR_API wMessagePipe* MessagePipe_New(void);
|
||||||
WINPR_API void MessagePipe_Free(wMessagePipe* pipe);
|
WINPR_API void MessagePipe_Free(wMessagePipe* pipe);
|
||||||
|
|
||||||
|
/* Publisher/Subscriber Pattern */
|
||||||
|
|
||||||
|
struct _wEventArgs
|
||||||
|
{
|
||||||
|
DWORD size;
|
||||||
|
};
|
||||||
|
typedef struct _wEventArgs wEventArgs;
|
||||||
|
|
||||||
|
typedef void (*pEventHandler)(void* context, wEventArgs* e);
|
||||||
|
|
||||||
|
#define MAX_EVENT_HANDLERS 32
|
||||||
|
|
||||||
|
struct _wEvent
|
||||||
|
{
|
||||||
|
const char* EventName;
|
||||||
|
wEventArgs EventArgs;
|
||||||
|
int EventHandlerCount;
|
||||||
|
pEventHandler EventHandlers[MAX_EVENT_HANDLERS];
|
||||||
|
};
|
||||||
|
typedef struct _wEvent wEvent;
|
||||||
|
|
||||||
|
#define DEFINE_EVENT_HANDLER(_name) \
|
||||||
|
typedef void (*p ## _name ## EventHandler)(void* context, _name ## EventArgs* e)
|
||||||
|
|
||||||
|
#define DEFINE_EVENT_BEGIN(_name) \
|
||||||
|
typedef struct _ ## _name ## EventArgs { \
|
||||||
|
wEventArgs e;
|
||||||
|
|
||||||
|
#define DEFINE_EVENT_END(_name) \
|
||||||
|
} _name ## EventArgs; \
|
||||||
|
DEFINE_EVENT_HANDLER(_name);
|
||||||
|
|
||||||
|
#define DEFINE_EVENT_ENTRY(_name) \
|
||||||
|
{ #_name, { sizeof( _name ## EventArgs) }, 0, { \
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } },
|
||||||
|
|
||||||
|
struct _wPubSub
|
||||||
|
{
|
||||||
|
HANDLE mutex;
|
||||||
|
BOOL synchronized;
|
||||||
|
|
||||||
|
int size;
|
||||||
|
int count;
|
||||||
|
wEvent* events;
|
||||||
|
};
|
||||||
|
typedef struct _wPubSub wPubSub;
|
||||||
|
|
||||||
|
WINPR_API BOOL PubSub_Lock(wPubSub* pubSub);
|
||||||
|
WINPR_API BOOL PubSub_Unlock(wPubSub* pubSub);
|
||||||
|
|
||||||
|
WINPR_API wEvent* PubSub_Events(wPubSub* pubSub, int* count);
|
||||||
|
WINPR_API wEvent* PubSub_FindEvent(wPubSub* pubSub, const char* EventName);
|
||||||
|
|
||||||
|
WINPR_API void PubSub_Publish(wPubSub* pubSub, wEvent* events, int count);
|
||||||
|
|
||||||
|
WINPR_API int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler);
|
||||||
|
WINPR_API int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler);
|
||||||
|
|
||||||
|
WINPR_API int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, wEventArgs* e);
|
||||||
|
|
||||||
|
WINPR_API wPubSub* PubSub_New(BOOL synchronized);
|
||||||
|
WINPR_API void PubSub_Free(wPubSub* pubSub);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define HANDLE_TYPE_ANONYMOUS_PIPE 7
|
#define HANDLE_TYPE_ANONYMOUS_PIPE 7
|
||||||
|
|
||||||
#define WINPR_HANDLE_DEF() \
|
#define WINPR_HANDLE_DEF() \
|
||||||
ULONG Type;
|
ULONG Type
|
||||||
|
|
||||||
struct winpr_handle
|
struct winpr_handle
|
||||||
{
|
{
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
|
|
||||||
BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
|
BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
|
||||||
{
|
{
|
||||||
void* ptr;
|
|
||||||
HANDLE handle;
|
|
||||||
int pipe_fd[2];
|
int pipe_fd[2];
|
||||||
WINPR_PIPE* pReadPipe;
|
WINPR_PIPE* pReadPipe;
|
||||||
WINPR_PIPE* pWritePipe;
|
WINPR_PIPE* pWritePipe;
|
||||||
|
@ -21,6 +21,7 @@ set(MODULE_PREFIX "WINPR_UTILS")
|
|||||||
set(${MODULE_PREFIX}_COLLECTIONS_SRCS
|
set(${MODULE_PREFIX}_COLLECTIONS_SRCS
|
||||||
collections/Queue.c
|
collections/Queue.c
|
||||||
collections/Stack.c
|
collections/Stack.c
|
||||||
|
collections/PubSub.c
|
||||||
collections/Reference.c
|
collections/Reference.c
|
||||||
collections/ArrayList.c
|
collections/ArrayList.c
|
||||||
collections/Dictionary.c
|
collections/Dictionary.c
|
||||||
|
@ -49,6 +49,7 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter, COMMAND_LINE_POST_FILTER_FN_A postFilter)
|
void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter, COMMAND_LINE_POST_FILTER_FN_A postFilter)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
int status;
|
||||||
int count;
|
int count;
|
||||||
int length;
|
int length;
|
||||||
int index;
|
int index;
|
||||||
@ -67,11 +68,16 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
int value_index;
|
int value_index;
|
||||||
int toggle;
|
int toggle;
|
||||||
|
|
||||||
|
status = 0;
|
||||||
|
|
||||||
if (!argv)
|
if (!argv)
|
||||||
return 0;
|
return status;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
return COMMAND_LINE_STATUS_PRINT_HELP;
|
{
|
||||||
|
status = COMMAND_LINE_STATUS_PRINT_HELP;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
@ -82,7 +88,10 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
count = preFilter(context, i, argc, argv);
|
count = preFilter(context, i, argc, argv);
|
||||||
|
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return COMMAND_LINE_ERROR;
|
{
|
||||||
|
status = COMMAND_LINE_ERROR;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
@ -257,7 +266,10 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!value && (options[j].Flags & COMMAND_LINE_VALUE_REQUIRED))
|
if (!value && (options[j].Flags & COMMAND_LINE_VALUE_REQUIRED))
|
||||||
return COMMAND_LINE_ERROR_MISSING_VALUE;
|
{
|
||||||
|
status = COMMAND_LINE_ERROR_MISSING_VALUE;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
options[j].Flags |= COMMAND_LINE_ARGUMENT_PRESENT;
|
options[j].Flags |= COMMAND_LINE_ARGUMENT_PRESENT;
|
||||||
|
|
||||||
@ -311,7 +323,7 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CommandLineParseArgumentsW(int argc, LPCWSTR* argv, COMMAND_LINE_ARGUMENT_W* options, DWORD flags,
|
int CommandLineParseArgumentsW(int argc, LPCWSTR* argv, COMMAND_LINE_ARGUMENT_W* options, DWORD flags,
|
||||||
|
224
winpr/libwinpr/utils/collections/PubSub.c
Normal file
224
winpr/libwinpr/utils/collections/PubSub.c
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
/**
|
||||||
|
* WinPR: Windows Portable Runtime
|
||||||
|
* Publisher/Subscriber Pattern
|
||||||
|
*
|
||||||
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <winpr/crt.h>
|
||||||
|
|
||||||
|
#include <winpr/collections.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties
|
||||||
|
*/
|
||||||
|
|
||||||
|
wEvent* PubSub_Events(wPubSub* pubSub, int* count)
|
||||||
|
{
|
||||||
|
if (count)
|
||||||
|
*count = pubSub->count;
|
||||||
|
|
||||||
|
return pubSub->events;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
BOOL PubSub_Lock(wPubSub* pubSub)
|
||||||
|
{
|
||||||
|
return (WaitForSingleObject(pubSub->mutex, INFINITE) == WAIT_OBJECT_0) ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL PubSub_Unlock(wPubSub* pubSub)
|
||||||
|
{
|
||||||
|
return ReleaseMutex(pubSub->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
wEvent* PubSub_FindEvent(wPubSub* pubSub, const char* EventName)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
wEvent* event = NULL;
|
||||||
|
|
||||||
|
for (index = 0; pubSub->count; index++)
|
||||||
|
{
|
||||||
|
if (strcmp(pubSub->events[index].EventName, EventName) == 0)
|
||||||
|
{
|
||||||
|
event = &(pubSub->events[index]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PubSub_Publish(wPubSub* pubSub, wEvent* events, int count)
|
||||||
|
{
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Lock(pubSub);
|
||||||
|
|
||||||
|
while (pubSub->count + count >= pubSub->size)
|
||||||
|
{
|
||||||
|
pubSub->size *= 2;
|
||||||
|
pubSub->events = (wEvent*) realloc(pubSub->events, pubSub->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyMemory(&pubSub->events[pubSub->count], events, count * sizeof(wEvent));
|
||||||
|
pubSub->count += count;
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Unlock(pubSub);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler)
|
||||||
|
{
|
||||||
|
wEvent* event;
|
||||||
|
int status = -1;
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Lock(pubSub);
|
||||||
|
|
||||||
|
event = PubSub_FindEvent(pubSub, EventName);
|
||||||
|
|
||||||
|
if (event)
|
||||||
|
{
|
||||||
|
status = 0;
|
||||||
|
|
||||||
|
if (event->EventHandlerCount <= MAX_EVENT_HANDLERS)
|
||||||
|
{
|
||||||
|
event->EventHandlers[event->EventHandlerCount] = EventHandler;
|
||||||
|
event->EventHandlerCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Unlock(pubSub);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
wEvent* event;
|
||||||
|
int status = -1;
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Lock(pubSub);
|
||||||
|
|
||||||
|
event = PubSub_FindEvent(pubSub, EventName);
|
||||||
|
|
||||||
|
if (event)
|
||||||
|
{
|
||||||
|
status = 0;
|
||||||
|
|
||||||
|
for (index = 0; index < event->EventHandlerCount; index++)
|
||||||
|
{
|
||||||
|
if (event->EventHandlers[index] == EventHandler)
|
||||||
|
{
|
||||||
|
event->EventHandlers[index] = NULL;
|
||||||
|
event->EventHandlerCount--;
|
||||||
|
MoveMemory(&event->EventHandlers[index], &event->EventHandlers[index + 1],
|
||||||
|
(MAX_EVENT_HANDLERS - index - 1) * sizeof(wEvent));
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Unlock(pubSub);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, wEventArgs* e)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
wEvent* event;
|
||||||
|
int status = -1;
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Lock(pubSub);
|
||||||
|
|
||||||
|
event = PubSub_FindEvent(pubSub, EventName);
|
||||||
|
|
||||||
|
if (event)
|
||||||
|
{
|
||||||
|
status = 0;
|
||||||
|
|
||||||
|
for (index = 0; index < event->EventHandlerCount; index++)
|
||||||
|
{
|
||||||
|
if (event->EventHandlers[index])
|
||||||
|
{
|
||||||
|
event->EventHandlers[index](context, e);
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
PubSub_Unlock(pubSub);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construction, Destruction
|
||||||
|
*/
|
||||||
|
|
||||||
|
wPubSub* PubSub_New(BOOL synchronized)
|
||||||
|
{
|
||||||
|
wPubSub* pubSub = NULL;
|
||||||
|
|
||||||
|
pubSub = (wPubSub*) malloc(sizeof(wPubSub));
|
||||||
|
|
||||||
|
if (pubSub)
|
||||||
|
{
|
||||||
|
pubSub->synchronized = synchronized;
|
||||||
|
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
pubSub->mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
|
||||||
|
pubSub->count = 0;
|
||||||
|
pubSub->size = 64;
|
||||||
|
|
||||||
|
pubSub->events = (wEvent*) malloc(sizeof(wEvent) * pubSub->size);
|
||||||
|
ZeroMemory(pubSub->events, sizeof(wEvent) * pubSub->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubSub;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PubSub_Free(wPubSub* pubSub)
|
||||||
|
{
|
||||||
|
if (pubSub)
|
||||||
|
{
|
||||||
|
if (pubSub->synchronized)
|
||||||
|
CloseHandle(pubSub->mutex);
|
||||||
|
|
||||||
|
if (pubSub->events)
|
||||||
|
free(pubSub->events);
|
||||||
|
|
||||||
|
free(pubSub);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
|
|||||||
set(${MODULE_PREFIX}_TESTS
|
set(${MODULE_PREFIX}_TESTS
|
||||||
TestQueue.c
|
TestQueue.c
|
||||||
TestPrint.c
|
TestPrint.c
|
||||||
|
TestPubSub.c
|
||||||
TestArrayList.c
|
TestArrayList.c
|
||||||
TestCmdLine.c
|
TestCmdLine.c
|
||||||
TestStreamPool.c
|
TestStreamPool.c
|
||||||
|
86
winpr/libwinpr/utils/test/TestPubSub.c
Normal file
86
winpr/libwinpr/utils/test/TestPubSub.c
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
#include <winpr/crt.h>
|
||||||
|
#include <winpr/thread.h>
|
||||||
|
#include <winpr/collections.h>
|
||||||
|
|
||||||
|
DEFINE_EVENT_BEGIN(MouseMotion)
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
DEFINE_EVENT_END(MouseMotion)
|
||||||
|
|
||||||
|
DEFINE_EVENT_BEGIN(MouseButton)
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int flags;
|
||||||
|
int button;
|
||||||
|
DEFINE_EVENT_END(MouseButton)
|
||||||
|
|
||||||
|
void MouseMotionEventHandler(void* context, MouseMotionEventArgs* e)
|
||||||
|
{
|
||||||
|
printf("MouseMotionEvent: x: %d y: %d\n", e->x, e->y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MouseButtonEventHandler(void* context, MouseButtonEventArgs* e)
|
||||||
|
{
|
||||||
|
printf("MouseButtonEvent: x: %d y: %d flags: %d button: %d\n", e->x, e->y, e->flags, e->button);
|
||||||
|
}
|
||||||
|
|
||||||
|
static wEvent Node_Events[] =
|
||||||
|
{
|
||||||
|
DEFINE_EVENT_ENTRY(MouseMotion)
|
||||||
|
DEFINE_EVENT_ENTRY(MouseButton)
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NODE_EVENT_COUNT (sizeof(Node_Events) / sizeof(wEvent))
|
||||||
|
|
||||||
|
/* strongly-typed wrappers could be automatically defined using a macro */
|
||||||
|
|
||||||
|
static INLINE int PubSub_SubscribeMouseMotion(wPubSub* pubSub, pMouseMotionEventHandler MouseMotionEventHandler)
|
||||||
|
{
|
||||||
|
return PubSub_Subscribe(pubSub, "MouseMotion", (pEventHandler) MouseMotionEventHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE int PubSub_OnMouseMotion(wPubSub* pubSub, void* context, MouseMotionEventArgs* e)
|
||||||
|
{
|
||||||
|
return PubSub_OnEvent(pubSub, "MouseMotion", context, (wEventArgs*) e);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TestPubSub(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
wPubSub* node;
|
||||||
|
|
||||||
|
node = PubSub_New(TRUE);
|
||||||
|
|
||||||
|
PubSub_Publish(node, Node_Events, NODE_EVENT_COUNT);
|
||||||
|
|
||||||
|
/* Register Event Handler */
|
||||||
|
|
||||||
|
PubSub_SubscribeMouseMotion(node, MouseMotionEventHandler);
|
||||||
|
PubSub_Subscribe(node, "MouseButton", (pEventHandler) MouseButtonEventHandler);
|
||||||
|
|
||||||
|
/* Call Event Handler */
|
||||||
|
{
|
||||||
|
MouseMotionEventArgs e;
|
||||||
|
|
||||||
|
e.x = 64;
|
||||||
|
e.y = 128;
|
||||||
|
|
||||||
|
PubSub_OnMouseMotion(node, NULL, &e);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
MouseButtonEventArgs e;
|
||||||
|
|
||||||
|
e.x = 23;
|
||||||
|
e.y = 56;
|
||||||
|
e.flags = 7;
|
||||||
|
e.button = 1;
|
||||||
|
|
||||||
|
PubSub_OnEvent(node, "MouseButton", NULL, (wEventArgs*) &e);
|
||||||
|
}
|
||||||
|
|
||||||
|
PubSub_Free(node);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user