2013-12-29 04:53:12 +00:00
|
|
|
/*
|
2016-03-25 19:59:40 +00:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you 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
|
2012-01-04 03:09:33 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-01-04 03:09:33 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* 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.
|
2013-12-29 04:53:12 +00:00
|
|
|
*/
|
|
|
|
|
2014-01-01 22:44:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "client.h"
|
2014-04-30 18:44:06 +00:00
|
|
|
#include "guac_surface.h"
|
2016-03-01 05:50:00 +00:00
|
|
|
#include "rdp.h"
|
2014-01-01 22:44:28 +00:00
|
|
|
#include "rdp_bitmap.h"
|
2014-11-21 05:06:39 +00:00
|
|
|
#include "rdp_color.h"
|
2014-06-11 01:45:14 +00:00
|
|
|
#include "rdp_settings.h"
|
2012-01-04 03:09:33 +00:00
|
|
|
|
2014-06-11 01:45:14 +00:00
|
|
|
#include <cairo/cairo.h>
|
2012-01-04 03:09:33 +00:00
|
|
|
#include <freerdp/freerdp.h>
|
2014-01-01 22:44:28 +00:00
|
|
|
#include <guacamole/client.h>
|
2014-06-11 01:45:14 +00:00
|
|
|
#include <guacamole/protocol.h>
|
2012-01-04 03:09:33 +00:00
|
|
|
|
2013-07-17 18:54:24 +00:00
|
|
|
#ifdef ENABLE_WINPR
|
|
|
|
#include <winpr/wtypes.h>
|
|
|
|
#else
|
|
|
|
#include "compat/winpr-wtypes.h"
|
|
|
|
#endif
|
|
|
|
|
2014-06-11 01:45:14 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2012-02-27 20:39:13 +00:00
|
|
|
guac_transfer_function guac_rdp_rop3_transfer_function(guac_client* client,
|
2012-02-27 18:53:45 +00:00
|
|
|
int rop3) {
|
|
|
|
|
|
|
|
/* Translate supported ROP3 opcodes into composite modes */
|
|
|
|
switch (rop3) {
|
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "DSon" !(src | dest) */
|
|
|
|
case 0x11: return GUAC_TRANSFER_BINARY_NOR;
|
|
|
|
|
|
|
|
/* "DSna" !src & dest */
|
|
|
|
case 0x22: return GUAC_TRANSFER_BINARY_NSRC_AND;
|
|
|
|
|
|
|
|
/* "Sn" !src */
|
|
|
|
case 0x33: return GUAC_TRANSFER_BINARY_NSRC;
|
|
|
|
|
|
|
|
/* "SDna" (src & !dest) */
|
|
|
|
case 0x44: return GUAC_TRANSFER_BINARY_NDEST_AND;
|
|
|
|
|
|
|
|
/* "Dn" !dest */
|
|
|
|
case 0x55: return GUAC_TRANSFER_BINARY_NDEST;
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
/* "SRCINVERT" (src ^ dest) */
|
2012-03-01 20:31:06 +00:00
|
|
|
case 0x66: return GUAC_TRANSFER_BINARY_XOR;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "DSan" !(src & dest) */
|
|
|
|
case 0x77: return GUAC_TRANSFER_BINARY_NAND;
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
/* "SRCAND" (src & dest) */
|
2012-02-27 20:39:13 +00:00
|
|
|
case 0x88: return GUAC_TRANSFER_BINARY_AND;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "DSxn" !(src ^ dest) */
|
|
|
|
case 0x99: return GUAC_TRANSFER_BINARY_XNOR;
|
|
|
|
|
2012-03-01 20:31:06 +00:00
|
|
|
/* "MERGEPAINT" (!src | dest)*/
|
|
|
|
case 0xBB: return GUAC_TRANSFER_BINARY_NSRC_OR;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "SDno" (src | !dest) */
|
|
|
|
case 0xDD: return GUAC_TRANSFER_BINARY_NDEST_OR;
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
/* "SRCPAINT" (src | dest) */
|
2012-02-27 20:39:13 +00:00
|
|
|
case 0xEE: return GUAC_TRANSFER_BINARY_OR;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* 0x00 = "BLACKNESS" (0) */
|
|
|
|
/* 0xAA = "NOP" (dest) */
|
2012-03-07 23:35:38 +00:00
|
|
|
/* 0xCC = "SRCCOPY" (src) */
|
2012-03-07 23:28:35 +00:00
|
|
|
/* 0xFF = "WHITENESS" (1) */
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Log warning if ROP3 opcode not supported */
|
2014-11-08 00:32:19 +00:00
|
|
|
guac_client_log(client, GUAC_LOG_INFO, "guac_rdp_rop3_transfer_function: "
|
2012-02-27 20:39:13 +00:00
|
|
|
"UNSUPPORTED opcode = 0x%02X", rop3);
|
|
|
|
|
|
|
|
/* Default to BINARY_SRC */
|
|
|
|
return GUAC_TRANSFER_BINARY_SRC;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) {
|
2012-02-17 21:57:27 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface* current_surface = ((guac_rdp_client*) client->data)->current_surface;
|
2012-02-17 21:57:27 +00:00
|
|
|
|
2013-05-13 21:34:24 +00:00
|
|
|
int x = dstblt->nLeftRect;
|
|
|
|
int y = dstblt->nTopRect;
|
|
|
|
int w = dstblt->nWidth;
|
|
|
|
int h = dstblt->nHeight;
|
|
|
|
|
2012-02-17 21:57:27 +00:00
|
|
|
switch (dstblt->bRop) {
|
|
|
|
|
|
|
|
/* Blackness */
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
/* Send black rectangle */
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h, 0, 0, 0);
|
2012-02-17 21:57:27 +00:00
|
|
|
break;
|
|
|
|
|
2013-05-14 00:58:19 +00:00
|
|
|
/* DSTINVERT */
|
|
|
|
case 0x55:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_transfer(current_surface, x, y, w, h,
|
|
|
|
GUAC_TRANSFER_BINARY_NDEST, current_surface, x, y);
|
2013-05-14 00:58:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* NOP */
|
|
|
|
case 0xAA:
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Whiteness */
|
|
|
|
case 0xFF:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h, 0xFF, 0xFF, 0xFF);
|
2013-05-14 00:58:19 +00:00
|
|
|
break;
|
|
|
|
|
2012-02-17 21:57:27 +00:00
|
|
|
/* Unsupported ROP3 */
|
|
|
|
default:
|
2014-11-08 00:32:19 +00:00
|
|
|
guac_client_log(client, GUAC_LOG_INFO,
|
2013-05-14 00:58:19 +00:00
|
|
|
"guac_rdp_gdi_dstblt(rop3=0x%x)", dstblt->bRop);
|
2012-02-17 21:57:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) {
|
2012-12-13 22:35:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that this is not a full implementation of PATBLT. This is a
|
|
|
|
* fallback implementation which only renders a solid block of background
|
|
|
|
* color using the specified ROP3 operation, ignoring whatever brush
|
|
|
|
* was actually specified.
|
|
|
|
*
|
|
|
|
* As libguac-client-rdp explicitly tells the server not to send PATBLT,
|
|
|
|
* well-behaved RDP servers will not use this operation at all, while
|
|
|
|
* others will at least have a fallback.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get client and current layer */
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface* current_surface =
|
2016-03-01 05:50:00 +00:00
|
|
|
((guac_rdp_client*) client->data)->current_surface;
|
2012-12-13 22:35:00 +00:00
|
|
|
|
2013-05-13 21:34:24 +00:00
|
|
|
int x = patblt->nLeftRect;
|
|
|
|
int y = patblt->nTopRect;
|
|
|
|
int w = patblt->nWidth;
|
|
|
|
int h = patblt->nHeight;
|
|
|
|
|
2012-12-13 22:35:00 +00:00
|
|
|
/*
|
|
|
|
* Warn that rendering is a fallback, as the server should not be sending
|
|
|
|
* this order.
|
|
|
|
*/
|
2014-11-08 00:32:19 +00:00
|
|
|
guac_client_log(client, GUAC_LOG_INFO, "Using fallback PATBLT (server is ignoring "
|
2012-12-13 22:35:00 +00:00
|
|
|
"negotiated client capabilities)");
|
|
|
|
|
|
|
|
/* Render rectangle based on ROP */
|
|
|
|
switch (patblt->bRop) {
|
|
|
|
|
|
|
|
/* If blackness, send black rectangle */
|
|
|
|
case 0x00:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h, 0, 0, 0);
|
2012-12-13 22:35:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* If NOP, do nothing */
|
|
|
|
case 0xAA:
|
|
|
|
break;
|
|
|
|
|
2012-12-13 23:01:11 +00:00
|
|
|
/* If operation is just a copy, send foreground only */
|
2012-12-13 22:35:00 +00:00
|
|
|
case 0xCC:
|
2012-12-13 22:56:45 +00:00
|
|
|
case 0xF0:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h,
|
2012-12-13 23:01:11 +00:00
|
|
|
(patblt->foreColor >> 16) & 0xFF,
|
|
|
|
(patblt->foreColor >> 8 ) & 0xFF,
|
2014-04-30 18:44:06 +00:00
|
|
|
(patblt->foreColor ) & 0xFF);
|
2012-12-13 22:35:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* If whiteness, send white rectangle */
|
|
|
|
case 0xFF:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h, 0xFF, 0xFF, 0xFF);
|
2012-12-13 22:35:00 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 23:01:11 +00:00
|
|
|
/* Otherwise, invert entire rect */
|
2012-12-13 22:35:00 +00:00
|
|
|
default:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_transfer(current_surface, x, y, w, h,
|
|
|
|
GUAC_TRANSFER_BINARY_NDEST, current_surface, x, y);
|
2012-12-13 22:35:00 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) {
|
2012-02-09 18:30:38 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface* current_surface = ((guac_rdp_client*) client->data)->current_surface;
|
2012-10-31 08:05:43 +00:00
|
|
|
|
2013-05-13 21:34:24 +00:00
|
|
|
int x = scrblt->nLeftRect;
|
|
|
|
int y = scrblt->nTopRect;
|
|
|
|
int w = scrblt->nWidth;
|
|
|
|
int h = scrblt->nHeight;
|
|
|
|
|
2013-05-14 00:50:14 +00:00
|
|
|
int x_src = scrblt->nXSrc;
|
|
|
|
int y_src = scrblt->nYSrc;
|
|
|
|
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
|
2013-05-14 00:50:14 +00:00
|
|
|
|
2012-02-09 18:30:38 +00:00
|
|
|
/* Copy screen rect to current surface */
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface_copy(rdp_client->display->default_surface,
|
|
|
|
x_src, y_src, w, h, current_surface, x, y);
|
2012-02-09 18:30:38 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) {
|
2012-02-08 23:09:12 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface* current_surface = ((guac_rdp_client*) client->data)->current_surface;
|
2012-02-08 23:09:12 +00:00
|
|
|
guac_rdp_bitmap* bitmap = (guac_rdp_bitmap*) memblt->bitmap;
|
|
|
|
|
2013-05-13 21:34:24 +00:00
|
|
|
int x = memblt->nLeftRect;
|
|
|
|
int y = memblt->nTopRect;
|
|
|
|
int w = memblt->nWidth;
|
|
|
|
int h = memblt->nHeight;
|
|
|
|
|
2013-05-14 00:50:14 +00:00
|
|
|
int x_src = memblt->nXSrc;
|
|
|
|
int y_src = memblt->nYSrc;
|
|
|
|
|
2013-06-14 06:38:20 +00:00
|
|
|
/* Make sure that the recieved bitmap is not NULL before processing */
|
|
|
|
if (bitmap == NULL) {
|
2014-11-08 00:32:19 +00:00
|
|
|
guac_client_log(client, GUAC_LOG_INFO, "NULL bitmap found in memblt instruction.");
|
2013-06-14 06:38:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-10 21:23:37 +00:00
|
|
|
switch (memblt->bRop) {
|
2012-03-07 23:35:38 +00:00
|
|
|
|
|
|
|
/* If blackness, send black rectangle */
|
|
|
|
case 0x00:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h, 0, 0, 0);
|
2012-03-07 23:35:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* If NOP, do nothing */
|
|
|
|
case 0xAA:
|
|
|
|
break;
|
|
|
|
|
2012-02-27 20:39:13 +00:00
|
|
|
/* If operation is just SRC, simply copy */
|
2012-03-07 23:35:38 +00:00
|
|
|
case 0xCC:
|
2012-04-10 21:23:37 +00:00
|
|
|
|
|
|
|
/* If not cached, cache if necessary */
|
2016-03-01 05:50:00 +00:00
|
|
|
if (bitmap->layer == NULL && bitmap->used >= 1)
|
2012-04-10 21:23:37 +00:00
|
|
|
guac_rdp_cache_bitmap(context, memblt->bitmap);
|
|
|
|
|
|
|
|
/* If not cached, send as PNG */
|
2016-03-01 05:50:00 +00:00
|
|
|
if (bitmap->layer == NULL) {
|
2012-04-10 21:23:37 +00:00
|
|
|
if (memblt->bitmap->data != NULL) {
|
|
|
|
|
|
|
|
/* Create surface from image data */
|
|
|
|
cairo_surface_t* surface = cairo_image_surface_create_for_data(
|
2013-05-14 00:50:14 +00:00
|
|
|
memblt->bitmap->data + 4*(x_src + y_src*memblt->bitmap->width),
|
|
|
|
CAIRO_FORMAT_RGB24, w, h, 4*memblt->bitmap->width);
|
2012-04-10 21:23:37 +00:00
|
|
|
|
|
|
|
/* Send surface to buffer */
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_draw(current_surface, x, y, surface);
|
2012-04-10 21:23:37 +00:00
|
|
|
|
|
|
|
/* Free surface */
|
|
|
|
cairo_surface_destroy(surface);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, copy */
|
|
|
|
else
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface_copy(bitmap->layer->surface,
|
|
|
|
x_src, y_src, w, h, current_surface, x, y);
|
2012-04-10 21:23:37 +00:00
|
|
|
|
|
|
|
/* Increment usage counter */
|
|
|
|
((guac_rdp_bitmap*) bitmap)->used++;
|
|
|
|
|
2012-03-07 23:35:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* If whiteness, send white rectangle */
|
|
|
|
case 0xFF:
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h, 0xFF, 0xFF, 0xFF);
|
2012-03-07 23:35:38 +00:00
|
|
|
break;
|
2012-02-27 20:39:13 +00:00
|
|
|
|
|
|
|
/* Otherwise, use transfer */
|
2012-03-07 23:35:38 +00:00
|
|
|
default:
|
2012-04-10 21:23:37 +00:00
|
|
|
|
|
|
|
/* If not available as a surface, make available. */
|
2016-03-01 05:50:00 +00:00
|
|
|
if (bitmap->layer == NULL)
|
2012-04-10 21:23:37 +00:00
|
|
|
guac_rdp_cache_bitmap(context, memblt->bitmap);
|
|
|
|
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface_transfer(bitmap->layer->surface,
|
|
|
|
x_src, y_src, w, h,
|
|
|
|
guac_rdp_rop3_transfer_function(client, memblt->bRop),
|
|
|
|
current_surface, x, y);
|
2012-02-27 20:39:13 +00:00
|
|
|
|
2012-04-10 21:23:37 +00:00
|
|
|
/* Increment usage counter */
|
|
|
|
((guac_rdp_bitmap*) bitmap)->used++;
|
2012-03-07 23:36:31 +00:00
|
|
|
|
2012-04-10 21:23:37 +00:00
|
|
|
}
|
2012-02-08 23:09:12 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) {
|
|
|
|
|
2013-07-18 22:27:06 +00:00
|
|
|
/* Get client data */
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2013-07-18 22:27:06 +00:00
|
|
|
|
2014-11-21 05:06:39 +00:00
|
|
|
UINT32 color = guac_rdp_convert_color(context, opaque_rect->color);
|
2012-01-04 03:09:33 +00:00
|
|
|
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface* current_surface = ((guac_rdp_client*) client->data)->current_surface;
|
2012-01-11 07:31:24 +00:00
|
|
|
|
2013-05-13 21:34:24 +00:00
|
|
|
int x = opaque_rect->nLeftRect;
|
|
|
|
int y = opaque_rect->nTopRect;
|
|
|
|
int w = opaque_rect->nWidth;
|
|
|
|
int h = opaque_rect->nHeight;
|
|
|
|
|
2014-04-30 18:44:06 +00:00
|
|
|
guac_common_surface_rect(current_surface, x, y, w, h,
|
2012-01-04 03:09:33 +00:00
|
|
|
(color >> 16) & 0xFF,
|
|
|
|
(color >> 8 ) & 0xFF,
|
2014-04-30 18:44:06 +00:00
|
|
|
(color ) & 0xFF);
|
2012-01-04 03:09:33 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-11-21 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* Updates the palette within a FreeRDP CLRCONV object using the new palette
|
|
|
|
* entries provided by an RDP palette update.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
2016-03-07 23:05:31 +00:00
|
|
|
* @param clrconv
|
|
|
|
* The FreeRDP CLRCONV object to update.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param palette
|
|
|
|
* An RDP palette update message containing the palette to store within the
|
|
|
|
* given CLRCONV object.
|
2014-11-21 02:35:17 +00:00
|
|
|
*/
|
|
|
|
static void guac_rdp_update_clrconv(CLRCONV* clrconv,
|
|
|
|
PALETTE_UPDATE* palette) {
|
2012-01-04 03:09:33 +00:00
|
|
|
|
2012-02-08 20:32:27 +00:00
|
|
|
clrconv->palette->count = palette->number;
|
2013-07-18 23:20:40 +00:00
|
|
|
#ifdef LEGACY_RDPPALETTE
|
2012-02-08 20:32:27 +00:00
|
|
|
clrconv->palette->entries = palette->entries;
|
2013-07-18 23:20:40 +00:00
|
|
|
#else
|
2014-11-21 02:35:17 +00:00
|
|
|
memcpy(clrconv->palette->entries, palette->entries,
|
|
|
|
sizeof(palette->entries));
|
2013-07-18 23:20:40 +00:00
|
|
|
#endif
|
2012-02-08 20:32:27 +00:00
|
|
|
|
|
|
|
}
|
2012-02-08 22:16:05 +00:00
|
|
|
|
2014-11-21 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* Updates a raw ARGB32 palette using the new palette entries provided by an
|
|
|
|
* RDP palette update.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param guac_palette
|
|
|
|
* An array of 256 ARGB32 colors, with each entry corresponding to an
|
|
|
|
* entry in the color palette.
|
|
|
|
*
|
|
|
|
* @param palette
|
|
|
|
* An RDP palette update message containing the palette to store within the
|
|
|
|
* given array of ARGB32 colors.
|
2014-11-21 02:35:17 +00:00
|
|
|
*/
|
|
|
|
static void guac_rdp_update_palette(UINT32* guac_palette,
|
|
|
|
PALETTE_UPDATE* palette) {
|
|
|
|
|
|
|
|
PALETTE_ENTRY* entry = palette->entries;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Copy each palette entry as ARGB32 */
|
|
|
|
for (i=0; i < palette->number; i++) {
|
|
|
|
|
|
|
|
*guac_palette = 0xFF000000
|
|
|
|
| (entry->red << 16)
|
|
|
|
| (entry->green << 8)
|
|
|
|
| entry->blue;
|
|
|
|
|
|
|
|
guac_palette++;
|
|
|
|
entry++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) {
|
|
|
|
|
|
|
|
CLRCONV* clrconv = ((rdp_freerdp_context*) context)->clrconv;
|
|
|
|
UINT32* guac_palette = ((rdp_freerdp_context*) context)->palette;
|
|
|
|
|
|
|
|
/* Update internal palette representations */
|
|
|
|
guac_rdp_update_clrconv(clrconv, palette);
|
|
|
|
guac_rdp_update_palette(guac_palette, palette);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-08 22:16:05 +00:00
|
|
|
void guac_rdp_gdi_set_bounds(rdpContext* context, rdpBounds* bounds) {
|
|
|
|
|
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
|
2012-03-12 04:32:06 +00:00
|
|
|
|
2013-05-13 21:27:15 +00:00
|
|
|
/* If no bounds given, clear bounding rect */
|
|
|
|
if (bounds == NULL)
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface_reset_clip(rdp_client->display->default_surface);
|
2013-05-13 21:27:15 +00:00
|
|
|
|
|
|
|
/* Otherwise, set bounding rectangle */
|
2014-05-05 00:00:26 +00:00
|
|
|
else
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface_clip(rdp_client->display->default_surface,
|
|
|
|
bounds->left, bounds->top,
|
|
|
|
bounds->right - bounds->left + 1,
|
|
|
|
bounds->bottom - bounds->top + 1);
|
2012-02-08 22:16:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-04 00:58:31 +00:00
|
|
|
void guac_rdp_gdi_end_paint(rdpContext* context) {
|
2013-05-14 01:38:13 +00:00
|
|
|
/* IGNORE */
|
2012-04-04 00:58:31 +00:00
|
|
|
}
|
|
|
|
|
2014-07-21 16:12:17 +00:00
|
|
|
void guac_rdp_gdi_desktop_resize(rdpContext* context) {
|
|
|
|
|
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
|
2014-07-21 16:12:17 +00:00
|
|
|
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface_resize(rdp_client->display->default_surface,
|
2014-07-21 16:12:17 +00:00
|
|
|
guac_rdp_get_width(context->instance),
|
|
|
|
guac_rdp_get_height(context->instance));
|
|
|
|
|
2016-03-01 05:50:00 +00:00
|
|
|
guac_common_surface_reset_clip(rdp_client->display->default_surface);
|
2014-07-21 16:12:17 +00:00
|
|
|
|
2014-11-25 10:20:54 +00:00
|
|
|
guac_client_log(client, GUAC_LOG_DEBUG, "Server resized display to %ix%i",
|
|
|
|
guac_rdp_get_width(context->instance),
|
|
|
|
guac_rdp_get_height(context->instance));
|
|
|
|
|
2014-07-21 16:12:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|