GUI-FreeRDP/freerdp/client/X11/cli/rxrandr_broker.c

49 lines
1.2 KiB
C
Raw Permalink Normal View History

/*
* xrandr_broker.c
*
* Created on: 11 июл. 2022 г.
* Author: alexander
*/
#include "rxrandr.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
x_info *getXInfo()
{
x_info *monitors = (x_info *) malloc(sizeof(x_info));
monitors->count = 0;
XInfo(monitors);
for (int i = 0; i < monitors->count; ++i)
{
size_t size = strlen(monitors->monitor[i].name) + 1;
monitors->monitor[i].ptrName = (char *)malloc(sizeof(char) * size);
monitors->monitor[i].ptrIndexItem = (char *)malloc(sizeof(char) * 3);
monitors->monitor[i].ptrIndexMonitor = (char *)malloc(sizeof(char) * 3);
strncpy(monitors->monitor[i].ptrName, monitors->monitor[i].name, size);
sprintf(monitors->monitor[i].ptrIndexItem, "%d", i + 1);
sprintf(monitors->monitor[i].ptrIndexMonitor, "%d", i);
}
return monitors;
}
void freeXInfo(x_info *info)
{
for (int i = 0; i < info->count; ++i)
{
if (info->monitor[i].ptrName)
free(info->monitor[i].ptrName);
if (info->monitor[i].ptrIndexItem)
free(info->monitor[i].ptrIndexItem);
if (info->monitor[i].ptrIndexMonitor)
free(info->monitor[i].ptrIndexMonitor);
}
free(info);
}