breakhack/src/screenresolution.c

27 lines
511 B
C
Raw Normal View History

2017-12-19 19:42:05 +01:00
#include "defines.h"
2017-12-19 22:51:00 +01:00
#ifndef _WIN32
2017-11-30 21:00:47 +01:00
#include <X11/Xlib.h>
2017-12-20 19:17:41 +01:00
#else // _WIN32
#include <windows.h>
2017-12-19 22:51:00 +01:00
#endif // _WIN32
2017-11-30 21:00:47 +01:00
#include <stdlib.h>
#include "screenresolution.h"
Dimension getScreenDimensions(void)
2017-11-30 21:00:47 +01:00
{
2017-12-19 22:51:00 +01:00
#ifndef _WIN32
2017-11-30 21:00:47 +01:00
Display *d = XOpenDisplay(NULL);
Screen *s = DefaultScreenOfDisplay(d);
Dimension dim = (Dimension) { s->width, s->height };
free(d);
free(s);
2017-12-19 22:51:00 +01:00
#else // _WIN32
2017-12-20 19:17:41 +01:00
Dimension dim = (Dimension) { GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };
2017-12-19 22:51:00 +01:00
#endif // _WIN32
2017-11-30 21:00:47 +01:00
return dim;
}