2022-07-11 10:12:29 +00:00
|
|
|
|
/*
|
|
|
|
|
* xrandr_broker.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 11 июл. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
2022-07-18 11:13:49 +00:00
|
|
|
|
#include "rxrandr.h"
|
2022-07-11 10:12:29 +00:00
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
x_info *getXInfo()
|
|
|
|
|
{
|
|
|
|
|
x_info *monitors = (x_info *) malloc(sizeof(x_info));
|
2022-07-18 11:13:49 +00:00
|
|
|
|
monitors->count = 0;
|
2022-07-11 10:12:29 +00:00
|
|
|
|
XInfo(monitors);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < monitors->count; ++i)
|
|
|
|
|
{
|
2022-07-19 10:13:57 +00:00
|
|
|
|
size_t size = strlen(monitors->monitor[i].name) + 1;
|
|
|
|
|
|
|
|
|
|
monitors->monitor[i].ptrName = (char *)malloc(sizeof(char) * size);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
monitors->monitor[i].ptrIndexItem = (char *)malloc(sizeof(char) * 3);
|
|
|
|
|
monitors->monitor[i].ptrIndexMonitor = (char *)malloc(sizeof(char) * 3);
|
2022-07-11 10:12:29 +00:00
|
|
|
|
|
2022-07-19 10:13:57 +00:00
|
|
|
|
strncpy(monitors->monitor[i].ptrName, monitors->monitor[i].name, size);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
sprintf(monitors->monitor[i].ptrIndexItem, "%d", i + 1);
|
|
|
|
|
sprintf(monitors->monitor[i].ptrIndexMonitor, "%d", i);
|
2022-07-11 10:12:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return monitors;
|
|
|
|
|
}
|
2022-07-11 17:06:05 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|