1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-10-08 15:17:25 -04:00

Comment updates and formatting.

This commit is contained in:
Camilla Berglund 2012-08-26 15:38:18 +02:00
parent 2d3f25ce99
commit bf3486f077
7 changed files with 54 additions and 66 deletions

View File

@ -40,7 +40,7 @@
//************************************************************************ //************************************************************************
//======================================================================== //========================================================================
// Save the original gamma ramp so that we can restore it later // Save the original gamma ramp so that it can be restored later
//======================================================================== //========================================================================
void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)

View File

@ -40,13 +40,14 @@
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window) void _glfwPlatformEnableSystemKeys(_GLFWwindow* window)
{ {
// This is checked in macosx_window.m; we take no action here // This is checked in cocoa_window.m; no action needed here
} }
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window) void _glfwPlatformDisableSystemKeys(_GLFWwindow* window)
{ {
// This is checked in macosx_window.m; we take no action here // This is checked in cocoa_window.m; no action needed here
// I don't think it's really possible to disable stuff like Exposé
// Note that it may not be possible to disable things like Exposé
// except in full-screen mode. // except in full-screen mode.
} }

View File

@ -46,7 +46,6 @@
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Joystick element information // Joystick element information
//------------------------------------------------------------------------ //------------------------------------------------------------------------
typedef struct typedef struct
{ {
IOHIDElementCookie cookie; IOHIDElementCookie cookie;
@ -65,7 +64,6 @@ typedef struct
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Joystick information & state // Joystick information & state
//------------------------------------------------------------------------ //------------------------------------------------------------------------
typedef struct typedef struct
{ {
int present; int present;
@ -213,7 +211,7 @@ static long getElementValue(_glfwJoystick* joystick, _glfwJoystickElement* eleme
&hidEvent); &hidEvent);
if (kIOReturnSuccess == result) if (kIOReturnSuccess == result)
{ {
/* record min and max for auto calibration */ // Record min and max for auto calibration
if (hidEvent.value < element->minReport) if (hidEvent.value < element->minReport)
element->minReport = hidEvent.value; element->minReport = hidEvent.value;
if (hidEvent.value > element->maxReport) if (hidEvent.value > element->maxReport)
@ -221,7 +219,7 @@ static long getElementValue(_glfwJoystick* joystick, _glfwJoystickElement* eleme
} }
} }
/* auto user scale */ // Auto user scale
return (long) hidEvent.value; return (long) hidEvent.value;
} }
@ -384,14 +382,14 @@ void _glfwInitJoysticks(void)
if (result != kIOReturnSuccess) if (result != kIOReturnSuccess)
continue; continue;
/* Check device type */ // Check device type
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey)); refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey));
if (refCF) if (refCF)
{ {
CFNumberGetValue(refCF, kCFNumberLongType, &usagePage); CFNumberGetValue(refCF, kCFNumberLongType, &usagePage);
if (usagePage != kHIDPage_GenericDesktop) if (usagePage != kHIDPage_GenericDesktop)
{ {
/* We are not interested in this device */ // This device is not relevant to GLFW
continue; continue;
} }
} }
@ -405,7 +403,7 @@ void _glfwInitJoysticks(void)
usage != kHIDUsage_GD_GamePad && usage != kHIDUsage_GD_GamePad &&
usage != kHIDUsage_GD_MultiAxisController)) usage != kHIDUsage_GD_MultiAxisController))
{ {
/* We are not interested in this device */ // This device is not relevant to GLFW
continue; continue;
} }
} }
@ -439,7 +437,7 @@ void _glfwInitJoysticks(void)
joystick, joystick,
joystick); joystick);
/* Get product string */ // Get product string
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
if (refCF) if (refCF)
{ {
@ -561,8 +559,6 @@ int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes)
else else
pos[i] = (2.0f * (axes->value - axes->minReport) / readScale) - 1.0f; pos[i] = (2.0f * (axes->value - axes->minReport) / readScale) - 1.0f;
//printf("%ld, %ld, %ld\n", axes->value, axes->minReport, axes->maxReport);
if (i & 1) if (i & 1)
pos[i] = -pos[i]; pos[i] = -pos[i];
} }

View File

@ -277,9 +277,6 @@ static int convertMacKeyCode(unsigned int macKeyCode)
if (macKeyCode >= 128) if (macKeyCode >= 128)
return -1; return -1;
// This treats keycodes as *positional*; that is, we'll return 'a'
// for the key left of 's', even on an AZERTY keyboard. The charInput
// function should still get 'q' though.
return table[macKeyCode]; return table[macKeyCode];
} }
@ -541,7 +538,7 @@ static NSString* findAppName(void)
} }
} }
// If we get here, we're unbundled // If we get here, the application is unbundled
ProcessSerialNumber psn = { 0, kCurrentProcess }; ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication); TransformProcessType(&psn, kProcessTransformToForegroundApplication);
@ -551,10 +548,7 @@ static NSString* findAppName(void)
char** progname = _NSGetProgname(); char** progname = _NSGetProgname();
if (progname && *progname) if (progname && *progname)
{
// TODO: UTF-8?
return [NSString stringWithUTF8String:*progname]; return [NSString stringWithUTF8String:*progname];
}
// Really shouldn't get here // Really shouldn't get here
return @"GLFW Application"; return @"GLFW Application";
@ -866,8 +860,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!initializeAppKit()) if (!initializeAppKit())
return GL_FALSE; return GL_FALSE;
// We can only have one application delegate, but we only allocate it the // There can only be one application delegate, but we allocate it the
// first time we create a window to keep all window code in this file // first time a window is created to keep all window code in this file
if (_glfwLibrary.NS.delegate == nil) if (_glfwLibrary.NS.delegate == nil)
{ {
_glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init]; _glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init];

View File

@ -87,7 +87,7 @@ void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
{ {
int delta; int delta;
// We assume that by 32 they really meant 24 // We assume that by 32 the user really meant 24
if (bpp == 32) if (bpp == 32)
bpp = 24; bpp = 24;

View File

@ -42,20 +42,21 @@
#include <GL/glx.h> #include <GL/glx.h>
// This path may need to be changed if you build GLFW using your own setup // This path may need to be changed if you build GLFW using your own setup
// We ship and use our own copy of glxext.h since GLFW uses fairly new // GLFW comes with its own copy of glxext.h since it uses some fairly new
// extensions and not all operating systems come with an up-to-date version // extensions and not all operating systems come with an up-to-date version
#include "../support/GL/glxext.h" #include "../support/GL/glxext.h"
// With XFree86, we can use the XF86VidMode extension // The XF86VidMode extension provides mode setting and gamma control
#if defined(_GLFW_HAS_XF86VIDMODE) #if defined(_GLFW_HAS_XF86VIDMODE)
#include <X11/extensions/xf86vmode.h> #include <X11/extensions/xf86vmode.h>
#endif #endif
// The XRandR extension provides mode setting and gamma control
#if defined(_GLFW_HAS_XRANDR) #if defined(_GLFW_HAS_XRANDR)
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
#endif #endif
// Do we have support for dlopen/dlsym? // dlopen is used as a fallback function retrieval mechanism
#if defined(_GLFW_HAS_DLOPEN) #if defined(_GLFW_HAS_DLOPEN)
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
@ -65,7 +66,7 @@
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
#endif #endif
// We support four different ways for getting addresses for GL/GLX // GLFW supports four different ways for getting addresses for GL/GLX
// extension functions: glXGetProcAddress, glXGetProcAddressARB, // extension functions: glXGetProcAddress, glXGetProcAddressARB,
// glXGetProcAddressEXT, and dlsym // glXGetProcAddressEXT, and dlsym
#if defined(_GLFW_HAS_GLXGETPROCADDRESSARB) #if defined(_GLFW_HAS_GLXGETPROCADDRESSARB)

View File

@ -43,22 +43,19 @@
#define Button6 6 #define Button6 6
#define Button7 7 #define Button7 7
//======================================================================== //========================================================================
// Translates an X Window key to internal coding // Translates an X Window key to internal coding
//======================================================================== //========================================================================
static int translateKey(int keycode) static int translateKey(int keycode)
{ {
// Use the pre-filled LUT (see updateKeyCodeLUT() ). // Use the pre-filled LUT (see updateKeyCodeLUT() in x11_init.c)
if ((keycode >= 0) && (keycode < 256)) if ((keycode >= 0) && (keycode < 256))
{
return _glfwLibrary.X11.keyCodeLUT[keycode]; return _glfwLibrary.X11.keyCodeLUT[keycode];
}
else else
{
return -1; return -1;
} }
}
//======================================================================== //========================================================================
@ -90,6 +87,7 @@ static GLboolean createWindow(_GLFWwindow* window,
// Every window needs a colormap // Every window needs a colormap
// Create one based on the visual used by the current context // Create one based on the visual used by the current context
// TODO: Decouple this from context creation
window->X11.colormap = XCreateColormap(_glfwLibrary.X11.display, window->X11.colormap = XCreateColormap(_glfwLibrary.X11.display,
_glfwLibrary.X11.root, _glfwLibrary.X11.root,
@ -109,30 +107,29 @@ static GLboolean createWindow(_GLFWwindow* window,
if (wndconfig->mode == GLFW_WINDOWED) if (wndconfig->mode == GLFW_WINDOWED)
{ {
// The /only/ reason we are setting the background pixel here is // The /only/ reason for setting the background pixel here is that
// that otherwise our window wont get any decorations on systems // otherwise our window won't get any decorations on systems using
// using Compiz on Intel hardware // certain versions of Compiz on Intel hardware
wa.background_pixel = BlackPixel(_glfwLibrary.X11.display, wa.background_pixel = BlackPixel(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen); _glfwLibrary.X11.screen);
wamask |= CWBackPixel; wamask |= CWBackPixel;
} }
window->X11.handle = XCreateWindow( window->X11.handle = XCreateWindow(_glfwLibrary.X11.display,
_glfwLibrary.X11.display,
_glfwLibrary.X11.root, _glfwLibrary.X11.root,
0, 0, // Upper left corner of this window on root 0, 0, // Position
window->width, window->height, window->width, window->height,
0, // Border width 0, // Border width
visual->depth, // Color depth visual->depth, // Color depth
InputOutput, InputOutput,
visual->visual, visual->visual,
wamask, wamask,
&wa &wa);
);
if (!window->X11.handle) if (!window->X11.handle)
{ {
// TODO: Handle all the various error codes here // TODO: Handle all the various error codes here and translate them
// to GLFW errors
_glfwSetError(GLFW_PLATFORM_ERROR, _glfwSetError(GLFW_PLATFORM_ERROR,
"X11/GLX: Failed to create window"); "X11/GLX: Failed to create window");
@ -147,8 +144,8 @@ static GLboolean createWindow(_GLFWwindow* window,
// manager ignore the window completely (ICCCM, section 4) // manager ignore the window completely (ICCCM, section 4)
// The good thing is that this makes undecorated fullscreen windows // The good thing is that this makes undecorated fullscreen windows
// easy to do; the bad thing is that we have to do everything manually // easy to do; the bad thing is that we have to do everything manually
// and some things (like iconify/restore) won't work at all, as they're // and some things (like iconify/restore) won't work at all, as those
// usually performed by the window manager // are tasks usually performed by the window manager
XSetWindowAttributes attributes; XSetWindowAttributes attributes;
attributes.override_redirect = True; attributes.override_redirect = True;
@ -165,7 +162,7 @@ static GLboolean createWindow(_GLFWwindow* window,
"WM_DELETE_WINDOW", "WM_DELETE_WINDOW",
False); False);
// Declare the WM protocols we support // Declare the WM protocols supported by GLFW
{ {
int count = 0; int count = 0;
Atom protocols[2]; Atom protocols[2];
@ -176,8 +173,8 @@ static GLboolean createWindow(_GLFWwindow* window,
protocols[count++] = _glfwLibrary.X11.wmDeleteWindow; protocols[count++] = _glfwLibrary.X11.wmDeleteWindow;
// The _NET_WM_PING EWMH protocol // The _NET_WM_PING EWMH protocol
// Tells the WM to ping our window and flag us as unresponsive if we // Tells the WM to ping the GLFW window and flag the application as
// don't reply within a few seconds // unresponsive if the WM doesn't get a reply within a few seconds
if (_glfwLibrary.X11.wmPing != None) if (_glfwLibrary.X11.wmPing != None)
protocols[count++] = _glfwLibrary.X11.wmPing; protocols[count++] = _glfwLibrary.X11.wmPing;
@ -283,7 +280,7 @@ static void captureCursor(_GLFWwindow* window)
static void showCursor(_GLFWwindow* window) static void showCursor(_GLFWwindow* window)
{ {
// Un-grab cursor (only in windowed mode: in fullscreen mode we still // Un-grab cursor (in windowed mode only; in fullscreen mode we still
// want the cursor grabbed in order to confine the cursor to the window // want the cursor grabbed in order to confine the cursor to the window
// area) // area)
if (window->X11.cursorGrabbed) if (window->X11.cursorGrabbed)
@ -377,7 +374,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
} }
else if (window->X11.overrideRedirect) else if (window->X11.overrideRedirect)
{ {
// In override-redirect mode, we have divorced ourselves from the // In override-redirect mode we have divorced ourselves from the
// window manager, so we need to do everything manually // window manager, so we need to do everything manually
XRaiseWindow(_glfwLibrary.X11.display, window->X11.handle); XRaiseWindow(_glfwLibrary.X11.display, window->X11.handle);
@ -405,7 +402,6 @@ static void leaveFullscreenMode(_GLFWwindow* window)
{ {
_glfwRestoreVideoMode(); _glfwRestoreVideoMode();
// Did we change the screen saver setting?
if (_glfwLibrary.X11.saver.changed) if (_glfwLibrary.X11.saver.changed)
{ {
// Restore old screen saver settings // Restore old screen saver settings
@ -648,7 +644,8 @@ static void processSingleEvent(void)
if (event.xmotion.x != window->X11.cursorPosX || if (event.xmotion.x != window->X11.cursorPosX ||
event.xmotion.y != window->X11.cursorPosY) event.xmotion.y != window->X11.cursorPosY)
{ {
// The cursor was moved and we didn't do it // The cursor was moved by something other than GLFW
int x, y; int x, y;
if (window->cursorMode == GLFW_CURSOR_CAPTURED) if (window->cursorMode == GLFW_CURSOR_CAPTURED)
@ -716,8 +713,8 @@ static void processSingleEvent(void)
else if (_glfwLibrary.X11.wmPing != None && else if (_glfwLibrary.X11.wmPing != None &&
(Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing) (Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing)
{ {
// The window manager is pinging us to make sure we are still // The window manager is pinging the application to ensure it's
// responding to events // still responding to events
event.xclient.window = _glfwLibrary.X11.root; event.xclient.window = _glfwLibrary.X11.root;
XSendEvent(_glfwLibrary.X11.display, XSendEvent(_glfwLibrary.X11.display,
@ -864,7 +861,6 @@ static void processSingleEvent(void)
{ {
case RRScreenChangeNotify: case RRScreenChangeNotify:
{ {
// Show XRandR that we really care
XRRUpdateConfiguration(&event); XRRUpdateConfiguration(&event);
break; break;
} }
@ -1071,8 +1067,8 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{ {
if (window->X11.overrideRedirect) if (window->X11.overrideRedirect)
{ {
// We can't iconify/restore override-redirect windows, as that's // Override-redirect windows cannot be iconified or restored, as those
// performed by the window manager // tasks are performed by the window manager
return; return;
} }
@ -1090,8 +1086,8 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{ {
if (window->X11.overrideRedirect) if (window->X11.overrideRedirect)
{ {
// We can't iconify/restore override-redirect windows, as that's // Override-redirect windows cannot be iconified or restored, as those
// performed by the window manager // tasks are performed by the window manager
return; return;
} }
@ -1195,7 +1191,7 @@ void _glfwPlatformWaitEvents(void)
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
{ {
// Store the new position so we can recognise it later // Store the new position so it can be recognized later
window->X11.cursorPosX = x; window->X11.cursorPosX = x;
window->X11.cursorPosY = y; window->X11.cursorPosY = y;