Wayland client overhaul.
This commit is contained in:
parent
543631ddd3
commit
346515a116
@ -27,6 +27,8 @@ set(${MODULE_PREFIX}_SRCS
|
|||||||
wlfreerdp.h
|
wlfreerdp.h
|
||||||
wlf_input.c
|
wlf_input.c
|
||||||
wlf_input.h
|
wlf_input.h
|
||||||
|
wlf_channels.c
|
||||||
|
wlf_channels.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||||
|
118
client/Wayland/wlf_channels.c
Normal file
118
client/Wayland/wlf_channels.c
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <freerdp/gdi/gfx.h>
|
||||||
|
|
||||||
|
#include "wlf_channels.h"
|
||||||
|
#include "wlfreerdp.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function description
|
||||||
|
*
|
||||||
|
* @return 0 on success, otherwise a Win32 error code
|
||||||
|
*/
|
||||||
|
static UINT wlf_encomsp_participant_created(EncomspClientContext* context,
|
||||||
|
ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
|
||||||
|
{
|
||||||
|
return CHANNEL_RC_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wlf_encomsp_init(wlfContext* wlf, EncomspClientContext* encomsp)
|
||||||
|
{
|
||||||
|
if (!wlf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlf->encomsp = encomsp;
|
||||||
|
encomsp->custom = (void*) wlf;
|
||||||
|
encomsp->ParticipantCreated = wlf_encomsp_participant_created;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wlf_encomsp_uninit(wlfContext* wlf, EncomspClientContext* encomsp)
|
||||||
|
{
|
||||||
|
if (!wlf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlf->encomsp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wlf_OnChannelConnectedEventHandler(rdpContext* context,
|
||||||
|
ChannelConnectedEventArgs* e)
|
||||||
|
{
|
||||||
|
wlfContext* wlf = (wlfContext*) context;
|
||||||
|
rdpSettings* settings = context->settings;
|
||||||
|
|
||||||
|
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
wlf->rdpei = (RdpeiClientContext*) e->pInterface;
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, TSMF_DVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
if (settings->SoftwareGdi)
|
||||||
|
gdi_graphics_pipeline_init(context->gdi, (RdpgfxClientContext*) e->pInterface);
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
wlf_encomsp_init(wlf, (EncomspClientContext*) e->pInterface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlf_OnChannelDisconnectedEventHandler(rdpContext* context,
|
||||||
|
ChannelDisconnectedEventArgs* e)
|
||||||
|
{
|
||||||
|
wlfContext* wlf = (wlfContext*) context;
|
||||||
|
rdpSettings* settings = context->settings;
|
||||||
|
|
||||||
|
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
wlf->rdpei = NULL;
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, TSMF_DVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
if (settings->SoftwareGdi)
|
||||||
|
gdi_graphics_pipeline_uninit(context->gdi,
|
||||||
|
(RdpgfxClientContext*) e->pInterface);
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
|
||||||
|
{
|
||||||
|
wlf_encomsp_uninit(wlf, (EncomspClientContext*) e->pInterface);
|
||||||
|
}
|
||||||
|
}
|
42
client/Wayland/wlf_channels.h
Normal file
42
client/Wayland/wlf_channels.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* 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 WLF_CHANNELS_H
|
||||||
|
#define WLF_CHANNELS_H
|
||||||
|
|
||||||
|
#include <freerdp/freerdp.h>
|
||||||
|
#include <freerdp/client/channels.h>
|
||||||
|
#include <freerdp/client/rdpei.h>
|
||||||
|
#include <freerdp/client/tsmf.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(rdpContext* context,
|
||||||
|
ChannelConnectedEventArgs* e);
|
||||||
|
void wlf_OnChannelDisconnectedEventHandler(rdpContext* context,
|
||||||
|
ChannelDisconnectedEventArgs* e);
|
||||||
|
|
||||||
|
#endif
|
@ -22,14 +22,17 @@
|
|||||||
#define __WLF_INPUT_H
|
#define __WLF_INPUT_H
|
||||||
|
|
||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
|
#include <freerdp/gdi/gdi.h>
|
||||||
|
#include <freerdp/gdi/gfx.h>
|
||||||
#include <uwac/uwac.h>
|
#include <uwac/uwac.h>
|
||||||
|
|
||||||
BOOL wlf_handle_pointer_enter(freerdp* instance, UwacPointerEnterLeaveEvent *ev);
|
BOOL wlf_handle_pointer_enter(freerdp* instance,
|
||||||
BOOL wlf_handle_pointer_motion(freerdp* instance, UwacPointerMotionEvent *ev);
|
UwacPointerEnterLeaveEvent* ev);
|
||||||
BOOL wlf_handle_pointer_buttons(freerdp* instance, UwacPointerButtonEvent *ev);
|
BOOL wlf_handle_pointer_motion(freerdp* instance, UwacPointerMotionEvent* ev);
|
||||||
BOOL wlf_handle_pointer_axis(freerdp* instance, UwacPointerAxisEvent *ev);
|
BOOL wlf_handle_pointer_buttons(freerdp* instance, UwacPointerButtonEvent* ev);
|
||||||
|
BOOL wlf_handle_pointer_axis(freerdp* instance, UwacPointerAxisEvent* ev);
|
||||||
|
|
||||||
BOOL wlf_handle_key(freerdp* instance, UwacKeyEvent *ev);
|
BOOL wlf_handle_key(freerdp* instance, UwacKeyEvent* ev);
|
||||||
BOOL wlf_keyboard_enter(freerdp *instance, UwacKeyboardEnterLeaveEvent *ev);
|
BOOL wlf_keyboard_enter(freerdp* instance, UwacKeyboardEnterLeaveEvent* ev);
|
||||||
|
|
||||||
#endif /* __WLF_INPUT_H */
|
#endif /* __WLF_INPUT_H */
|
||||||
|
@ -21,37 +21,23 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include <freerdp/client/cmdline.h>
|
#include <freerdp/client/cmdline.h>
|
||||||
#include <freerdp/channels/channels.h>
|
#include <freerdp/channels/channels.h>
|
||||||
#include <freerdp/gdi/gdi.h>
|
#include <freerdp/gdi/gdi.h>
|
||||||
|
#include <freerdp/client.h>
|
||||||
|
#include <freerdp/utils/signal.h>
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
|
||||||
|
#include <uwac/uwac.h>
|
||||||
|
|
||||||
#include "wlfreerdp.h"
|
#include "wlfreerdp.h"
|
||||||
#include "wlf_input.h"
|
#include "wlf_input.h"
|
||||||
|
#include "wlf_channels.h"
|
||||||
|
|
||||||
UwacDisplay *g_display;
|
static BOOL wl_update_content(wlfContext* context_w)
|
||||||
HANDLE g_displayHandle;
|
|
||||||
|
|
||||||
static BOOL wl_context_new(freerdp* instance, rdpContext* context)
|
|
||||||
{
|
|
||||||
if (!(context->channels = freerdp_channels_new()))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wl_context_free(freerdp* instance, rdpContext* context)
|
|
||||||
{
|
|
||||||
if (context && context->channels)
|
|
||||||
{
|
|
||||||
freerdp_channels_close(context->channels, instance);
|
|
||||||
freerdp_channels_free(context->channels);
|
|
||||||
context->channels = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL wl_update_content(wlfContext *context_w)
|
|
||||||
{
|
{
|
||||||
if (!context_w->waitingFrameDone && context_w->haveDamage)
|
if (!context_w->waitingFrameDone && context_w->haveDamage)
|
||||||
{
|
{
|
||||||
@ -66,7 +52,6 @@ BOOL wl_update_content(wlfContext *context_w)
|
|||||||
static BOOL wl_begin_paint(rdpContext* context)
|
static BOOL wl_begin_paint(rdpContext* context)
|
||||||
{
|
{
|
||||||
rdpGdi* gdi;
|
rdpGdi* gdi;
|
||||||
|
|
||||||
gdi = context->gdi;
|
gdi = context->gdi;
|
||||||
gdi->primary->hdc->hwnd->invalid->null = 1;
|
gdi->primary->hdc->hwnd->invalid->null = 1;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -76,13 +61,13 @@ static BOOL wl_begin_paint(rdpContext* context)
|
|||||||
static BOOL wl_end_paint(rdpContext* context)
|
static BOOL wl_end_paint(rdpContext* context)
|
||||||
{
|
{
|
||||||
rdpGdi* gdi;
|
rdpGdi* gdi;
|
||||||
char *data;
|
char* data;
|
||||||
wlfContext *context_w;
|
wlfContext* context_w;
|
||||||
INT32 x, y;
|
INT32 x, y;
|
||||||
UINT32 w, h;
|
UINT32 w, h;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
gdi = context->gdi;
|
gdi = context->gdi;
|
||||||
|
|
||||||
if (gdi->primary->hdc->hwnd->invalid->null)
|
if (gdi->primary->hdc->hwnd->invalid->null)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -90,18 +75,19 @@ static BOOL wl_end_paint(rdpContext* context)
|
|||||||
y = gdi->primary->hdc->hwnd->invalid->y;
|
y = gdi->primary->hdc->hwnd->invalid->y;
|
||||||
w = gdi->primary->hdc->hwnd->invalid->w;
|
w = gdi->primary->hdc->hwnd->invalid->w;
|
||||||
h = gdi->primary->hdc->hwnd->invalid->h;
|
h = gdi->primary->hdc->hwnd->invalid->h;
|
||||||
|
|
||||||
context_w = (wlfContext*) context;
|
context_w = (wlfContext*) context;
|
||||||
|
|
||||||
data = UwacWindowGetDrawingBuffer(context_w->window);
|
data = UwacWindowGetDrawingBuffer(context_w->window);
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < h; i++)
|
for (i = 0; i < h; i++)
|
||||||
{
|
{
|
||||||
memcpy(data + ((i+y)*(gdi->width*GetBytesPerPixel(gdi->dstFormat))) + x*GetBytesPerPixel(gdi->dstFormat),
|
memcpy(data + ((i + y) * (gdi->width * GetBytesPerPixel(
|
||||||
gdi->primary_buffer + ((i+y)*(gdi->width*GetBytesPerPixel(gdi->dstFormat))) + x*GetBytesPerPixel(gdi->dstFormat),
|
gdi->dstFormat))) + x * GetBytesPerPixel(gdi->dstFormat),
|
||||||
w*GetBytesPerPixel(gdi->dstFormat));
|
gdi->primary_buffer + ((i + y) * (gdi->width * GetBytesPerPixel(
|
||||||
|
gdi->dstFormat))) + x * GetBytesPerPixel(gdi->dstFormat),
|
||||||
|
w * GetBytesPerPixel(gdi->dstFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UwacWindowAddDamage(context_w->window, x, y, w, h) != UWAC_SUCCESS)
|
if (UwacWindowAddDamage(context_w->window, x, y, w, h) != UWAC_SUCCESS)
|
||||||
@ -114,16 +100,58 @@ static BOOL wl_end_paint(rdpContext* context)
|
|||||||
|
|
||||||
static BOOL wl_pre_connect(freerdp* instance)
|
static BOOL wl_pre_connect(freerdp* instance)
|
||||||
{
|
{
|
||||||
|
rdpSettings* settings;
|
||||||
wlfContext* context;
|
wlfContext* context;
|
||||||
|
|
||||||
if (freerdp_channels_pre_connect(instance->context->channels, instance) != CHANNEL_RC_OK)
|
if (!instance)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
context = (wlfContext*) instance->context;
|
context = (wlfContext*) instance->context;
|
||||||
if (!context)
|
settings = instance->settings;
|
||||||
|
|
||||||
|
if (!context || !settings)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
context->display = g_display;
|
settings->OsMajorType = OSMAJORTYPE_UNIX;
|
||||||
|
settings->OsMinorType = OSMINORTYPE_NATIVE_WAYLAND;
|
||||||
|
settings->SoftwareGdi = TRUE;
|
||||||
|
ZeroMemory(settings->OrderSupport, 32);
|
||||||
|
settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_PATBLT_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_LINETO_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_MEMBLT_INDEX] = settings->BitmapCacheEnabled;
|
||||||
|
settings->OrderSupport[NEG_MEM3BLT_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled;
|
||||||
|
settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_POLYGON_SC_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_POLYGON_CB_INDEX] = TRUE;
|
||||||
|
settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
|
||||||
|
settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
|
||||||
|
PubSub_SubscribeChannelConnected(instance->context->pubSub,
|
||||||
|
(pChannelConnectedEventHandler) wlf_OnChannelConnectedEventHandler);
|
||||||
|
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
|
||||||
|
(pChannelDisconnectedEventHandler) wlf_OnChannelDisconnectedEventHandler);
|
||||||
|
|
||||||
|
if (!freerdp_client_load_addins(instance->context->channels,
|
||||||
|
instance->settings))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (freerdp_channels_pre_connect(instance->context->channels,
|
||||||
|
instance) != CHANNEL_RC_OK)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -134,28 +162,31 @@ static BOOL wl_post_connect(freerdp* instance)
|
|||||||
UwacWindow* window;
|
UwacWindow* window;
|
||||||
wlfContext* context;
|
wlfContext* context;
|
||||||
|
|
||||||
if (!gdi_init(instance, PIXEL_FORMAT_ARGB32))
|
if (!gdi_init(instance, PIXEL_FORMAT_BGRA32))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gdi = instance->context->gdi;
|
gdi = instance->context->gdi;
|
||||||
|
|
||||||
if (!gdi)
|
if (!gdi)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
context = (wlfContext*) instance->context;
|
context = (wlfContext*) instance->context;
|
||||||
context->window = window = UwacCreateWindowShm(context->display, gdi->width, gdi->height, WL_SHM_FORMAT_XRGB8888);
|
context->window = window = UwacCreateWindowShm(context->display, gdi->width,
|
||||||
|
gdi->height, WL_SHM_FORMAT_XRGB8888);
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
UwacWindowSetTitle(window, "FreeRDP");
|
UwacWindowSetTitle(window, "FreeRDP");
|
||||||
|
|
||||||
instance->update->BeginPaint = wl_begin_paint;
|
instance->update->BeginPaint = wl_begin_paint;
|
||||||
instance->update->EndPaint = wl_end_paint;
|
instance->update->EndPaint = wl_end_paint;
|
||||||
|
|
||||||
if (freerdp_channels_post_connect(instance->context->channels, instance) != CHANNEL_RC_OK)
|
if (freerdp_channels_post_connect(instance->context->channels,
|
||||||
|
instance) != CHANNEL_RC_OK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
memcpy(UwacWindowGetDrawingBuffer(context->window), gdi->primary_buffer,
|
||||||
memcpy(UwacWindowGetDrawingBuffer(context->window), gdi->primary_buffer, gdi->width * gdi->height * 4);
|
gdi->width * gdi->height * 4);
|
||||||
UwacWindowAddDamage(context->window, 0, 0, gdi->width, gdi->height);
|
UwacWindowAddDamage(context->window, 0, 0, gdi->width, gdi->height);
|
||||||
context->haveDamage = TRUE;
|
context->haveDamage = TRUE;
|
||||||
return wl_update_content(context);
|
return wl_update_content(context);
|
||||||
@ -163,7 +194,8 @@ static BOOL wl_post_connect(freerdp* instance)
|
|||||||
|
|
||||||
static void wl_post_disconnect(freerdp* instance)
|
static void wl_post_disconnect(freerdp* instance)
|
||||||
{
|
{
|
||||||
wlfContext *context;
|
wlfContext* context;
|
||||||
|
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -171,19 +203,16 @@ static void wl_post_disconnect(freerdp* instance)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
context = (wlfContext*) instance->context;
|
context = (wlfContext*) instance->context;
|
||||||
|
|
||||||
gdi_free(instance);
|
gdi_free(instance);
|
||||||
|
|
||||||
if (context->window)
|
if (context->window)
|
||||||
UwacDestroyWindow(&context->window);
|
UwacDestroyWindow(&context->window);
|
||||||
|
|
||||||
if (context->display)
|
|
||||||
UwacCloseDisplay(&context->display);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL handle_uwac_events(freerdp* instance, UwacDisplay *display) {
|
static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
|
||||||
|
{
|
||||||
UwacEvent event;
|
UwacEvent event;
|
||||||
wlfContext *context;
|
wlfContext* context;
|
||||||
|
|
||||||
if (UwacDisplayDispatch(display, 1) < 0)
|
if (UwacDisplayDispatch(display, 1) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -194,80 +223,108 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay *display) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/*printf("UWAC event type %d\n", event.type);*/
|
/*printf("UWAC event type %d\n", event.type);*/
|
||||||
switch (event.type) {
|
switch (event.type)
|
||||||
case UWAC_EVENT_FRAME_DONE:
|
{
|
||||||
if (!instance)
|
case UWAC_EVENT_FRAME_DONE:
|
||||||
continue;
|
if (!instance)
|
||||||
|
continue;
|
||||||
|
|
||||||
context = (wlfContext *)instance->context;
|
context = (wlfContext*)instance->context;
|
||||||
context->waitingFrameDone = FALSE;
|
context->waitingFrameDone = FALSE;
|
||||||
if (context->haveDamage && !wl_end_paint(instance->context))
|
|
||||||
return FALSE;
|
if (context->haveDamage && !wl_end_paint(instance->context))
|
||||||
break;
|
return FALSE;
|
||||||
case UWAC_EVENT_POINTER_ENTER:
|
|
||||||
if (!wlf_handle_pointer_enter(instance, &event.mouse_enter_leave))
|
break;
|
||||||
return FALSE;
|
|
||||||
break;
|
case UWAC_EVENT_POINTER_ENTER:
|
||||||
case UWAC_EVENT_POINTER_MOTION:
|
if (!wlf_handle_pointer_enter(instance, &event.mouse_enter_leave))
|
||||||
if (!wlf_handle_pointer_motion(instance, &event.mouse_motion))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
break;
|
break;
|
||||||
case UWAC_EVENT_POINTER_BUTTONS:
|
|
||||||
if (!wlf_handle_pointer_buttons(instance, &event.mouse_button))
|
case UWAC_EVENT_POINTER_MOTION:
|
||||||
return FALSE;
|
if (!wlf_handle_pointer_motion(instance, &event.mouse_motion))
|
||||||
break;
|
return FALSE;
|
||||||
case UWAC_EVENT_POINTER_AXIS:
|
|
||||||
if (!wlf_handle_pointer_axis(instance, &event.mouse_axis))
|
break;
|
||||||
return FALSE;
|
|
||||||
break;
|
case UWAC_EVENT_POINTER_BUTTONS:
|
||||||
case UWAC_EVENT_KEY:
|
if (!wlf_handle_pointer_buttons(instance, &event.mouse_button))
|
||||||
if (!wlf_handle_key(instance, &event.key))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
break;
|
break;
|
||||||
case UWAC_EVENT_KEYBOARD_ENTER:
|
|
||||||
if (!wlf_keyboard_enter(instance, &event.keyboard_enter_leave))
|
case UWAC_EVENT_POINTER_AXIS:
|
||||||
return FALSE;
|
if (!wlf_handle_pointer_axis(instance, &event.mouse_axis))
|
||||||
break;
|
return FALSE;
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case UWAC_EVENT_KEY:
|
||||||
|
if (!wlf_handle_key(instance, &event.key))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UWAC_EVENT_KEYBOARD_ENTER:
|
||||||
|
if (!wlf_keyboard_enter(instance, &event.keyboard_enter_leave))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wlfreerdp_run(freerdp* instance)
|
static int wlfreerdp_run(freerdp* instance)
|
||||||
{
|
{
|
||||||
|
wlfContext* context;
|
||||||
DWORD count;
|
DWORD count;
|
||||||
HANDLE handles[64];
|
HANDLE handles[64];
|
||||||
DWORD status;
|
DWORD status;
|
||||||
|
|
||||||
|
if (!instance)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
context = (wlfContext*)instance->context;
|
||||||
|
|
||||||
|
if (!context)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (!freerdp_connect(instance))
|
if (!freerdp_connect(instance))
|
||||||
{
|
{
|
||||||
printf("Failed to connect\n");
|
printf("Failed to connect\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_uwac_events(instance, g_display);
|
handle_uwac_events(instance, context->display);
|
||||||
|
|
||||||
while (!freerdp_shall_disconnect(instance))
|
while (!freerdp_shall_disconnect(instance))
|
||||||
{
|
{
|
||||||
handles[0] = g_displayHandle;
|
handles[0] = context->displayHandle;
|
||||||
|
|
||||||
count = freerdp_get_event_handles(instance->context, &handles[1], 63);
|
count = freerdp_get_event_handles(instance->context, &handles[1], 63);
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
printf("Failed to get FreeRDP file descriptor\n");
|
printf("Failed to get FreeRDP file descriptor\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = WaitForMultipleObjects(count+1, handles, FALSE, INFINITE);
|
status = WaitForMultipleObjects(count + 1, handles, FALSE, INFINITE);
|
||||||
|
|
||||||
if (WAIT_FAILED == status)
|
if (WAIT_FAILED == status)
|
||||||
{
|
{
|
||||||
printf("%s: WaitForMultipleObjects failed\n", __FUNCTION__);
|
printf("%s: WaitForMultipleObjects failed\n", __FUNCTION__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handle_uwac_events(instance, g_display)) {
|
if (!handle_uwac_events(instance, context->display))
|
||||||
|
{
|
||||||
printf("error handling UWAC events\n");
|
printf("error handling UWAC events\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -278,33 +335,40 @@ static int wlfreerdp_run(freerdp* instance)
|
|||||||
printf("Failed to check FreeRDP file descriptor\n");
|
printf("Failed to check FreeRDP file descriptor\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
freerdp_channels_disconnect(instance->context->channels, instance);
|
freerdp_channels_disconnect(instance->context->channels, instance);
|
||||||
freerdp_disconnect(instance);
|
freerdp_disconnect(instance);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
static BOOL wlf_client_global_init()
|
||||||
|
{
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
|
if (freerdp_handle_signals() != 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wlf_client_global_uninit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
|
||||||
{
|
{
|
||||||
UwacReturnCode status;
|
UwacReturnCode status;
|
||||||
freerdp* instance;
|
wlfContext* wfl = (wlfContext*) context;
|
||||||
|
|
||||||
g_display = UwacOpenDisplay(NULL, &status);
|
if (!instance || !context)
|
||||||
if (!g_display)
|
return FALSE;
|
||||||
exit(1);
|
|
||||||
|
|
||||||
g_displayHandle = CreateFileDescriptorEvent(NULL, FALSE, FALSE, UwacDisplayGetFd(g_display), WINPR_FD_READ);
|
if (!(context->channels = freerdp_channels_new()))
|
||||||
if (!g_displayHandle)
|
return FALSE;
|
||||||
exit(1);
|
|
||||||
|
|
||||||
//if (!handle_uwac_events(NULL, g_display))
|
|
||||||
// exit(1);
|
|
||||||
|
|
||||||
instance = freerdp_new();
|
|
||||||
instance->PreConnect = wl_pre_connect;
|
instance->PreConnect = wl_pre_connect;
|
||||||
instance->PostConnect = wl_post_connect;
|
instance->PostConnect = wl_post_connect;
|
||||||
instance->PostDisconnect = wl_post_disconnect;
|
instance->PostDisconnect = wl_post_disconnect;
|
||||||
@ -312,28 +376,99 @@ int main(int argc, char* argv[])
|
|||||||
instance->GatewayAuthenticate = client_cli_gw_authenticate;
|
instance->GatewayAuthenticate = client_cli_gw_authenticate;
|
||||||
instance->VerifyCertificate = client_cli_verify_certificate;
|
instance->VerifyCertificate = client_cli_verify_certificate;
|
||||||
instance->VerifyChangedCertificate = client_cli_verify_changed_certificate;
|
instance->VerifyChangedCertificate = client_cli_verify_changed_certificate;
|
||||||
|
instance->LogonErrorInfo = NULL;
|
||||||
|
wfl->display = UwacOpenDisplay(NULL, &status);
|
||||||
|
|
||||||
instance->ContextSize = sizeof(wlfContext);
|
if (!wfl->display || (status != UWAC_SUCCESS))
|
||||||
instance->ContextNew = wl_context_new;
|
return FALSE;
|
||||||
instance->ContextFree = wl_context_free;
|
|
||||||
|
|
||||||
freerdp_context_new(instance);
|
wfl->displayHandle = CreateFileDescriptorEvent(NULL, FALSE, FALSE,
|
||||||
|
UwacDisplayGetFd(wfl->display), WINPR_FD_READ);
|
||||||
|
|
||||||
status = freerdp_client_settings_parse_command_line(instance->settings, argc, argv, FALSE);
|
if (!wfl->displayHandle)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
status = freerdp_client_settings_command_line_status_print(instance->settings, status, argc, argv);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (status)
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
if (!freerdp_client_load_addins(instance->context->channels, instance->settings))
|
static void wlf_client_free(freerdp* instance, rdpContext* context)
|
||||||
exit(-1);
|
{
|
||||||
|
wlfContext* wlf = (wlfContext*) instance->context;
|
||||||
|
|
||||||
wlfreerdp_run(instance);
|
if (!context)
|
||||||
|
return;
|
||||||
|
|
||||||
freerdp_context_free(instance);
|
if (context->channels)
|
||||||
|
{
|
||||||
|
freerdp_channels_close(context->channels, instance);
|
||||||
|
freerdp_channels_free(context->channels);
|
||||||
|
context->channels = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
freerdp_free(instance);
|
if (wlf->display)
|
||||||
|
UwacCloseDisplay(&wlf->display);
|
||||||
|
|
||||||
|
if (wlf->displayHandle)
|
||||||
|
CloseHandle(wlf->displayHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int wfl_client_start(rdpContext* context)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wfl_client_stop(rdpContext* context)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* 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 = wfl_client_stop;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
int rc = -1;
|
||||||
|
DWORD status;
|
||||||
|
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
|
||||||
|
rdpContext* context;
|
||||||
|
//if (!handle_uwac_events(NULL, g_display))
|
||||||
|
// exit(1);
|
||||||
|
RdpClientEntry(&clientEntryPoints);
|
||||||
|
context = freerdp_client_context_new(&clientEntryPoints);
|
||||||
|
|
||||||
|
if (!context)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
status = freerdp_client_settings_parse_command_line(context->settings, argc,
|
||||||
|
argv, FALSE);
|
||||||
|
status = freerdp_client_settings_command_line_status_print(context->settings,
|
||||||
|
status, argc, argv);
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
#ifndef __WLFREERDP_H
|
#ifndef __WLFREERDP_H
|
||||||
#define __WLFREERDP_H
|
#define __WLFREERDP_H
|
||||||
|
|
||||||
|
#include <freerdp/client/encomsp.h>
|
||||||
|
#include <freerdp/client/rdpei.h>
|
||||||
|
#include <freerdp/gdi/gfx.h>
|
||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
#include <freerdp/log.h>
|
#include <freerdp/log.h>
|
||||||
#include <winpr/wtypes.h>
|
#include <winpr/wtypes.h>
|
||||||
@ -34,11 +37,17 @@ struct wlf_context
|
|||||||
{
|
{
|
||||||
rdpContext context;
|
rdpContext context;
|
||||||
|
|
||||||
UwacDisplay *display;
|
UwacDisplay* display;
|
||||||
UwacWindow *window;
|
HANDLE displayHandle;
|
||||||
|
UwacWindow* window;
|
||||||
|
|
||||||
BOOL waitingFrameDone;
|
BOOL waitingFrameDone;
|
||||||
BOOL haveDamage;
|
BOOL haveDamage;
|
||||||
|
|
||||||
|
/* Channels */
|
||||||
|
RdpeiClientContext* rdpei;
|
||||||
|
RdpgfxClientContext* gfx;
|
||||||
|
EncomspClientContext* encomsp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __WLFREERDP_H */
|
#endif /* __WLFREERDP_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user