GUI-FreeRDP/xrandr_broker.c

46 lines
1.2 KiB
C
Raw Normal View History

/*
* xrandr_broker.c
*
* Created on: 11 июл. 2022 г.
* Author: alexander
*/
#include "xrandr.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
x_info *getXInfo()
{
x_info *monitors = (x_info *) malloc(sizeof(x_info));
XInfo(monitors);
for (int i = 0; i < monitors->count; ++i)
{
monitors->monitor[i].ptrName = (char *)malloc(sizeof(char) * strlen(monitors->monitor[i].name));
monitors->monitor[i].ptrIndexItem = (char *)malloc(sizeof(char) * 3);
monitors->monitor[i].ptrIndexMonitor = (char *)malloc(sizeof(char) * 3);
strcpy(monitors->monitor[i].ptrName, monitors->monitor[i].name);
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);
}