[Frugalware-git] firepl: xorg: initial import to replace firepl code

James Buren ryuo at frugalware.org
Fri May 11 17:13:07 CEST 2012


Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=firepl.git;a=commitdiff;h=4a5bd93252b689b0a99748528ef6941299ae22f3

commit 4a5bd93252b689b0a99748528ef6941299ae22f3
Author: James Buren <ryuo at frugalware.org>
Date:   Fri May 11 10:12:40 2012 -0500

xorg: initial import to replace firepl code

diff --git a/firepl.c b/firepl.c
index 17eaffc..bda09b0 100644
--- a/firepl.c
+++ b/firepl.c
@@ -2,6 +2,7 @@
#include <unistd.h>
#include "utility.h"
#include "xdg.h"
+#include "xorg.h"
#include "firepl.h"

gpv *firepl;
@@ -97,5 +98,8 @@ extern int main(int argc,char **argv)
return EXIT_FAILURE;
}

+	if(!xorg_initialize())
+		return EXIT_FAILURE;
+
return EXIT_SUCCESS;
}
diff --git a/xorg.c b/xorg.c
new file mode 100644
index 0000000..45122e3
--- /dev/null
+++ b/xorg.c
@@ -0,0 +1,72 @@
+#include <stdlib.h>
+#include <X11/extensions/Xrender.h>
+#include "utility.h"
+#include "xorg.h"
+
+typedef struct
+{
+	Display *display;
+	Screen *screen;
+	Visual *visual;
+	int depth;
+	int class;
+	XRenderPictFormat *pictformat;
+} _xorg;
+
+static _xorg *xorg;
+
+extern bool xorg_initialize(void)
+{
+	int screen, ev, err;
+	XVisualInfo vinfo;
+
+	xorg = alloc0(_xorg,1);
+
+	xorg->display = XOpenDisplay(0);
+
+	if(!xorg->display)
+	{
+		eprintf("Failed to open the X11 display.\n");
+
+		return false;
+	}
+
+	screen = XDefaultScreen(xorg->display);
+
+	xorg->screen = XScreenOfDisplay(xorg->display,screen);
+
+	if(!XMatchVisualInfo(xorg->display,screen,32,TrueColor,&vinfo))
+	{
+		eprintf("This display does not have any visuals of depth 32 and type TrueColor.\n");
+
+		return false;
+	}
+
+	xorg->visual = vinfo.visual;
+
+	xorg->depth = vinfo.depth;
+
+	xorg->class = vinfo.class;
+
+	if(!XRenderQueryExtension(xorg->display,&ev,&err))
+	{
+		eprintf("This display does not support XRender.\n");
+
+		return false;
+	}
+
+	xorg->pictformat = XRenderFindVisualFormat(xorg->display,xorg->visual);
+
+	return true;
+}
+
+extern void xorg_release(void)
+{
+	if(xorg)
+	{
+		if(xorg->display)
+			XCloseDisplay(xorg->display);
+
+		free(xorg);
+	}
+}
diff --git a/xorg.h b/xorg.h
new file mode 100644
index 0000000..66e323b
--- /dev/null
+++ b/xorg.h
@@ -0,0 +1,6 @@
+#pragma once
+
+#include <stdbool.h>
+
+extern bool xorg_initialize(void);
+extern void xorg_release(void);


More information about the Frugalware-git mailing list