Merge pull request #4240 from akallabeth/wl_client_fixes

Fixed wayland issues.
This commit is contained in:
Martin Fleisz 2018-07-31 11:03:39 +02:00 committed by GitHub
commit e3eae5db8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 98 additions and 44 deletions

View File

@ -39,9 +39,6 @@ static UINT wlf_encomsp_participant_created(EncomspClientContext* context,
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;
@ -49,10 +46,14 @@ static void wlf_encomsp_init(wlfContext* wlf, EncomspClientContext* encomsp)
static void wlf_encomsp_uninit(wlfContext* wlf, EncomspClientContext* encomsp)
{
if (!wlf)
return;
if (encomsp)
{
encomsp->custom = NULL;
encomsp->ParticipantCreated = NULL;
}
wlf->encomsp = NULL;
if (wlf)
wlf->encomsp = NULL;
}
@ -60,7 +61,9 @@ void wlf_OnChannelConnectedEventHandler(void* context,
ChannelConnectedEventArgs* e)
{
wlfContext* wlf = (wlfContext*) context;
rdpSettings* settings = wlf->context.settings;
rdpSettings* settings;
settings = wlf->context.settings;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
@ -90,7 +93,9 @@ void wlf_OnChannelDisconnectedEventHandler(void* context,
ChannelDisconnectedEventArgs* e)
{
wlfContext* wlf = (wlfContext*) context;
rdpSettings* settings = wlf->context.settings;
rdpSettings* settings;
settings = wlf->context.settings;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{

View File

@ -25,22 +25,30 @@
#include "wlf_input.h"
BOOL wlf_handle_pointer_enter(freerdp *instance, UwacPointerEnterLeaveEvent *ev) {
rdpInput* input = instance->input;
BOOL wlf_handle_pointer_enter(freerdp* instance, UwacPointerEnterLeaveEvent* ev)
{
if (!instance || !ev || !instance->input)
return FALSE;
return input->MouseEvent(input, PTR_FLAGS_MOVE, ev->x, ev->y);
return freerdp_input_send_mouse_event(instance->input, PTR_FLAGS_MOVE, ev->x, ev->y);
}
BOOL wlf_handle_pointer_motion(freerdp *instance, UwacPointerMotionEvent *ev) {
rdpInput* input = instance->input;
BOOL wlf_handle_pointer_motion(freerdp* instance, UwacPointerMotionEvent* ev)
{
if (!instance || !ev || !instance->input)
return FALSE;
return input->MouseEvent(input, PTR_FLAGS_MOVE, ev->x, ev->y);
return freerdp_input_send_mouse_event(instance->input, PTR_FLAGS_MOVE, ev->x, ev->y);
}
BOOL wlf_handle_pointer_buttons(freerdp *instance, UwacPointerButtonEvent *ev) {
BOOL wlf_handle_pointer_buttons(freerdp* instance, UwacPointerButtonEvent* ev)
{
rdpInput* input;
UINT16 flags;
if (!instance || !ev || !instance->input)
return FALSE;
input = instance->input;
if (ev->state == WL_POINTER_BUTTON_STATE_PRESSED)
@ -53,45 +61,57 @@ BOOL wlf_handle_pointer_buttons(freerdp *instance, UwacPointerButtonEvent *ev) {
case BTN_LEFT:
flags |= PTR_FLAGS_BUTTON1;
break;
case BTN_RIGHT:
flags |= PTR_FLAGS_BUTTON2;
break;
case BTN_MIDDLE:
flags |= PTR_FLAGS_BUTTON3;
break;
default:
return TRUE;
}
return input->MouseEvent(input, flags, ev->x, ev->y);
return freerdp_input_send_mouse_event(input, flags, ev->x, ev->y);
}
BOOL wlf_handle_pointer_axis(freerdp *instance, UwacPointerAxisEvent *ev) {
BOOL wlf_handle_pointer_axis(freerdp* instance, UwacPointerAxisEvent* ev)
{
rdpInput* input;
UINT16 flags;
int direction;
input = instance->input;
if (!instance || !ev || !instance->input)
return FALSE;
input = instance->input;
flags = PTR_FLAGS_WHEEL;
if (ev->axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
{
direction = wl_fixed_to_int(ev->value);
if (direction < 0)
flags |= 0x0078;
else
flags |= PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
}
return input->MouseEvent(input, flags, ev->x, ev->y);
return freerdp_input_send_mouse_event(input, flags, ev->x, ev->y);
}
BOOL wlf_handle_key(freerdp *instance, UwacKeyEvent *ev) {
rdpInput* input = instance->input;
BOOL wlf_handle_key(freerdp* instance, UwacKeyEvent* ev)
{
rdpInput* input;
DWORD rdp_scancode;
if (!instance || !ev || !instance->input)
return FALSE;
input = instance->input;
rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(ev->raw_key + 8);
if (rdp_scancode == RDP_SCANCODE_UNKNOWN)
@ -100,10 +120,14 @@ BOOL wlf_handle_key(freerdp *instance, UwacKeyEvent *ev) {
return freerdp_input_send_keyboard_event_ex(input, ev->pressed, rdp_scancode);
}
BOOL wlf_keyboard_enter(freerdp *instance, UwacKeyboardEnterLeaveEvent *ev) {
rdpInput* input = instance->input;
BOOL wlf_keyboard_enter(freerdp* instance, UwacKeyboardEnterLeaveEvent* ev)
{
rdpInput* input;
return input->FocusInEvent(input, 0) &&
input->MouseEvent(input, PTR_FLAGS_MOVE, 0, 0);
if (!instance || !ev || !instance->input)
return FALSE;
input = instance->input;
return freerdp_input_send_focus_in_event(input, 0) &&
freerdp_input_send_mouse_event(input, PTR_FLAGS_MOVE, 0, 0);
}

View File

@ -40,6 +40,9 @@
static BOOL wl_update_content(wlfContext* context_w)
{
if (!context_w)
return FALSE;
if (!context_w->waitingFrameDone && context_w->haveDamage)
{
UwacWindowSubmitBuffer(context_w->window, true);
@ -53,7 +56,15 @@ static BOOL wl_update_content(wlfContext* context_w)
static BOOL wl_begin_paint(rdpContext* context)
{
rdpGdi* gdi;
if (!context || !context->gdi)
return FALSE;
gdi = context->gdi;
if (!gdi->primary)
return FALSE;
gdi->primary->hdc->hwnd->invalid->null = TRUE;
return TRUE;
}
@ -66,7 +77,11 @@ static BOOL wl_end_paint(rdpContext* context)
wlfContext* context_w;
INT32 x, y;
UINT32 w, h;
int i;
UINT32 i;
if (!context || !context->gdi || !context->gdi->primary)
return FALSE;
gdi = context->gdi;
if (gdi->primary->hdc->hwnd->invalid->null)
@ -132,9 +147,9 @@ static BOOL wl_pre_connect(freerdp* instance)
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_MEM3BLT_INDEX] = settings->BitmapCacheEnabled;
settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled;
settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE;
settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = settings->BitmapCacheEnabled;
settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE;
settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE;
@ -177,6 +192,9 @@ static BOOL wl_post_connect(freerdp* instance)
UwacWindow* window;
wlfContext* context;
if (!instance || !instance->context)
return FALSE;
if (!gdi_init(instance, PIXEL_FORMAT_BGRA32))
return FALSE;
@ -245,7 +263,7 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
context = (wlfContext*)instance->context;
context->waitingFrameDone = FALSE;
if (context->haveDamage && !wl_end_paint(instance->context))
if (context->haveDamage && !wl_update_content(context))
return FALSE;
break;
@ -299,7 +317,7 @@ static int wlfreerdp_run(freerdp* instance)
wlfContext* context;
DWORD count;
HANDLE handles[64];
DWORD status;
DWORD status = WAIT_ABANDONED;
if (!instance)
return -1;
@ -315,20 +333,18 @@ static int wlfreerdp_run(freerdp* instance)
return -1;
}
handle_uwac_events(instance, context->display);
while (!freerdp_shall_disconnect(instance))
{
handles[0] = context->displayHandle;
count = freerdp_get_event_handles(instance->context, &handles[1], 63);
count = freerdp_get_event_handles(instance->context, &handles[1], 63) + 1;
if (!count)
if (count <= 1)
{
printf("Failed to get FreeRDP file descriptor\n");
break;
}
status = WaitForMultipleObjects(count + 1, handles, FALSE, INFINITE);
status = WaitForMultipleObjects(count, handles, FALSE, INFINITE);
if (WAIT_FAILED == status)
{
@ -342,7 +358,6 @@ static int wlfreerdp_run(freerdp* instance)
break;
}
//if (WaitForMultipleObjects(count, &handles[1], FALSE, INFINITE)) {
if (freerdp_check_event_handles(instance->context) != TRUE)
{
if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_SUCCESS)
@ -350,15 +365,13 @@ static int wlfreerdp_run(freerdp* instance)
break;
}
//}
}
freerdp_disconnect(instance);
return 0;
return status;
}
static BOOL wlf_client_global_init()
static BOOL wlf_client_global_init(void)
{
setlocale(LC_ALL, "");
@ -368,10 +381,24 @@ static BOOL wlf_client_global_init()
return TRUE;
}
static void wlf_client_global_uninit()
static void wlf_client_global_uninit(void)
{
}
static int wlf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
{
wlfContext* wlf;
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_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type);
return 1;
}
static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
{
UwacReturnCode status;
@ -387,7 +414,7 @@ static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
instance->GatewayAuthenticate = client_cli_gw_authenticate;
instance->VerifyCertificate = client_cli_verify_certificate;
instance->VerifyChangedCertificate = client_cli_verify_changed_certificate;
instance->LogonErrorInfo = NULL;
instance->LogonErrorInfo = wlf_logon_error_info;
wfl->display = UwacOpenDisplay(NULL, &status);
if (!wfl->display || (status != UWAC_SUCCESS))
@ -448,8 +475,6 @@ int main(int argc, char* argv[])
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);