2 * freeglut_internal_x11.h
4 * The freeglut library private include file.
6 * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
7 * Written by Diederick C. Niehorster, <dcnieho@gmail.com>
8 * Creation date: Fri Jan 20, 2012
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #ifndef FREEGLUT_INTERNAL_X11_H
29 #define FREEGLUT_INTERNAL_X11_H
32 /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
33 #ifdef EGL_VERSION_1_0
34 #include "egl/fg_internal_egl.h"
37 #include "x11/fg_internal_x11_glx.h"
40 #include <X11/Xatom.h>
41 #include <X11/keysym.h>
42 #include <X11/extensions/XInput.h>
43 #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
44 # include <X11/extensions/xf86vmode.h>
46 #ifdef HAVE_X11_EXTENSIONS_XRANDR_H
47 # include <X11/extensions/Xrandr.h>
51 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
52 /* The structure used by display initialization in freeglut_init.c */
53 typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
54 struct tagSFG_PlatformDisplay
56 Display* Display; /* The display we are being run in. */
57 int Screen; /* The screen we are about to use. */
58 Window RootWindow; /* The screen's root window. */
59 int Connection; /* The display's connection number */
60 Atom DeleteWindow; /* The window deletion atom */
61 Atom State; /* The state atom */
62 Atom StateFullScreen; /* The full screen atom */
64 #ifdef HAVE_X11_EXTENSIONS_XRANDR_H
65 int prev_xsz, prev_ysz;
68 #endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
70 #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
72 * XF86VidMode may be compilable even if it fails at runtime. Therefore,
73 * the validity of the VidMode has to be tracked
75 int DisplayModeValid; /* Flag that indicates runtime status*/
76 XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
77 int DisplayModeClock; /* The display mode's refresh rate */
78 int DisplayViewPortX; /* saved X location of the viewport */
79 int DisplayViewPortY; /* saved Y location of the viewport */
80 #endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
82 #ifdef EGL_VERSION_1_0
83 struct tagSFG_PlatformDisplayEGL egl;
86 int DisplayPointerX; /* saved X location of the pointer */
87 int DisplayPointerY; /* saved Y location of the pointer */
92 * Make "freeglut" window handle and context types so that we don't need so
93 * much conditionally-compiled code later in the library.
95 #ifndef EGL_VERSION_1_0
96 typedef Window SFG_WindowHandleType ;
97 typedef GLXContext SFG_WindowContextType ;
99 typedef struct tagSFG_PlatformContext SFG_PlatformContext;
100 struct tagSFG_PlatformContext
102 #ifdef EGL_VERSION_1_0
103 struct tagSFG_PlatformContextEGL egl;
105 GLXFBConfig FBConfig; /* The window's FBConfig */
110 /* Window's state description. This structure should be kept portable. */
111 typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
112 struct tagSFG_PlatformWindowState
114 int OldWidth; /* Window width from before a resize */
115 int OldHeight; /* " height " " " " */
116 GLboolean KeyRepeating; /* Currently in repeat mode? */
120 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
122 * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
125 # ifdef HAVE_SYS_IOCTL_H
126 # include <sys/ioctl.h>
135 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
136 /* XXX The below hack is done until freeglut's autoconf is updated. */
137 # define HAVE_USB_JS 1
139 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
140 # include <sys/joystick.h>
143 * XXX NetBSD/amd64 systems may find that they have to steal the
144 * XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.
145 * XXX I cannot comment whether that works for the interface, but
146 * XXX it lets you compile...(^& I do not think that we can do away
147 * XXX with this header.
149 # include <machine/joystick.h> /* For analog joysticks */
151 # define JS_DATA_TYPE joystick
152 # define JS_RETURN (sizeof(struct JS_DATA_TYPE))
155 # if defined(__linux__)
156 # include <linux/joystick.h>
158 /* check the joystick driver version */
159 # if defined(JS_VERSION) && JS_VERSION >= 0x010000
162 # else /* Not BSD or Linux */
166 * We'll put these values in and that should
167 * allow the code to at least compile when there is
168 * no support. The JS open routine should error out
169 * and shut off all the code downstream anyway and if
170 * the application doesn't use a joystick we'll be fine.
180 # define JS_RETURN (sizeof(struct JS_DATA_TYPE))
184 /* XXX It might be better to poll the operating system for the numbers of buttons and
185 * XXX axes and then dynamically allocate the arrays.
187 # define _JS_MAX_AXES 16
188 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
189 struct tagSFG_PlatformJoystick
191 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
192 struct os_specific_s *os;
198 float tmp_axes [ _JS_MAX_AXES ];
200 struct JS_DATA_TYPE js;
208 /* Menu font and color definitions */
209 #define FREEGLUT_MENU_FONT GLUT_BITMAP_HELVETICA_18
211 #define FREEGLUT_MENU_PEN_FORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
212 #define FREEGLUT_MENU_PEN_BACK_COLORS {0.70f, 0.70f, 0.70f, 1.0f}
213 #define FREEGLUT_MENU_PEN_HFORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
214 #define FREEGLUT_MENU_PEN_HBACK_COLORS {1.0f, 1.0f, 1.0f, 1.0f}
219 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
220 /* spaceball device functions, defined in freeglut_spaceball.c */
221 int fgIsSpaceballXEvent( const XEvent *ev );
222 void fgSpaceballHandleXEvent( const XEvent *ev );
225 * Check if "hint" is present in "property" for "window". See freeglut_init.c
227 int fgHintPresent(Window window, Atom property, Atom hint);
229 /* Handler for X extension Events */
230 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
231 void fgHandleExtensionEvents( XEvent * ev );
232 void fgRegisterDevices( Display* dpy, Window* win );
236 #endif /* FREEGLUT_INTERNAL_X11_H */