Milestone 5: deliver embedded RDP sessions and lifecycle hardening
This commit is contained in:
59
third_party/FreeRDP/client/Wayland/CMakeLists.txt
vendored
Normal file
59
third_party/FreeRDP/client/Wayland/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# FreeRDP: A Remote Desktop Protocol Implementation
|
||||
# FreeRDP Wayland Client cmake build script
|
||||
#
|
||||
# Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
|
||||
# Copyright 2015 David Fort <contact@hardening-consulting.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.
|
||||
|
||||
set(MODULE_NAME "wlfreerdp")
|
||||
set(MODULE_PREFIX "FREERDP_CLIENT_WAYLAND")
|
||||
|
||||
include(WarnUnmaintained)
|
||||
warn_unmaintained(${MODULE_NAME} "-DWITH_CLIENT_WAYLAND=OFF")
|
||||
|
||||
include_directories(SYSTEM ${WAYLAND_INCLUDE_DIR})
|
||||
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
wlfreerdp.c
|
||||
wlfreerdp.h
|
||||
wlf_disp.c
|
||||
wlf_disp.h
|
||||
wlf_pointer.c
|
||||
wlf_pointer.h
|
||||
wlf_input.c
|
||||
wlf_input.h
|
||||
wlf_cliprdr.c
|
||||
wlf_cliprdr.h
|
||||
wlf_channels.c
|
||||
wlf_channels.h
|
||||
)
|
||||
|
||||
if(FREERDP_UNIFIED_BUILD)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/uwac/include)
|
||||
include_directories(${PROJECT_BINARY_DIR}/uwac/include)
|
||||
else()
|
||||
find_package(uwac 0 REQUIRED)
|
||||
include_directories(SYSTEM ${UWAC_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
list(APPEND ${MODULE_PREFIX}_LIBS freerdp-client freerdp uwac)
|
||||
|
||||
addtargetwithresourcefile(${MODULE_NAME} TRUE ${FREERDP_VERSION} ${MODULE_PREFIX}_SRCS)
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
|
||||
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Wayland")
|
||||
generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${FREERDP_API_VERSION}")
|
||||
79
third_party/FreeRDP/client/Wayland/wlf_channels.c
vendored
Normal file
79
third_party/FreeRDP/client/Wayland/wlf_channels.c
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* X11 Client Channels
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <freerdp/gdi/gfx.h>
|
||||
|
||||
#include <freerdp/gdi/video.h>
|
||||
|
||||
#include "wlf_channels.h"
|
||||
#include "wlf_cliprdr.h"
|
||||
#include "wlf_disp.h"
|
||||
#include "wlfreerdp.h"
|
||||
|
||||
void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e)
|
||||
{
|
||||
wlfContext* wlf = (wlfContext*)context;
|
||||
|
||||
WINPR_ASSERT(wlf);
|
||||
WINPR_ASSERT(e);
|
||||
|
||||
if (FALSE)
|
||||
{
|
||||
}
|
||||
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
|
||||
{
|
||||
}
|
||||
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
|
||||
{
|
||||
wlf_cliprdr_init(wlf->clipboard, (CliprdrClientContext*)e->pInterface);
|
||||
}
|
||||
else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
|
||||
{
|
||||
wlf_disp_init(wlf->disp, (DispClientContext*)e->pInterface);
|
||||
}
|
||||
else
|
||||
freerdp_client_OnChannelConnectedEventHandler(context, e);
|
||||
}
|
||||
|
||||
void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e)
|
||||
{
|
||||
wlfContext* wlf = (wlfContext*)context;
|
||||
|
||||
WINPR_ASSERT(wlf);
|
||||
WINPR_ASSERT(e);
|
||||
|
||||
if (FALSE)
|
||||
{
|
||||
}
|
||||
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
|
||||
{
|
||||
}
|
||||
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
|
||||
{
|
||||
wlf_cliprdr_uninit(wlf->clipboard, (CliprdrClientContext*)e->pInterface);
|
||||
}
|
||||
else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
|
||||
{
|
||||
wlf_disp_uninit(wlf->disp, (DispClientContext*)e->pInterface);
|
||||
}
|
||||
else
|
||||
freerdp_client_OnChannelDisconnectedEventHandler(context, e);
|
||||
}
|
||||
37
third_party/FreeRDP/client/Wayland/wlf_channels.h
vendored
Normal file
37
third_party/FreeRDP/client/Wayland/wlf_channels.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* X11 Client Channels
|
||||
*
|
||||
* 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_CLIENT_WAYLAND_CHANNELS_H
|
||||
#define FREERDP_CLIENT_WAYLAND_CHANNELS_H
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/client/channels.h>
|
||||
#include <freerdp/client/rdpei.h>
|
||||
#include <freerdp/client/rail.h>
|
||||
#include <freerdp/client/cliprdr.h>
|
||||
#include <freerdp/client/rdpgfx.h>
|
||||
#include <freerdp/client/encomsp.h>
|
||||
|
||||
int wlf_on_channel_connected(freerdp* instance, const char* name, void* pInterface);
|
||||
int wlf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface);
|
||||
|
||||
void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e);
|
||||
void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e);
|
||||
|
||||
#endif /* FREERDP_CLIENT_WAYLAND_CHANNELS_H */
|
||||
1025
third_party/FreeRDP/client/Wayland/wlf_cliprdr.c
vendored
Normal file
1025
third_party/FreeRDP/client/Wayland/wlf_cliprdr.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
36
third_party/FreeRDP/client/Wayland/wlf_cliprdr.h
vendored
Normal file
36
third_party/FreeRDP/client/Wayland/wlf_cliprdr.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Clipboard Redirection
|
||||
*
|
||||
* Copyright 2018 Armin Novak <armin.novak@thincast.com>
|
||||
* Copyright 2018 Thincast Technologies GmbH
|
||||
*
|
||||
* 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_CLIENT_WAYLAND_CLIPRDR_H
|
||||
#define FREERDP_CLIENT_WAYLAND_CLIPRDR_H
|
||||
|
||||
#include "wlfreerdp.h"
|
||||
|
||||
#include <freerdp/client/cliprdr.h>
|
||||
|
||||
wfClipboard* wlf_clipboard_new(wlfContext* wfc);
|
||||
void wlf_clipboard_free(wfClipboard* clipboard);
|
||||
|
||||
BOOL wlf_cliprdr_init(wfClipboard* clipboard, CliprdrClientContext* cliprdr);
|
||||
BOOL wlf_cliprdr_uninit(wfClipboard* clipboard, CliprdrClientContext* cliprdr);
|
||||
|
||||
BOOL wlf_cliprdr_handle_event(wfClipboard* clipboard, const UwacClipboardEvent* event);
|
||||
|
||||
#endif /* FREERDP_CLIENT_WAYLAND_CLIPRDR_H */
|
||||
481
third_party/FreeRDP/client/Wayland/wlf_disp.c
vendored
Normal file
481
third_party/FreeRDP/client/Wayland/wlf_disp.c
vendored
Normal file
@@ -0,0 +1,481 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Display Control Channel
|
||||
*
|
||||
* Copyright 2018 Armin Novak <armin.novak@thincast.com>
|
||||
* Copyright 2018 Thincast Technologies GmbH
|
||||
*
|
||||
* 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/sysinfo.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <freerdp/timer.h>
|
||||
|
||||
#include "wlf_disp.h"
|
||||
|
||||
#define TAG CLIENT_TAG("wayland.disp")
|
||||
|
||||
#define RESIZE_MIN_DELAY_NS 200000000UL /* minimum delay in ns between two resizes */
|
||||
|
||||
struct s_wlfDispContext
|
||||
{
|
||||
wlfContext* wlc;
|
||||
DispClientContext* disp;
|
||||
BOOL haveXRandr;
|
||||
int eventBase, errorBase;
|
||||
int lastSentWidth, lastSentHeight;
|
||||
UINT64 lastSentDate;
|
||||
int targetWidth, targetHeight;
|
||||
BOOL activated;
|
||||
BOOL waitingResize;
|
||||
BOOL fullscreen;
|
||||
UINT16 lastSentDesktopOrientation;
|
||||
UINT32 lastSentDesktopScaleFactor;
|
||||
UINT32 lastSentDeviceScaleFactor;
|
||||
FreeRDP_TimerID timerID;
|
||||
};
|
||||
|
||||
static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp, BOOL fromTimer);
|
||||
static BOOL wlf_disp_check_context(void* context, wlfContext** ppwlc, wlfDispContext** ppwlfDisp,
|
||||
rdpSettings** ppSettings);
|
||||
static UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors,
|
||||
size_t nmonitors);
|
||||
|
||||
static BOOL wlf_disp_settings_changed(wlfDispContext* wlfDisp)
|
||||
{
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
WINPR_ASSERT(wlfDisp);
|
||||
WINPR_ASSERT(wlfDisp->wlc);
|
||||
|
||||
settings = wlfDisp->wlc->common.context.settings;
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
if (wlfDisp->lastSentWidth != wlfDisp->targetWidth)
|
||||
return TRUE;
|
||||
|
||||
if (wlfDisp->lastSentHeight != wlfDisp->targetHeight)
|
||||
return TRUE;
|
||||
|
||||
if (wlfDisp->lastSentDesktopOrientation !=
|
||||
freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation))
|
||||
return TRUE;
|
||||
|
||||
if (wlfDisp->lastSentDesktopScaleFactor !=
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor))
|
||||
return TRUE;
|
||||
|
||||
if (wlfDisp->lastSentDeviceScaleFactor !=
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor))
|
||||
return TRUE;
|
||||
|
||||
if (wlfDisp->fullscreen != wlfDisp->wlc->fullscreen)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL wlf_update_last_sent(wlfDispContext* wlfDisp)
|
||||
{
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
WINPR_ASSERT(wlfDisp);
|
||||
WINPR_ASSERT(wlfDisp->wlc);
|
||||
|
||||
settings = wlfDisp->wlc->common.context.settings;
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
wlfDisp->lastSentDate = winpr_GetTickCount64NS();
|
||||
wlfDisp->lastSentWidth = wlfDisp->targetWidth;
|
||||
wlfDisp->lastSentHeight = wlfDisp->targetHeight;
|
||||
wlfDisp->lastSentDesktopOrientation =
|
||||
freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
|
||||
wlfDisp->lastSentDesktopScaleFactor =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
|
||||
wlfDisp->lastSentDeviceScaleFactor =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
|
||||
wlfDisp->fullscreen = wlfDisp->wlc->fullscreen;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static uint64_t wlf_disp_OnTimer(rdpContext* context, WINPR_ATTR_UNUSED void* userdata,
|
||||
WINPR_ATTR_UNUSED FreeRDP_TimerID timerID,
|
||||
WINPR_ATTR_UNUSED uint64_t timestamp, uint64_t interval)
|
||||
{
|
||||
wlfContext* wlc = nullptr;
|
||||
wlfDispContext* wlfDisp = nullptr;
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings))
|
||||
return interval;
|
||||
|
||||
if (!wlfDisp->activated || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
|
||||
return interval;
|
||||
|
||||
wlf_disp_sendResize(wlfDisp, TRUE);
|
||||
wlfDisp->timerID = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL update_timer(wlfDispContext* wlfDisp, uint64_t intervalNS)
|
||||
{
|
||||
WINPR_ASSERT(wlfDisp);
|
||||
|
||||
if (wlfDisp->timerID == 0)
|
||||
{
|
||||
rdpContext* context = &wlfDisp->wlc->common.context;
|
||||
|
||||
wlfDisp->timerID = freerdp_timer_add(context, intervalNS, wlf_disp_OnTimer, nullptr, true);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp, BOOL fromTimer)
|
||||
{
|
||||
DISPLAY_CONTROL_MONITOR_LAYOUT layout;
|
||||
wlfContext* wlc = nullptr;
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
if (!wlfDisp || !wlfDisp->wlc)
|
||||
return FALSE;
|
||||
|
||||
wlc = wlfDisp->wlc;
|
||||
settings = wlc->common.context.settings;
|
||||
|
||||
if (!settings)
|
||||
return FALSE;
|
||||
|
||||
if (!wlfDisp->activated || !wlfDisp->disp)
|
||||
return update_timer(wlfDisp, RESIZE_MIN_DELAY_NS);
|
||||
|
||||
const uint64_t now = winpr_GetTickCount64NS();
|
||||
const uint64_t diff = now - wlfDisp->lastSentDate;
|
||||
if (diff < RESIZE_MIN_DELAY_NS)
|
||||
return update_timer(wlfDisp, RESIZE_MIN_DELAY_NS);
|
||||
|
||||
if (!fromTimer && (wlfDisp->timerID != 0))
|
||||
return TRUE;
|
||||
|
||||
if (!wlf_disp_settings_changed(wlfDisp))
|
||||
return TRUE;
|
||||
|
||||
if (wlc->fullscreen && (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) > 0))
|
||||
{
|
||||
const rdpMonitor* monitors =
|
||||
freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray);
|
||||
const size_t nmonitors = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount);
|
||||
if (wlf_disp_sendLayout(wlfDisp->disp, monitors, nmonitors) != CHANNEL_RC_OK)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
wlfDisp->waitingResize = TRUE;
|
||||
layout.Flags = DISPLAY_CONTROL_MONITOR_PRIMARY;
|
||||
layout.Top = layout.Left = 0;
|
||||
layout.Width = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetWidth);
|
||||
layout.Height = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetHeight);
|
||||
layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
|
||||
layout.DesktopScaleFactor =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
|
||||
layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
|
||||
layout.PhysicalWidth = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetWidth);
|
||||
layout.PhysicalHeight = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetHeight);
|
||||
|
||||
if (IFCALLRESULT(CHANNEL_RC_OK, wlfDisp->disp->SendMonitorLayout, wlfDisp->disp, 1,
|
||||
&layout) != CHANNEL_RC_OK)
|
||||
return FALSE;
|
||||
}
|
||||
return wlf_update_last_sent(wlfDisp);
|
||||
}
|
||||
|
||||
static BOOL wlf_disp_set_window_resizable(WINPR_ATTR_UNUSED wlfDispContext* wlfDisp)
|
||||
{
|
||||
WLog_ERR("TODO", "TODO: implement");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL wlf_disp_check_context(void* context, wlfContext** ppwlc, wlfDispContext** ppwlfDisp,
|
||||
rdpSettings** ppSettings)
|
||||
{
|
||||
wlfContext* wlc = nullptr;
|
||||
|
||||
if (!context)
|
||||
return FALSE;
|
||||
|
||||
wlc = (wlfContext*)context;
|
||||
|
||||
if (!(wlc->disp))
|
||||
return FALSE;
|
||||
|
||||
if (!wlc->common.context.settings)
|
||||
return FALSE;
|
||||
|
||||
*ppwlc = wlc;
|
||||
*ppwlfDisp = wlc->disp;
|
||||
*ppSettings = wlc->common.context.settings;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void wlf_disp_OnActivated(void* context, const ActivatedEventArgs* e)
|
||||
{
|
||||
wlfContext* wlc = nullptr;
|
||||
wlfDispContext* wlfDisp = nullptr;
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings))
|
||||
return;
|
||||
|
||||
wlfDisp->waitingResize = FALSE;
|
||||
|
||||
if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
|
||||
{
|
||||
wlf_disp_set_window_resizable(wlfDisp);
|
||||
|
||||
if (e->firstActivation)
|
||||
return;
|
||||
|
||||
wlf_disp_sendResize(wlfDisp, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void wlf_disp_OnGraphicsReset(void* context, const GraphicsResetEventArgs* e)
|
||||
{
|
||||
wlfContext* wlc = nullptr;
|
||||
wlfDispContext* wlfDisp = nullptr;
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
WINPR_UNUSED(e);
|
||||
if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings))
|
||||
return;
|
||||
|
||||
wlfDisp->waitingResize = FALSE;
|
||||
|
||||
if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
|
||||
{
|
||||
wlf_disp_set_window_resizable(wlfDisp);
|
||||
wlf_disp_sendResize(wlfDisp, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
wlfDispContext* wlf_disp_new(wlfContext* wlc)
|
||||
{
|
||||
if (!wlc || !wlc->common.context.settings || !wlc->common.context.pubSub)
|
||||
return nullptr;
|
||||
|
||||
rdpSettings* settings = wlc->common.context.settings;
|
||||
wPubSub* pubSub = wlc->common.context.pubSub;
|
||||
|
||||
if (PubSub_SubscribeActivated(pubSub, wlf_disp_OnActivated) < 0)
|
||||
return nullptr;
|
||||
if (PubSub_SubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset) < 0)
|
||||
return nullptr;
|
||||
|
||||
wlfDispContext* ret = calloc(1, sizeof(wlfDispContext));
|
||||
|
||||
if (!ret)
|
||||
return nullptr;
|
||||
|
||||
ret->wlc = wlc;
|
||||
ret->lastSentWidth = ret->targetWidth =
|
||||
WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
|
||||
ret->lastSentHeight = ret->targetHeight =
|
||||
WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wlf_disp_free(wlfDispContext* disp)
|
||||
{
|
||||
if (!disp)
|
||||
return;
|
||||
|
||||
if (disp->wlc)
|
||||
{
|
||||
wPubSub* pubSub = disp->wlc->common.context.pubSub;
|
||||
PubSub_UnsubscribeActivated(pubSub, wlf_disp_OnActivated);
|
||||
PubSub_UnsubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset);
|
||||
}
|
||||
|
||||
free(disp);
|
||||
}
|
||||
|
||||
UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, size_t nmonitors)
|
||||
{
|
||||
UINT ret = CHANNEL_RC_OK;
|
||||
DISPLAY_CONTROL_MONITOR_LAYOUT* layouts = nullptr;
|
||||
wlfDispContext* wlfDisp = nullptr;
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
WINPR_ASSERT(disp);
|
||||
WINPR_ASSERT(monitors);
|
||||
WINPR_ASSERT(nmonitors > 0);
|
||||
WINPR_ASSERT(nmonitors <= UINT32_MAX);
|
||||
|
||||
wlfDisp = (wlfDispContext*)disp->custom;
|
||||
WINPR_ASSERT(wlfDisp);
|
||||
WINPR_ASSERT(wlfDisp->wlc);
|
||||
|
||||
settings = wlfDisp->wlc->common.context.settings;
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
layouts = calloc(nmonitors, sizeof(DISPLAY_CONTROL_MONITOR_LAYOUT));
|
||||
|
||||
if (!layouts)
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
|
||||
for (size_t i = 0; i < nmonitors; i++)
|
||||
{
|
||||
const rdpMonitor* monitor = &monitors[i];
|
||||
DISPLAY_CONTROL_MONITOR_LAYOUT* layout = &layouts[i];
|
||||
|
||||
layout->Flags = (monitor->is_primary ? DISPLAY_CONTROL_MONITOR_PRIMARY : 0);
|
||||
layout->Left = monitor->x;
|
||||
layout->Top = monitor->y;
|
||||
layout->Width = WINPR_ASSERTING_INT_CAST(UINT32, monitor->width);
|
||||
layout->Height = WINPR_ASSERTING_INT_CAST(UINT32, monitor->height);
|
||||
layout->Orientation = ORIENTATION_LANDSCAPE;
|
||||
layout->PhysicalWidth = monitor->attributes.physicalWidth;
|
||||
layout->PhysicalHeight = monitor->attributes.physicalHeight;
|
||||
|
||||
switch (monitor->attributes.orientation)
|
||||
{
|
||||
case 90:
|
||||
layout->Orientation = ORIENTATION_PORTRAIT;
|
||||
break;
|
||||
|
||||
case 180:
|
||||
layout->Orientation = ORIENTATION_LANDSCAPE_FLIPPED;
|
||||
break;
|
||||
|
||||
case 270:
|
||||
layout->Orientation = ORIENTATION_PORTRAIT_FLIPPED;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
/* MS-RDPEDISP - 2.2.2.2.1:
|
||||
* Orientation (4 bytes): A 32-bit unsigned integer that specifies the
|
||||
* orientation of the monitor in degrees. Valid values are 0, 90, 180
|
||||
* or 270
|
||||
*
|
||||
* So we default to ORIENTATION_LANDSCAPE
|
||||
*/
|
||||
layout->Orientation = ORIENTATION_LANDSCAPE;
|
||||
break;
|
||||
}
|
||||
|
||||
layout->DesktopScaleFactor =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
|
||||
layout->DeviceScaleFactor =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
|
||||
}
|
||||
|
||||
ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, (UINT32)nmonitors, layouts);
|
||||
free(layouts);
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL wlf_disp_handle_configure(wlfDispContext* disp, int32_t width, int32_t height)
|
||||
{
|
||||
if (!disp)
|
||||
return FALSE;
|
||||
|
||||
disp->targetWidth = width;
|
||||
disp->targetHeight = height;
|
||||
return wlf_disp_sendResize(disp, FALSE);
|
||||
}
|
||||
|
||||
static UINT wlf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors,
|
||||
UINT32 maxMonitorAreaFactorA, UINT32 maxMonitorAreaFactorB)
|
||||
{
|
||||
/* we're called only if dynamic resolution update is activated */
|
||||
wlfDispContext* wlfDisp = nullptr;
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
WINPR_ASSERT(disp);
|
||||
|
||||
wlfDisp = (wlfDispContext*)disp->custom;
|
||||
WINPR_ASSERT(wlfDisp);
|
||||
WINPR_ASSERT(wlfDisp->wlc);
|
||||
|
||||
settings = wlfDisp->wlc->common.context.settings;
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
WLog_DBG(TAG,
|
||||
"DisplayControlCapsPdu: MaxNumMonitors: %" PRIu32 " MaxMonitorAreaFactorA: %" PRIu32
|
||||
" MaxMonitorAreaFactorB: %" PRIu32 "",
|
||||
maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
|
||||
wlfDisp->activated = TRUE;
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
|
||||
return CHANNEL_RC_OK;
|
||||
|
||||
WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable");
|
||||
return wlf_disp_set_window_resizable(wlfDisp) ? CHANNEL_RC_OK : CHANNEL_RC_NO_MEMORY;
|
||||
}
|
||||
|
||||
BOOL wlf_disp_init(wlfDispContext* wlfDisp, DispClientContext* disp)
|
||||
{
|
||||
rdpSettings* settings = nullptr;
|
||||
|
||||
if (!wlfDisp || !wlfDisp->wlc || !disp)
|
||||
return FALSE;
|
||||
|
||||
settings = wlfDisp->wlc->common.context.settings;
|
||||
|
||||
if (!settings)
|
||||
return FALSE;
|
||||
|
||||
wlfDisp->disp = disp;
|
||||
disp->custom = (void*)wlfDisp;
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
|
||||
{
|
||||
disp->DisplayControlCaps = wlf_DisplayControlCaps;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL wlf_disp_uninit(wlfDispContext* wlfDisp, DispClientContext* disp)
|
||||
{
|
||||
if (!wlfDisp || !disp)
|
||||
return FALSE;
|
||||
|
||||
wlfDisp->disp = nullptr;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wlf_list_monitors(wlfContext* wlc)
|
||||
{
|
||||
uint32_t nmonitors = UwacDisplayGetNbOutputs(wlc->display);
|
||||
|
||||
for (uint32_t i = 0; i < nmonitors; i++)
|
||||
{
|
||||
const UwacOutput* monitor =
|
||||
UwacDisplayGetOutput(wlc->display, WINPR_ASSERTING_INT_CAST(int, i));
|
||||
UwacSize resolution;
|
||||
UwacPosition pos;
|
||||
|
||||
if (!monitor)
|
||||
continue;
|
||||
UwacOutputGetPosition(monitor, &pos);
|
||||
UwacOutputGetResolution(monitor, &resolution);
|
||||
|
||||
printf(" %s [%u] %dx%d\t+%d+%d\n", (i == 0) ? "*" : " ", i, resolution.width,
|
||||
resolution.height, pos.x, pos.y);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
38
third_party/FreeRDP/client/Wayland/wlf_disp.h
vendored
Normal file
38
third_party/FreeRDP/client/Wayland/wlf_disp.h
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Display Control Channel
|
||||
*
|
||||
* Copyright 2018 Armin Novak <armin.novak@thincast.com>
|
||||
* Copyright 2018 Thincast Technologies GmbH
|
||||
*
|
||||
* 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_CLIENT_WAYLAND_DISP_H
|
||||
#define FREERDP_CLIENT_WAYLAND_DISP_H
|
||||
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/client/disp.h>
|
||||
|
||||
#include "wlfreerdp.h"
|
||||
|
||||
FREERDP_API BOOL wlf_disp_init(wlfDispContext* wlfDisp, DispClientContext* disp);
|
||||
FREERDP_API BOOL wlf_disp_uninit(wlfDispContext* wlfDisp, DispClientContext* disp);
|
||||
|
||||
wlfDispContext* wlf_disp_new(wlfContext* wlc);
|
||||
void wlf_disp_free(wlfDispContext* disp);
|
||||
BOOL wlf_disp_handle_configure(wlfDispContext* disp, int32_t width, int32_t height);
|
||||
void wlf_disp_resized(wlfDispContext* disp);
|
||||
|
||||
int wlf_list_monitors(wlfContext* wlc);
|
||||
|
||||
#endif /* FREERDP_CLIENT_WAYLAND_DISP_H */
|
||||
452
third_party/FreeRDP/client/Wayland/wlf_input.c
vendored
Normal file
452
third_party/FreeRDP/client/Wayland/wlf_input.c
vendored
Normal file
@@ -0,0 +1,452 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Input
|
||||
*
|
||||
* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
|
||||
* Copyright 2015 David Fort <contact@hardening-consulting.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 <stdlib.h>
|
||||
#include <float.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/locale/keyboard.h>
|
||||
#include <uwac/uwac.h>
|
||||
|
||||
#include "wlfreerdp.h"
|
||||
#include "wlf_input.h"
|
||||
|
||||
static BOOL scale_signed_coordinates(rdpContext* context, int32_t* x, int32_t* y,
|
||||
BOOL fromLocalToRDP)
|
||||
{
|
||||
BOOL rc = 0;
|
||||
UINT32 ux = 0;
|
||||
UINT32 uy = 0;
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(x);
|
||||
WINPR_ASSERT(y);
|
||||
WINPR_ASSERT(*x >= 0);
|
||||
WINPR_ASSERT(*y >= 0);
|
||||
|
||||
ux = (UINT32)*x;
|
||||
uy = (UINT32)*y;
|
||||
rc = wlf_scale_coordinates(context, &ux, &uy, fromLocalToRDP);
|
||||
WINPR_ASSERT(ux < INT32_MAX);
|
||||
WINPR_ASSERT(uy < INT32_MAX);
|
||||
*x = (int32_t)ux;
|
||||
*y = (int32_t)uy;
|
||||
return rc;
|
||||
}
|
||||
|
||||
BOOL wlf_handle_pointer_enter(freerdp* instance, const UwacPointerEnterLeaveEvent* ev)
|
||||
{
|
||||
uint32_t x = 0;
|
||||
uint32_t y = 0;
|
||||
rdpClientContext* cctx = nullptr;
|
||||
|
||||
if (!instance || !ev)
|
||||
return FALSE;
|
||||
|
||||
x = ev->x;
|
||||
y = ev->y;
|
||||
|
||||
if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
|
||||
cctx = (rdpClientContext*)instance->context;
|
||||
return freerdp_client_send_button_event(cctx, FALSE, PTR_FLAGS_MOVE,
|
||||
WINPR_ASSERTING_INT_CAST(int, x),
|
||||
WINPR_ASSERTING_INT_CAST(int, y));
|
||||
}
|
||||
|
||||
BOOL wlf_handle_pointer_motion(freerdp* instance, const UwacPointerMotionEvent* ev)
|
||||
{
|
||||
rdpClientContext* cctx = nullptr;
|
||||
|
||||
if (!instance || !ev)
|
||||
return FALSE;
|
||||
|
||||
cctx = (rdpClientContext*)instance->context;
|
||||
WINPR_ASSERT(cctx);
|
||||
|
||||
uint32_t x = ev->x;
|
||||
uint32_t y = ev->y;
|
||||
|
||||
if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
|
||||
return freerdp_client_send_button_event(cctx, FALSE, PTR_FLAGS_MOVE,
|
||||
WINPR_ASSERTING_INT_CAST(int32_t, x),
|
||||
WINPR_ASSERTING_INT_CAST(int32_t, y));
|
||||
}
|
||||
|
||||
BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent* ev)
|
||||
{
|
||||
rdpClientContext* cctx = nullptr;
|
||||
UINT16 flags = 0;
|
||||
UINT16 xflags = 0;
|
||||
|
||||
if (!instance || !ev)
|
||||
return FALSE;
|
||||
|
||||
cctx = (rdpClientContext*)instance->context;
|
||||
WINPR_ASSERT(cctx);
|
||||
|
||||
uint32_t x = ev->x;
|
||||
uint32_t y = ev->y;
|
||||
|
||||
if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
|
||||
if (ev->state == WL_POINTER_BUTTON_STATE_PRESSED)
|
||||
{
|
||||
flags |= PTR_FLAGS_DOWN;
|
||||
xflags |= PTR_XFLAGS_DOWN;
|
||||
}
|
||||
|
||||
switch (ev->button)
|
||||
{
|
||||
case BTN_LEFT:
|
||||
flags |= PTR_FLAGS_BUTTON1;
|
||||
break;
|
||||
|
||||
case BTN_RIGHT:
|
||||
flags |= PTR_FLAGS_BUTTON2;
|
||||
break;
|
||||
|
||||
case BTN_MIDDLE:
|
||||
flags |= PTR_FLAGS_BUTTON3;
|
||||
break;
|
||||
|
||||
case BTN_SIDE:
|
||||
xflags |= PTR_XFLAGS_BUTTON1;
|
||||
break;
|
||||
|
||||
case BTN_EXTRA:
|
||||
xflags |= PTR_XFLAGS_BUTTON2;
|
||||
break;
|
||||
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const INT32 cx = WINPR_ASSERTING_INT_CAST(int32_t, x);
|
||||
const INT32 cy = WINPR_ASSERTING_INT_CAST(int32_t, y);
|
||||
|
||||
if ((flags & ~PTR_FLAGS_DOWN) != 0)
|
||||
return freerdp_client_send_button_event(cctx, FALSE, flags, cx, cy);
|
||||
|
||||
if ((xflags & ~PTR_XFLAGS_DOWN) != 0)
|
||||
return freerdp_client_send_extended_button_event(cctx, FALSE, xflags, cx, cy);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev)
|
||||
{
|
||||
wlfContext* context = nullptr;
|
||||
if (!instance || !instance->context || !ev)
|
||||
return FALSE;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
return ArrayList_Append(context->events, ev);
|
||||
}
|
||||
|
||||
BOOL wlf_handle_pointer_axis_discrete(freerdp* instance, const UwacPointerAxisEvent* ev)
|
||||
{
|
||||
wlfContext* context = nullptr;
|
||||
if (!instance || !instance->context || !ev)
|
||||
return FALSE;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
return ArrayList_Append(context->events, ev);
|
||||
}
|
||||
|
||||
static BOOL wlf_handle_wheel(freerdp* instance, uint32_t x, uint32_t y, uint32_t axis,
|
||||
int32_t value)
|
||||
{
|
||||
rdpClientContext* cctx = nullptr;
|
||||
UINT16 flags = 0;
|
||||
int32_t direction = 0;
|
||||
uint32_t avalue = (uint32_t)abs(value);
|
||||
|
||||
WINPR_ASSERT(instance);
|
||||
|
||||
cctx = (rdpClientContext*)instance->context;
|
||||
WINPR_ASSERT(cctx);
|
||||
|
||||
if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
|
||||
direction = value;
|
||||
switch (axis)
|
||||
{
|
||||
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||
flags |= PTR_FLAGS_WHEEL;
|
||||
if (direction > 0)
|
||||
flags |= PTR_FLAGS_WHEEL_NEGATIVE;
|
||||
break;
|
||||
|
||||
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||
flags |= PTR_FLAGS_HWHEEL;
|
||||
if (direction < 0)
|
||||
flags |= PTR_FLAGS_WHEEL_NEGATIVE;
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Wheel rotation steps:
|
||||
*
|
||||
* positive: 0 ... 0xFF -> slow ... fast
|
||||
* negative: 0 ... 0xFF -> fast ... slow
|
||||
*/
|
||||
|
||||
while (avalue > 0)
|
||||
{
|
||||
const UINT16 cval = (avalue > 0xFF) ? 0xFF : (UINT16)avalue;
|
||||
UINT16 cflags = flags | cval;
|
||||
/* Convert negative values to 9bit twos complement */
|
||||
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
|
||||
cflags = (flags & 0xFF00) | (0x100 - cval);
|
||||
if (!freerdp_client_send_wheel_event(cctx, cflags))
|
||||
return FALSE;
|
||||
|
||||
avalue -= cval;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev)
|
||||
{
|
||||
BOOL success = TRUE;
|
||||
BOOL handle = FALSE;
|
||||
wlfContext* context = nullptr;
|
||||
enum wl_pointer_axis_source source = WL_POINTER_AXIS_SOURCE_CONTINUOUS;
|
||||
|
||||
if (!instance || !ev || !instance->context)
|
||||
return FALSE;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
|
||||
for (size_t x = 0; x < ArrayList_Count(context->events); x++)
|
||||
{
|
||||
UwacEvent* cev = ArrayList_GetItem(context->events, x);
|
||||
if (!cev)
|
||||
continue;
|
||||
if (cev->type == UWAC_EVENT_POINTER_SOURCE)
|
||||
{
|
||||
handle = TRUE;
|
||||
source = cev->mouse_source.axis_source;
|
||||
}
|
||||
}
|
||||
|
||||
/* We need source events to determine how to interpret the data */
|
||||
if (handle)
|
||||
{
|
||||
for (size_t x = 0; x < ArrayList_Count(context->events); x++)
|
||||
{
|
||||
UwacEvent* cev = ArrayList_GetItem(context->events, x);
|
||||
if (!cev)
|
||||
continue;
|
||||
|
||||
switch (source)
|
||||
{
|
||||
/* If we have a mouse wheel, just use discrete data */
|
||||
case WL_POINTER_AXIS_SOURCE_WHEEL:
|
||||
#if defined(WL_POINTER_AXIS_SOURCE_WHEEL_TILT_SINCE_VERSION)
|
||||
case WL_POINTER_AXIS_SOURCE_WHEEL_TILT:
|
||||
#endif
|
||||
if (cev->type == UWAC_EVENT_POINTER_AXIS_DISCRETE)
|
||||
{
|
||||
/* Get the number of steps, multiply by default step width of 120 */
|
||||
int32_t val = cev->mouse_axis.value * 0x78;
|
||||
/* No wheel event received, success! */
|
||||
if (!wlf_handle_wheel(instance, cev->mouse_axis.x, cev->mouse_axis.y,
|
||||
cev->mouse_axis.axis, val))
|
||||
success = FALSE;
|
||||
}
|
||||
break;
|
||||
/* If we have a touch pad we get actual data, scale */
|
||||
case WL_POINTER_AXIS_SOURCE_FINGER:
|
||||
case WL_POINTER_AXIS_SOURCE_CONTINUOUS:
|
||||
if (cev->type == UWAC_EVENT_POINTER_AXIS)
|
||||
{
|
||||
double dval = wl_fixed_to_double(cev->mouse_axis.value);
|
||||
int32_t val = (int32_t)(dval * 0x78 / 10.0);
|
||||
if (!wlf_handle_wheel(instance, cev->mouse_axis.x, cev->mouse_axis.y,
|
||||
cev->mouse_axis.axis, val))
|
||||
success = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList_Clear(context->events);
|
||||
return success;
|
||||
}
|
||||
|
||||
BOOL wlf_handle_pointer_source(freerdp* instance, const UwacPointerSourceEvent* ev)
|
||||
{
|
||||
wlfContext* context = nullptr;
|
||||
if (!instance || !instance->context || !ev)
|
||||
return FALSE;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
return ArrayList_Append(context->events, ev);
|
||||
}
|
||||
|
||||
BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev)
|
||||
{
|
||||
if (!instance || !ev)
|
||||
return FALSE;
|
||||
|
||||
WINPR_ASSERT(instance->context);
|
||||
wlfContext* ctx = (wlfContext*)instance->context;
|
||||
if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard) &&
|
||||
ev->raw_key == KEY_RIGHTCTRL)
|
||||
wlf_handle_ungrab_key(instance, ev);
|
||||
|
||||
rdpInput* input = instance->context->input;
|
||||
|
||||
const DWORD vc = GetVirtualKeyCodeFromKeycode(ev->raw_key, WINPR_KEYCODE_TYPE_EVDEV);
|
||||
const DWORD sc = GetVirtualScanCodeFromVirtualKeyCode(vc, WINPR_KBD_TYPE_IBM_ENHANCED);
|
||||
const DWORD rdp_scancode = freerdp_keyboard_remap_key(ctx->remap_table, sc);
|
||||
|
||||
if (rdp_scancode == RDP_SCANCODE_UNKNOWN)
|
||||
return TRUE;
|
||||
|
||||
return freerdp_input_send_keyboard_event_ex(input, ev->pressed, ev->repeated, rdp_scancode);
|
||||
}
|
||||
|
||||
BOOL wlf_handle_ungrab_key(freerdp* instance, const UwacKeyEvent* ev)
|
||||
{
|
||||
wlfContext* context = nullptr;
|
||||
if (!instance || !instance->context || !ev)
|
||||
return FALSE;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
|
||||
return UwacSeatInhibitShortcuts(context->seat, false) == UWAC_SUCCESS;
|
||||
}
|
||||
|
||||
BOOL wlf_keyboard_enter(freerdp* instance, const UwacKeyboardEnterLeaveEvent* ev)
|
||||
{
|
||||
if (!instance || !ev)
|
||||
return FALSE;
|
||||
|
||||
((wlfContext*)instance->context)->focusing = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL wlf_keyboard_modifiers(freerdp* instance, const UwacKeyboardModifiersEvent* ev)
|
||||
{
|
||||
rdpInput* input = nullptr;
|
||||
UINT16 syncFlags = 0;
|
||||
wlfContext* wlf = nullptr;
|
||||
|
||||
if (!instance || !ev)
|
||||
return FALSE;
|
||||
|
||||
wlf = (wlfContext*)instance->context;
|
||||
WINPR_ASSERT(wlf);
|
||||
|
||||
input = instance->context->input;
|
||||
WINPR_ASSERT(input);
|
||||
|
||||
syncFlags = 0;
|
||||
|
||||
if (ev->modifiers & UWAC_MOD_CAPS_MASK)
|
||||
syncFlags |= KBD_SYNC_CAPS_LOCK;
|
||||
if (ev->modifiers & UWAC_MOD_NUM_MASK)
|
||||
syncFlags |= KBD_SYNC_NUM_LOCK;
|
||||
|
||||
if (!wlf->focusing)
|
||||
return TRUE;
|
||||
|
||||
((wlfContext*)instance->context)->focusing = FALSE;
|
||||
|
||||
return freerdp_input_send_focus_in_event(input, syncFlags) &&
|
||||
freerdp_client_send_button_event(&wlf->common, FALSE, PTR_FLAGS_MOVE, 0, 0);
|
||||
}
|
||||
|
||||
BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev)
|
||||
{
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
|
||||
WINPR_ASSERT(instance);
|
||||
WINPR_ASSERT(ev);
|
||||
|
||||
wlfContext* wlf = (wlfContext*)instance->context;
|
||||
WINPR_ASSERT(wlf);
|
||||
|
||||
x = ev->x;
|
||||
y = ev->y;
|
||||
|
||||
if (!scale_signed_coordinates(instance->context, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
|
||||
return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_UP, ev->id, 0, x, y);
|
||||
}
|
||||
|
||||
BOOL wlf_handle_touch_down(freerdp* instance, const UwacTouchDown* ev)
|
||||
{
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
|
||||
WINPR_ASSERT(instance);
|
||||
WINPR_ASSERT(ev);
|
||||
|
||||
wlfContext* wlf = (wlfContext*)instance->context;
|
||||
WINPR_ASSERT(wlf);
|
||||
|
||||
x = ev->x;
|
||||
y = ev->y;
|
||||
|
||||
if (!scale_signed_coordinates(instance->context, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
|
||||
return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_DOWN, ev->id, 0, x, y);
|
||||
}
|
||||
|
||||
BOOL wlf_handle_touch_motion(freerdp* instance, const UwacTouchMotion* ev)
|
||||
{
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
|
||||
WINPR_ASSERT(instance);
|
||||
WINPR_ASSERT(ev);
|
||||
|
||||
wlfContext* wlf = (wlfContext*)instance->context;
|
||||
WINPR_ASSERT(wlf);
|
||||
|
||||
x = ev->x;
|
||||
y = ev->y;
|
||||
|
||||
if (!scale_signed_coordinates(instance->context, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
|
||||
return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_MOTION, 0,
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, ev->id), x, y);
|
||||
}
|
||||
45
third_party/FreeRDP/client/Wayland/wlf_input.h
vendored
Normal file
45
third_party/FreeRDP/client/Wayland/wlf_input.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Input
|
||||
*
|
||||
* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
|
||||
* Copyright 2015 David Fort <contact@hardening-consulting.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_CLIENT_WAYLAND_INPUT_H
|
||||
#define FREERDP_CLIENT_WAYLAND_INPUT_H
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/gdi/gdi.h>
|
||||
#include <freerdp/gdi/gfx.h>
|
||||
#include <uwac/uwac.h>
|
||||
|
||||
BOOL wlf_handle_pointer_enter(freerdp* instance, const UwacPointerEnterLeaveEvent* ev);
|
||||
BOOL wlf_handle_pointer_motion(freerdp* instance, const UwacPointerMotionEvent* ev);
|
||||
BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent* ev);
|
||||
BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev);
|
||||
BOOL wlf_handle_pointer_axis_discrete(freerdp* instance, const UwacPointerAxisEvent* ev);
|
||||
BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev);
|
||||
BOOL wlf_handle_pointer_source(freerdp* instance, const UwacPointerSourceEvent* ev);
|
||||
BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev);
|
||||
BOOL wlf_handle_touch_down(freerdp* instance, const UwacTouchDown* ev);
|
||||
BOOL wlf_handle_touch_motion(freerdp* instance, const UwacTouchMotion* ev);
|
||||
|
||||
BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev);
|
||||
BOOL wlf_handle_ungrab_key(freerdp* instance, const UwacKeyEvent* ev);
|
||||
BOOL wlf_keyboard_enter(freerdp* instance, const UwacKeyboardEnterLeaveEvent* ev);
|
||||
BOOL wlf_keyboard_modifiers(freerdp* instance, const UwacKeyboardModifiersEvent* ev);
|
||||
|
||||
#endif /* FREERDP_CLIENT_WAYLAND_INPUT_H */
|
||||
164
third_party/FreeRDP/client/Wayland/wlf_pointer.c
vendored
Normal file
164
third_party/FreeRDP/client/Wayland/wlf_pointer.c
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Mouse Pointer
|
||||
*
|
||||
* Copyright 2019 Armin Novak <armin.novak@thincast.com>
|
||||
* Copyright 2019 Thincast Technologies GmbH
|
||||
*
|
||||
* 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 <freerdp/config.h>
|
||||
|
||||
#include "wlf_pointer.h"
|
||||
#include "wlfreerdp.h"
|
||||
|
||||
#define TAG CLIENT_TAG("wayland.pointer")
|
||||
|
||||
typedef struct
|
||||
{
|
||||
rdpPointer pointer;
|
||||
size_t size;
|
||||
void* data;
|
||||
} wlfPointer;
|
||||
|
||||
static BOOL wlf_Pointer_New(rdpContext* context, rdpPointer* pointer)
|
||||
{
|
||||
wlfPointer* ptr = (wlfPointer*)pointer;
|
||||
|
||||
if (!ptr)
|
||||
return FALSE;
|
||||
|
||||
ptr->size = 4ULL * pointer->width * pointer->height;
|
||||
ptr->data = winpr_aligned_malloc(ptr->size, 16);
|
||||
|
||||
if (!ptr->data)
|
||||
return FALSE;
|
||||
|
||||
if (!freerdp_image_copy_from_pointer_data(
|
||||
ptr->data, PIXEL_FORMAT_BGRA32, 0, 0, 0, pointer->width, pointer->height,
|
||||
pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData,
|
||||
pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette))
|
||||
{
|
||||
winpr_aligned_free(ptr->data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void wlf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
|
||||
{
|
||||
wlfPointer* ptr = (wlfPointer*)pointer;
|
||||
WINPR_UNUSED(context);
|
||||
|
||||
if (ptr)
|
||||
winpr_aligned_free(ptr->data);
|
||||
}
|
||||
|
||||
static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
|
||||
{
|
||||
wlfContext* wlf = (wlfContext*)context;
|
||||
wlfPointer* ptr = (wlfPointer*)pointer;
|
||||
void* data = nullptr;
|
||||
size_t size = 0;
|
||||
UwacReturnCode rc = UWAC_ERROR_INTERNAL;
|
||||
BOOL res = FALSE;
|
||||
RECTANGLE_16 area;
|
||||
|
||||
if (!wlf || !wlf->seat)
|
||||
return FALSE;
|
||||
|
||||
UINT32 x = pointer->xPos;
|
||||
UINT32 y = pointer->yPos;
|
||||
UINT32 w = pointer->width;
|
||||
UINT32 h = pointer->height;
|
||||
|
||||
if (!wlf_scale_coordinates(context, &x, &y, FALSE) ||
|
||||
!wlf_scale_coordinates(context, &w, &h, FALSE))
|
||||
return FALSE;
|
||||
|
||||
size = 4ULL * w * h;
|
||||
data = malloc(size);
|
||||
|
||||
if (!data)
|
||||
return FALSE;
|
||||
|
||||
area.top = 0;
|
||||
area.left = 0;
|
||||
area.right = (UINT16)pointer->width;
|
||||
area.bottom = (UINT16)pointer->height;
|
||||
|
||||
if (!wlf_copy_image(ptr->data, 4ULL * pointer->width, pointer->width, pointer->height, data,
|
||||
4ULL * w, w, h, &area,
|
||||
freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing)))
|
||||
goto fail;
|
||||
|
||||
rc = UwacSeatSetMouseCursor(wlf->seat, data, size, w, h, x, y);
|
||||
|
||||
if (rc == UWAC_SUCCESS)
|
||||
res = TRUE;
|
||||
|
||||
fail:
|
||||
free(data);
|
||||
return res;
|
||||
}
|
||||
|
||||
static BOOL wlf_Pointer_SetNull(rdpContext* context)
|
||||
{
|
||||
wlfContext* wlf = (wlfContext*)context;
|
||||
|
||||
if (!wlf || !wlf->seat)
|
||||
return FALSE;
|
||||
|
||||
if (UwacSeatSetMouseCursor(wlf->seat, nullptr, 0, 0, 0, 0, 0) != UWAC_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL wlf_Pointer_SetDefault(rdpContext* context)
|
||||
{
|
||||
wlfContext* wlf = (wlfContext*)context;
|
||||
|
||||
if (!wlf || !wlf->seat)
|
||||
return FALSE;
|
||||
|
||||
if (UwacSeatSetMouseCursor(wlf->seat, nullptr, 1, 0, 0, 0, 0) != UWAC_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL wlf_Pointer_SetPosition(WINPR_ATTR_UNUSED rdpContext* context,
|
||||
WINPR_ATTR_UNUSED UINT32 x, WINPR_ATTR_UNUSED UINT32 y)
|
||||
{
|
||||
// TODO
|
||||
WLog_ERR(TAG, "TODO: implement");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL wlf_register_pointer(rdpGraphics* graphics)
|
||||
{
|
||||
rdpPointer pointer = WINPR_C_ARRAY_INIT;
|
||||
|
||||
pointer.size = sizeof(wlfPointer);
|
||||
pointer.New = wlf_Pointer_New;
|
||||
pointer.Free = wlf_Pointer_Free;
|
||||
pointer.Set = wlf_Pointer_Set;
|
||||
pointer.SetNull = wlf_Pointer_SetNull;
|
||||
pointer.SetDefault = wlf_Pointer_SetDefault;
|
||||
pointer.SetPosition = wlf_Pointer_SetPosition;
|
||||
graphics_register_pointer(graphics, &pointer);
|
||||
return TRUE;
|
||||
}
|
||||
28
third_party/FreeRDP/client/Wayland/wlf_pointer.h
vendored
Normal file
28
third_party/FreeRDP/client/Wayland/wlf_pointer.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Mouse Pointer
|
||||
*
|
||||
* Copyright 2019 Armin Novak <armin.novak@thincast.com>
|
||||
* Copyright 2019 Thincast Technologies GmbH
|
||||
*
|
||||
* 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_CLIENT_WAYLAND_POINTER_H
|
||||
#define FREERDP_CLIENT_WAYLAND_POINTER_H
|
||||
|
||||
#include <freerdp/graphics.h>
|
||||
|
||||
BOOL wlf_register_pointer(rdpGraphics* graphics);
|
||||
|
||||
#endif /* FREERDP_CLIENT_WAYLAND_POINTER_H */
|
||||
38
third_party/FreeRDP/client/Wayland/wlfreerdp.1.in
vendored
Normal file
38
third_party/FreeRDP/client/Wayland/wlfreerdp.1.in
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
.de URL
|
||||
\\$2 \(laURL: \\$1 \(ra\\$3
|
||||
..
|
||||
.if \n[.g] .mso www.tmac
|
||||
.TH @MANPAGE_NAME@ 1 2017-01-12 "@FREERDP_VERSION_FULL@" "FreeRDP"
|
||||
.SH NAME
|
||||
@MANPAGE_NAME@ \- FreeRDP wayland client
|
||||
.SH SYNOPSIS
|
||||
.B @MANPAGE_NAME@
|
||||
[file]
|
||||
[\fIdefault_client_options\fP]
|
||||
[\fB/v\fP:<server>[:port]]
|
||||
[\fB/version\fP]
|
||||
[\fB/help\fP]
|
||||
.SH DESCRIPTION
|
||||
.B @MANPAGE_NAME@
|
||||
is a wayland Remote Desktop Protocol (RDP) client which is part of the FreeRDP project. A RDP server is built-in to many editions of Windows.. Alternative servers included ogon, gnome-remote-desktop, xrdp and VRDP (VirtualBox).
|
||||
.SH OPTIONS
|
||||
The wayland client also supports a lot of the \fIdefault client options\fP which are not described here. For details on those see the xfreerdp(1) man page.
|
||||
.IP \fB/v:\fP\fI<server>[:port]\fP
|
||||
The server hostname or IP, and optionally the port, to connect to.
|
||||
.IP /version
|
||||
Print the version and exit.
|
||||
.IP /help
|
||||
Print the help and exit.
|
||||
.SH EXIT STATUS
|
||||
.TP
|
||||
.B 0
|
||||
Successful program execution.
|
||||
.TP
|
||||
.B not 0
|
||||
On failure.
|
||||
|
||||
.SH SEE ALSO
|
||||
xfreerdp(1) wlog(7)
|
||||
|
||||
.SH AUTHOR
|
||||
FreeRDP <team@freerdp.com>
|
||||
782
third_party/FreeRDP/client/Wayland/wlfreerdp.c
vendored
Normal file
782
third_party/FreeRDP/client/Wayland/wlfreerdp.c
vendored
Normal file
@@ -0,0 +1,782 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Client
|
||||
*
|
||||
* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
|
||||
* Copyright 2016 Thincast Technologies GmbH
|
||||
* Copyright 2016 Armin Novak <armin.novak@thincast.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 <math.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <float.h>
|
||||
|
||||
#include <winpr/sysinfo.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <freerdp/client/cmdline.h>
|
||||
#include <freerdp/channels/channels.h>
|
||||
#include <freerdp/gdi/gdi.h>
|
||||
#include <freerdp/client.h>
|
||||
#include <freerdp/utils/signal.h>
|
||||
#include <freerdp/locale/keyboard.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <uwac/uwac.h>
|
||||
|
||||
#include "wlfreerdp.h"
|
||||
#include "wlf_input.h"
|
||||
#include "wlf_cliprdr.h"
|
||||
#include "wlf_disp.h"
|
||||
#include "wlf_channels.h"
|
||||
#include "wlf_pointer.h"
|
||||
|
||||
#define TAG CLIENT_TAG("wayland")
|
||||
|
||||
static BOOL wl_update_buffer(wlfContext* context_w, INT32 ix, INT32 iy, INT32 iw, INT32 ih)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
rdpGdi* gdi = nullptr;
|
||||
char* data = nullptr;
|
||||
UwacSize geometry = WINPR_C_ARRAY_INIT;
|
||||
size_t stride = 0;
|
||||
UwacReturnCode rc = UWAC_ERROR_INTERNAL;
|
||||
RECTANGLE_16 area = WINPR_C_ARRAY_INIT;
|
||||
|
||||
if (!context_w)
|
||||
return FALSE;
|
||||
|
||||
if ((ix < 0) || (iy < 0) || (iw < 0) || (ih < 0))
|
||||
return FALSE;
|
||||
|
||||
EnterCriticalSection(&context_w->critical);
|
||||
UINT32 x = WINPR_ASSERTING_INT_CAST(UINT16, ix);
|
||||
UINT32 y = WINPR_ASSERTING_INT_CAST(UINT16, iy);
|
||||
UINT32 w = WINPR_ASSERTING_INT_CAST(UINT16, iw);
|
||||
UINT32 h = WINPR_ASSERTING_INT_CAST(UINT16, ih);
|
||||
rc = UwacWindowGetDrawingBufferGeometry(context_w->window, &geometry, &stride);
|
||||
data = UwacWindowGetDrawingBuffer(context_w->window);
|
||||
|
||||
if (!data || (rc != UWAC_SUCCESS))
|
||||
goto fail;
|
||||
|
||||
gdi = context_w->common.context.gdi;
|
||||
|
||||
if (!gdi)
|
||||
goto fail;
|
||||
|
||||
/* Ignore output if the surface size does not match. */
|
||||
if (((INT64)x > geometry.width) || ((INT64)y > geometry.height))
|
||||
{
|
||||
res = TRUE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
area.left = WINPR_ASSERTING_INT_CAST(UINT16, x);
|
||||
area.top = WINPR_ASSERTING_INT_CAST(UINT16, y);
|
||||
area.right = WINPR_ASSERTING_INT_CAST(UINT16, x + w);
|
||||
area.bottom = WINPR_ASSERTING_INT_CAST(UINT16, y + h);
|
||||
|
||||
if (!wlf_copy_image(
|
||||
gdi->primary_buffer, gdi->stride, WINPR_ASSERTING_INT_CAST(size_t, gdi->width),
|
||||
WINPR_ASSERTING_INT_CAST(size_t, gdi->height), data, stride,
|
||||
WINPR_ASSERTING_INT_CAST(size_t, geometry.width),
|
||||
WINPR_ASSERTING_INT_CAST(size_t, geometry.height), &area,
|
||||
freerdp_settings_get_bool(context_w->common.context.settings, FreeRDP_SmartSizing)))
|
||||
goto fail;
|
||||
|
||||
if (!wlf_scale_coordinates(&context_w->common.context, &x, &y, FALSE))
|
||||
goto fail;
|
||||
|
||||
if (!wlf_scale_coordinates(&context_w->common.context, &w, &h, FALSE))
|
||||
goto fail;
|
||||
|
||||
if (UwacWindowAddDamage(context_w->window, x, y, w, h) != UWAC_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
if (UwacWindowSubmitBuffer(context_w->window, false) != UWAC_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
res = TRUE;
|
||||
fail:
|
||||
LeaveCriticalSection(&context_w->critical);
|
||||
return res;
|
||||
}
|
||||
|
||||
static BOOL wl_end_paint(rdpContext* context)
|
||||
{
|
||||
if (!context || !context->gdi || !context->gdi->primary)
|
||||
return FALSE;
|
||||
|
||||
rdpGdi* gdi = context->gdi;
|
||||
HGDI_DC hdc = gdi->primary->hdc;
|
||||
WINPR_ASSERT(hdc);
|
||||
if (!hdc->hwnd)
|
||||
return TRUE;
|
||||
|
||||
HGDI_WND hwnd = hdc->hwnd;
|
||||
WINPR_ASSERT(hwnd->invalid || (hwnd->ninvalid == 0));
|
||||
|
||||
if (hwnd->invalid->null)
|
||||
return TRUE;
|
||||
|
||||
const INT32 x = hwnd->invalid->x;
|
||||
const INT32 y = hwnd->invalid->y;
|
||||
const INT32 w = hwnd->invalid->w;
|
||||
const INT32 h = hwnd->invalid->h;
|
||||
wlfContext* context_w = (wlfContext*)context;
|
||||
if (!wl_update_buffer(context_w, x, y, w, h))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hwnd->invalid->null = TRUE;
|
||||
hwnd->ninvalid = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL wl_refresh_display(wlfContext* context)
|
||||
{
|
||||
rdpGdi* gdi = nullptr;
|
||||
|
||||
if (!context || !context->common.context.gdi)
|
||||
return FALSE;
|
||||
|
||||
gdi = context->common.context.gdi;
|
||||
return wl_update_buffer(context, 0, 0, gdi->width, gdi->height);
|
||||
}
|
||||
|
||||
static BOOL wl_resize_display(rdpContext* context)
|
||||
{
|
||||
wlfContext* wlc = (wlfContext*)context;
|
||||
rdpGdi* gdi = context->gdi;
|
||||
rdpSettings* settings = context->settings;
|
||||
|
||||
if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
|
||||
return FALSE;
|
||||
|
||||
return wl_refresh_display(wlc);
|
||||
}
|
||||
|
||||
static BOOL wl_pre_connect(freerdp* instance)
|
||||
{
|
||||
rdpSettings* settings = nullptr;
|
||||
wlfContext* context = nullptr;
|
||||
const UwacOutput* output = nullptr;
|
||||
UwacSize resolution;
|
||||
|
||||
if (!instance)
|
||||
return FALSE;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
settings = instance->context->settings;
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_CertificateCallbackPreferPEM, TRUE))
|
||||
return FALSE;
|
||||
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX))
|
||||
return FALSE;
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_WAYLAND))
|
||||
return FALSE;
|
||||
if (PubSub_SubscribeChannelConnected(instance->context->pubSub,
|
||||
wlf_OnChannelConnectedEventHandler) < 0)
|
||||
return FALSE;
|
||||
if (PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
|
||||
wlf_OnChannelDisconnectedEventHandler) < 0)
|
||||
return FALSE;
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
|
||||
{
|
||||
// Use the resolution of the first display output
|
||||
output = UwacDisplayGetOutput(context->display, 0);
|
||||
|
||||
if ((output != nullptr) && (UwacOutputGetResolution(output, &resolution) == UWAC_SUCCESS))
|
||||
{
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth,
|
||||
(UINT32)resolution.width))
|
||||
return FALSE;
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight,
|
||||
(UINT32)resolution.height))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
WLog_WARN(TAG, "Failed to get output resolution! Check your display settings");
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL wl_post_connect(freerdp* instance)
|
||||
{
|
||||
if (!instance || !instance->context)
|
||||
return FALSE;
|
||||
|
||||
wlfContext* context = (wlfContext*)instance->context;
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
rdpSettings* settings = instance->context->settings;
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
const char* title = "FreeRDP";
|
||||
const char* wtitle = freerdp_settings_get_string(settings, FreeRDP_WindowTitle);
|
||||
if (wtitle)
|
||||
title = wtitle;
|
||||
|
||||
const char* app_id = "wlfreerdp";
|
||||
const char* wmclass = freerdp_settings_get_string(settings, FreeRDP_WmClass);
|
||||
if (wmclass)
|
||||
app_id = wmclass;
|
||||
|
||||
if (!gdi_init(instance, PIXEL_FORMAT_BGRA32))
|
||||
return FALSE;
|
||||
|
||||
rdpGdi* gdi = instance->context->gdi;
|
||||
|
||||
if (!gdi || (gdi->width < 0) || (gdi->height < 0))
|
||||
return FALSE;
|
||||
|
||||
if (!wlf_register_pointer(instance->context->graphics))
|
||||
return FALSE;
|
||||
|
||||
UINT32 w = (UINT32)gdi->width;
|
||||
UINT32 h = (UINT32)gdi->height;
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && !context->fullscreen)
|
||||
{
|
||||
const UINT32 sw = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth);
|
||||
if (sw > 0)
|
||||
w = sw;
|
||||
|
||||
const UINT32 sh = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight);
|
||||
if (sh > 0)
|
||||
h = sh;
|
||||
}
|
||||
|
||||
context->window = UwacCreateWindowShm(context->display, w, h, WL_SHM_FORMAT_XRGB8888);
|
||||
|
||||
if (!context->window)
|
||||
return FALSE;
|
||||
|
||||
UwacWindowSetFullscreenState(
|
||||
context->window, nullptr,
|
||||
freerdp_settings_get_bool(instance->context->settings, FreeRDP_Fullscreen));
|
||||
UwacWindowSetTitle(context->window, title);
|
||||
UwacWindowSetAppId(context->window, app_id);
|
||||
UwacWindowSetOpaqueRegion(context->window, 0, 0, w, h);
|
||||
instance->context->update->EndPaint = wl_end_paint;
|
||||
instance->context->update->DesktopResize = wl_resize_display;
|
||||
const char* KeyboardRemappingList =
|
||||
freerdp_settings_get_string(instance->context->settings, FreeRDP_KeyboardRemappingList);
|
||||
|
||||
context->remap_table = freerdp_keyboard_remap_string_to_list(KeyboardRemappingList);
|
||||
if (!context->remap_table)
|
||||
return FALSE;
|
||||
|
||||
if (!(context->disp = wlf_disp_new(context)))
|
||||
return FALSE;
|
||||
|
||||
context->clipboard = wlf_clipboard_new(context);
|
||||
|
||||
if (!context->clipboard)
|
||||
return FALSE;
|
||||
|
||||
return wl_refresh_display(context);
|
||||
}
|
||||
|
||||
static void wl_post_disconnect(freerdp* instance)
|
||||
{
|
||||
if (!instance)
|
||||
return;
|
||||
|
||||
if (!instance->context)
|
||||
return;
|
||||
|
||||
wlfContext* context = (wlfContext*)instance->context;
|
||||
gdi_free(instance);
|
||||
wlf_clipboard_free(context->clipboard);
|
||||
wlf_disp_free(context->disp);
|
||||
|
||||
if (context->window)
|
||||
UwacDestroyWindow(&context->window);
|
||||
freerdp_keyboard_remap_free(context->remap_table);
|
||||
context->remap_table = nullptr;
|
||||
}
|
||||
|
||||
static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
|
||||
{
|
||||
UwacEvent event;
|
||||
wlfContext* context = nullptr;
|
||||
|
||||
if (UwacDisplayDispatch(display, 1) < 0)
|
||||
return FALSE;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
|
||||
while (UwacHasEvent(display))
|
||||
{
|
||||
if (UwacNextEvent(display, &event) != UWAC_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
/*printf("UWAC event type %d\n", event.type);*/
|
||||
switch (event.type)
|
||||
{
|
||||
case UWAC_EVENT_NEW_SEAT:
|
||||
context->seat = event.seat_new.seat;
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_REMOVED_SEAT:
|
||||
context->seat = nullptr;
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_FRAME_DONE:
|
||||
{
|
||||
EnterCriticalSection(&context->critical);
|
||||
UwacReturnCode r = UwacWindowSubmitBuffer(context->window, false);
|
||||
LeaveCriticalSection(&context->critical);
|
||||
if (r != UWAC_SUCCESS)
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_POINTER_ENTER:
|
||||
if (!wlf_handle_pointer_enter(instance, &event.mouse_enter_leave))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_POINTER_MOTION:
|
||||
if (!wlf_handle_pointer_motion(instance, &event.mouse_motion))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_POINTER_BUTTONS:
|
||||
if (!wlf_handle_pointer_buttons(instance, &event.mouse_button))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_POINTER_AXIS:
|
||||
if (!wlf_handle_pointer_axis(instance, &event.mouse_axis))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_POINTER_AXIS_DISCRETE:
|
||||
if (!wlf_handle_pointer_axis_discrete(instance, &event.mouse_axis))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_POINTER_FRAME:
|
||||
if (!wlf_handle_pointer_frame(instance, &event.mouse_frame))
|
||||
return FALSE;
|
||||
break;
|
||||
case UWAC_EVENT_POINTER_SOURCE:
|
||||
if (!wlf_handle_pointer_source(instance, &event.mouse_source))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_KEY:
|
||||
if (!wlf_handle_key(instance, &event.key))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_TOUCH_UP:
|
||||
if (!wlf_handle_touch_up(instance, &event.touchUp))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_TOUCH_DOWN:
|
||||
if (!wlf_handle_touch_down(instance, &event.touchDown))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_TOUCH_MOTION:
|
||||
if (!wlf_handle_touch_motion(instance, &event.touchMotion))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_KEYBOARD_ENTER:
|
||||
if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard))
|
||||
UwacSeatInhibitShortcuts(event.keyboard_enter_leave.seat, true);
|
||||
|
||||
if (!wlf_keyboard_enter(instance, &event.keyboard_enter_leave))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_KEYBOARD_MODIFIERS:
|
||||
if (!wlf_keyboard_modifiers(instance, &event.keyboard_modifiers))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_CONFIGURE:
|
||||
if (!wlf_disp_handle_configure(context->disp, event.configure.width,
|
||||
event.configure.height))
|
||||
return FALSE;
|
||||
|
||||
if (!wl_refresh_display(context))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_CLIPBOARD_AVAILABLE:
|
||||
case UWAC_EVENT_CLIPBOARD_OFFER:
|
||||
case UWAC_EVENT_CLIPBOARD_SELECT:
|
||||
if (!wlf_cliprdr_handle_event(context->clipboard, &event.clipboard))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case UWAC_EVENT_CLOSE:
|
||||
context->closed = TRUE;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL handle_window_events(freerdp* instance)
|
||||
{
|
||||
return instance != nullptr;
|
||||
}
|
||||
|
||||
static int wlfreerdp_run(freerdp* instance)
|
||||
{
|
||||
wlfContext* context = nullptr;
|
||||
HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
|
||||
DWORD status = WAIT_ABANDONED;
|
||||
|
||||
if (!instance)
|
||||
return -1;
|
||||
|
||||
context = (wlfContext*)instance->context;
|
||||
|
||||
if (!context)
|
||||
return -1;
|
||||
|
||||
if (!freerdp_connect(instance))
|
||||
{
|
||||
WLog_Print(context->log, WLOG_ERROR, "Failed to connect");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (!freerdp_shall_disconnect_context(instance->context))
|
||||
{
|
||||
DWORD count = 0;
|
||||
handles[count++] = context->displayHandle;
|
||||
count += freerdp_get_event_handles(instance->context, &handles[count],
|
||||
ARRAYSIZE(handles) - count);
|
||||
|
||||
if (count <= 2)
|
||||
{
|
||||
WLog_Print(context->log, WLOG_ERROR, "Failed to get FreeRDP file descriptor");
|
||||
break;
|
||||
}
|
||||
|
||||
status = WaitForMultipleObjects(count, handles, FALSE, INFINITE);
|
||||
|
||||
if (WAIT_FAILED == status)
|
||||
{
|
||||
WLog_Print(context->log, WLOG_ERROR, "WaitForMultipleObjects failed");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!handle_uwac_events(instance, context->display))
|
||||
{
|
||||
WLog_Print(context->log, WLOG_ERROR, "error handling UWAC events");
|
||||
break;
|
||||
}
|
||||
|
||||
if (context->closed)
|
||||
{
|
||||
WLog_Print(context->log, WLOG_INFO, "Closed from Wayland");
|
||||
break;
|
||||
}
|
||||
|
||||
if (freerdp_check_event_handles(instance->context) != TRUE)
|
||||
{
|
||||
if (client_auto_reconnect_ex(instance, handle_window_events))
|
||||
continue;
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Indicate an unsuccessful connection attempt if reconnect
|
||||
* did not succeed and no other error was specified.
|
||||
*/
|
||||
if (freerdp_error_info(instance) == 0)
|
||||
status = 42;
|
||||
}
|
||||
|
||||
if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_SUCCESS)
|
||||
WLog_Print(context->log, WLOG_ERROR, "Failed to check FreeRDP file descriptor");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
freerdp_disconnect(instance);
|
||||
return WINPR_ASSERTING_INT_CAST(int, status);
|
||||
}
|
||||
|
||||
static BOOL wlf_client_global_init(void)
|
||||
{
|
||||
// NOLINTNEXTLINE(concurrency-mt-unsafe)
|
||||
(void)setlocale(LC_ALL, "");
|
||||
|
||||
return (freerdp_handle_signals() == 0);
|
||||
}
|
||||
|
||||
static void wlf_client_global_uninit(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int wlf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
|
||||
{
|
||||
wlfContext* wlf = nullptr;
|
||||
const char* str_data = freerdp_get_logon_error_info_data(data);
|
||||
const char* str_type = freerdp_get_logon_error_info_type(type);
|
||||
|
||||
if (!instance || !instance->context)
|
||||
return -1;
|
||||
|
||||
wlf = (wlfContext*)instance->context;
|
||||
WLog_Print(wlf->log, WLOG_INFO, "Logon Error Info %s [%s]", str_data, str_type);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void wlf_client_free(freerdp* instance, rdpContext* context)
|
||||
{
|
||||
wlfContext* wlf = (wlfContext*)instance->context;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
if (wlf->display)
|
||||
UwacCloseDisplay(&wlf->display);
|
||||
|
||||
if (wlf->displayHandle)
|
||||
(void)CloseHandle(wlf->displayHandle);
|
||||
ArrayList_Free(wlf->events);
|
||||
DeleteCriticalSection(&wlf->critical);
|
||||
}
|
||||
|
||||
static void* uwac_event_clone(const void* val)
|
||||
{
|
||||
UwacEvent* copy = nullptr;
|
||||
const UwacEvent* ev = (const UwacEvent*)val;
|
||||
|
||||
copy = calloc(1, sizeof(UwacEvent));
|
||||
if (!copy)
|
||||
return nullptr;
|
||||
*copy = *ev;
|
||||
return copy;
|
||||
}
|
||||
|
||||
static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
|
||||
{
|
||||
wObject* obj = nullptr;
|
||||
UwacReturnCode status = UWAC_ERROR_INTERNAL;
|
||||
wlfContext* wfl = (wlfContext*)context;
|
||||
|
||||
if (!instance || !context)
|
||||
return FALSE;
|
||||
|
||||
instance->PreConnect = wl_pre_connect;
|
||||
instance->PostConnect = wl_post_connect;
|
||||
instance->PostDisconnect = wl_post_disconnect;
|
||||
instance->LogonErrorInfo = wlf_logon_error_info;
|
||||
wfl->log = WLog_Get(TAG);
|
||||
wfl->display = UwacOpenDisplay(nullptr, &status);
|
||||
|
||||
if (!wfl->display || (status != UWAC_SUCCESS) || !wfl->log)
|
||||
return FALSE;
|
||||
|
||||
wfl->displayHandle = CreateFileDescriptorEvent(nullptr, FALSE, FALSE,
|
||||
UwacDisplayGetFd(wfl->display), WINPR_FD_READ);
|
||||
|
||||
if (!wfl->displayHandle)
|
||||
return FALSE;
|
||||
|
||||
wfl->events = ArrayList_New(FALSE);
|
||||
if (!wfl->events)
|
||||
return FALSE;
|
||||
|
||||
obj = ArrayList_Object(wfl->events);
|
||||
obj->fnObjectNew = uwac_event_clone;
|
||||
obj->fnObjectFree = free;
|
||||
|
||||
InitializeCriticalSection(&wfl->critical);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int wfl_client_start(rdpContext* context)
|
||||
{
|
||||
WINPR_UNUSED(context);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
||||
{
|
||||
WINPR_ASSERT(pEntryPoints);
|
||||
ZeroMemory(pEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
|
||||
pEntryPoints->Version = RDP_CLIENT_INTERFACE_VERSION;
|
||||
pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
|
||||
pEntryPoints->GlobalInit = wlf_client_global_init;
|
||||
pEntryPoints->GlobalUninit = wlf_client_global_uninit;
|
||||
pEntryPoints->ContextSize = sizeof(wlfContext);
|
||||
pEntryPoints->ClientNew = wlf_client_new;
|
||||
pEntryPoints->ClientFree = wlf_client_free;
|
||||
pEntryPoints->ClientStart = wfl_client_start;
|
||||
pEntryPoints->ClientStop = freerdp_client_common_stop;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int rc = -1;
|
||||
int status = 0;
|
||||
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
|
||||
rdpContext* context = nullptr;
|
||||
rdpSettings* settings = nullptr;
|
||||
wlfContext* wlc = nullptr;
|
||||
|
||||
freerdp_client_warn_deprecated(argc, argv);
|
||||
|
||||
RdpClientEntry(&clientEntryPoints);
|
||||
context = freerdp_client_context_new(&clientEntryPoints);
|
||||
if (!context)
|
||||
goto fail;
|
||||
wlc = (wlfContext*)context;
|
||||
settings = context->settings;
|
||||
|
||||
status = freerdp_client_settings_parse_command_line(settings, argc, argv, FALSE);
|
||||
if (status)
|
||||
{
|
||||
rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors))
|
||||
wlf_list_monitors(wlc);
|
||||
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (freerdp_client_start(context) != 0)
|
||||
goto fail;
|
||||
|
||||
rc = wlfreerdp_run(context->instance);
|
||||
|
||||
if (freerdp_client_stop(context) != 0)
|
||||
rc = -1;
|
||||
|
||||
fail:
|
||||
freerdp_client_context_free(context);
|
||||
return rc;
|
||||
}
|
||||
|
||||
BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight, void* dst,
|
||||
size_t dstStride, size_t dstWidth, size_t dstHeight, const RECTANGLE_16* area,
|
||||
BOOL scale)
|
||||
{
|
||||
BOOL rc = FALSE;
|
||||
|
||||
if (!src || !dst || !area)
|
||||
return FALSE;
|
||||
|
||||
if (scale)
|
||||
{
|
||||
WINPR_ASSERT(dstStride <= UINT32_MAX);
|
||||
WINPR_ASSERT(dstWidth <= UINT32_MAX);
|
||||
WINPR_ASSERT(dstHeight <= UINT32_MAX);
|
||||
WINPR_ASSERT(srcStride <= UINT32_MAX);
|
||||
WINPR_ASSERT(srcWidth <= UINT32_MAX);
|
||||
WINPR_ASSERT(srcHeight <= UINT32_MAX);
|
||||
return freerdp_image_scale(dst, PIXEL_FORMAT_BGRA32, (UINT32)dstStride, 0, 0,
|
||||
(UINT32)dstWidth, (UINT32)dstHeight, src, PIXEL_FORMAT_BGRA32,
|
||||
(UINT32)srcStride, 0, 0, (UINT32)srcWidth, (UINT32)srcHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
const size_t baseSrcOffset = 1ULL * area->top * srcStride + 4ULL * area->left;
|
||||
const size_t baseDstOffset = 1ULL * area->top * dstStride + 4ULL * area->left;
|
||||
const size_t width = MIN((size_t)area->right - area->left, dstWidth - area->left);
|
||||
const size_t height = MIN((size_t)area->bottom - area->top, dstHeight - area->top);
|
||||
const BYTE* psrc = (const BYTE*)src;
|
||||
BYTE* pdst = (BYTE*)dst;
|
||||
|
||||
for (size_t i = 0; i < height; i++)
|
||||
{
|
||||
const size_t srcOffset = i * srcStride + baseSrcOffset;
|
||||
const size_t dstOffset = i * dstStride + baseDstOffset;
|
||||
memcpy(&pdst[dstOffset], &psrc[srcOffset], width * 4);
|
||||
}
|
||||
|
||||
rc = TRUE;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fromLocalToRDP)
|
||||
{
|
||||
wlfContext* wlf = (wlfContext*)context;
|
||||
UwacSize geometry = WINPR_C_ARRAY_INIT;
|
||||
|
||||
if (!context || !px || !py || !context->gdi)
|
||||
return FALSE;
|
||||
|
||||
if (!freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))
|
||||
return TRUE;
|
||||
|
||||
rdpGdi* gdi = context->gdi;
|
||||
|
||||
if (UwacWindowGetDrawingBufferGeometry(wlf->window, &geometry, nullptr) != UWAC_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
const double sx = 1.0 * geometry.width / (double)gdi->width;
|
||||
const double sy = 1.0 * geometry.height / (double)gdi->height;
|
||||
|
||||
if (!fromLocalToRDP)
|
||||
{
|
||||
*px *= (UINT32)lround(sx);
|
||||
*py *= (UINT32)lround(sy);
|
||||
}
|
||||
else
|
||||
{
|
||||
*px /= (UINT32)lround(sx);
|
||||
*py /= (UINT32)lround(sy);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
61
third_party/FreeRDP/client/Wayland/wlfreerdp.h
vendored
Normal file
61
third_party/FreeRDP/client/Wayland/wlfreerdp.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Wayland Client
|
||||
*
|
||||
* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
|
||||
*
|
||||
* 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_CLIENT_WAYLAND_FREERDP_H
|
||||
#define FREERDP_CLIENT_WAYLAND_FREERDP_H
|
||||
|
||||
#include <freerdp/client/rdpei.h>
|
||||
#include <freerdp/gdi/gfx.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/log.h>
|
||||
#include <freerdp/locale/keyboard.h>
|
||||
#include <winpr/wtypes.h>
|
||||
#include <uwac/uwac.h>
|
||||
|
||||
typedef struct wlf_clipboard wfClipboard;
|
||||
typedef struct s_wlfDispContext wlfDispContext;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
rdpClientContext common;
|
||||
|
||||
UwacDisplay* display;
|
||||
HANDLE displayHandle;
|
||||
UwacWindow* window;
|
||||
UwacSeat* seat;
|
||||
|
||||
BOOL fullscreen;
|
||||
BOOL closed;
|
||||
BOOL focusing;
|
||||
|
||||
/* Channels */
|
||||
wfClipboard* clipboard;
|
||||
wlfDispContext* disp;
|
||||
wLog* log;
|
||||
CRITICAL_SECTION critical;
|
||||
wArrayList* events;
|
||||
FREERDP_REMAP_TABLE* remap_table;
|
||||
} wlfContext;
|
||||
|
||||
BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fromLocalToRDP);
|
||||
BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight, void* dst,
|
||||
size_t dstStride, size_t dstWidth, size_t dstHeight, const RECTANGLE_16* area,
|
||||
BOOL scale);
|
||||
|
||||
#endif /* FREERDP_CLIENT_WAYLAND_FREERDP_H */
|
||||
Reference in New Issue
Block a user