2011-09-26 00:30:20 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-09-26 00:30:20 +04:00
|
|
|
* Windows GDI
|
|
|
|
*
|
|
|
|
* Copyright 2009-2011 Jay Sorg
|
|
|
|
* Copyright 2010-2011 Vic Lee
|
|
|
|
* Copyright 2010-2011 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.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-08-15 01:20:53 +04:00
|
|
|
|
2011-09-26 00:30:20 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <conio.h>
|
|
|
|
|
2014-09-12 19:13:01 +04:00
|
|
|
#include <freerdp/log.h>
|
2011-09-26 00:30:20 +04:00
|
|
|
#include <freerdp/gdi/gdi.h>
|
2011-11-12 11:35:18 +04:00
|
|
|
#include <freerdp/constants.h>
|
2011-10-03 04:28:20 +04:00
|
|
|
#include <freerdp/codec/color.h>
|
2011-10-05 00:05:09 +04:00
|
|
|
#include <freerdp/codec/bitmap.h>
|
2011-11-12 11:35:18 +04:00
|
|
|
#include <freerdp/codec/rfx.h>
|
|
|
|
#include <freerdp/codec/nsc.h>
|
2016-07-21 16:36:15 +03:00
|
|
|
#include <freerdp/gdi/gdi.h>
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2014-09-13 00:30:57 +04:00
|
|
|
#include "wf_client.h"
|
2011-10-22 00:45:35 +04:00
|
|
|
#include "wf_graphics.h"
|
2013-04-26 01:18:14 +04:00
|
|
|
#include "wf_gdi.h"
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2014-09-12 19:13:01 +04:00
|
|
|
#define TAG CLIENT_TAG("windows.gdi")
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static const BYTE wf_rop2_table[] = {
|
2011-10-05 00:05:09 +04:00
|
|
|
R2_BLACK, /* 0 */
|
|
|
|
R2_NOTMERGEPEN, /* DPon */
|
|
|
|
R2_MASKNOTPEN, /* DPna */
|
|
|
|
R2_NOTCOPYPEN, /* Pn */
|
|
|
|
R2_MASKPENNOT, /* PDna */
|
|
|
|
R2_NOT, /* Dn */
|
|
|
|
R2_XORPEN, /* DPx */
|
|
|
|
R2_NOTMASKPEN, /* DPan */
|
|
|
|
R2_MASKPEN, /* DPa */
|
|
|
|
R2_NOTXORPEN, /* DPxn */
|
|
|
|
R2_NOP, /* D */
|
|
|
|
R2_MERGENOTPEN, /* DPno */
|
|
|
|
R2_COPYPEN, /* P */
|
|
|
|
R2_MERGEPENNOT, /* PDno */
|
|
|
|
R2_MERGEPEN, /* PDo */
|
|
|
|
R2_WHITE, /* 1 */
|
|
|
|
};
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor, COLORREF* color, UINT32* format)
|
2016-08-03 13:37:40 +03:00
|
|
|
{
|
2016-08-08 16:15:55 +03:00
|
|
|
rdpGdi* gdi;
|
|
|
|
rdpSettings* settings;
|
|
|
|
UINT32 SrcFormat, DstFormat;
|
|
|
|
|
|
|
|
if (!wfc)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-01-19 11:27:39 +03:00
|
|
|
gdi = wfc->common.context.gdi;
|
|
|
|
settings = wfc->common.context.settings;
|
2016-08-08 16:15:55 +03:00
|
|
|
|
|
|
|
if (!gdi || !settings)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-06-22 13:42:48 +03:00
|
|
|
SrcFormat = gdi_get_pixel_format(freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
|
2016-08-08 16:15:55 +03:00
|
|
|
|
|
|
|
if (format)
|
|
|
|
*format = SrcFormat;
|
|
|
|
|
2022-04-28 06:43:31 +03:00
|
|
|
switch (FreeRDPGetBitsPerPixel(gdi->dstFormat))
|
2016-08-08 16:15:55 +03:00
|
|
|
{
|
2016-08-10 14:33:34 +03:00
|
|
|
case 32:
|
|
|
|
DstFormat = PIXEL_FORMAT_ABGR32;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
DstFormat = PIXEL_FORMAT_BGR24;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
DstFormat = PIXEL_FORMAT_RGB16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2016-08-08 16:15:55 +03:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
*color = FreeRDPConvertColor(srcColor, SrcFormat, DstFormat, &gdi->palette);
|
2016-08-08 16:15:55 +03:00
|
|
|
return TRUE;
|
2016-08-03 13:37:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL wf_set_rop2(HDC hdc, int rop2)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
|
|
|
if ((rop2 < 0x01) || (rop2 > 0x10))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "Unsupported ROP2: %d", rop2);
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
SetROP2(hdc, wf_rop2_table[rop2 - 1]);
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-08-03 13:37:40 +03:00
|
|
|
static wfBitmap* wf_glyph_new(wfContext* wfc, GLYPH_DATA* glyph)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
2011-10-14 04:10:59 +04:00
|
|
|
wfBitmap* glyph_bmp;
|
2019-11-06 17:24:51 +03:00
|
|
|
glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, PIXEL_FORMAT_MONO, glyph->aj);
|
2011-10-05 00:05:09 +04:00
|
|
|
return glyph_bmp;
|
|
|
|
}
|
|
|
|
|
2016-08-03 13:37:40 +03:00
|
|
|
static void wf_glyph_free(wfBitmap* glyph)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
|
|
|
wf_image_free(glyph);
|
|
|
|
}
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, const BYTE* data)
|
2011-11-12 11:11:10 +04:00
|
|
|
{
|
2024-01-30 12:25:38 +03:00
|
|
|
const int src_bytes_per_row = (width + 7) / 8;
|
|
|
|
const int dst_bytes_per_row = src_bytes_per_row + (src_bytes_per_row % 2);
|
|
|
|
BYTE* cdata = (BYTE*)malloc(dst_bytes_per_row * height);
|
|
|
|
const BYTE* src = data;
|
|
|
|
|
|
|
|
for (int indexy = 0; indexy < height; indexy++)
|
2011-11-12 11:11:10 +04:00
|
|
|
{
|
2024-02-15 15:10:45 +03:00
|
|
|
BYTE* dst = &cdata[1ull * indexy * dst_bytes_per_row];
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (int indexx = 0; indexx < dst_bytes_per_row; indexx++)
|
2011-11-12 11:11:10 +04:00
|
|
|
{
|
|
|
|
if (indexx < src_bytes_per_row)
|
|
|
|
*dst++ = *src++;
|
|
|
|
else
|
|
|
|
*dst++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cdata;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, UINT32 bpp)
|
2011-11-12 11:11:10 +04:00
|
|
|
{
|
|
|
|
HBRUSH br;
|
|
|
|
LOGBRUSH lbr;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* cdata;
|
|
|
|
BYTE ipattern[8];
|
2011-11-12 11:11:10 +04:00
|
|
|
HBITMAP pattern = NULL;
|
|
|
|
lbr.lbStyle = brush->style;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (lbr.lbStyle == BS_DIBPATTERN || lbr.lbStyle == BS_DIBPATTERN8X8 ||
|
|
|
|
lbr.lbStyle == BS_DIBPATTERNPT)
|
2011-11-12 11:11:10 +04:00
|
|
|
lbr.lbColor = DIB_RGB_COLORS;
|
|
|
|
else
|
|
|
|
lbr.lbColor = color;
|
|
|
|
|
|
|
|
if (lbr.lbStyle == BS_PATTERN || lbr.lbStyle == BS_PATTERN8X8)
|
|
|
|
{
|
|
|
|
if (brush->bpp > 1)
|
|
|
|
{
|
2017-02-17 13:17:45 +03:00
|
|
|
UINT32 format = gdi_get_pixel_format(bpp);
|
2016-08-03 13:09:24 +03:00
|
|
|
pattern = wf_create_dib(wfc, 8, 8, format, brush->data, NULL);
|
2019-11-06 17:24:51 +03:00
|
|
|
lbr.lbHatch = (ULONG_PTR)pattern;
|
2011-11-12 11:11:10 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i != 8; i++)
|
2011-11-12 11:11:10 +04:00
|
|
|
ipattern[7 - i] = brush->data[i];
|
2012-10-16 22:20:04 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
cdata = wf_glyph_convert(wfc, 8, 8, ipattern);
|
2011-11-12 11:11:10 +04:00
|
|
|
pattern = CreateBitmap(8, 8, 1, 1, cdata);
|
2019-11-06 17:24:51 +03:00
|
|
|
lbr.lbHatch = (ULONG_PTR)pattern;
|
2011-11-12 11:11:10 +04:00
|
|
|
free(cdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lbr.lbStyle == BS_HATCHED)
|
|
|
|
{
|
|
|
|
lbr.lbHatch = brush->hatch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lbr.lbHatch = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
br = CreateBrushIndirect(&lbr);
|
2013-06-16 06:57:21 +04:00
|
|
|
SetBrushOrgEx(wfc->drawing->hdc, brush->x, brush->y, NULL);
|
2011-11-12 11:11:10 +04:00
|
|
|
|
|
|
|
if (pattern != NULL)
|
|
|
|
DeleteObject(pattern);
|
|
|
|
|
|
|
|
return br;
|
|
|
|
}
|
|
|
|
|
2022-08-28 03:34:27 +03:00
|
|
|
BOOL wf_scale_rect(wfContext* wfc, RECT* source)
|
2013-04-11 00:58:14 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
UINT32 ww, wh, dw, dh;
|
|
|
|
rdpSettings* settings;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2022-01-19 11:27:39 +03:00
|
|
|
if (!wfc || !source || !wfc->common.context.settings)
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2022-01-19 11:27:39 +03:00
|
|
|
settings = wfc->common.context.settings;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
|
|
|
if (!settings)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
|
|
|
dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_width)
|
2016-08-03 13:09:24 +03:00
|
|
|
wfc->client_width = dw;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_height)
|
2016-08-03 13:09:24 +03:00
|
|
|
wfc->client_height = dh;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
ww = wfc->client_width;
|
|
|
|
wh = wfc->client_height;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
|
|
|
if (!ww)
|
|
|
|
ww = dw;
|
|
|
|
|
|
|
|
if (!wh)
|
|
|
|
wh = dh;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing) &&
|
|
|
|
(ww != dw || wh != dh))
|
2013-04-11 00:58:14 +04:00
|
|
|
{
|
2013-04-30 20:56:16 +04:00
|
|
|
source->bottom = source->bottom * wh / dh + 20;
|
|
|
|
source->top = source->top * wh / dh - 20;
|
|
|
|
source->left = source->left * ww / dw - 20;
|
|
|
|
source->right = source->right * ww / dw + 20;
|
2013-04-11 00:58:14 +04:00
|
|
|
}
|
2013-04-26 23:46:36 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
source->bottom -= wfc->yCurrentScroll;
|
|
|
|
source->top -= wfc->yCurrentScroll;
|
|
|
|
source->left -= wfc->xCurrentScroll;
|
|
|
|
source->right -= wfc->xCurrentScroll;
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2013-04-11 00:58:14 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
2013-04-11 00:58:14 +04:00
|
|
|
RECT rect;
|
2022-01-19 11:27:39 +03:00
|
|
|
rdpGdi* gdi = wfc->common.context.gdi;
|
2013-06-16 06:57:21 +04:00
|
|
|
wfc->update_rect.left = x + wfc->offset_x;
|
|
|
|
wfc->update_rect.top = y + wfc->offset_y;
|
|
|
|
wfc->update_rect.right = wfc->update_rect.left + width;
|
|
|
|
wfc->update_rect.bottom = wfc->update_rect.top + height;
|
|
|
|
wf_scale_rect(wfc, &(wfc->update_rect));
|
|
|
|
InvalidateRect(wfc->hwnd, &(wfc->update_rect), FALSE);
|
2013-04-11 00:58:14 +04:00
|
|
|
rect.left = x;
|
|
|
|
rect.right = width;
|
|
|
|
rect.top = y;
|
|
|
|
rect.bottom = height;
|
2013-06-16 06:57:21 +04:00
|
|
|
wf_scale_rect(wfc, &rect);
|
2019-11-06 17:24:51 +03:00
|
|
|
gdi_InvalidateRegion(gdi->primary->hdc, rect.left, rect.top, rect.right, rect.bottom);
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
void wf_update_offset(wfContext* wfc)
|
2012-12-25 08:10:24 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
rdpSettings* settings;
|
2022-01-19 11:27:39 +03:00
|
|
|
settings = wfc->common.context.settings;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->fullscreen)
|
2012-12-25 08:10:24 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon))
|
2013-04-25 18:50:26 +04:00
|
|
|
{
|
|
|
|
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
|
|
|
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
|
|
|
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
|
|
|
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->offset_x = (w - freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) / 2;
|
2013-04-25 18:50:26 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->offset_x < x)
|
|
|
|
wfc->offset_x = x;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->offset_y = (h - freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) / 2;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->offset_y < y)
|
|
|
|
wfc->offset_y = y;
|
2013-04-25 18:50:26 +04:00
|
|
|
}
|
2016-08-03 13:09:24 +03:00
|
|
|
else
|
2013-04-25 18:50:26 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) -
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) /
|
|
|
|
2;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->offset_x < 0)
|
|
|
|
wfc->offset_x = 0;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) -
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) /
|
|
|
|
2;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->offset_y < 0)
|
|
|
|
wfc->offset_y = 0;
|
2013-04-25 18:50:26 +04:00
|
|
|
}
|
2012-12-25 08:10:24 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
wfc->offset_x = 0;
|
|
|
|
wfc->offset_y = 0;
|
2012-12-25 08:10:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
void wf_resize_window(wfContext* wfc)
|
2012-12-25 08:10:24 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
rdpSettings* settings;
|
2022-01-19 11:27:39 +03:00
|
|
|
settings = wfc->common.context.settings;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->fullscreen)
|
2012-12-25 08:10:24 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon))
|
2013-04-25 18:50:26 +04:00
|
|
|
{
|
|
|
|
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
|
|
|
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
|
|
|
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
|
|
|
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
2013-06-16 06:57:21 +04:00
|
|
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_POPUP);
|
|
|
|
SetWindowPos(wfc->hwnd, HWND_TOP, x, y, w, h, SWP_FRAMECHANGED);
|
2013-04-25 18:50:26 +04:00
|
|
|
}
|
|
|
|
else
|
2013-04-25 23:42:40 +04:00
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_POPUP);
|
2016-08-03 13:09:24 +03:00
|
|
|
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN),
|
2016-08-10 14:33:34 +03:00
|
|
|
GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
|
2013-04-25 23:42:40 +04:00
|
|
|
}
|
2012-12-25 08:10:24 +04:00
|
|
|
}
|
2023-10-13 10:48:44 +03:00
|
|
|
else if (!freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_Decorations))
|
2016-08-03 13:09:24 +03:00
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CHILD);
|
2018-11-16 12:33:29 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow))
|
2018-03-02 21:39:59 +03:00
|
|
|
{
|
2019-02-21 08:33:52 +03:00
|
|
|
if (!wfc->client_height)
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
2019-02-21 08:33:52 +03:00
|
|
|
|
|
|
|
if (!wfc->client_width)
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
2019-02-21 08:33:52 +03:00
|
|
|
|
2018-03-02 21:39:59 +03:00
|
|
|
wf_update_canvas_diff(wfc);
|
2019-02-21 08:33:52 +03:00
|
|
|
/* Now resize to get full canvas size and room for caption and borders */
|
|
|
|
SetWindowPos(wfc->hwnd, HWND_TOP, wfc->client_x, wfc->client_y,
|
2019-11-06 17:24:51 +03:00
|
|
|
wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y,
|
|
|
|
0 /*SWP_FRAMECHANGED*/);
|
2018-03-02 21:39:59 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Now resize to get full canvas size and room for caption and borders */
|
2023-10-13 10:48:44 +03:00
|
|
|
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0,
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight),
|
2019-11-06 17:24:51 +03:00
|
|
|
SWP_FRAMECHANGED);
|
2018-03-02 21:39:59 +03:00
|
|
|
wf_update_canvas_diff(wfc);
|
2023-10-13 10:48:44 +03:00
|
|
|
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1,
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + wfc->diff.x,
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + wfc->diff.y,
|
|
|
|
SWP_NOMOVE | SWP_FRAMECHANGED);
|
2018-03-02 21:39:59 +03:00
|
|
|
}
|
2013-04-02 02:32:14 +04:00
|
|
|
}
|
2012-12-25 08:10:24 +04:00
|
|
|
else
|
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
SetWindowLongPtr(wfc->hwnd, GWL_STYLE,
|
2016-08-10 14:33:34 +03:00
|
|
|
WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX |
|
2019-11-06 17:24:51 +03:00
|
|
|
WS_MAXIMIZEBOX);
|
2013-04-25 23:42:40 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_height)
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
2013-04-25 23:42:40 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_width)
|
2023-10-13 10:48:44 +03:00
|
|
|
wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
2013-04-25 23:42:40 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_x)
|
|
|
|
wfc->client_x = 10;
|
2013-04-25 23:42:40 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_y)
|
|
|
|
wfc->client_y = 10;
|
2013-04-02 02:32:14 +04:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
wf_update_canvas_diff(wfc);
|
2013-04-26 01:18:14 +04:00
|
|
|
/* Now resize to get full canvas size and room for caption and borders */
|
2022-09-06 05:50:55 +03:00
|
|
|
int width, height;
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) &&
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) &&
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight))
|
2022-09-06 05:50:55 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
width = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth);
|
|
|
|
height = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight);
|
2022-09-06 05:50:55 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
width = wfc->client_width + wfc->diff.x;
|
|
|
|
height = wfc->client_height + wfc->diff.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
int xpos, ypos;
|
2023-10-13 10:48:44 +03:00
|
|
|
if ((freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX) &&
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX))
|
2022-09-06 05:50:55 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
xpos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX);
|
|
|
|
ypos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY);
|
2022-09-06 05:50:55 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xpos = wfc->client_x;
|
|
|
|
ypos = wfc->client_y;
|
|
|
|
}
|
2022-09-06 19:30:08 +03:00
|
|
|
SetWindowPos(wfc->hwnd, HWND_TOP, xpos, ypos, width, height, 0 /*SWP_FRAMECHANGED*/);
|
2019-11-06 17:24:51 +03:00
|
|
|
// wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
|
2012-12-25 08:10:24 +04:00
|
|
|
}
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
wf_update_offset(wfc);
|
2012-12-25 08:10:24 +04:00
|
|
|
}
|
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
void wf_toggle_fullscreen(wfContext* wfc)
|
2011-09-26 00:30:20 +04:00
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
ShowWindow(wfc->hwnd, SW_HIDE);
|
|
|
|
wfc->fullscreen = !wfc->fullscreen;
|
2013-04-26 01:18:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->fullscreen)
|
2013-04-26 01:18:14 +04:00
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
wfc->disablewindowtracking = TRUE;
|
2013-04-26 01:18:14 +04:00
|
|
|
}
|
|
|
|
|
2018-11-16 12:33:29 +03:00
|
|
|
wf_floatbar_toggle_fullscreen(wfc->floatbar, wfc->fullscreen);
|
2013-06-16 06:57:21 +04:00
|
|
|
SetParent(wfc->hwnd, wfc->fullscreen ? NULL : wfc->hWndParent);
|
|
|
|
wf_resize_window(wfc);
|
|
|
|
ShowWindow(wfc->hwnd, SW_SHOW);
|
|
|
|
SetForegroundWindow(wfc->hwnd);
|
2013-04-26 01:18:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->fullscreen)
|
2013-04-26 01:18:14 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
// Reenable window tracking AFTER resizing it back, otherwise it can lean to repositioning
|
|
|
|
// errors.
|
2013-06-16 06:57:21 +04:00
|
|
|
wfc->disablewindowtracking = FALSE;
|
2013-04-26 01:18:14 +04:00
|
|
|
}
|
2011-09-26 00:30:20 +04:00
|
|
|
}
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL wf_gdi_palette_update(rdpContext* context, const PALETTE_UPDATE* palette)
|
2014-09-12 19:34:30 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
void wf_set_null_clip_rgn(wfContext* wfc)
|
2011-11-12 11:35:18 +04:00
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
SelectClipRgn(wfc->drawing->hdc, NULL);
|
2011-11-12 11:35:18 +04:00
|
|
|
}
|
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
void wf_set_clip_rgn(wfContext* wfc, int x, int y, int width, int height)
|
2011-11-12 11:35:18 +04:00
|
|
|
{
|
|
|
|
HRGN clip;
|
2011-12-16 23:43:14 +04:00
|
|
|
clip = CreateRectRgn(x, y, x + width, y + height);
|
2013-06-16 06:57:21 +04:00
|
|
|
SelectClipRgn(wfc->drawing->hdc, clip);
|
2011-11-12 11:35:18 +04:00
|
|
|
DeleteObject(clip);
|
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static BOOL wf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
|
|
|
HRGN hrgn;
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !bounds)
|
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
|
|
|
if (bounds != NULL)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
hrgn = CreateRectRgn(bounds->left, bounds->top, bounds->right + 1, bounds->bottom + 1);
|
2013-06-16 06:57:21 +04:00
|
|
|
SelectClipRgn(wfc->drawing->hdc, hrgn);
|
2011-10-05 00:05:09 +04:00
|
|
|
DeleteObject(hrgn);
|
|
|
|
}
|
|
|
|
else
|
2013-06-16 06:57:21 +04:00
|
|
|
SelectClipRgn(wfc->drawing->hdc, NULL);
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static BOOL wf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !dstblt)
|
|
|
|
return FALSE;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth,
|
|
|
|
dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
wf_invalidate_region(wfc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static BOOL wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
2011-11-12 11:11:10 +04:00
|
|
|
HBRUSH brush;
|
|
|
|
HBRUSH org_brush;
|
|
|
|
int org_bkmode;
|
2021-05-28 18:50:09 +03:00
|
|
|
COLORREF fgcolor;
|
|
|
|
COLORREF bgcolor;
|
2011-11-12 11:11:10 +04:00
|
|
|
COLORREF org_bkcolor;
|
|
|
|
COLORREF org_textcolor;
|
2016-08-03 13:09:24 +03:00
|
|
|
BOOL rc;
|
|
|
|
wfContext* wfc = (wfContext*)context;
|
|
|
|
|
|
|
|
if (!context || !patblt)
|
|
|
|
return FALSE;
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2016-08-03 13:37:40 +03:00
|
|
|
if (!wf_decode_color(wfc, patblt->foreColor, &fgcolor, NULL))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2016-08-03 13:37:40 +03:00
|
|
|
if (!wf_decode_color(wfc, patblt->backColor, &bgcolor, NULL))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2022-06-22 13:42:48 +03:00
|
|
|
brush = wf_create_brush(wfc, &patblt->brush, fgcolor,
|
|
|
|
freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth));
|
2013-06-16 06:57:21 +04:00
|
|
|
org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE);
|
|
|
|
org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor);
|
|
|
|
org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor);
|
|
|
|
org_brush = (HBRUSH)SelectObject(wfc->drawing->hdc, brush);
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth,
|
|
|
|
patblt->nHeight, gdi_rop3_code(patblt->bRop));
|
2013-06-16 06:57:21 +04:00
|
|
|
SelectObject(wfc->drawing->hdc, org_brush);
|
2011-11-12 11:11:10 +04:00
|
|
|
DeleteObject(brush);
|
2013-06-16 06:57:21 +04:00
|
|
|
SetBkMode(wfc->drawing->hdc, org_bkmode);
|
|
|
|
SetBkColor(wfc->drawing->hdc, org_bkcolor);
|
|
|
|
SetTextColor(wfc->drawing->hdc, org_textcolor);
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->drawing == wfc->primary)
|
2016-08-03 13:09:24 +03:00
|
|
|
wf_invalidate_region(wfc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth,
|
2016-08-10 14:33:34 +03:00
|
|
|
patblt->nHeight);
|
2016-08-03 13:09:24 +03:00
|
|
|
|
|
|
|
return rc;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static BOOL wf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !scrblt || !wfc->drawing)
|
|
|
|
return FALSE;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth,
|
|
|
|
scrblt->nHeight, wfc->primary->hdc, scrblt->nXSrc, scrblt->nYSrc,
|
|
|
|
gdi_rop3_code(scrblt->bRop)))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
wf_invalidate_region(wfc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight);
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL wf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
HBRUSH brush;
|
2021-05-28 18:50:09 +03:00
|
|
|
COLORREF brush_color;
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !opaque_rect)
|
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2016-08-03 13:37:40 +03:00
|
|
|
if (!wf_decode_color(wfc, opaque_rect->color, &brush_color, NULL))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
|
|
|
rect.left = opaque_rect->nLeftRect;
|
|
|
|
rect.top = opaque_rect->nTopRect;
|
|
|
|
rect.right = opaque_rect->nLeftRect + opaque_rect->nWidth;
|
|
|
|
rect.bottom = opaque_rect->nTopRect + opaque_rect->nHeight;
|
|
|
|
brush = CreateSolidBrush(brush_color);
|
2013-06-16 06:57:21 +04:00
|
|
|
FillRect(wfc->drawing->hdc, &rect, brush);
|
2011-10-05 00:05:09 +04:00
|
|
|
DeleteObject(brush);
|
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->drawing == wfc->primary)
|
2016-08-03 13:09:24 +03:00
|
|
|
wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1,
|
2016-08-10 14:33:34 +03:00
|
|
|
rect.bottom - rect.top + 1);
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
static BOOL wf_gdi_multi_opaque_rect(rdpContext* context,
|
2016-08-10 14:33:34 +03:00
|
|
|
const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
HBRUSH brush;
|
2021-05-28 18:50:09 +03:00
|
|
|
COLORREF brush_color;
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !multi_opaque_rect)
|
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!wf_decode_color(wfc, multi_opaque_rect->color, &brush_color, NULL))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2014-09-12 19:34:30 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < multi_opaque_rect->numRectangles; i++)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
|
2011-10-05 00:05:09 +04:00
|
|
|
rect.left = rectangle->left;
|
|
|
|
rect.top = rectangle->top;
|
|
|
|
rect.right = rectangle->left + rectangle->width;
|
|
|
|
rect.bottom = rectangle->top + rectangle->height;
|
|
|
|
brush = CreateSolidBrush(brush_color);
|
2013-06-16 06:57:21 +04:00
|
|
|
FillRect(wfc->drawing->hdc, &rect, brush);
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->drawing == wfc->primary)
|
2016-08-03 13:09:24 +03:00
|
|
|
wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1,
|
2016-08-10 14:33:34 +03:00
|
|
|
rect.bottom - rect.top + 1);
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2011-10-05 00:05:09 +04:00
|
|
|
DeleteObject(brush);
|
|
|
|
}
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static BOOL wf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
|
|
|
HPEN pen;
|
|
|
|
HPEN org_pen;
|
2011-11-12 11:11:10 +04:00
|
|
|
int x, y, w, h;
|
2021-05-28 18:50:09 +03:00
|
|
|
COLORREF pen_color;
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !line_to)
|
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2016-08-03 13:37:40 +03:00
|
|
|
if (!wf_decode_color(wfc, line_to->penColor, &pen_color, NULL))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
pen = CreatePen(line_to->penStyle, line_to->penWidth, pen_color);
|
2013-06-16 06:57:21 +04:00
|
|
|
wf_set_rop2(wfc->drawing->hdc, line_to->bRop2);
|
2019-11-06 17:24:51 +03:00
|
|
|
org_pen = (HPEN)SelectObject(wfc->drawing->hdc, pen);
|
2013-06-16 06:57:21 +04:00
|
|
|
MoveToEx(wfc->drawing->hdc, line_to->nXStart, line_to->nYStart, NULL);
|
|
|
|
LineTo(wfc->drawing->hdc, line_to->nXEnd, line_to->nYEnd);
|
2011-11-12 11:11:10 +04:00
|
|
|
x = (line_to->nXStart < line_to->nXEnd) ? line_to->nXStart : line_to->nXEnd;
|
|
|
|
y = (line_to->nYStart < line_to->nYEnd) ? line_to->nYStart : line_to->nYEnd;
|
2016-08-03 13:09:24 +03:00
|
|
|
w = (line_to->nXStart < line_to->nXEnd) ? (line_to->nXEnd - line_to->nXStart)
|
2019-11-06 17:24:51 +03:00
|
|
|
: (line_to->nXStart - line_to->nXEnd);
|
2016-08-03 13:09:24 +03:00
|
|
|
h = (line_to->nYStart < line_to->nYEnd) ? (line_to->nYEnd - line_to->nYStart)
|
2019-11-06 17:24:51 +03:00
|
|
|
: (line_to->nYStart - line_to->nYEnd);
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->drawing == wfc->primary)
|
|
|
|
wf_invalidate_region(wfc, x, y, w, h);
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
SelectObject(wfc->drawing->hdc, org_pen);
|
2011-10-05 00:05:09 +04:00
|
|
|
DeleteObject(pen);
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static BOOL wf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
|
2011-10-05 00:05:09 +04:00
|
|
|
{
|
2011-11-12 11:11:10 +04:00
|
|
|
int org_rop2;
|
|
|
|
HPEN hpen;
|
|
|
|
HPEN org_hpen;
|
2021-05-28 18:50:09 +03:00
|
|
|
COLORREF pen_color;
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
|
|
|
|
|
|
|
if (!context || !polyline)
|
|
|
|
return FALSE;
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2016-08-03 13:37:40 +03:00
|
|
|
if (!wf_decode_color(wfc, polyline->penColor, &pen_color, NULL))
|
2016-08-03 13:09:24 +03:00
|
|
|
return FALSE;
|
2011-11-12 11:11:10 +04:00
|
|
|
|
|
|
|
hpen = CreatePen(0, 1, pen_color);
|
2013-06-16 06:57:21 +04:00
|
|
|
org_rop2 = wf_set_rop2(wfc->drawing->hdc, polyline->bRop2);
|
2019-11-06 17:24:51 +03:00
|
|
|
org_hpen = (HPEN)SelectObject(wfc->drawing->hdc, hpen);
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2014-10-09 14:11:38 +04:00
|
|
|
if (polyline->numDeltaEntries > 0)
|
2011-11-12 11:11:10 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
POINT* pts;
|
|
|
|
POINT temp;
|
|
|
|
int numPoints;
|
2014-10-09 14:11:38 +04:00
|
|
|
numPoints = polyline->numDeltaEntries + 1;
|
2019-11-06 17:24:51 +03:00
|
|
|
pts = (POINT*)malloc(sizeof(POINT) * numPoints);
|
2014-10-09 14:11:38 +04:00
|
|
|
pts[0].x = temp.x = polyline->xStart;
|
|
|
|
pts[0].y = temp.y = polyline->yStart;
|
2011-11-12 11:11:10 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < polyline->numDeltaEntries; i++)
|
2011-11-12 11:11:10 +04:00
|
|
|
{
|
2014-02-10 10:43:58 +04:00
|
|
|
temp.x += polyline->points[i].x;
|
|
|
|
temp.y += polyline->points[i].y;
|
2014-10-09 14:11:38 +04:00
|
|
|
pts[i + 1].x = temp.x;
|
|
|
|
pts[i + 1].y = temp.y;
|
2011-11-12 11:11:10 +04:00
|
|
|
}
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2014-10-09 14:11:38 +04:00
|
|
|
if (wfc->drawing == wfc->primary)
|
2016-08-03 13:09:24 +03:00
|
|
|
wf_invalidate_region(wfc, wfc->client_x, wfc->client_y, wfc->client_width,
|
2016-08-10 14:33:34 +03:00
|
|
|
wfc->client_height);
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2014-10-09 14:11:38 +04:00
|
|
|
Polyline(wfc->drawing->hdc, pts, numPoints);
|
2012-10-09 07:21:26 +04:00
|
|
|
free(pts);
|
2011-11-12 11:11:10 +04:00
|
|
|
}
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
SelectObject(wfc->drawing->hdc, org_hpen);
|
|
|
|
wf_set_rop2(wfc->drawing->hdc, org_rop2);
|
2011-11-12 11:11:10 +04:00
|
|
|
DeleteObject(hpen);
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static BOOL wf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
|
2011-10-07 22:55:07 +04:00
|
|
|
{
|
2011-10-14 04:10:59 +04:00
|
|
|
wfBitmap* bitmap;
|
2016-08-03 13:09:24 +03:00
|
|
|
wfContext* wfc = (wfContext*)context;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !memblt)
|
|
|
|
return FALSE;
|
2011-10-07 22:55:07 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
bitmap = (wfBitmap*)memblt->bitmap;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
|
|
|
if (!bitmap || !wfc->drawing || !wfc->drawing->hdc)
|
|
|
|
return FALSE;
|
2011-10-07 22:55:07 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!BitBlt(wfc->drawing->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth,
|
|
|
|
memblt->nHeight, bitmap->hdc, memblt->nXSrc, memblt->nYSrc,
|
|
|
|
gdi_rop3_code(memblt->bRop)))
|
2016-08-10 14:33:34 +03:00
|
|
|
return FALSE;
|
2011-10-07 22:55:07 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc->drawing == wfc->primary)
|
2016-08-03 13:09:24 +03:00
|
|
|
wf_invalidate_region(wfc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth,
|
2016-08-10 14:33:34 +03:00
|
|
|
memblt->nHeight);
|
2011-12-16 23:43:14 +04:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
|
|
|
|
2016-08-10 15:45:55 +03:00
|
|
|
static BOOL wf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
|
|
|
|
{
|
|
|
|
BOOL rc = FALSE;
|
|
|
|
HDC hdc;
|
|
|
|
wfBitmap* bitmap;
|
|
|
|
wfContext* wfc = (wfContext*)context;
|
|
|
|
COLORREF fgcolor, bgcolor, orgColor;
|
|
|
|
HBRUSH orgBrush = NULL, brush = NULL;
|
|
|
|
|
|
|
|
if (!context || !mem3blt)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
bitmap = (wfBitmap*)mem3blt->bitmap;
|
2016-08-10 15:45:55 +03:00
|
|
|
|
|
|
|
if (!bitmap || !wfc->drawing || !wfc->drawing->hdc)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hdc = wfc->drawing->hdc;
|
|
|
|
|
|
|
|
if (!wf_decode_color(wfc, mem3blt->foreColor, &fgcolor, NULL))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!wf_decode_color(wfc, mem3blt->backColor, &bgcolor, NULL))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
orgColor = SetTextColor(hdc, fgcolor);
|
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
switch (mem3blt->brush.style)
|
2016-08-10 15:45:55 +03:00
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
case GDI_BS_SOLID:
|
|
|
|
brush = CreateSolidBrush(fgcolor);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDI_BS_HATCHED:
|
|
|
|
case GDI_BS_PATTERN:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
HBITMAP bmp = CreateBitmap(8, 8, 1, mem3blt->brush.bpp, mem3blt->brush.data);
|
|
|
|
brush = CreatePatternBrush(bmp);
|
|
|
|
}
|
|
|
|
break;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
goto fail;
|
2016-08-10 15:45:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
orgBrush = SelectObject(hdc, brush);
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!BitBlt(hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight,
|
|
|
|
bitmap->hdc, mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop)))
|
2016-08-10 15:45:55 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (wfc->drawing == wfc->primary)
|
2019-11-06 17:24:51 +03:00
|
|
|
wf_invalidate_region(wfc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth,
|
2016-10-04 10:00:00 +03:00
|
|
|
mem3blt->nHeight);
|
2016-08-10 15:45:55 +03:00
|
|
|
|
|
|
|
rc = TRUE;
|
|
|
|
fail:
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2016-08-10 15:45:55 +03:00
|
|
|
if (brush)
|
|
|
|
SelectObject(hdc, orgBrush);
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2016-08-10 15:45:55 +03:00
|
|
|
SetTextColor(hdc, orgColor);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
static BOOL wf_gdi_surface_frame_marker(rdpContext* context,
|
2016-08-10 14:33:34 +03:00
|
|
|
const SURFACE_FRAME_MARKER* surface_frame_marker)
|
2013-01-17 08:58:01 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
rdpSettings* settings;
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!context || !surface_frame_marker || !context->instance)
|
|
|
|
return FALSE;
|
2013-01-17 08:58:01 +04:00
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
settings = context->settings;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
|
|
|
if (!settings)
|
|
|
|
return FALSE;
|
2013-06-16 06:57:21 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END &&
|
2023-10-13 10:48:44 +03:00
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_FrameAcknowledge) > 0)
|
2013-01-17 08:58:01 +04:00
|
|
|
{
|
2022-03-23 15:18:35 +03:00
|
|
|
IFCALL(context->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId);
|
2013-01-17 08:58:01 +04:00
|
|
|
}
|
2016-07-21 16:36:15 +03:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2013-01-17 08:58:01 +04:00
|
|
|
}
|
|
|
|
|
2011-10-05 00:05:09 +04:00
|
|
|
void wf_gdi_register_update_callbacks(rdpUpdate* update)
|
|
|
|
{
|
2011-12-04 02:24:18 +04:00
|
|
|
rdpPrimaryUpdate* primary = update->primary;
|
2016-08-03 13:09:24 +03:00
|
|
|
update->Palette = wf_gdi_palette_update;
|
|
|
|
update->SetBounds = wf_gdi_set_bounds;
|
|
|
|
primary->DstBlt = wf_gdi_dstblt;
|
|
|
|
primary->PatBlt = wf_gdi_patblt;
|
|
|
|
primary->ScrBlt = wf_gdi_scrblt;
|
|
|
|
primary->OpaqueRect = wf_gdi_opaque_rect;
|
|
|
|
primary->MultiOpaqueRect = wf_gdi_multi_opaque_rect;
|
|
|
|
primary->LineTo = wf_gdi_line_to;
|
|
|
|
primary->Polyline = wf_gdi_polyline;
|
|
|
|
primary->MemBlt = wf_gdi_memblt;
|
2016-08-10 15:45:55 +03:00
|
|
|
primary->Mem3Blt = wf_gdi_mem3blt;
|
2016-08-03 13:09:24 +03:00
|
|
|
update->SurfaceFrameMarker = wf_gdi_surface_frame_marker;
|
2011-10-05 00:05:09 +04:00
|
|
|
}
|
2013-04-26 01:18:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
void wf_update_canvas_diff(wfContext* wfc)
|
2013-04-26 01:18:14 +04:00
|
|
|
{
|
|
|
|
RECT rc_client, rc_wnd;
|
|
|
|
int dx, dy;
|
2013-06-16 06:57:21 +04:00
|
|
|
GetClientRect(wfc->hwnd, &rc_client);
|
|
|
|
GetWindowRect(wfc->hwnd, &rc_wnd);
|
2013-04-26 01:18:14 +04:00
|
|
|
dx = (rc_wnd.right - rc_wnd.left) - rc_client.right;
|
|
|
|
dy = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
|
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->disablewindowtracking)
|
2013-04-26 01:18:14 +04:00
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
wfc->diff.x = dx;
|
|
|
|
wfc->diff.y = dy;
|
2013-04-26 01:18:14 +04:00
|
|
|
}
|
2013-06-16 06:57:21 +04:00
|
|
|
}
|