2014-09-29 16:08:08 -04:00
|
|
|
/**
|
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2014 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 11:20:38 +01:00
|
|
|
#include <freerdp/config.h>
|
2014-09-29 16:08:08 -04:00
|
|
|
|
2021-06-18 10:00:43 +02:00
|
|
|
#include <winpr/assert.h>
|
2024-12-19 12:32:40 +01:00
|
|
|
#include <winpr/cast.h>
|
|
|
|
|
|
2026-02-19 12:36:06 +01:00
|
|
|
#if defined(WITH_RDTK)
|
2014-09-29 16:08:08 -04:00
|
|
|
#include <rdtk/rdtk.h>
|
2026-02-19 12:36:06 +01:00
|
|
|
#endif
|
2014-09-29 16:08:08 -04:00
|
|
|
|
|
|
|
|
#include "shadow.h"
|
|
|
|
|
|
|
|
|
|
#include "shadow_lobby.h"
|
|
|
|
|
|
2015-04-12 02:57:16 +08:00
|
|
|
BOOL shadow_client_init_lobby(rdpShadowServer* server)
|
2014-09-29 16:08:08 -04:00
|
|
|
{
|
2024-04-15 09:55:11 +02:00
|
|
|
BOOL rc = FALSE;
|
2026-02-24 20:18:25 +01:00
|
|
|
RECTANGLE_16 invalidRect = WINPR_C_ARRAY_INIT;
|
2026-02-19 11:07:21 +01:00
|
|
|
|
|
|
|
|
WINPR_ASSERT(server);
|
2015-04-12 02:57:16 +08:00
|
|
|
rdpShadowSurface* lobby = server->lobby;
|
2014-09-29 16:08:08 -04:00
|
|
|
|
2015-04-12 02:57:16 +08:00
|
|
|
if (!lobby)
|
|
|
|
|
return FALSE;
|
2014-09-29 16:08:08 -04:00
|
|
|
|
2026-02-19 12:36:06 +01:00
|
|
|
#if defined(WITH_RDTK)
|
2024-04-15 09:55:11 +02:00
|
|
|
rdtkEngine* engine = rdtk_engine_new();
|
|
|
|
|
if (!engine)
|
2024-04-15 11:52:39 +02:00
|
|
|
return FALSE;
|
2014-09-29 16:08:08 -04:00
|
|
|
|
2024-04-15 09:55:11 +02:00
|
|
|
EnterCriticalSection(&lobby->lock);
|
2026-02-19 12:36:06 +01:00
|
|
|
rdtkSurface* surface =
|
2024-12-19 12:32:40 +01:00
|
|
|
rdtk_surface_new(engine, lobby->data, WINPR_ASSERTING_INT_CAST(uint16_t, lobby->width),
|
|
|
|
|
WINPR_ASSERTING_INT_CAST(uint16_t, lobby->height), lobby->scanline);
|
2024-04-15 09:55:11 +02:00
|
|
|
if (!surface)
|
|
|
|
|
goto fail;
|
2026-02-19 12:36:06 +01:00
|
|
|
#endif
|
2014-09-29 16:08:08 -04:00
|
|
|
|
2015-04-12 02:57:16 +08:00
|
|
|
invalidRect.left = 0;
|
|
|
|
|
invalidRect.top = 0;
|
2021-06-18 10:00:43 +02:00
|
|
|
WINPR_ASSERT(lobby->width <= UINT16_MAX);
|
|
|
|
|
WINPR_ASSERT(lobby->height <= UINT16_MAX);
|
|
|
|
|
invalidRect.right = (UINT16)lobby->width;
|
|
|
|
|
invalidRect.bottom = (UINT16)lobby->height;
|
2015-04-12 02:57:16 +08:00
|
|
|
if (server->shareSubRect)
|
|
|
|
|
{
|
|
|
|
|
/* If we have shared sub rect setting, only fill shared rect */
|
2026-02-16 10:57:57 +01:00
|
|
|
if (!rectangles_intersection(&invalidRect, &(server->subRect), &invalidRect))
|
|
|
|
|
goto fail;
|
2015-04-12 02:57:16 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-19 12:36:06 +01:00
|
|
|
#if defined(WITH_RDTK)
|
|
|
|
|
const int width = invalidRect.right - invalidRect.left;
|
|
|
|
|
const int height = invalidRect.bottom - invalidRect.top;
|
2021-06-16 17:38:33 +02:00
|
|
|
WINPR_ASSERT(width <= UINT16_MAX);
|
|
|
|
|
WINPR_ASSERT(width >= 0);
|
|
|
|
|
WINPR_ASSERT(height <= UINT16_MAX);
|
|
|
|
|
WINPR_ASSERT(height >= 0);
|
2026-02-19 12:36:06 +01:00
|
|
|
|
2026-02-19 07:18:48 +01:00
|
|
|
if (rdtk_surface_fill(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
|
|
|
|
|
0x3BB9FF) < 0)
|
|
|
|
|
goto fail;
|
2015-04-12 02:57:16 +08:00
|
|
|
|
2026-02-19 07:18:48 +01:00
|
|
|
if (rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
|
2026-02-26 14:34:11 +01:00
|
|
|
nullptr, "Welcome", 0, 0) < 0)
|
2026-02-19 07:18:48 +01:00
|
|
|
goto fail;
|
2026-02-26 14:34:11 +01:00
|
|
|
// rdtk_button_draw(surface, 16, 64, 128, 32, nullptr, "button");
|
|
|
|
|
// rdtk_text_field_draw(surface, 16, 128, 128, 32, nullptr, "text field");
|
2026-02-19 12:36:06 +01:00
|
|
|
#endif
|
2014-09-29 16:08:08 -04:00
|
|
|
|
2026-02-16 10:57:57 +01:00
|
|
|
if (!region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect))
|
|
|
|
|
goto fail;
|
2014-09-29 16:08:08 -04:00
|
|
|
|
2024-04-15 09:55:11 +02:00
|
|
|
rc = TRUE;
|
|
|
|
|
fail:
|
2026-02-19 12:36:06 +01:00
|
|
|
|
|
|
|
|
#if defined(WITH_RDTK)
|
2026-02-19 07:18:48 +01:00
|
|
|
rdtk_surface_free(surface);
|
2024-04-15 09:55:11 +02:00
|
|
|
rdtk_engine_free(engine);
|
2026-02-19 12:36:06 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
LeaveCriticalSection(&lobby->lock);
|
2024-04-15 09:55:11 +02:00
|
|
|
return rc;
|
2014-09-29 16:08:08 -04:00
|
|
|
}
|