*
*/
-include <stdio.h>
-include <stdlib.h>
-include <string.h>
-
-include <X11/Xlib.h>
-
-include "minirgb.h"
+/* includes */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <X11/Xlib.h>
+#include "minirgb.h"
+/* variables */
Display *display;
+/* main routine */
int main(int argc,char **argv) {
- XEvent xevent;
- char *image, *device=VIDEO_DEV;
+ /* local variables */
+ int screen_id,screen_width,screen_height;
+ Window root_window,win;
+ unsigned long white_pixel,black_pixel;
- display=XOpenDisplay(NULL);
- if(!display) {
- printf("cannot open display\n");
- exit(1);
+ /* opening display */
+ display=XOpenDisplay(NULL); /* connect on local display :0 */
+ if(display==NULL) {
+ printf("cannot connect to xserver!\n");
+ exit(EXIT_FAILURE);
}
- if (minirg_init(display)) {
- printf("minirg init process failed\n");
- exit(1);
- }
+ /* getting basic xserver information */
+ // our screen id
+ screen_id=DefaultScreen(display);
+ // dimensions of screen
+ screen_width=DisplayWidth(display,screen_id);
+ screen_height=DisplayHeight(display,screen_id);
+ // how to draw white/black pixels */
+ white_pixel=WhitePixel(display,screen_id);
+ black_pixel=BlackPixel(display,screen_id);
+ // the screen's root window id
+ root_window=RootWindow(display,screen_id);
+
+ /* print basic xserver settings */
+ printf("screen ID: %d\n",screen_id);
+ printf("dimensions: %d x %d\n",screen_width,screen_height);
+ printf("white color -> %d\n",white_pixel);
+ printf("black color -> %d\n",black_pixel);
+ /* open a window */
+ win=XCreateSimpleWindow(display,
+ root_window,
+ 0,0, // coordinates
+ screen_width/3,screen_height/3,
+ 500,black_pixel,white_pixel);
+ /* map the window */
+ XMapWindow(display,win);
+
+ /* flush */
+ XFlush(display);
+
+ /* wait a bit */
+ sleep(5);
+ printf("blabla ....\n");
+
+ /* close display */
+ XCloseDisplay(display);
+
+}