From 48d15998e75bd5f6adb5a86248434bfc4d8d4558 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 17 Sep 2014 22:58:57 -0400 Subject: [PATCH] shadow: add common subsystem code --- include/freerdp/server/shadow.h | 1 + server/shadow/CMakeLists.txt | 2 ++ server/shadow/Mac/mac_shadow.c | 9 ++++---- server/shadow/Win/win_shadow.c | 12 ++++------- server/shadow/X11/x11_shadow.c | 15 ++++++-------- server/shadow/shadow_client.c | 7 +++++++ server/shadow/shadow_subsystem.c | 45 ++++++++++++++++++++++++++++++++++++++++ server/shadow/shadow_subsystem.h | 41 ++++++++++++++++++++++++++++++++++++ 8 files changed, 111 insertions(+), 21 deletions(-) create mode 100644 server/shadow/shadow_subsystem.c create mode 100644 server/shadow/shadow_subsystem.h diff --git a/include/freerdp/server/shadow.h b/include/freerdp/server/shadow.h index 8f010b5..23789c6 100644 --- a/include/freerdp/server/shadow.h +++ b/include/freerdp/server/shadow.h @@ -118,6 +118,7 @@ struct rdp_shadow_server MONITOR_DEF virtualScreen; \ HANDLE updateEvent; \ REGION16 invalidRegion; \ + wMessagePipe* MsgPipe; \ SYNCHRONIZATION_BARRIER barrier; \ \ pfnShadowSubsystemInit Init; \ diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index b928a27..5c25c41 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -151,6 +151,8 @@ set(${MODULE_PREFIX}_SRCS shadow_encomsp.h shadow_remdesk.c shadow_remdesk.h + shadow_subsystem.c + shadow_subsystem.h shadow_server.c shadow.h) diff --git a/server/shadow/Mac/mac_shadow.c b/server/shadow/Mac/mac_shadow.c index 65e8b8b..abec9e8 100644 --- a/server/shadow/Mac/mac_shadow.c +++ b/server/shadow/Mac/mac_shadow.c @@ -26,6 +26,8 @@ #include "../shadow_screen.h" #include "../shadow_surface.h" +#include "../shadow_capture.h" +#include "../shadow_subsystem.h" #include "mac_shadow.h" @@ -586,6 +588,8 @@ void mac_shadow_subsystem_free(macShadowSubsystem* subsystem) mac_shadow_subsystem_uninit(subsystem); + shadow_subsystem_common_free((rdpShadowSubsystem*) subsystem); + free(subsystem); } @@ -599,10 +603,7 @@ macShadowSubsystem* mac_shadow_subsystem_new(rdpShadowServer* server) return NULL; subsystem->server = server; - - subsystem->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - region16_init(&(subsystem->invalidRegion)); + shadow_subsystem_common_new((rdpShadowSubsystem*) subsystem); subsystem->Init = (pfnShadowSubsystemInit) mac_shadow_subsystem_init; subsystem->Uninit = (pfnShadowSubsystemInit) mac_shadow_subsystem_uninit; diff --git a/server/shadow/Win/win_shadow.c b/server/shadow/Win/win_shadow.c index 1615764..e5d4b28 100644 --- a/server/shadow/Win/win_shadow.c +++ b/server/shadow/Win/win_shadow.c @@ -20,13 +20,14 @@ #include #include +#include #include #include -#include #include "../shadow_screen.h" #include "../shadow_surface.h" #include "../shadow_capture.h" +#include "../shadow_subsystem.h" #include "win_shadow.h" @@ -492,9 +493,7 @@ void win_shadow_subsystem_free(winShadowSubsystem* subsystem) win_shadow_subsystem_uninit(subsystem); - region16_uninit(&(subsystem->invalidRegion)); - - CloseHandle(subsystem->updateEvent); + shadow_subsystem_common_free((rdpShadowSubsystem*) subsystem); free(subsystem); } @@ -509,10 +508,7 @@ winShadowSubsystem* win_shadow_subsystem_new(rdpShadowServer* server) return NULL; subsystem->server = server; - - subsystem->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - region16_init(&(subsystem->invalidRegion)); + shadow_subsystem_common_new((rdpShadowSubsystem*) subsystem); subsystem->Init = (pfnShadowSubsystemInit) win_shadow_subsystem_init; subsystem->Uninit = (pfnShadowSubsystemInit) win_shadow_subsystem_uninit; diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index eff82b7..b3ef078 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -42,6 +42,7 @@ #include "../shadow_screen.h" #include "../shadow_capture.h" #include "../shadow_surface.h" +#include "../shadow_subsystem.h" #include "x11_shadow.h" @@ -136,7 +137,7 @@ void x11_shadow_input_mouse_event(x11ShadowSubsystem* subsystem, UINT16 flags, U if (flags & PTR_FLAGS_DOWN) down = TRUE; - if (button != 0) + if (button) XTestFakeButtonEvent(subsystem->display, button, down, 0); } @@ -165,6 +166,7 @@ void x11_shadow_input_extended_mouse_event(x11ShadowSubsystem* subsystem, UINT16 } XTestGrabControl(subsystem->display, True); + XTestFakeMotionEvent(subsystem->display, 0, x, y, CurrentTime); if (flags & PTR_XFLAGS_BUTTON1) @@ -175,7 +177,7 @@ void x11_shadow_input_extended_mouse_event(x11ShadowSubsystem* subsystem, UINT16 if (flags & PTR_XFLAGS_DOWN) down = TRUE; - if (button != 0) + if (button) XTestFakeButtonEvent(subsystem->display, button, down, 0); XTestGrabControl(subsystem->display, False); @@ -995,9 +997,7 @@ void x11_shadow_subsystem_free(x11ShadowSubsystem* subsystem) x11_shadow_subsystem_uninit(subsystem); - region16_uninit(&(subsystem->invalidRegion)); - - CloseHandle(subsystem->updateEvent); + shadow_subsystem_common_free((rdpShadowSubsystem*) subsystem); free(subsystem); } @@ -1012,10 +1012,7 @@ x11ShadowSubsystem* x11_shadow_subsystem_new(rdpShadowServer* server) return NULL; subsystem->server = server; - - subsystem->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - region16_init(&(subsystem->invalidRegion)); + shadow_subsystem_common_new((rdpShadowSubsystem*) subsystem); subsystem->Init = (pfnShadowSubsystemInit) x11_shadow_subsystem_init; subsystem->Uninit = (pfnShadowSubsystemInit) x11_shadow_subsystem_uninit; diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index 5002fa7..6728ee8 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -194,6 +194,11 @@ void shadow_client_surface_frame_acknowledge(rdpShadowClient* client, UINT32 fra } } +void shadow_client_refresh_rect(rdpContext* context, BYTE count, RECTANGLE_16* areas) +{ + +} + void shadow_client_suppress_output(rdpShadowClient* client, BYTE allow, RECTANGLE_16* area) { @@ -682,6 +687,8 @@ void* shadow_client_thread(rdpShadowClient* client) peer->update->SurfaceFrameAcknowledge = (pSurfaceFrameAcknowledge) shadow_client_surface_frame_acknowledge; + + peer->update->RefreshRect = (pRefreshRect) shadow_client_refresh_rect; peer->update->SuppressOutput = (pSuppressOutput) shadow_client_suppress_output; StopEvent = client->StopEvent; diff --git a/server/shadow/shadow_subsystem.c b/server/shadow/shadow_subsystem.c new file mode 100644 index 0000000..8193755 --- /dev/null +++ b/server/shadow/shadow_subsystem.c @@ -0,0 +1,45 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2014 Marc-Andre Moreau + * + * 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 "shadow.h" + +#include "shadow_subsystem.h" + +int shadow_subsystem_common_new(rdpShadowSubsystem* subsystem) +{ + subsystem->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + subsystem->MsgPipe = MessagePipe_New(); + + region16_init(&(subsystem->invalidRegion)); + + return 1; +} + +void shadow_subsystem_common_free(rdpShadowSubsystem* subsystem) +{ + CloseHandle(subsystem->updateEvent); + + MessagePipe_Free(subsystem->MsgPipe); + + region16_uninit(&(subsystem->invalidRegion)); +} diff --git a/server/shadow/shadow_subsystem.h b/server/shadow/shadow_subsystem.h new file mode 100644 index 0000000..bc8a241 --- /dev/null +++ b/server/shadow/shadow_subsystem.h @@ -0,0 +1,41 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2014 Marc-Andre Moreau + * + * 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_SHADOW_SERVER_SUBSYSTEM_H +#define FREERDP_SHADOW_SERVER_SUBSYSTEM_H + +#include + +#include +#include + +#include "shadow_subsystem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int shadow_subsystem_common_new(rdpShadowSubsystem* subsystem); +void shadow_subsystem_common_free(rdpShadowSubsystem* subsystem); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_SHADOW_SERVER_SUBSYSTEM_H */ + -- 2.7.4