#ifndef _X11_OUT_H
#define _X11_OUT_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <gpac/modules/video_out.h>
#include <gpac/thread.h>
#include <gpac/list.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#if !defined(GPAC_DISABLE_3D) && !defined(GPAC_USE_GLES1X) && !defined(GPAC_USE_TINYGL)
#define GPAC_HAS_OPENGL
#endif
#ifdef GPAC_HAS_OPENGL
#include <GL/glx.h>
#endif
#ifdef GPAC_HAS_X11_SHM
#include <X11/extensions/XShm.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#endif
#ifdef GPAC_HAS_X11_XV
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvlib.h>
#endif
#if defined(ENABLE_JOYSTICK) || defined(ENABLE_JOYSTICK_NO_CURSOR)
#include <linux/joystick.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#define X11VID() XWindow *xWindow = (XWindow *)vout->opaque;
#define RGB555(r,g,b) (((r&248)<<7) + ((g&248)<<2) + (b>>3))
#define RGB565(r,g,b) (((r&248)<<8) + ((g&252)<<3) + (b>>3))
typedef struct
{
Window par_wnd;
Bool setup_done, no_select_input;
Display *display;
Window wnd;
Window full_wnd;
Screen *screenptr;
int screennum;
Visual *visual;
GC the_gc;
XImage *surface;
Pixmap pixmap;
u32 pwidth, pheight;
u32 init_flags;
Atom WM_DELETE_WINDOW;
Bool use_shared_memory;
int ss_t, ss_b, ss_i, ss_e;
#ifdef GPAC_HAS_X11_SHM
XShmSegmentInfo *shmseginfo;
#endif
#ifdef GPAC_HAS_X11_XV
int xvport;
u32 xv_pf_format;
XvImage *overlay;
#endif
char *x_data;
Bool is_init, fullscreen, has_focus;
Bool ctrl_down, alt_down, meta_down;
u32 store_width, store_height;
u32 w_width, w_height;
u32 depth, bpp, pixel_format;
u32 output_3d_mode;
#ifdef GPAC_HAS_OPENGL
XVisualInfo *glx_visualinfo;
GLXContext glx_context;
Pixmap gl_pixmap;
GLXPixmap gl_offscreen;
Window gl_wnd;
u32 offscreen_type;
#endif
#if defined(ENABLE_JOYSTICK) || defined(ENABLE_JOYSTICK_NO_CURSOR)
s32 prev_x, prev_y, fd;
#endif
} XWindow;
void StretchBits (void *dst, u32 dst_bpp, u32 dst_w, u32 dst_h, u32 dst_pitch,
void *src, u32 src_bpp, u32 src_w, u32 src_h, u32 src_pitch, Bool FlipIt);
#endif