test_x11window.c 1.67 KB
Newer Older
Simon Morlat's avatar
Simon Morlat committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2010  Belledonne Communications SARL (simon.morlat@linphone.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Simon Morlat's avatar
Simon Morlat committed
18 19 20 21
*/
#ifdef HAVE_CONFIG_H
#include "mediastreamer-config.h"
#endif
22
#include <stdio.h>
Simon Morlat's avatar
Simon Morlat committed
23 24 25 26 27 28 29 30 31 32 33 34
#ifdef HAVE_X11_XLIB_H
#include <X11/Xlib.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#endif


int main(int argc, char *argv[]){
#ifdef HAVE_X11_XLIB_H
	Display *display=XOpenDisplay(getenv("DISPLAY"));
	XSetWindowAttributes wa;
35
	Window w;
Simon Morlat's avatar
Simon Morlat committed
36 37 38 39 40 41
	memset(&wa,0,sizeof(wa));
	wa.event_mask=StructureNotifyMask;
	if (display==NULL){
		printf("Could not open display.\n");
		return -1;
	}
42
	w=XCreateWindow(display,DefaultRootWindow(display),200,200,
Simon Morlat's avatar
Simon Morlat committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
	                      352, 288,0,CopyFromParent,CopyFromParent,CopyFromParent,
	                CWEventMask|CWBackPixel,&wa);
	XMapWindow(display,w);
	XSync(display,0);
	printf("Created window with id=%lu\n",w);
	while (1){
		sleep(1);
	}
	return 0;
#else
	printf("This program only works with X11.\n");
	return -1;
#endif
}