Skip to content

Commit

Permalink
icon cache values, cleanup and lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ilammy committed Nov 10, 2018
1 parent 8696117 commit 9f473d8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions client/X11/xf_rail.c
Expand Up @@ -63,6 +63,9 @@ static const char* movetype_names[] =

struct xf_rail_icon
{
UINT16 width;
UINT16 height;
BYTE* pixels;
};
typedef struct xf_rail_icon xfRailIcon;

Expand Down Expand Up @@ -572,13 +575,42 @@ static xfRailIconCache* RailIconCache_New(rdpSettings* settings)

static void RailIconCache_Free(xfRailIconCache* cache)
{
size_t i;

if (cache)
{
for (i = 0; i < cache->numCaches * cache->numCacheEntries; i++)
{
free(cache->entries[i].pixels);
}
free(cache->entries);
free(cache);
}
}

static xfRailIcon* RailIconCache_Lookup(xfRailIconCache* cache,
UINT8 cacheId, UINT16 cacheEntry)
{
/*
* MS-RDPERP 2.2.1.2.3 Icon Info (TS_ICON_INFO)
*
* CacheId (1 byte):
* If the value is 0xFFFF, the icon SHOULD NOT be cached.
*
* Yes, the spec says "0xFFFF" in the 2018-03-16 revision,
* but the actual protocol field is 1-byte wide.
*/
if (cacheId == 0xFF)
return NULL;

if (cacheId >= cache->numCaches)
return NULL;
if (cacheEntry >= cache->numCacheEntries)
return NULL;

return &cache->entries[cache->numCacheEntries * cacheId + cacheEntry];
}

static BOOL xf_rail_window_icon(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* windowIcon)
{
Expand Down

0 comments on commit 9f473d8

Please sign in to comment.