moved common files back to src root
[freeglut] / src / x11 / freeglut_internal_x11.h
index 02472e7..8a8e197 100644 (file)
-/*\r
- * freeglut_internal_x11.h\r
- *\r
- * The freeglut library private include file.\r
- *\r
- * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.\r
- * Written by Diederick C. Niehorster, <dcnieho@gmail.com>\r
- * Creation date: Fri Jan 20, 2012\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
- * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-#ifndef  FREEGLUT_INTERNAL_X11_H\r
-#define  FREEGLUT_INTERNAL_X11_H\r
-\r
-\r
-/* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */\r
-#include <GL/glx.h>\r
-#include <X11/Xlib.h>\r
-#include <X11/Xatom.h>\r
-#include <X11/keysym.h>\r
-#include <X11/extensions/XInput.h>\r
-#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H\r
-#    include <X11/extensions/xf86vmode.h>\r
-#endif\r
-#ifdef HAVE_X11_EXTENSIONS_XRANDR_H\r
-#    include <X11/extensions/Xrandr.h>\r
-#endif\r
-/* If GLX is too old, we will fail during runtime when multisampling\r
-   is requested, but at least freeglut compiles. */\r
-#ifndef GLX_SAMPLE_BUFFERS\r
-#    define GLX_SAMPLE_BUFFERS 0x80A8\r
-#endif\r
-#ifndef GLX_SAMPLES\r
-#    define GLX_SAMPLES 0x80A9\r
-#endif\r
-\r
-\r
-\r
-/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */\r
-/* The structure used by display initialization in freeglut_init.c */\r
-typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;\r
-struct tagSFG_PlatformDisplay\r
-{\r
-    Display*        Display;            /* The display we are being run in.  */\r
-    int             Screen;             /* The screen we are about to use.   */\r
-    Window          RootWindow;         /* The screen's root window.         */\r
-    int             Connection;         /* The display's connection number   */\r
-    Atom            DeleteWindow;       /* The window deletion atom          */\r
-    Atom            State;              /* The state atom                    */\r
-    Atom            StateFullScreen;    /* The full screen atom              */\r
-\r
-#ifdef HAVE_X11_EXTENSIONS_XRANDR_H\r
-    int prev_xsz, prev_ysz;\r
-    int prev_refresh;\r
-    int prev_size_valid;\r
-#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */\r
-\r
-#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H\r
-    /*\r
-     * XF86VidMode may be compilable even if it fails at runtime.  Therefore,\r
-     * the validity of the VidMode has to be tracked\r
-     */\r
-    int             DisplayModeValid;   /* Flag that indicates runtime status*/\r
-    XF86VidModeModeLine DisplayMode;    /* Current screen's display settings */\r
-    int             DisplayModeClock;   /* The display mode's refresh rate   */\r
-    int             DisplayViewPortX;   /* saved X location of the viewport  */\r
-    int             DisplayViewPortY;   /* saved Y location of the viewport  */\r
-#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */\r
-\r
-    int             DisplayPointerX;    /* saved X location of the pointer   */\r
-    int             DisplayPointerY;    /* saved Y location of the pointer   */\r
-};\r
-\r
-\r
-/*\r
- * Make "freeglut" window handle and context types so that we don't need so\r
- * much conditionally-compiled code later in the library.\r
- */\r
-typedef Window     SFG_WindowHandleType ;\r
-typedef GLXContext SFG_WindowContextType ;\r
-typedef struct tagSFG_PlatformContext SFG_PlatformContext;\r
-struct tagSFG_PlatformContext\r
-{\r
-    GLXFBConfig*    FBConfig;        /* The window's FBConfig               */\r
-};\r
-\r
-\r
-/* Window's state description. This structure should be kept portable. */\r
-typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;\r
-struct tagSFG_PlatformWindowState\r
-{\r
-    int             OldWidth;           /* Window width from before a resize */\r
-    int             OldHeight;          /*   "    height  "    "    "   "    */\r
-};\r
-\r
-\r
-/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */\r
-/*\r
- * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"\r
- * interspersed\r
- */\r
-#    ifdef HAVE_SYS_IOCTL_H\r
-#        include <sys/ioctl.h>\r
-#    endif\r
-#    ifdef HAVE_FCNTL_H\r
-#        include <fcntl.h>\r
-#    endif\r
-#    ifdef HAVE_ERRNO_H\r
-#        include <errno.h>\r
-#        include <string.h>\r
-#    endif\r
-#    if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)\r
-/* XXX The below hack is done until freeglut's autoconf is updated. */\r
-#        define HAVE_USB_JS    1\r
-\r
-#        if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)\r
-#            include <sys/joystick.h>\r
-#        else\r
-/*\r
- * XXX NetBSD/amd64 systems may find that they have to steal the\r
- * XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.\r
- * XXX I cannot comment whether that works for the interface, but\r
- * XXX it lets you compile...(^&  I do not think that we can do away\r
- * XXX with this header.\r
- */\r
-#            include <machine/joystick.h>         /* For analog joysticks */\r
-#        endif\r
-#        define JS_DATA_TYPE joystick\r
-#        define JS_RETURN (sizeof(struct JS_DATA_TYPE))\r
-#    endif\r
-\r
-#    if defined(__linux__)\r
-#        include <linux/joystick.h>\r
-\r
-/* check the joystick driver version */\r
-#        if defined(JS_VERSION) && JS_VERSION >= 0x010000\r
-#            define JS_NEW\r
-#        endif\r
-#    else  /* Not BSD or Linux */\r
-#        ifndef JS_RETURN\r
-\r
-  /*\r
-   * We'll put these values in and that should\r
-   * allow the code to at least compile when there is\r
-   * no support. The JS open routine should error out\r
-   * and shut off all the code downstream anyway and if\r
-   * the application doesn't use a joystick we'll be fine.\r
-   */\r
-\r
-  struct JS_DATA_TYPE\r
-  {\r
-    int buttons;\r
-    int x;\r
-    int y;\r
-  };\r
-\r
-#            define JS_RETURN (sizeof(struct JS_DATA_TYPE))\r
-#        endif\r
-#    endif\r
-\r
-/* XXX It might be better to poll the operating system for the numbers of buttons and\r
- * XXX axes and then dynamically allocate the arrays.\r
- */\r
-#    define _JS_MAX_AXES 16\r
-typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
-struct tagSFG_PlatformJoystick\r
-{\r
-#   if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)\r
-       struct os_specific_s *os;\r
-#   endif\r
-\r
-#   ifdef JS_NEW\r
-       struct js_event     js;\r
-       int          tmp_buttons;\r
-       float        tmp_axes [ _JS_MAX_AXES ];\r
-#   else\r
-       struct JS_DATA_TYPE js;\r
-#   endif\r
-\r
-    char         fname [ 128 ];\r
-    int          fd;\r
-};\r
-\r
-\r
-/* Menu font and color definitions */\r
-#define  FREEGLUT_MENU_FONT    GLUT_BITMAP_HELVETICA_18\r
-\r
-#define  FREEGLUT_MENU_PEN_FORE_COLORS   {0.0f,  0.0f,  0.0f,  1.0f}\r
-#define  FREEGLUT_MENU_PEN_BACK_COLORS   {0.70f, 0.70f, 0.70f, 1.0f}\r
-#define  FREEGLUT_MENU_PEN_HFORE_COLORS  {0.0f,  0.0f,  0.0f,  1.0f}\r
-#define  FREEGLUT_MENU_PEN_HBACK_COLORS  {1.0f,  1.0f,  1.0f,  1.0f}\r
-\r
-\r
-\r
-\r
-/* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */\r
-/* spaceball device functions, defined in freeglut_spaceball.c */\r
-int             fgIsSpaceballXEvent( const XEvent *ev );\r
-void            fgSpaceballHandleXEvent( const XEvent *ev );\r
-\r
-/*\r
- * Check if "hint" is present in "property" for "window".  See freeglut_init.c\r
- */\r
-int             fgHintPresent(Window window, Atom property, Atom hint);\r
-\r
-/* Handler for X extension Events */\r
-#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H\r
-  void          fgHandleExtensionEvents( XEvent * ev );\r
-  void          fgRegisterDevices( Display* dpy, Window* win );\r
-#endif\r
-\r
-\r
-#endif  /* FREEGLUT_INTERNAL_X11_H */\r
+/*
+ * freeglut_internal_x11.h
+ *
+ * The freeglut library private include file.
+ *
+ * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
+ * Written by Diederick C. Niehorster, <dcnieho@gmail.com>
+ * Creation date: Fri Jan 20, 2012
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef  FREEGLUT_INTERNAL_X11_H
+#define  FREEGLUT_INTERNAL_X11_H
+
+
+/* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
+#include <GL/glx.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XInput.h>
+#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
+#    include <X11/extensions/xf86vmode.h>
+#endif
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+#    include <X11/extensions/Xrandr.h>
+#endif
+/* If GLX is too old, we will fail during runtime when multisampling
+   is requested, but at least freeglut compiles. */
+#ifndef GLX_SAMPLE_BUFFERS
+#    define GLX_SAMPLE_BUFFERS 0x80A8
+#endif
+#ifndef GLX_SAMPLES
+#    define GLX_SAMPLES 0x80A9
+#endif
+
+
+
+/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
+/* The structure used by display initialization in freeglut_init.c */
+typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
+struct tagSFG_PlatformDisplay
+{
+    Display*        Display;            /* The display we are being run in.  */
+    int             Screen;             /* The screen we are about to use.   */
+    Window          RootWindow;         /* The screen's root window.         */
+    int             Connection;         /* The display's connection number   */
+    Atom            DeleteWindow;       /* The window deletion atom          */
+    Atom            State;              /* The state atom                    */
+    Atom            StateFullScreen;    /* The full screen atom              */
+
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+    int prev_xsz, prev_ysz;
+    int prev_refresh;
+    int prev_size_valid;
+#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
+
+#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
+    /*
+     * XF86VidMode may be compilable even if it fails at runtime.  Therefore,
+     * the validity of the VidMode has to be tracked
+     */
+    int             DisplayModeValid;   /* Flag that indicates runtime status*/
+    XF86VidModeModeLine DisplayMode;    /* Current screen's display settings */
+    int             DisplayModeClock;   /* The display mode's refresh rate   */
+    int             DisplayViewPortX;   /* saved X location of the viewport  */
+    int             DisplayViewPortY;   /* saved Y location of the viewport  */
+#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
+
+    int             DisplayPointerX;    /* saved X location of the pointer   */
+    int             DisplayPointerY;    /* saved Y location of the pointer   */
+};
+
+
+/*
+ * Make "freeglut" window handle and context types so that we don't need so
+ * much conditionally-compiled code later in the library.
+ */
+typedef Window     SFG_WindowHandleType ;
+typedef GLXContext SFG_WindowContextType ;
+typedef struct tagSFG_PlatformContext SFG_PlatformContext;
+struct tagSFG_PlatformContext
+{
+    GLXFBConfig*    FBConfig;        /* The window's FBConfig               */
+};
+
+
+/* Window's state description. This structure should be kept portable. */
+typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
+struct tagSFG_PlatformWindowState
+{
+    int             OldWidth;           /* Window width from before a resize */
+    int             OldHeight;          /*   "    height  "    "    "   "    */
+};
+
+
+/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
+/*
+ * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
+ * interspersed
+ */
+#    ifdef HAVE_SYS_IOCTL_H
+#        include <sys/ioctl.h>
+#    endif
+#    ifdef HAVE_FCNTL_H
+#        include <fcntl.h>
+#    endif
+#    ifdef HAVE_ERRNO_H
+#        include <errno.h>
+#        include <string.h>
+#    endif
+#    if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
+/* XXX The below hack is done until freeglut's autoconf is updated. */
+#        define HAVE_USB_JS    1
+
+#        if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#            include <sys/joystick.h>
+#        else
+/*
+ * XXX NetBSD/amd64 systems may find that they have to steal the
+ * XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.
+ * XXX I cannot comment whether that works for the interface, but
+ * XXX it lets you compile...(^&  I do not think that we can do away
+ * XXX with this header.
+ */
+#            include <machine/joystick.h>         /* For analog joysticks */
+#        endif
+#        define JS_DATA_TYPE joystick
+#        define JS_RETURN (sizeof(struct JS_DATA_TYPE))
+#    endif
+
+#    if defined(__linux__)
+#        include <linux/joystick.h>
+
+/* check the joystick driver version */
+#        if defined(JS_VERSION) && JS_VERSION >= 0x010000
+#            define JS_NEW
+#        endif
+#    else  /* Not BSD or Linux */
+#        ifndef JS_RETURN
+
+  /*
+   * We'll put these values in and that should
+   * allow the code to at least compile when there is
+   * no support. The JS open routine should error out
+   * and shut off all the code downstream anyway and if
+   * the application doesn't use a joystick we'll be fine.
+   */
+
+  struct JS_DATA_TYPE
+  {
+    int buttons;
+    int x;
+    int y;
+  };
+
+#            define JS_RETURN (sizeof(struct JS_DATA_TYPE))
+#        endif
+#    endif
+
+/* XXX It might be better to poll the operating system for the numbers of buttons and
+ * XXX axes and then dynamically allocate the arrays.
+ */
+#    define _JS_MAX_AXES 16
+typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
+struct tagSFG_PlatformJoystick
+{
+#   if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
+       struct os_specific_s *os;
+#   endif
+
+#   ifdef JS_NEW
+       struct js_event     js;
+       int          tmp_buttons;
+       float        tmp_axes [ _JS_MAX_AXES ];
+#   else
+       struct JS_DATA_TYPE js;
+#   endif
+
+    char         fname [ 128 ];
+    int          fd;
+};
+
+
+/* Menu font and color definitions */
+#define  FREEGLUT_MENU_FONT    GLUT_BITMAP_HELVETICA_18
+
+#define  FREEGLUT_MENU_PEN_FORE_COLORS   {0.0f,  0.0f,  0.0f,  1.0f}
+#define  FREEGLUT_MENU_PEN_BACK_COLORS   {0.70f, 0.70f, 0.70f, 1.0f}
+#define  FREEGLUT_MENU_PEN_HFORE_COLORS  {0.0f,  0.0f,  0.0f,  1.0f}
+#define  FREEGLUT_MENU_PEN_HBACK_COLORS  {1.0f,  1.0f,  1.0f,  1.0f}
+
+
+
+
+/* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
+/* spaceball device functions, defined in freeglut_spaceball.c */
+int             fgIsSpaceballXEvent( const XEvent *ev );
+void            fgSpaceballHandleXEvent( const XEvent *ev );
+
+/*
+ * Check if "hint" is present in "property" for "window".  See freeglut_init.c
+ */
+int             fgHintPresent(Window window, Atom property, Atom hint);
+
+/* Handler for X extension Events */
+#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
+  void          fgHandleExtensionEvents( XEvent * ev );
+  void          fgRegisterDevices( Display* dpy, Window* win );
+#endif
+
+
+#endif  /* FREEGLUT_INTERNAL_X11_H */