I found this question related, but not directly answering my question, which is:
How to get combined resolution of all connected displays to Linux machine in C++? (rectangle around all monitors, whichever placed)
I know quite little of C++, but I've written this code, unsure if it does the job correctly or not, as I do not have multiple monitors layout, I'm just coding something which will have to take into account all connected monitors.
Excerpt of my code follows:
#include <X11/Xlib.h>
#include <iostream>
Display * my_display = XOpenDisplay(NULL);
Screen * my_screen = XDefaultScreenOfDisplay(my_display);
const int screen_width = my_screen->width;
const int screen_height = my_screen->height;
if (x_coord >= screen_width)
{
std::cerr
<< "X coord bigger than the screen width\n";
return 1;
}
if (y_coord >= screen_height)
{
std::cerr
<< "Y coord bigger than the screen height\n";
return 1;
}
Thank you.