shadow/mac: add monitor detection

This commit is contained in:
Marc-André Moreau 2014-09-13 13:12:55 -04:00
parent aa49e63cda
commit 6a1b76e42a
4 changed files with 102 additions and 109 deletions

View File

@ -357,21 +357,7 @@ void mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
void mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
/*
INPUT keyboard_event;
keyboard_event.type = INPUT_KEYBOARD;
keyboard_event.ki.wVk = 0;
keyboard_event.ki.wScan = code;
keyboard_event.ki.dwFlags = KEYEVENTF_UNICODE;
keyboard_event.ki.dwExtraInfo = 0;
keyboard_event.ki.time = 0;
if (flags & KBD_FLAGS_RELEASE)
keyboard_event.ki.dwFlags |= KEYEVENTF_KEYUP;
SendInput(1, &keyboard_event, sizeof(INPUT));
*/
}
void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
@ -406,34 +392,6 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
CFRelease(scroll);
CFRelease(source);
}
/*
///////////////////////////////////////////////
// We dont support horizontal scrolling yet...
///////////////////////////////////////////////
else if (flags & PTR_FLAGS_)
{
scroll_y = flags & WheelRotationMask;
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
{
scroll_y = -(flags & WheelRotationMask) / 392;
}
else
{
scroll_y = (flags & WheelRotationMask) / 120;
}
CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateCombinedSessionState);
CGEventRef scroll = CGEventCreateScrollWheelEvent(source,
kCGScrollEventUnitLine,
wheelCount,
scroll_y,
scroll_x);
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
CFRelease(source);
} */
else
{
@ -542,55 +500,7 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
void mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
/*
if ((flags & PTR_XFLAGS_BUTTON1) || (flags & PTR_XFLAGS_BUTTON2))
{
INPUT mouse_event;
ZeroMemory(&mouse_event, sizeof(INPUT));
mouse_event.type = INPUT_MOUSE;
if (flags & PTR_FLAGS_MOVE)
{
float width, height;
wfInfo * wfi;
wfi = wf_info_get_instance();
//width and height of primary screen (even in multimon setups
width = (float) GetSystemMetrics(SM_CXSCREEN);
height = (float) GetSystemMetrics(SM_CYSCREEN);
x += wfi->servscreen_xoffset;
y += wfi->servscreen_yoffset;
//mouse_event.mi.dx = x * (0xFFFF / width);
//mouse_event.mi.dy = y * (0xFFFF / height);
mouse_event.mi.dx = (LONG) ((float) x * (65535.0f / width));
mouse_event.mi.dy = (LONG) ((float) y * (65535.0f / height));
mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
SendInput(1, &mouse_event, sizeof(INPUT));
}
mouse_event.mi.dx = mouse_event.mi.dy = mouse_event.mi.dwFlags = 0;
if (flags & PTR_XFLAGS_DOWN)
mouse_event.mi.dwFlags |= MOUSEEVENTF_XDOWN;
else
mouse_event.mi.dwFlags |= MOUSEEVENTF_XUP;
if (flags & PTR_XFLAGS_BUTTON1)
mouse_event.mi.mouseData = XBUTTON1;
else if (flags & PTR_XFLAGS_BUTTON2)
mouse_event.mi.mouseData = XBUTTON2;
SendInput(1, &mouse_event, sizeof(INPUT));
}
else
{
mf_input_mouse_event(input, flags, x, y);
}
*/
}

View File

@ -18,7 +18,15 @@
set(MODULE_NAME "freerdp-shadow")
set(MODULE_PREFIX "FREERDP_SERVER_SHADOW")
if(WITH_X11)
if(WIN32)
set(WITH_SHADOW_WIN 1)
elseif(X11_FOUND AND NOT APPLE)
set(WITH_SHADOW_X11 1)
elseif(APPLE AND NOT IOS)
set(WITH_SHADOW_MAC 1)
endif()
if(WITH_SHADOW_X11)
set(XEXT_FEATURE_TYPE "RECOMMENDED")
set(XEXT_FEATURE_PURPOSE "X11 extension")
set(XEXT_FEATURE_DESCRIPTION "X11 core extensions")
@ -115,6 +123,13 @@ if(WITH_X11)
endif()
endif()
if(WITH_SHADOW_MAC)
find_library(IOKIT IOKit)
find_library(IOSURFACE IOSurface)
find_library(CARBON Carbon)
list(APPEND ${MODULE_PREFIX}_MAC_LIBS ${IOKIT} ${IOSURFACE} ${CARBON})
endif()
include_directories(${OPENSSL_INCLUDE_DIR})
set(${MODULE_PREFIX}_SRCS
@ -157,14 +172,6 @@ set(${MODULE_PREFIX}_MAC_SRCS
Mac/mac_shadow.c
Mac/mac_shadow.h)
if(WIN32)
set(WITH_SHADOW_WIN 1)
elseif(X11_FOUND AND NOT APPLE)
set(WITH_SHADOW_X11 1)
elseif(APPLE AND NOT IOS)
set(WITH_SHADOW_MAC 1)
endif()
if(WITH_SHADOW_WIN)
add_definitions(-DWITH_SHADOW_WIN)
list(APPEND ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_WIN_SRCS})
@ -183,15 +190,14 @@ add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "freerdp-shadow")
list(APPEND ${MODULE_PREFIX}_LIBS freerdp-server)
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp
MODULES freerdp-core freerdp-common freerdp-codec freerdp-primitives freerdp-utils freerdp-gdi freerdp-crypto freerdp-locale)
list(APPEND ${MODULE_PREFIX}_LIBS freerdp-server)
list(APPEND ${MODULE_PREFIX}_LIBS freerdp-client)
list(APPEND ${MODULE_PREFIX}_LIBS winpr-makecert-tool winpr)
list(APPEND ${MODULE_PREFIX}_LIBS winpr winpr-makecert-tool)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})

View File

@ -79,23 +79,87 @@ void* mac_shadow_subsystem_thread(macShadowSubsystem* subsystem)
return NULL;
}
int mac_shadow_subsystem_init(macShadowSubsystem* subsystem)
int mac_shadow_detect_monitors(macShadowSubsystem* subsystem)
{
size_t wide, high;
MONITOR_DEF* monitor;
CGDirectDisplayID displayId;
displayId = CGMainDisplayID();
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayId);
subsystem->pixelWidth = CGDisplayModeGetPixelWidth(mode);
subsystem->pixelHeight = CGDisplayModeGetPixelHeight(mode);
wide = CGDisplayPixelsWide(displayId);
high = CGDisplayPixelsHigh(displayId);
CGDisplayModeRelease(mode);
subsystem->retina = ((subsystem->pixelWidth / wide) == 2) ? TRUE : FALSE;
if (subsystem->retina)
{
subsystem->width = wide;
subsystem->height = high;
}
else
{
subsystem->width = subsystem->pixelWidth;
subsystem->height = subsystem->pixelHeight;
}
subsystem->monitorCount = 1;
monitor = &(subsystem->monitors[0]);
monitor->left = 0;
monitor->top = 0;
monitor->right = 1024;
monitor->bottom = 768;
monitor->right = subsystem->width;
monitor->bottom = subsystem->height;
monitor->flags = 1;
return 1;
}
void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, CGDisplayStreamUpdateRef) = ^(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef)
{
};
int mac_shadow_capture_init(macShadowSubsystem* subsystem)
{
void* keys[2];
void* values[2];
CFDictionaryRef opts;
CGDirectDisplayID displayId;
displayId = CGMainDisplayID();
subsystem->captureQueue = dispatch_queue_create("mac.shadow.capture", NULL);
keys[0] = (void*) kCGDisplayStreamShowCursor;
values[0] = (void*) kCFBooleanFalse;
opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**) keys, (const void**) values, 1, NULL, NULL);
subsystem->stream = CGDisplayStreamCreateWithDispatchQueue(displayId,
subsystem->pixelWidth, subsystem->pixelHeight,
'BGRA', opts, subsystem->captureQueue, streamHandler);
CFRelease(opts);
return 1;
}
int mac_shadow_subsystem_init(macShadowSubsystem* subsystem)
{
mac_shadow_detect_monitors(subsystem);
return 1;
}
int mac_shadow_subsystem_uninit(macShadowSubsystem* subsystem)
{
if (!subsystem)

View File

@ -29,11 +29,24 @@ typedef struct mac_shadow_subsystem macShadowSubsystem;
#include <winpr/stream.h>
#include <winpr/collections.h>
#include <dispatch/dispatch.h>
#include <IOKit/IOKitLib.h>
#include <IOSurface/IOSurface.h>
#include <CoreVideo/CoreVideo.h>
#include <CoreGraphics/CoreGraphics.h>
struct mac_shadow_subsystem
{
RDP_SHADOW_SUBSYSTEM_COMMON();
int width;
int height;
BOOL retina;
int pixelWidth;
int pixelHeight;
CGDisplayStreamRef stream;
dispatch_queue_t captureQueue;
};
#ifdef __cplusplus