From a49944377f6d1753207597834eb3ec737edc579d Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 4 Sep 2012 15:00:40 +0200 Subject: initial commit --- .gitignore | 1 + Makefile | 7 +++++++ xinerama-resolution.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 xinerama-resolution.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4089d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +xinerama-resolution diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..758c559 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +TARGETS:= xinerama-resolution +LDFLAGS:=-lX11 -lXinerama + +all: $(TARGETS) + +clean: + $(RM) $(TARGETS) diff --git a/xinerama-resolution.c b/xinerama-resolution.c new file mode 100644 index 0000000..adbd38a --- /dev/null +++ b/xinerama-resolution.c @@ -0,0 +1,46 @@ +#include +#include +#include + +#include +#include + +int main(int argc, char **argv) +{ + Display *dpy; + XineramaScreenInfo *xsi; + int i, nscreens; + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) { + fputs("ERROR: Could not open display!\n", stderr); + return EXIT_FAILURE; + } + + /* Is xinerama extension available? */ + if (!XineramaIsActive(dpy)) { + fputs("ERROR: Xinerama extension unavailable on current screen!\n", stderr); + return EXIT_FAILURE; + } + else { + xsi = XineramaQueryScreens(dpy, &nscreens); + + if (argc <= 1) { + for (i = 0; i < nscreens; i++) { + printf("screen %d: %dx%d\n", i, xsi[i].width, xsi[i].height); + } + } + else { + i = atoi(argv[1]); + if (i <= 0 || i > nscreens) { + fprintf(stderr, "ERROR: Screen %d not available!\n", i); + return EXIT_FAILURE; + } + else + printf("%dx%d\n", xsi[i-1].width, xsi[i-1].height); + } + } + + return EXIT_SUCCESS; +} + -- cgit v1.2.3