Merge pull request #4879 from akallabeth/clip_fix

Fixes for clipboard #4876
This commit is contained in:
Martin Fleisz 2018-09-26 09:37:41 +02:00 committed by GitHub
commit a90b74b8dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 48 deletions

View File

@ -1358,7 +1358,7 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
UINT32 dstFormatId;
BOOL nullTerminated = FALSE;
UINT32 size = formatDataResponse->dataLen;
BYTE* data = formatDataResponse->requestedFormatData;
const BYTE* data = formatDataResponse->requestedFormatData;
xfClipboard* clipboard = (xfClipboard*) context->custom;
xfContext* xfc = clipboard->xfc;
@ -1411,6 +1411,9 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
srcFormatId = CF_DIB;
dstFormatId = ClipboardGetFormatId(clipboard->system, "image/bmp");
break;
default:
break;
}
}
@ -1419,6 +1422,12 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
if (bSuccess)
{
if (SrcSize == 0)
{
WLog_INFO(TAG, "skipping, empty data detected!!!");
return CHANNEL_RC_OK;
}
DstSize = 0;
pDstData = (BYTE*) ClipboardGetData(clipboard->system, dstFormatId, &DstSize);

View File

@ -1003,7 +1003,7 @@ int freerdp_map_keyboard_layout_name_to_id(char* name)
id = layouts[i].code;
}
free(layouts);
freerdp_keyboard_layouts_free(layouts);
if (id)
return id;
@ -1019,7 +1019,7 @@ int freerdp_map_keyboard_layout_name_to_id(char* name)
id = layouts[i].code;
}
free(layouts);
freerdp_keyboard_layouts_free(layouts);
if (id)
return id;
@ -1035,7 +1035,7 @@ int freerdp_map_keyboard_layout_name_to_id(char* name)
id = layouts[i].code;
}
free(layouts);
freerdp_keyboard_layouts_free(layouts);
if (id)
return id;
@ -1244,7 +1244,7 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
for (i = 0; layouts[i].code; i++)
printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
free(layouts);
freerdp_keyboard_layouts_free(layouts);
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
//if (!layouts) /* FIXME*/
printf("\nKeyboard Layout Variants\n");
@ -1252,7 +1252,7 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
for (i = 0; layouts[i].code; i++)
printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
free(layouts);
freerdp_keyboard_layouts_free(layouts);
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
//if (!layouts) /* FIXME*/
printf("\nKeyboard Input Method Editors (IMEs)\n");
@ -1260,7 +1260,7 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
for (i = 0; layouts[i].code; i++)
printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
free(layouts);
freerdp_keyboard_layouts_free(layouts);
printf("\n");
}

View File

@ -94,6 +94,7 @@ static UINT gdi_ResetGraphics(RdpgfxClientContext* context,
static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
{
UINT rc = ERROR_INTERNAL_ERROR;
UINT32 nXDst, nYDst;
UINT32 nXSrc, nYSrc;
UINT16 width, height;
@ -118,7 +119,8 @@ static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
if (!(rects = region16_rects(&surface->invalidRegion, &nbRects)) || !nbRects)
return CHANNEL_RC_OK;
update->BeginPaint(gdi->context);
if (!IFCALLRESULT(TRUE, update->BeginPaint, gdi->context))
goto fail;
for (i = 0; i < nbRects; i++)
{
@ -139,9 +141,13 @@ static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, width, height);
}
update->EndPaint(gdi->context);
if (!IFCALLRESULT(FALSE, update->EndPaint, gdi->context))
goto fail;
rc = CHANNEL_RC_OK;
fail:
region16_clear(&(surface->invalidRegion));
return CHANNEL_RC_OK;
return rc;
}
static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context)

View File

@ -60,7 +60,7 @@ static const RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT_TABLE[] =
{ KBD_DUTCH, "Dutch" },
{ KBD_NORWEGIAN, "Norwegian" },
{ KBD_POLISH_PROGRAMMERS, "Polish (Programmers)" },
{ KBD_PORTUGUESE_BRAZILIAN_ABNT,"Portuguese (Brazilian ABNT)" },
{ KBD_PORTUGUESE_BRAZILIAN_ABNT, "Portuguese (Brazilian ABNT)" },
{ KBD_ROMANIAN, "Romanian" },
{ KBD_RUSSIAN, "Russian" },
{ KBD_CROATIAN, "Croatian" },
@ -219,17 +219,28 @@ static const RDP_KEYBOARD_IME RDP_KEYBOARD_IME_TABLE[] =
void freerdp_keyboard_layouts_free(RDP_KEYBOARD_LAYOUT* layouts)
{
free(layouts);
RDP_KEYBOARD_LAYOUT* current = layouts;
if (!layouts)
return;
while ((current->code != 0) && (current->name != NULL))
{
free(current->name);
current ++;
}
free(layouts);
}
RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types)
{
int num, length, i;
size_t num, length, i;
RDP_KEYBOARD_LAYOUT* layouts;
RDP_KEYBOARD_LAYOUT* new;
num = 0;
layouts = (RDP_KEYBOARD_LAYOUT*) calloc((num + 1), sizeof(RDP_KEYBOARD_LAYOUT));
if (!layouts)
return NULL;
@ -237,81 +248,67 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types)
{
length = ARRAYSIZE(RDP_KEYBOARD_LAYOUT_TABLE);
new = (RDP_KEYBOARD_LAYOUT*) realloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT));
if (!new)
{
free(layouts);
return NULL;
}
goto fail;
layouts = new;
for (i = 0; i < length; i++, num++)
{
layouts[num].code = RDP_KEYBOARD_LAYOUT_TABLE[i].code;
layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_TABLE[i].name);
if (!layouts[num].name)
{
for (--i; i >=0; --i)
free(layouts[num].name);
free(layouts);
return NULL;
}
if (!layouts[num].name)
goto fail;
}
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_VARIANT) != 0)
{
length = ARRAYSIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE);
new = (RDP_KEYBOARD_LAYOUT*) realloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT));
if (!new)
{
free(layouts);
return NULL;
}
goto fail;
layouts = new;
for (i = 0; i < length; i++, num++)
{
layouts[num].code = RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code;
layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name);
if (!layouts[num].name)
{
for (--i; i >=0; --i)
free(layouts[num].name);
free(layouts);
return NULL;
}
if (!layouts[num].name)
goto fail;
}
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_IME) != 0)
{
length = ARRAYSIZE(RDP_KEYBOARD_IME_TABLE);
new = (RDP_KEYBOARD_LAYOUT*) realloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT));
if (!new)
{
free(layouts);
return NULL;
}
goto fail;
layouts = new;
for (i = 0; i < length; i++, num++)
{
layouts[num].code = RDP_KEYBOARD_IME_TABLE[i].code;
layouts[num].name = _strdup(RDP_KEYBOARD_IME_TABLE[i].name);
if (!layouts[num].name)
{
for (--i; i >=0; --i)
free(layouts[num].name);
free(layouts);
return NULL;
}
if (!layouts[num].name)
goto fail;
}
}
ZeroMemory(&layouts[num], sizeof(RDP_KEYBOARD_LAYOUT));
return layouts;
fail:
freerdp_keyboard_layouts_free(layouts);
return NULL;
}
const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutID)