From f8d80a936fd219ecd3dfe0e9236acd11aef7bb41 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 2 Sep 2014 19:42:43 +0200 Subject: [PATCH] Internal header cleanup. --- src/cocoa_platform.h | 45 ++++++++++++--------------------- src/egl_context.h | 19 ++++---------- src/glx_context.h | 29 +++++++++------------- src/internal.h | 4 +-- src/iokit_joystick.h | 14 +++-------- src/linux_joystick.h | 13 ++-------- src/nsgl_context.h | 21 +++++----------- src/posix_time.h | 4 +++ src/posix_tls.h | 10 ++------ src/wgl_context.h | 24 ++++++------------ src/win32_platform.h | 59 ++++++++++++-------------------------------- src/win32_tls.h | 10 ++------ src/winmm_joystick.h | 13 ++-------- src/wl_platform.h | 22 ++++++++++++++--- src/x11_init.c | 8 +++--- src/x11_platform.h | 45 +++++++++------------------------ src/xkb_unicode.h | 2 +- 17 files changed, 113 insertions(+), 229 deletions(-) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index feeeb0b2..6b768c78 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -54,14 +54,8 @@ typedef void* id; #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns -//======================================================================== -// GLFW platform specific types -//======================================================================== - - -//------------------------------------------------------------------------ -// Platform-specific window structure -//------------------------------------------------------------------------ +// Cocoa-specific per-window data +// typedef struct _GLFWwindowNS { id object; @@ -69,12 +63,12 @@ typedef struct _GLFWwindowNS id view; unsigned int modifierFlags; int cursorInside; + } _GLFWwindowNS; -//------------------------------------------------------------------------ -// Platform-specific library global data for Cocoa -//------------------------------------------------------------------------ +// Cocoa-specific global data +// typedef struct _GLFWlibraryNS { CGEventSourceRef eventSource; @@ -87,9 +81,8 @@ typedef struct _GLFWlibraryNS } _GLFWlibraryNS; -//------------------------------------------------------------------------ -// Platform-specific monitor structure -//------------------------------------------------------------------------ +// Cocoa-specific per-monitor data +// typedef struct _GLFWmonitorNS { CGDirectDisplayID displayID; @@ -99,33 +92,27 @@ typedef struct _GLFWmonitorNS } _GLFWmonitorNS; -//------------------------------------------------------------------------ -// Platform-specific cursor structure -//------------------------------------------------------------------------ +// Cocoa-specific per-cursor data +// typedef struct _GLFWcursorNS { - id object; + id object; + } _GLFWcursorNS; -//------------------------------------------------------------------------ -// Platform-specific time structure -//------------------------------------------------------------------------ +// Cocoa-specific global timer data +// typedef struct _GLFWtimeNS { - double base; - double resolution; + double base; + double resolution; + } _GLFWtimeNS; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - -// Time void _glfwInitTimer(void); -// Fullscreen GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); diff --git a/src/egl_context.h b/src/egl_context.h index 6b3779e9..21d68527 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -45,13 +45,8 @@ #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl -//======================================================================== -// GLFW platform specific types -//======================================================================== - -//------------------------------------------------------------------------ -// Platform-specific OpenGL context structure -//------------------------------------------------------------------------ +// EGL-specific per-context data +// typedef struct _GLFWcontextEGL { EGLConfig config; @@ -61,12 +56,12 @@ typedef struct _GLFWcontextEGL #if defined(_GLFW_X11) XVisualInfo* visual; #endif + } _GLFWcontextEGL; -//------------------------------------------------------------------------ -// Platform-specific library global data for EGL -//------------------------------------------------------------------------ +// EGL-specific global data +// typedef struct _GLFWlibraryEGL { EGLDisplay display; @@ -77,10 +72,6 @@ typedef struct _GLFWlibraryEGL } _GLFWlibraryEGL; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - int _glfwInitContextAPI(void); void _glfwTerminateContextAPI(void); int _glfwCreateContext(_GLFWwindow* window, diff --git a/src/glx_context.h b/src/glx_context.h index 628232ef..918ab000 100644 --- a/src/glx_context.h +++ b/src/glx_context.h @@ -66,27 +66,22 @@ typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int); #endif -//======================================================================== -// GLFW platform specific types -//======================================================================== - -//------------------------------------------------------------------------ -// Platform-specific OpenGL context structure -//------------------------------------------------------------------------ +// GLX-specific per-context data +// typedef struct _GLFWcontextGLX { - GLXContext context; // OpenGL rendering context - XVisualInfo* visual; // Visual for selected GLXFBConfig + // Rendering context + GLXContext context; + // Visual of selected GLXFBConfig + XVisualInfo* visual; } _GLFWcontextGLX; -//------------------------------------------------------------------------ -// Platform-specific library global data for GLX -//------------------------------------------------------------------------ +// GLX-specific global data +// typedef struct _GLFWlibraryGLX { - // Server-side GLX version int versionMajor, versionMinor; int eventBase; int errorBase; @@ -108,15 +103,13 @@ typedef struct _GLFWlibraryGLX GLboolean ARB_context_flush_control; #if defined(_GLFW_DLOPEN_LIBGL) - void* libGL; // dlopen handle for libGL.so + // dlopen handle for libGL.so (for glfwGetProcAddress) + void* libGL; #endif + } _GLFWlibraryGLX; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - int _glfwInitContextAPI(void); void _glfwTerminateContextAPI(void); int _glfwCreateContext(_GLFWwindow* window, diff --git a/src/internal.h b/src/internal.h index 59c03fdd..c963ada2 100644 --- a/src/internal.h +++ b/src/internal.h @@ -135,7 +135,7 @@ typedef struct _GLFWcursor _GLFWcursor; //======================================================================== -// Internal types +// Platform-independent structures //======================================================================== /*! @brief Window configuration. @@ -298,7 +298,6 @@ struct _GLFWmonitor /*! @brief Cursor structure */ - struct _GLFWcursor { _GLFWcursor* next; @@ -628,6 +627,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor); */ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor); + //======================================================================== // Event API functions //======================================================================== diff --git a/src/iokit_joystick.h b/src/iokit_joystick.h index 7bff41ee..c08809f2 100644 --- a/src/iokit_joystick.h +++ b/src/iokit_joystick.h @@ -36,13 +36,8 @@ _GLFWjoystickIOKit iokit_js[GLFW_JOYSTICK_LAST + 1] -//======================================================================== -// GLFW platform specific types -//======================================================================== - -//------------------------------------------------------------------------ -// Platform-specific joystick structure -//------------------------------------------------------------------------ +// IOKit-specific per-joystick data +// typedef struct _GLFWjoystickIOKit { int present; @@ -56,13 +51,10 @@ typedef struct _GLFWjoystickIOKit float* axes; unsigned char* buttons; + } _GLFWjoystickIOKit; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - void _glfwInitJoysticks(void); void _glfwTerminateJoysticks(void); diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 56089221..8f713d84 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -31,13 +31,8 @@ _GLFWjoystickLinux linux_js[GLFW_JOYSTICK_LAST + 1] -//======================================================================== -// GLFW platform specific types -//======================================================================== - -//------------------------------------------------------------------------ -// Platform-specific joystick structure -//------------------------------------------------------------------------ +// Linux-specific per-joystick data +// typedef struct _GLFWjoystickLinux { int present; @@ -50,10 +45,6 @@ typedef struct _GLFWjoystickLinux } _GLFWjoystickLinux; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - void _glfwInitJoysticks(void); void _glfwTerminateJoysticks(void); diff --git a/src/nsgl_context.h b/src/nsgl_context.h index 71e8edbd..fd045359 100644 --- a/src/nsgl_context.h +++ b/src/nsgl_context.h @@ -32,35 +32,26 @@ #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl -//======================================================================== -// GLFW platform specific types -//======================================================================== - -//------------------------------------------------------------------------ -// Platform-specific OpenGL context structure -//------------------------------------------------------------------------ +// NSGL-specific per-context data +// typedef struct _GLFWcontextNSGL { id pixelFormat; id context; + } _GLFWcontextNSGL; -//------------------------------------------------------------------------ -// Platform-specific library global data for NSGL -//------------------------------------------------------------------------ +// NSGL-specific global data +// typedef struct _GLFWlibraryNSGL { - // dlopen handle for dynamically loading OpenGL extension entry points + // dlopen handle for OpenGL.framework (for glfwGetProcAddress) void* framework; } _GLFWlibraryNSGL; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - int _glfwInitContextAPI(void); void _glfwTerminateContextAPI(void); int _glfwCreateContext(_GLFWwindow* window, diff --git a/src/posix_time.h b/src/posix_time.h index 1a7aab8a..3e0955a1 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -32,6 +32,9 @@ #include + +// POSIX-specific global timer data +// typedef struct _GLFWtimePOSIX { GLboolean monotonic; @@ -40,6 +43,7 @@ typedef struct _GLFWtimePOSIX } _GLFWtimePOSIX; + void _glfwInitTimer(void); #endif // _posix_time_h_ diff --git a/src/posix_tls.h b/src/posix_tls.h index e63ade78..d6fa000d 100644 --- a/src/posix_tls.h +++ b/src/posix_tls.h @@ -33,10 +33,8 @@ #define _GLFW_PLATFORM_LIBRARY_TLS_STATE _GLFWtlsPOSIX posix_tls -//======================================================================== -// GLFW platform specific types -//======================================================================== - +// POSIX-specific global TLS data +// typedef struct _GLFWtlsPOSIX { pthread_key_t context; @@ -44,10 +42,6 @@ typedef struct _GLFWtlsPOSIX } _GLFWtlsPOSIX; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - int _glfwInitTLS(void); void _glfwTerminateTLS(void); void _glfwSetCurrentContext(_GLFWwindow* context); diff --git a/src/wgl_context.h b/src/wgl_context.h index e57072c6..3fc29e72 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -38,20 +38,14 @@ #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl -//======================================================================== -// GLFW platform specific types -//======================================================================== - -//------------------------------------------------------------------------ -// Platform-specific OpenGL context structure -//------------------------------------------------------------------------ +// WGL-specific per-context data +// typedef struct _GLFWcontextWGL { - // Platform specific window resources HDC dc; // Private GDI device context HGLRC context; // Permanent rendering context - // Platform specific extensions (context specific) + // WGL extensions (context specific) PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB; PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; @@ -66,15 +60,15 @@ typedef struct _GLFWcontextWGL GLboolean EXT_create_context_es2_profile; GLboolean ARB_create_context_robustness; GLboolean ARB_context_flush_control; + } _GLFWcontextWGL; -//------------------------------------------------------------------------ -// Platform-specific library global data for WGL -//------------------------------------------------------------------------ +// WGL-specific global data +// typedef struct _GLFWlibraryWGL { - // opengl32.dll + // opengl32.dll (for glfwGetProcAddress) struct { HINSTANCE instance; } opengl32; @@ -82,10 +76,6 @@ typedef struct _GLFWlibraryWGL } _GLFWlibraryWGL; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - int _glfwInitContextAPI(void); void _glfwTerminateContextAPI(void); int _glfwCreateContext(_GLFWwindow* window, diff --git a/src/win32_platform.h b/src/win32_platform.h index 953e6970..697ade4a 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -72,9 +72,7 @@ #endif -//======================================================================== -// Hack: Define things that some windows.h variants don't -//======================================================================== +// HACK: Define macros that some older windows.h variants don't #ifndef WM_MOUSEHWHEEL #define WM_MOUSEHWHEEL 0x020E @@ -105,10 +103,6 @@ typedef struct tagCHANGEFILTERSTRUCT #endif /*Windows 7*/ -//======================================================================== -// DLLs that are loaded at glfwInit() -//======================================================================== - // winmm.dll function pointer typedefs typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT); typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO); @@ -156,32 +150,24 @@ typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*); #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32 -//======================================================================== -// GLFW platform specific types -//======================================================================== - - -//------------------------------------------------------------------------ -// Platform-specific window structure -//------------------------------------------------------------------------ +// Win32-specific per-window data +// typedef struct _GLFWwindowWin32 { - // Platform specific window resources - HWND handle; // Window handle - DWORD dwStyle; // Window styles used for window creation - DWORD dwExStyle; // --"-- + HWND handle; + DWORD dwStyle; + DWORD dwExStyle; - // Various platform specific internal variables GLboolean cursorCentered; GLboolean cursorInside; GLboolean cursorHidden; int oldCursorX, oldCursorY; + } _GLFWwindowWin32; -//------------------------------------------------------------------------ -// Platform-specific library global data for Win32 -//------------------------------------------------------------------------ +// Win32-specific global data +// typedef struct _GLFWlibraryWin32 { DWORD foregroundLockTimeout; @@ -209,13 +195,11 @@ typedef struct _GLFWlibraryWin32 DWMISCOMPOSITIONENABLED_T DwmIsCompositionEnabled; } dwmapi; - } _GLFWlibraryWin32; -//------------------------------------------------------------------------ -// Platform-specific monitor structure -//------------------------------------------------------------------------ +// Win32-specific per-monitor data +// typedef struct _GLFWmonitorWin32 { // This size matches the static size of DISPLAY_DEVICE.DeviceName @@ -225,18 +209,17 @@ typedef struct _GLFWmonitorWin32 } _GLFWmonitorWin32; -//------------------------------------------------------------------------ -// Platform-specific cursor structure -//------------------------------------------------------------------------ +// Win32-specific per-cursor data +// typedef struct _GLFWcursorWin32 { HCURSOR handle; + } _GLFWcursorWin32; -//------------------------------------------------------------------------ -// Platform-specific time structure -//------------------------------------------------------------------------ +// Win32-specific global timer data +// typedef struct _GLFWtimeWin32 { GLboolean hasPC; @@ -246,27 +229,17 @@ typedef struct _GLFWtimeWin32 } _GLFWtimeWin32; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - -// Window class GLboolean _glfwRegisterWindowClass(void); void _glfwUnregisterWindowClass(void); -// Desktop compositing BOOL _glfwIsCompositionEnabled(void); -// Wide strings WCHAR* _glfwCreateWideStringFromUTF8(const char* source); char* _glfwCreateUTF8FromWideString(const WCHAR* source); -// Time void _glfwInitTimer(void); -// Fullscreen support GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); - #endif // _win32_platform_h_ diff --git a/src/win32_tls.h b/src/win32_tls.h index 9f6fa780..3ffef725 100644 --- a/src/win32_tls.h +++ b/src/win32_tls.h @@ -31,10 +31,8 @@ #define _GLFW_PLATFORM_LIBRARY_TLS_STATE _GLFWtlsWin32 win32_tls -//======================================================================== -// GLFW platform specific types -//======================================================================== - +// Win32-specific global TLS data +// typedef struct _GLFWtlsWin32 { GLboolean allocated; @@ -43,10 +41,6 @@ typedef struct _GLFWtlsWin32 } _GLFWtlsWin32; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - int _glfwInitTLS(void); void _glfwTerminateTLS(void); void _glfwSetCurrentContext(_GLFWwindow* context); diff --git a/src/winmm_joystick.h b/src/winmm_joystick.h index 52c3558a..608f1dc5 100644 --- a/src/winmm_joystick.h +++ b/src/winmm_joystick.h @@ -31,13 +31,8 @@ _GLFWjoystickWinMM winmm_js[GLFW_JOYSTICK_LAST + 1] -//======================================================================== -// GLFW platform specific types -//======================================================================== - -//------------------------------------------------------------------------ -// Platform-specific joystick structure -//------------------------------------------------------------------------ +// WinMM-specific per-joystick data +// typedef struct _GLFWjoystickWinMM { float axes[6]; @@ -46,10 +41,6 @@ typedef struct _GLFWjoystickWinMM } _GLFWjoystickWinMM; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - void _glfwInitJoysticks(void); void _glfwTerminateJoysticks(void); diff --git a/src/wl_platform.h b/src/wl_platform.h index f2bcc2e0..8179917f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -50,8 +50,13 @@ #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl +// Wayland-specific video mode data +// typedef struct _GLFWvidmodeWayland _GLFWvidmodeWayland; + +// Wayland-specific per-window data +// typedef struct _GLFWwindowWayland { int width, height; @@ -61,8 +66,12 @@ typedef struct _GLFWwindowWayland struct wl_shell_surface* shell_surface; EGLSurface egl_surface; struct wl_callback* callback; + } _GLFWwindowWayland; + +// Wayland-specific global data +// typedef struct _GLFWlibraryWayland { struct wl_display* display; @@ -90,8 +99,12 @@ typedef struct _GLFWlibraryWayland _GLFWwindow* pointerFocus; _GLFWwindow* keyboardFocus; + } _GLFWlibraryWayland; + +// Wayland-specific per-monitor data +// typedef struct _GLFWmonitorWayland { struct wl_output* output; @@ -103,18 +116,19 @@ typedef struct _GLFWmonitorWayland int x; int y; + } _GLFWmonitorWayland; + +// Wayland-specific per-cursor data +// typedef struct _GLFWcursorWayland { int dummy; + } _GLFWcursorWayland; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - void _glfwAddOutput(uint32_t name, uint32_t version); #endif // _wayland_platform_h_ diff --git a/src/x11_init.c b/src/x11_init.c index 256e4122..3d07736c 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -618,7 +618,7 @@ static int errorHandler(Display *display, XErrorEvent* event) ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -// Install the X error handler +// Sets the X error handler callback // void _glfwGrabXErrorHandler(void) { @@ -626,7 +626,7 @@ void _glfwGrabXErrorHandler(void) XSetErrorHandler(errorHandler); } -// Remove the X error handler +// Clears the X error handler callback // void _glfwReleaseXErrorHandler(void) { @@ -635,7 +635,7 @@ void _glfwReleaseXErrorHandler(void) XSetErrorHandler(NULL); } -// Report X error +// Reports the specified error, appending information about the last X error // void _glfwInputXError(int error, const char* message) { @@ -646,7 +646,7 @@ void _glfwInputXError(int error, const char* message) _glfwInputError(error, "%s: %s", message, buffer); } -// Create a cursor object +// Creates a native cursor object from the specified image and hotspot // Cursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) { diff --git a/src/x11_platform.h b/src/x11_platform.h index 5b9ca894..1a290f04 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -72,22 +72,14 @@ #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorX11 x11 -//======================================================================== -// GLFW platform specific types -//======================================================================== - - -//------------------------------------------------------------------------ -// Platform-specific window structure -//------------------------------------------------------------------------ +// X11-specific per-window data +// typedef struct _GLFWwindowX11 { - // Platform specific window resources - Colormap colormap; // Window colormap - Window handle; // Window handle + Colormap colormap; + Window handle; - // Various platform specific internal variables - GLboolean overrideRedirect; // True if window is OverrideRedirect + GLboolean overrideRedirect; // Cached position and size used to filter out duplicate events int width, height; @@ -101,9 +93,8 @@ typedef struct _GLFWwindowX11 } _GLFWwindowX11; -//------------------------------------------------------------------------ -// Platform-specific library global data for X11 -//------------------------------------------------------------------------ +// X11-specific global data +// typedef struct _GLFWlibraryX11 { Display* display; @@ -214,9 +205,8 @@ typedef struct _GLFWlibraryX11 } _GLFWlibraryX11; -//------------------------------------------------------------------------ -// Platform-specific monitor structure -//------------------------------------------------------------------------ +// X11-specific per-monitor data +// typedef struct _GLFWmonitorX11 { RROutput output; @@ -226,41 +216,30 @@ typedef struct _GLFWmonitorX11 } _GLFWmonitorX11; -//------------------------------------------------------------------------ -// Platform-specific cursor structure -//------------------------------------------------------------------------ +// X11-specific per-cursor data +// typedef struct _GLFWcursorX11 { Cursor handle; + } _GLFWcursorX11; -//======================================================================== -// Prototypes for platform specific internal functions -//======================================================================== - -// Gamma -void _glfwInitGammaRamp(void); - -// Fullscreen support GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); -// Clipboard handling void _glfwHandleSelectionClear(XEvent* event); void _glfwHandleSelectionRequest(XEvent* event); void _glfwPushSelectionToManager(_GLFWwindow* window); Cursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot); -// Window support _GLFWwindow* _glfwFindWindowByHandle(Window handle); unsigned long _glfwGetWindowProperty(Window window, Atom property, Atom type, unsigned char** value); -// X11 error handler void _glfwGrabXErrorHandler(void); void _glfwReleaseXErrorHandler(void); void _glfwInputXError(int error, const char* message); diff --git a/src/xkb_unicode.h b/src/xkb_unicode.h index f043781b..9772901d 100644 --- a/src/xkb_unicode.h +++ b/src/xkb_unicode.h @@ -27,7 +27,7 @@ #ifndef _xkb_unicode_h_ #define _xkb_unicode_h_ -// Unicode support + long _glfwKeySym2Unicode(unsigned int keysym); #endif // _xkb_unicode_h_