FreeRDP
shadow_lobby.c
1 
19 #include <freerdp/config.h>
20 
21 #include <winpr/assert.h>
22 #include <rdtk/rdtk.h>
23 
24 #include "shadow.h"
25 
26 #include "shadow_lobby.h"
27 
28 BOOL shadow_client_init_lobby(rdpShadowServer* server)
29 {
30  BOOL rc = FALSE;
31  int width = 0;
32  int height = 0;
33  rdtkSurface* surface = NULL;
34  RECTANGLE_16 invalidRect;
35  rdpShadowSurface* lobby = server->lobby;
36 
37  if (!lobby)
38  return FALSE;
39 
40  rdtkEngine* engine = rdtk_engine_new();
41  if (!engine)
42  return FALSE;
43 
44  EnterCriticalSection(&lobby->lock);
45  surface = rdtk_surface_new(engine, lobby->data, lobby->width, lobby->height, lobby->scanline);
46  if (!surface)
47  goto fail;
48 
49  invalidRect.left = 0;
50  invalidRect.top = 0;
51  WINPR_ASSERT(lobby->width <= UINT16_MAX);
52  WINPR_ASSERT(lobby->height <= UINT16_MAX);
53  invalidRect.right = (UINT16)lobby->width;
54  invalidRect.bottom = (UINT16)lobby->height;
55  if (server->shareSubRect)
56  {
57  /* If we have shared sub rect setting, only fill shared rect */
58  rectangles_intersection(&invalidRect, &(server->subRect), &invalidRect);
59  }
60 
61  width = invalidRect.right - invalidRect.left;
62  height = invalidRect.bottom - invalidRect.top;
63  WINPR_ASSERT(width <= UINT16_MAX);
64  WINPR_ASSERT(width >= 0);
65  WINPR_ASSERT(height <= UINT16_MAX);
66  WINPR_ASSERT(height >= 0);
67  rdtk_surface_fill(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
68  0x3BB9FF);
69 
70  rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height, NULL,
71  "Welcome", 0, 0);
72  // rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button");
73  // rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field");
74 
75  rdtk_surface_free(surface);
76 
77  region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect);
78 
79  rc = TRUE;
80 fail:
81  LeaveCriticalSection(&lobby->lock);
82  rdtk_engine_free(engine);
83  return rc;
84 }