2014-07-18 02:27:40 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
*
|
|
|
|
* Copyright 2011-2014 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/synch.h>
|
|
|
|
#include <winpr/sysinfo.h>
|
|
|
|
|
2014-09-18 06:58:57 +04:00
|
|
|
#include <freerdp/log.h>
|
2014-07-18 02:27:40 +04:00
|
|
|
#include <freerdp/codec/color.h>
|
|
|
|
#include <freerdp/codec/region.h>
|
|
|
|
|
|
|
|
#include "win_shadow.h"
|
|
|
|
|
2014-09-12 19:38:12 +04:00
|
|
|
#define TAG SERVER_TAG("shadow.win")
|
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
void win_shadow_input_synchronize_event(winShadowSubsystem* subsystem,
|
|
|
|
rdpShadowClient* client, UINT32 flags)
|
2014-07-18 02:27:40 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
void win_shadow_input_keyboard_event(winShadowSubsystem* subsystem,
|
|
|
|
rdpShadowClient* client, UINT16 flags, UINT16 code)
|
2014-07-18 02:27:40 +04:00
|
|
|
{
|
|
|
|
INPUT event;
|
|
|
|
event.type = INPUT_KEYBOARD;
|
|
|
|
event.ki.wVk = 0;
|
|
|
|
event.ki.wScan = code;
|
|
|
|
event.ki.dwFlags = KEYEVENTF_SCANCODE;
|
|
|
|
event.ki.dwExtraInfo = 0;
|
|
|
|
event.ki.time = 0;
|
|
|
|
|
|
|
|
if (flags & KBD_FLAGS_RELEASE)
|
|
|
|
event.ki.dwFlags |= KEYEVENTF_KEYUP;
|
|
|
|
|
|
|
|
if (flags & KBD_FLAGS_EXTENDED)
|
|
|
|
event.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
|
|
|
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
void win_shadow_input_unicode_keyboard_event(winShadowSubsystem* subsystem,
|
|
|
|
rdpShadowClient* client, UINT16 flags, UINT16 code)
|
2014-07-18 02:27:40 +04:00
|
|
|
{
|
|
|
|
INPUT event;
|
|
|
|
event.type = INPUT_KEYBOARD;
|
|
|
|
event.ki.wVk = 0;
|
|
|
|
event.ki.wScan = code;
|
|
|
|
event.ki.dwFlags = KEYEVENTF_UNICODE;
|
|
|
|
event.ki.dwExtraInfo = 0;
|
|
|
|
event.ki.time = 0;
|
|
|
|
|
|
|
|
if (flags & KBD_FLAGS_RELEASE)
|
|
|
|
event.ki.dwFlags |= KEYEVENTF_KEYUP;
|
|
|
|
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
void win_shadow_input_mouse_event(winShadowSubsystem* subsystem,
|
|
|
|
rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
|
2014-07-18 02:27:40 +04:00
|
|
|
{
|
|
|
|
INPUT event;
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
ZeroMemory(&event, sizeof(INPUT));
|
|
|
|
event.type = INPUT_MOUSE;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_WHEEL)
|
|
|
|
{
|
|
|
|
event.mi.dwFlags = MOUSEEVENTF_WHEEL;
|
|
|
|
event.mi.mouseData = flags & WheelRotationMask;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
|
|
|
|
event.mi.mouseData *= -1;
|
|
|
|
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
width = (float) GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
height = (float) GetSystemMetrics(SM_CYSCREEN);
|
2016-09-20 10:25:13 +03:00
|
|
|
event.mi.dx = (LONG)((float) x * (65535.0f / width));
|
|
|
|
event.mi.dy = (LONG)((float) y * (65535.0f / height));
|
2014-07-18 02:27:40 +04:00
|
|
|
event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_MOVE)
|
|
|
|
{
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_MOVE;
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_BUTTON1)
|
|
|
|
{
|
|
|
|
if (flags & PTR_FLAGS_DOWN)
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
|
|
|
|
else
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
|
|
|
|
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
else if (flags & PTR_FLAGS_BUTTON2)
|
|
|
|
{
|
|
|
|
if (flags & PTR_FLAGS_DOWN)
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
|
|
|
|
else
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
|
|
|
|
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
else if (flags & PTR_FLAGS_BUTTON3)
|
|
|
|
{
|
|
|
|
if (flags & PTR_FLAGS_DOWN)
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
|
|
|
|
else
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
|
|
|
|
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
void win_shadow_input_extended_mouse_event(winShadowSubsystem* subsystem,
|
|
|
|
rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
|
2014-07-18 02:27:40 +04:00
|
|
|
{
|
|
|
|
INPUT event;
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
ZeroMemory(&event, sizeof(INPUT));
|
|
|
|
|
|
|
|
if ((flags & PTR_XFLAGS_BUTTON1) || (flags & PTR_XFLAGS_BUTTON2))
|
|
|
|
{
|
|
|
|
event.type = INPUT_MOUSE;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_MOVE)
|
|
|
|
{
|
|
|
|
width = (float) GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
height = (float) GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
event.mi.dx = (LONG)((float) x * (65535.0f / width));
|
|
|
|
event.mi.dy = (LONG)((float) y * (65535.0f / height));
|
|
|
|
event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
event.mi.dx = event.mi.dy = event.mi.dwFlags = 0;
|
|
|
|
|
|
|
|
if (flags & PTR_XFLAGS_DOWN)
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_XDOWN;
|
|
|
|
else
|
|
|
|
event.mi.dwFlags |= MOUSEEVENTF_XUP;
|
|
|
|
|
|
|
|
if (flags & PTR_XFLAGS_BUTTON1)
|
|
|
|
event.mi.mouseData = XBUTTON1;
|
|
|
|
else if (flags & PTR_XFLAGS_BUTTON2)
|
|
|
|
event.mi.mouseData = XBUTTON2;
|
|
|
|
|
|
|
|
SendInput(1, &event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-18 05:15:22 +04:00
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
int win_shadow_invalidate_region(winShadowSubsystem* subsystem, int x, int y,
|
|
|
|
int width, int height)
|
2014-07-18 05:15:22 +04:00
|
|
|
{
|
|
|
|
rdpShadowServer* server;
|
2015-06-28 11:20:49 +03:00
|
|
|
rdpShadowSurface* surface;
|
2014-07-18 05:15:22 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
|
|
|
server = subsystem->server;
|
2015-06-28 11:20:49 +03:00
|
|
|
surface = server->surface;
|
2014-07-18 05:15:22 +04:00
|
|
|
invalidRect.left = x;
|
|
|
|
invalidRect.top = y;
|
|
|
|
invalidRect.right = x + width;
|
|
|
|
invalidRect.bottom = y + height;
|
2015-06-28 11:20:49 +03:00
|
|
|
EnterCriticalSection(&(surface->lock));
|
2016-09-20 10:25:13 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
|
|
|
&invalidRect);
|
2015-06-28 11:20:49 +03:00
|
|
|
LeaveCriticalSection(&(surface->lock));
|
2014-07-18 05:15:22 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-07-18 02:27:40 +04:00
|
|
|
int win_shadow_surface_copy(winShadowSubsystem* subsystem)
|
|
|
|
{
|
2014-07-18 06:38:10 +04:00
|
|
|
int x, y;
|
|
|
|
int width;
|
|
|
|
int height;
|
2014-08-13 00:57:58 +04:00
|
|
|
int count;
|
2014-08-12 03:31:38 +04:00
|
|
|
int status = 1;
|
2014-07-18 06:38:10 +04:00
|
|
|
int nDstStep = 0;
|
2016-09-20 10:25:13 +03:00
|
|
|
DWORD DstFormat;
|
2014-07-18 06:38:10 +04:00
|
|
|
BYTE* pDstData = NULL;
|
|
|
|
rdpShadowServer* server;
|
|
|
|
rdpShadowSurface* surface;
|
|
|
|
RECTANGLE_16 surfaceRect;
|
2014-08-13 00:57:58 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
2014-07-18 06:38:10 +04:00
|
|
|
const RECTANGLE_16* extents;
|
|
|
|
server = subsystem->server;
|
|
|
|
surface = server->surface;
|
|
|
|
|
2014-08-16 02:12:53 +04:00
|
|
|
if (ArrayList_Count(server->clients) < 1)
|
|
|
|
{
|
2016-04-23 20:49:10 +03:00
|
|
|
region16_clear(&(surface->invalidRegion));
|
2014-08-16 02:12:53 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-07-18 06:38:10 +04:00
|
|
|
surfaceRect.left = surface->x;
|
|
|
|
surfaceRect.top = surface->y;
|
|
|
|
surfaceRect.right = surface->x + surface->width;
|
|
|
|
surfaceRect.bottom = surface->y + surface->height;
|
2016-09-20 10:25:13 +03:00
|
|
|
region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
|
|
|
&surfaceRect);
|
2014-07-18 06:38:10 +04:00
|
|
|
|
2016-04-23 20:49:10 +03:00
|
|
|
if (region16_is_empty(&(surface->invalidRegion)))
|
2014-07-18 06:38:10 +04:00
|
|
|
return 1;
|
|
|
|
|
2016-04-23 20:49:10 +03:00
|
|
|
extents = region16_extents(&(surface->invalidRegion));
|
2014-08-13 00:57:58 +04:00
|
|
|
CopyMemory(&invalidRect, extents, sizeof(RECTANGLE_16));
|
|
|
|
shadow_capture_align_clip_rect(&invalidRect, &surfaceRect);
|
|
|
|
x = invalidRect.left;
|
|
|
|
y = invalidRect.top;
|
|
|
|
width = invalidRect.right - invalidRect.left;
|
|
|
|
height = invalidRect.bottom - invalidRect.top;
|
2014-07-18 06:38:10 +04:00
|
|
|
|
2014-08-13 00:57:58 +04:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
width = surface->width;
|
|
|
|
height = surface->height;
|
|
|
|
}
|
2014-07-18 06:38:10 +04:00
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
WLog_INFO(TAG,
|
|
|
|
"SurfaceCopy x: %d y: %d width: %d height: %d right: %d bottom: %d",
|
|
|
|
x, y, width, height, x + width, y + height);
|
2014-08-15 22:57:09 +04:00
|
|
|
#if defined(WITH_WDS_API)
|
|
|
|
{
|
|
|
|
rdpGdi* gdi;
|
|
|
|
shwContext* shw;
|
|
|
|
rdpContext* context;
|
|
|
|
shw = subsystem->shw;
|
|
|
|
context = (rdpContext*) shw;
|
|
|
|
gdi = context->gdi;
|
|
|
|
pDstData = gdi->primary_buffer;
|
|
|
|
nDstStep = gdi->width * 4;
|
2016-09-20 10:25:13 +03:00
|
|
|
DstFormat = gdi->dstFormat;
|
2014-08-15 22:57:09 +04:00
|
|
|
}
|
|
|
|
#elif defined(WITH_DXGI_1_2)
|
2016-09-20 10:25:13 +03:00
|
|
|
DstFormat = PIXEL_FORMAT_BGRX32;
|
|
|
|
status = win_shadow_dxgi_fetch_frame_data(subsystem, &pDstData, &nDstStep, x, y,
|
|
|
|
width, height);
|
2014-08-12 03:31:38 +04:00
|
|
|
#endif
|
2014-07-18 06:38:10 +04:00
|
|
|
|
2014-08-13 00:57:58 +04:00
|
|
|
if (status <= 0)
|
|
|
|
return status;
|
2014-07-19 01:26:21 +04:00
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
freerdp_image_copy(surface->data, surface->format,
|
|
|
|
surface->scanline, x - surface->x, y - surface->y, width, height,
|
|
|
|
pDstData, DstFormat, nDstStep, 0, 0, NULL);
|
2014-08-16 02:12:53 +04:00
|
|
|
ArrayList_Lock(server->clients);
|
2014-08-13 00:57:58 +04:00
|
|
|
count = ArrayList_Count(server->clients);
|
2016-09-20 10:25:13 +03:00
|
|
|
shadow_subsystem_frame_update((rdpShadowSubsystem*)subsystem);
|
2014-08-16 02:12:53 +04:00
|
|
|
ArrayList_Unlock(server->clients);
|
2016-04-23 20:49:10 +03:00
|
|
|
region16_clear(&(surface->invalidRegion));
|
2014-07-18 02:27:40 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-08-15 22:57:09 +04:00
|
|
|
#if defined(WITH_WDS_API)
|
|
|
|
|
|
|
|
void* win_shadow_subsystem_thread(winShadowSubsystem* subsystem)
|
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
DWORD nCount;
|
|
|
|
HANDLE events[32];
|
|
|
|
HANDLE StopEvent;
|
|
|
|
StopEvent = subsystem->server->StopEvent;
|
|
|
|
nCount = 0;
|
|
|
|
events[nCount++] = StopEvent;
|
|
|
|
events[nCount++] = subsystem->RdpUpdateEnterEvent;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
|
|
|
|
|
|
|
if (WaitForSingleObject(StopEvent, 0) == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WaitForSingleObject(subsystem->RdpUpdateEnterEvent, 0) == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
win_shadow_surface_copy(subsystem);
|
|
|
|
ResetEvent(subsystem->RdpUpdateEnterEvent);
|
|
|
|
SetEvent(subsystem->RdpUpdateLeaveEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ExitThread(0);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(WITH_DXGI_1_2)
|
|
|
|
|
2014-07-18 02:27:40 +04:00
|
|
|
void* win_shadow_subsystem_thread(winShadowSubsystem* subsystem)
|
|
|
|
{
|
2014-07-18 05:15:22 +04:00
|
|
|
int fps;
|
2014-07-18 02:27:40 +04:00
|
|
|
DWORD status;
|
|
|
|
DWORD nCount;
|
2014-07-18 05:15:22 +04:00
|
|
|
UINT64 cTime;
|
|
|
|
DWORD dwTimeout;
|
|
|
|
DWORD dwInterval;
|
|
|
|
UINT64 frameTime;
|
2014-07-18 02:27:40 +04:00
|
|
|
HANDLE events[32];
|
|
|
|
HANDLE StopEvent;
|
|
|
|
StopEvent = subsystem->server->StopEvent;
|
|
|
|
nCount = 0;
|
|
|
|
events[nCount++] = StopEvent;
|
2014-07-18 05:15:22 +04:00
|
|
|
fps = 16;
|
|
|
|
dwInterval = 1000 / fps;
|
|
|
|
frameTime = GetTickCount64() + dwInterval;
|
|
|
|
|
2014-07-18 02:27:40 +04:00
|
|
|
while (1)
|
|
|
|
{
|
2014-07-18 05:15:22 +04:00
|
|
|
dwTimeout = INFINITE;
|
|
|
|
cTime = GetTickCount64();
|
2016-09-20 10:25:13 +03:00
|
|
|
dwTimeout = (DWORD)((cTime > frameTime) ? 0 : frameTime - cTime);
|
2014-07-18 05:15:22 +04:00
|
|
|
status = WaitForMultipleObjects(nCount, events, FALSE, dwTimeout);
|
2014-07-18 02:27:40 +04:00
|
|
|
|
|
|
|
if (WaitForSingleObject(StopEvent, 0) == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2014-07-18 05:15:22 +04:00
|
|
|
|
|
|
|
if ((status == WAIT_TIMEOUT) || (GetTickCount64() > frameTime))
|
|
|
|
{
|
2014-07-18 06:38:10 +04:00
|
|
|
int dxgi_status;
|
|
|
|
dxgi_status = win_shadow_dxgi_get_next_frame(subsystem);
|
2016-09-20 10:25:13 +03:00
|
|
|
|
2014-08-13 00:57:58 +04:00
|
|
|
if (dxgi_status > 0)
|
|
|
|
dxgi_status = win_shadow_dxgi_get_invalid_region(subsystem);
|
2014-07-18 06:38:10 +04:00
|
|
|
|
2014-08-13 00:57:58 +04:00
|
|
|
if (dxgi_status > 0)
|
|
|
|
win_shadow_surface_copy(subsystem);
|
2014-07-18 05:15:22 +04:00
|
|
|
|
|
|
|
dwInterval = 1000 / fps;
|
|
|
|
frameTime += dwInterval;
|
|
|
|
}
|
2014-07-18 02:27:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ExitThread(0);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-15 22:57:09 +04:00
|
|
|
#endif
|
|
|
|
|
2014-09-18 23:43:11 +04:00
|
|
|
int win_shadow_enum_monitors(MONITOR_DEF* monitors, int maxMonitors)
|
2014-09-18 22:29:42 +04:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
int index;
|
|
|
|
int desktopWidth;
|
|
|
|
int desktopHeight;
|
|
|
|
DWORD iDevNum = 0;
|
|
|
|
int numMonitors = 0;
|
|
|
|
MONITOR_DEF* monitor;
|
|
|
|
DISPLAY_DEVICE displayDevice;
|
|
|
|
ZeroMemory(&displayDevice, sizeof(DISPLAY_DEVICE));
|
|
|
|
displayDevice.cb = sizeof(DISPLAY_DEVICE);
|
|
|
|
|
|
|
|
if (EnumDisplayDevices(NULL, iDevNum, &displayDevice, 0))
|
|
|
|
{
|
|
|
|
hdc = CreateDC(displayDevice.DeviceName, NULL, NULL, NULL);
|
|
|
|
desktopWidth = GetDeviceCaps(hdc, HORZRES);
|
|
|
|
desktopHeight = GetDeviceCaps(hdc, VERTRES);
|
|
|
|
index = 0;
|
|
|
|
numMonitors = 1;
|
|
|
|
monitor = &monitors[index];
|
|
|
|
monitor->left = 0;
|
|
|
|
monitor->top = 0;
|
|
|
|
monitor->right = desktopWidth;
|
|
|
|
monitor->bottom = desktopHeight;
|
|
|
|
monitor->flags = 1;
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return numMonitors;
|
|
|
|
}
|
|
|
|
|
2014-07-18 02:27:40 +04:00
|
|
|
int win_shadow_subsystem_init(winShadowSubsystem* subsystem)
|
|
|
|
{
|
2014-07-18 05:15:22 +04:00
|
|
|
int status;
|
|
|
|
MONITOR_DEF* virtualScreen;
|
2014-09-18 23:43:11 +04:00
|
|
|
subsystem->numMonitors = win_shadow_enum_monitors(subsystem->monitors, 16);
|
2014-08-14 01:48:57 +04:00
|
|
|
#if defined(WITH_WDS_API)
|
|
|
|
status = win_shadow_wds_init(subsystem);
|
|
|
|
#elif defined(WITH_DXGI_1_2)
|
2014-07-18 05:15:22 +04:00
|
|
|
status = win_shadow_dxgi_init(subsystem);
|
|
|
|
#endif
|
|
|
|
virtualScreen = &(subsystem->virtualScreen);
|
|
|
|
virtualScreen->left = 0;
|
|
|
|
virtualScreen->top = 0;
|
|
|
|
virtualScreen->right = subsystem->width;
|
|
|
|
virtualScreen->bottom = subsystem->height;
|
|
|
|
virtualScreen->flags = 1;
|
2014-09-12 19:38:12 +04:00
|
|
|
WLog_INFO(TAG, "width: %d height: %d", subsystem->width, subsystem->height);
|
2014-07-18 02:27:40 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int win_shadow_subsystem_uninit(winShadowSubsystem* subsystem)
|
|
|
|
{
|
|
|
|
if (!subsystem)
|
|
|
|
return -1;
|
|
|
|
|
2014-08-14 01:48:57 +04:00
|
|
|
#if defined(WITH_WDS_API)
|
|
|
|
win_shadow_wds_uninit(subsystem);
|
|
|
|
#elif defined(WITH_DXGI_1_2)
|
2014-07-18 06:38:10 +04:00
|
|
|
win_shadow_dxgi_uninit(subsystem);
|
|
|
|
#endif
|
2014-07-18 02:27:40 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int win_shadow_subsystem_start(winShadowSubsystem* subsystem)
|
|
|
|
{
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
if (!subsystem)
|
|
|
|
return -1;
|
|
|
|
|
2015-05-05 14:55:48 +03:00
|
|
|
if (!(thread = CreateThread(NULL, 0,
|
2016-09-20 10:25:13 +03:00
|
|
|
(LPTHREAD_START_ROUTINE) win_shadow_subsystem_thread,
|
|
|
|
(void*) subsystem, 0, NULL)))
|
2015-05-05 14:55:48 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to create thread");
|
|
|
|
return -1;
|
|
|
|
}
|
2014-07-18 02:27:40 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int win_shadow_subsystem_stop(winShadowSubsystem* subsystem)
|
|
|
|
{
|
|
|
|
if (!subsystem)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void win_shadow_subsystem_free(winShadowSubsystem* subsystem)
|
|
|
|
{
|
|
|
|
if (!subsystem)
|
|
|
|
return;
|
|
|
|
|
|
|
|
win_shadow_subsystem_uninit(subsystem);
|
|
|
|
free(subsystem);
|
|
|
|
}
|
|
|
|
|
2014-09-18 23:43:11 +04:00
|
|
|
winShadowSubsystem* win_shadow_subsystem_new()
|
2014-07-18 02:27:40 +04:00
|
|
|
{
|
|
|
|
winShadowSubsystem* subsystem;
|
|
|
|
subsystem = (winShadowSubsystem*) calloc(1, sizeof(winShadowSubsystem));
|
|
|
|
|
|
|
|
if (!subsystem)
|
|
|
|
return NULL;
|
|
|
|
|
2016-09-20 10:25:13 +03:00
|
|
|
subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent)
|
|
|
|
win_shadow_input_synchronize_event;
|
|
|
|
subsystem->KeyboardEvent = (pfnShadowKeyboardEvent)
|
|
|
|
win_shadow_input_keyboard_event;
|
|
|
|
subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent)
|
|
|
|
win_shadow_input_unicode_keyboard_event;
|
2014-07-18 02:27:40 +04:00
|
|
|
subsystem->MouseEvent = (pfnShadowMouseEvent) win_shadow_input_mouse_event;
|
2016-09-20 10:25:13 +03:00
|
|
|
subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent)
|
|
|
|
win_shadow_input_extended_mouse_event;
|
2014-07-18 02:27:40 +04:00
|
|
|
return subsystem;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:25:49 +03:00
|
|
|
FREERDP_API int Win_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
|
2014-07-18 02:27:40 +04:00
|
|
|
{
|
2014-09-18 23:43:11 +04:00
|
|
|
pEntryPoints->New = (pfnShadowSubsystemNew) win_shadow_subsystem_new;
|
|
|
|
pEntryPoints->Free = (pfnShadowSubsystemFree) win_shadow_subsystem_free;
|
|
|
|
pEntryPoints->Init = (pfnShadowSubsystemInit) win_shadow_subsystem_init;
|
|
|
|
pEntryPoints->Uninit = (pfnShadowSubsystemInit) win_shadow_subsystem_uninit;
|
|
|
|
pEntryPoints->Start = (pfnShadowSubsystemStart) win_shadow_subsystem_start;
|
|
|
|
pEntryPoints->Stop = (pfnShadowSubsystemStop) win_shadow_subsystem_stop;
|
|
|
|
pEntryPoints->EnumMonitors = (pfnShadowEnumMonitors) win_shadow_enum_monitors;
|
|
|
|
return 1;
|
2014-07-18 02:27:40 +04:00
|
|
|
}
|