summaryrefslogtreecommitdiff
path: root/xineramainfo
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2008-09-24 23:24:03 +0200
committerKristian Lyngstol <kristian@nihilus.(none)>2008-09-24 23:24:03 +0200
commit994cb264478c893bc175a365fd19a1cce04c1a46 (patch)
tree920c8e17a2e26c39f337b187ffa09f96eed1cff1 /xineramainfo
parentaaf83993f3cc385e7dae5620bd804332d5a8ae75 (diff)
downloadpink-elephants-repo-994cb264478c893bc175a365fd19a1cce04c1a46.tar.gz
pink-elephants-repo-994cb264478c893bc175a365fd19a1cce04c1a46.tar.bz2
Simple xinerama-gett stuff for those too lazy to find if it exist already
Diffstat (limited to 'xineramainfo')
-rwxr-xr-xxineramainfo/2dollarbuildscript4
-rw-r--r--xineramainfo/xgetxineramainfo.c67
2 files changed, 71 insertions, 0 deletions
diff --git a/xineramainfo/2dollarbuildscript b/xineramainfo/2dollarbuildscript
new file mode 100755
index 0000000..003a11e
--- /dev/null
+++ b/xineramainfo/2dollarbuildscript
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo Building it to "xgetxineramainfo"
+gcc -Wall -g -lX11 -lXinerama xgetxineramainfo.c -o xgetxineramainfo
diff --git a/xineramainfo/xgetxineramainfo.c b/xineramainfo/xgetxineramainfo.c
new file mode 100644
index 0000000..c22a2b7
--- /dev/null
+++ b/xineramainfo/xgetxineramainfo.c
@@ -0,0 +1,67 @@
+/* Copyright (C) 2008, Kristian Lyngstol <kristian@bohemians.org>
+ *
+ * GNU GPLv2 goes here.
+ *
+ * Tiny utility app to fetch xinerama info.
+ *
+ * Coding style per compiz... Please don't hurt me.
+ */
+
+#include <stdio.h>
+#include <X11/extensions/Xinerama.h>
+#include <X11/Xlib.h>
+#include <stdlib.h>
+int xineramaEvent, xineramaError;
+int majorVersion, minorVersion;
+Display *dpy;
+XineramaScreenInfo *screenInfo;
+int nScreenInfo;
+void bail(char *str)
+{
+ perror ("The flux capacitor is broken! Bailing!");
+ perror (str);
+ exit (1);
+}
+void verbose (char *str)
+{
+ printf (str);
+}
+void printVersion ()
+{
+ Status ret;
+ ret = XineramaQueryVersion (dpy, &majorVersion, &minorVersion);
+ printf ("Xinerama version: %d.%d\n", majorVersion,minorVersion);
+ if (!ret)
+ bail ("Incompatible xinerama version. XineramaQueryVersion failed!");
+
+}
+
+int main (int argc, char **argv)
+{
+ Bool ret;
+ dpy = XOpenDisplay (0);
+ if (!dpy)
+ bail ("Couldn't open display. OH WOE IS ME.");
+
+ ret = XineramaQueryExtension (dpy, &xineramaEvent, &xineramaError);
+ if (!ret)
+ bail ("No xinerama extension");
+
+ printVersion ();
+ verbose ("Attempting to get screen info.\n");
+ screenInfo = XineramaQueryScreens (dpy, &nScreenInfo);
+ int i;
+ if (nScreenInfo == 0)
+ verbose ("Only 0 heads? HELP THIS DOES NOT MAKE SENSE. I think. right.\n");
+ printf ("Screen\tx_org\ty_org\twidth\theight\n");
+ for (i = 0; i < nScreenInfo; i++)
+ printf ("%d\t%d\t%d\t%d\t%d\n",
+ screenInfo[i].screen_number,
+ screenInfo[i].x_org,
+ screenInfo[i].y_org,
+ screenInfo[i].width,
+ screenInfo[i].height);
+ verbose ("Gee, that's all. Thanks for tuning in.\n");
+ return 0;
+
+}