Get output size from primary output resolution 60/268660/4
authorJunkyeong, Kim <jk0430.kim@samsung.com>
Wed, 29 Dec 2021 04:54:17 +0000 (13:54 +0900)
committerJunkyeong, Kim <jk0430.kim@samsung.com>
Wed, 5 Jan 2022 01:55:35 +0000 (10:55 +0900)
Get rdp output size from primary output resolution. (half size)
If cannot find current mode, use hardcoded WIDTH and HEIGHT.

Change-Id: I3def0e3e47878367c17c5c35043c2b17b4898c67
Signed-off-by: Junkyeong, Kim <jk0430.kim@samsung.com>
src/e_mod_rdp.c

index 9c76f3c..092158c 100644 (file)
@@ -63,6 +63,8 @@ struct _E_Rdp_Output
    Ecore_Timer *frame_timer;
    pixman_image_t *pix_surface;
    tbm_surface_h tbm_surface;
+   uint32_t w;
+   uint32_t h;
 
    struct wl_list peers;
 };
@@ -814,7 +816,7 @@ _e_rdp_frame_timer(void *data)
 
    output = (E_Rdp_Output *)data;
 
-   tbm_surface = _e_rdp_tbm_image_create(output, E_RDP_WIDTH, E_RDP_HEIGHT, 0x00000000);
+   tbm_surface = _e_rdp_tbm_image_create(output, output->w, output->h, 0x00000000);
    if (tbm_surface == NULL)
      {
         ERR("create tbm surface failed");
@@ -832,8 +834,8 @@ _e_rdp_frame_timer(void *data)
    /* sends a full refresh */
    box.x1 = 0;
    box.y1 = 0;
-   box.x2 = E_RDP_WIDTH;
-   box.y2 = E_RDP_HEIGHT;
+   box.x2 = output->w;
+   box.y2 = output->h;
    pixman_region32_init_with_extents(&damage, &box);
 
    wl_list_for_each_safe(rdp_peer, tmp, &output->peers, link)
@@ -916,7 +918,7 @@ e_rdp_peer_activate(freerdp_peer *client)
         settings->CompressionEnabled = FALSE;
      }
 
-   if (E_RDP_WIDTH != (int)settings->DesktopWidth || E_RDP_HEIGHT != (int)settings->DesktopHeight)
+   if (output->w != settings->DesktopWidth || output->h != settings->DesktopHeight)
      {
         if (b->no_clients_resize)
           {
@@ -929,8 +931,8 @@ e_rdp_peer_activate(freerdp_peer *client)
                }
              else
                {
-                  settings->DesktopWidth = E_RDP_WIDTH;
-                  settings->DesktopHeight = E_RDP_HEIGHT;
+                  settings->DesktopWidth = output->w;
+                  settings->DesktopHeight = output->h;
                   client->update->DesktopResize(client->context);
                }
           }
@@ -941,8 +943,8 @@ e_rdp_peer_activate(freerdp_peer *client)
           }
      }
 
-   rfx_context_reset(peerCtx->rfx_context, E_RDP_WIDTH, E_RDP_HEIGHT);
-   nsc_context_reset(peerCtx->nsc_context, E_RDP_WIDTH, E_RDP_HEIGHT);
+   rfx_context_reset(peerCtx->rfx_context, output->w, output->h);
+   nsc_context_reset(peerCtx->nsc_context, output->w, output->h);
    if (peersItem->flags & RDP_PEER_ACTIVATED)
      return TRUE;
 
@@ -957,7 +959,7 @@ e_rdp_peer_activate(freerdp_peer *client)
    pointer_system.type = SYSPTR_NULL;
    pointer->PointerSystem(client->context, &pointer_system);
 
-   tbm_surface = _e_rdp_tbm_image_create(output, E_RDP_WIDTH, E_RDP_HEIGHT, 0xFFFFCCFF);
+   tbm_surface = _e_rdp_tbm_image_create(output, output->w, output->h, 0xFFFFCCFF);
    if (tbm_surface == NULL)
      {
         ERR("create sample tbm surface failed");
@@ -974,8 +976,8 @@ e_rdp_peer_activate(freerdp_peer *client)
    /* sends a full refresh */
    box.x1 = 0;
    box.y1 = 0;
-   box.x2 = E_RDP_WIDTH;
-   box.y2 = E_RDP_HEIGHT;
+   box.x2 = output->w;
+   box.y2 = output->h;
    pixman_region32_init_with_extents(&damage, &box);
 
    e_rdp_peer_refresh_region(&damage, client, tbm_surface, pix_surface);
@@ -1297,12 +1299,31 @@ E_Rdp_Output *
 e_rdp_output_create(void)
 {
    E_Rdp_Output *output = NULL;
+   Eina_List *l;
+   E_Output_Mode *emode = NULL;
+   Eina_Bool mode = EINA_FALSE;
 
    output = E_NEW(E_Rdp_Output, 1);
    EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
 
    output->primary_output = e_output_find_by_index(0);
 
+   EINA_LIST_FOREACH(output->primary_output->info.modes, l, emode)
+     {
+        if (emode->current)
+          {
+             output->w = emode->w / 2;
+             output->h = emode->h / 2;
+             mode = EINA_TRUE;
+             break;
+          }
+     }
+   if (mode == EINA_FALSE)
+     {
+        output->w = E_RDP_WIDTH;
+        output->h = E_RDP_HEIGHT;
+     }
+
    wl_list_init(&output->peers);
 
    return output;