Merge branch 'master' into multi-display-support

Conflicts:
	src/CMakeLists.txt
	src/input.c
This commit is contained in:
Marcel Metz
2011-11-22 16:06:24 +01:00
17 changed files with 448 additions and 334 deletions
-19
View File
@@ -3,18 +3,6 @@ if(WIN32)
add_definitions(-DWINVER=0x0501)
endif(WIN32)
if(CYGWIN)
# These lines are intended to remove the --export-all-symbols
# flag added in the Modules/Platform/CYGWIN.cmake file of the
# CMake distribution.
# This is a HACK. If you have trouble _linking_ the GLFW
# _shared_ library on Cygwin, try disabling this.
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
endif(CYGWIN)
if(UNIX)
if(_GLFW_HAS_XRANDR)
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr")
@@ -71,13 +59,6 @@ if(WIN32)
IMPORT_SUFFIX "dll.lib")
endif(WIN32)
if(CYGWIN)
# Build for the regular Win32 environment (not Cygwin)
set_target_properties(libglfwStatic libglfwShared PROPERTIES
COMPILE_FLAGS "-mwin32 -mno-cygwin"
LINK_FLAGS "-mwin32 -mno-cygwin")
endif(CYGWIN)
if(APPLE)
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
+5 -5
View File
@@ -109,7 +109,7 @@ static NSString* findAppName(void)
char** progname = _NSGetProgname();
if (progname && *progname)
{
// TODO: UTF8?
// TODO: UTF-8?
return [NSString stringWithUTF8String:*progname];
}
@@ -202,7 +202,7 @@ int _glfwPlatformInit(void)
[GLFWApplication sharedApplication];
_glfwLibrary.NS.OpenGLFramework =
CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) );
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfwLibrary.NS.OpenGLFramework == NULL)
{
_glfwSetError(GLFW_PLATFORM_ERROR,
@@ -229,7 +229,7 @@ int _glfwPlatformInit(void)
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
return GL_TRUE;
}
@@ -240,10 +240,10 @@ int _glfwPlatformInit(void)
int _glfwPlatformTerminate(void)
{
// TODO: Probably other cleanup
// Restore the original gamma ramp
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
[NSApp setDelegate:nil];
[_glfwLibrary.NS.delegate release];
_glfwLibrary.NS.delegate = nil;
+11 -30
View File
@@ -67,11 +67,8 @@
NSRect contentRect =
[window->NS.window contentRectForFrameRect:[window->NS.window frame]];
window->width = contentRect.size.width;
window->height = contentRect.size.height;
if (_glfwLibrary.windowSizeCallback)
_glfwLibrary.windowSizeCallback(window, window->width, window->height);
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
}
- (void)windowDidMove:(NSNotification *)notification
@@ -87,24 +84,17 @@
mainScreenHeight - contentRect.origin.y -
mainScreenOrigin.y - window->height);
window->positionX = flippedPos.x;
window->positionY = flippedPos.y;
_glfwInputWindowPos(window, flippedPos.x, flippedPos.y);
}
- (void)windowDidMiniaturize:(NSNotification *)notification
{
window->iconified = GL_TRUE;
if (_glfwLibrary.windowIconifyCallback)
_glfwLibrary.windowIconifyCallback(window, window->iconified);
_glfwInputWindowIconify(window, GL_TRUE);
}
- (void)windowDidDeminiaturize:(NSNotification *)notification
{
window->iconified = GL_FALSE;
if (_glfwLibrary.windowIconifyCallback)
_glfwLibrary.windowIconifyCallback(window, window->iconified);
_glfwInputWindowIconify(window, GL_FALSE);
}
- (void)windowDidBecomeKey:(NSNotification *)notification
@@ -349,24 +339,15 @@ static int convertMacKeyCode(unsigned int macKeyCode)
- (void)mouseMoved:(NSEvent *)event
{
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
window->mousePosX += [event deltaX];
window->mousePosY += [event deltaY];
}
_glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
else
{
NSPoint p = [event locationInWindow];
// Cocoa coordinate system has origin at lower left
window->mousePosX = p.x;
window->mousePosY = [[window->NS.window contentView] bounds].size.height - p.y;
}
p.y = [[window->NS.window contentView] bounds].size.height - p.y;
if (_glfwLibrary.mousePosCallback)
{
_glfwLibrary.mousePosCallback(window,
window->mousePosX,
window->mousePosY);
_glfwInputCursorMotion(window, p.x, p.y);
}
}
@@ -587,7 +568,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
styleMask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask;
if (!wndconfig->windowNoResize)
if (wndconfig->resizable)
styleMask |= NSResizableWindowMask;
}
else
@@ -707,10 +688,10 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
glfwMakeContextCurrent(window);
NSPoint point = [[NSCursor currentCursor] hotSpot];
window->mousePosX = point.x;
window->mousePosY = point.y;
window->cursorPosX = point.x;
window->cursorPosY = point.y;
window->windowNoResize = wndconfig->windowNoResize;
window->resizable = wndconfig->resizable;
return GL_TRUE;
}
+124 -24
View File
@@ -31,6 +31,119 @@
#include "internal.h"
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
//========================================================================
// Register keyboard activity
//========================================================================
void _glfwInputKey(_GLFWwindow* window, int key, int action)
{
GLboolean keyrepeat = GL_FALSE;
if (key < 0 || key > GLFW_KEY_LAST)
return;
// Are we trying to release an already released key?
if (action == GLFW_RELEASE && window->key[key] != GLFW_PRESS)
return;
// Register key action
if(action == GLFW_RELEASE && window->stickyKeys)
window->key[key] = GLFW_STICK;
else
{
keyrepeat = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS);
window->key[key] = (char) action;
}
// Call user callback function
if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat))
_glfwLibrary.keyCallback(window, key, action);
}
//========================================================================
// Register (keyboard) character activity
//========================================================================
void _glfwInputChar(_GLFWwindow* window, int character)
{
// Valid Unicode (ISO 10646) character?
if (!((character >= 32 && character <= 126) || character >= 160))
return;
if (_glfwLibrary.charCallback)
_glfwLibrary.charCallback(window, character);
}
//========================================================================
// Register scroll events
//========================================================================
void _glfwInputScroll(_GLFWwindow* window, int xoffset, int yoffset)
{
window->scrollX += xoffset;
window->scrollY += yoffset;
if (_glfwLibrary.scrollCallback)
_glfwLibrary.scrollCallback(window, xoffset, yoffset);
}
//========================================================================
// Register mouse button clicks
//========================================================================
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action)
{
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
return;
// Register mouse button action
if (action == GLFW_RELEASE && window->stickyMouseButtons)
window->mouseButton[button] = GLFW_STICK;
else
window->mouseButton[button] = (char) action;
if (_glfwLibrary.mouseButtonCallback)
_glfwLibrary.mouseButtonCallback(window, button, action);
}
//========================================================================
// Register cursor moves
//========================================================================
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
{
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (!x && !y)
return;
window->cursorPosX += x;
window->cursorPosY += y;
}
else
{
if (window->cursorPosX == x && window->cursorPosY == y)
return;
window->cursorPosX = x;
window->cursorPosY = y;
}
if (_glfwLibrary.mousePosCallback)
_glfwLibrary.mousePosCallback(window,
window->cursorPosX,
window->cursorPosY);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
@@ -118,10 +231,10 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
// Return mouse position
if (xpos != NULL)
*xpos = window->mousePosX;
*xpos = window->cursorPosX;
if (ypos != NULL)
*ypos = window->mousePosY;
*ypos = window->cursorPosY;
}
@@ -147,12 +260,12 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
}
// Don't do anything if the mouse position did not change
if (xpos == window->mousePosX && ypos == window->mousePosY)
if (xpos == window->cursorPosX && ypos == window->cursorPosY)
return;
// Set GLFW mouse position
window->mousePosX = xpos;
window->mousePosY = ypos;
window->cursorPosX = xpos;
window->cursorPosY = ypos;
// Do not move physical cursor in locked cursor mode
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
@@ -191,8 +304,7 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode)
{
int centerPosX;
int centerPosY;
int centerPosX, centerPosY;
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
@@ -216,25 +328,13 @@ GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode)
centerPosY = window->height / 2;
if (mode == GLFW_CURSOR_CAPTURED)
{
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
}
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (centerPosX != window->mousePosX || centerPosY != window->mousePosY)
{
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
window->mousePosX = centerPosX;
window->mousePosY = centerPosY;
if (_glfwLibrary.mousePosCallback)
{
_glfwLibrary.mousePosCallback(window,
window->mousePosX,
window->mousePosY);
}
}
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
_glfwInputCursorMotion(window,
centerPosX - window->cursorPosX,
centerPosY - window->cursorPosY);
}
_glfwPlatformSetCursorMode(window, mode);
@@ -313,7 +413,7 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
cbfun(window, window->mousePosX, window->mousePosY);
cbfun(window, window->cursorPosX, window->cursorPosY);
}
}
+13 -6
View File
@@ -104,7 +104,7 @@ struct _GLFWhints
int accumAlphaBits;
int auxBuffers;
GLboolean stereo;
GLboolean windowNoResize;
GLboolean resizable;
int samples;
int glMajor;
int glMinor;
@@ -126,7 +126,7 @@ struct _GLFWwndconfig
int mode;
const char* title;
int refreshRate;
GLboolean windowNoResize;
GLboolean resizable;
int glMajor;
int glMinor;
GLboolean glForward;
@@ -176,7 +176,7 @@ struct _GLFWwindow
int width, height;
int positionX, positionY;
int mode; // GLFW_WINDOW or GLFW_FULLSCREEN
GLboolean windowNoResize; // resize- and maximize gadgets disabled flag
GLboolean resizable; // GL_TRUE if user may resize this window
int refreshRate; // monitor refresh rate
void* userPointer;
@@ -185,7 +185,7 @@ struct _GLFWwindow
GLboolean stickyMouseButtons;
GLboolean keyRepeat;
GLboolean sysKeysDisabled; // system keys disabled flag
int mousePosX, mousePosY;
int cursorPosX, cursorPosY;
int cursorMode;
int scrollX, scrollY;
char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1];
@@ -365,12 +365,19 @@ void _glfwSetError(int error, const char* description);
// Window management (window.c)
void _glfwSetDefaultWindowHints(void);
// Input handling (window.c)
// WIndow event notification
void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated);
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
void _glfwInputWindowDamage(_GLFWwindow* window);
// Input event notification
void _glfwInputKey(_GLFWwindow* window, int key, int action);
void _glfwInputChar(_GLFWwindow* window, int character);
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated);
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
// OpenGL context helpers (opengl.c)
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
+17 -42
View File
@@ -851,15 +851,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
}
_glfwInputWindowFocus(window, active);
if (iconified != window->iconified)
{
window->iconified = iconified;
if (_glfwLibrary.windowIconifyCallback)
_glfwLibrary.windowIconifyCallback(window, window->iconified);
}
_glfwInputWindowIconify(window, iconified);
return 0;
}
@@ -1005,32 +997,27 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (newMouseX != window->Win32.oldMouseX ||
newMouseY != window->Win32.oldMouseY)
{
int x, y;
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (_glfwLibrary.activeWindow != window)
return 0;
window->mousePosX += newMouseX -
window->Win32.oldMouseX;
window->mousePosY += newMouseY -
window->Win32.oldMouseY;
x = newMouseX - window->Win32.oldMouseX;
y = newMouseY - window->Win32.oldMouseY;
}
else
{
window->mousePosX = newMouseX;
window->mousePosY = newMouseY;
x = newMouseX;
y = newMouseY;
}
window->Win32.oldMouseX = newMouseX;
window->Win32.oldMouseY = newMouseY;
window->Win32.cursorCentered = GL_FALSE;
if (_glfwLibrary.mousePosCallback)
{
_glfwLibrary.mousePosCallback(window,
window->mousePosX,
window->mousePosY);
}
_glfwInputCursorMotion(window, x, y);
}
return 0;
@@ -1052,9 +1039,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_SIZE:
{
window->width = LOWORD(lParam);
window->height = HIWORD(lParam);
// If window is in cursor capture mode, update clipping rect
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
@@ -1063,21 +1047,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
ClipCursor(&ClipWindowRect);
}
if (_glfwLibrary.windowSizeCallback)
{
_glfwLibrary.windowSizeCallback(window,
window->width,
window->height);
}
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
return 0;
}
case WM_MOVE:
{
window->positionX = LOWORD(lParam);
window->positionY = HIWORD(lParam);
// If window is in cursor capture mode, update clipping rect
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
@@ -1085,15 +1060,15 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
ClipCursor(&ClipWindowRect);
}
_glfwInputWindowPos(window, LOWORD(lParam), HIWORD(lParam));
return 0;
}
// Was the window contents damaged?
case WM_PAINT:
{
if (_glfwLibrary.windowRefreshCallback)
_glfwLibrary.windowRefreshCallback(window);
_glfwInputWindowDamage(window);
break;
}
@@ -1343,7 +1318,7 @@ static int createWindow(_GLFWwindow* window,
{
dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
if (!wndconfig->windowNoResize)
if (wndconfig->resizable)
{
dwStyle |= (WS_MAXIMIZEBOX | WS_SIZEBOX);
dwExStyle |= WS_EX_WINDOWEDGE;
@@ -1405,8 +1380,8 @@ static int createWindow(_GLFWwindow* window,
// Initialize mouse position data
GetCursorPos(&pos);
ScreenToClient(window->Win32.handle, &pos);
window->Win32.oldMouseX = window->mousePosX = pos.x;
window->Win32.oldMouseY = window->mousePosY = pos.y;
window->Win32.oldMouseX = window->cursorPosX = pos.x;
window->Win32.oldMouseY = window->cursorPosY = pos.y;
return GL_TRUE;
}
@@ -1820,8 +1795,8 @@ void _glfwPlatformPollEvents(void)
}
else
{
//window->Win32.oldMouseX = window->mousePosX;
//window->Win32.oldMouseY = window->mousePosY;
//window->Win32.oldMouseX = window->cursorPosX;
//window->Win32.oldMouseY = window->cursorPosY;
}
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+62 -83
View File
@@ -100,85 +100,9 @@ void _glfwSetDefaultWindowHints(void)
// The default minimum OpenGL version is 1.0
_glfwLibrary.hints.glMajor = 1;
_glfwLibrary.hints.glMinor = 0;
}
//========================================================================
// Register keyboard activity
//========================================================================
void _glfwInputKey(_GLFWwindow* window, int key, int action)
{
GLboolean keyrepeat = GL_FALSE;
if (key < 0 || key > GLFW_KEY_LAST)
return;
// Are we trying to release an already released key?
if (action == GLFW_RELEASE && window->key[key] != GLFW_PRESS)
return;
// Register key action
if(action == GLFW_RELEASE && window->stickyKeys)
window->key[key] = GLFW_STICK;
else
{
keyrepeat = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS);
window->key[key] = (char) action;
}
// Call user callback function
if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat))
_glfwLibrary.keyCallback(window, key, action);
}
//========================================================================
// Register (keyboard) character activity
//========================================================================
void _glfwInputChar(_GLFWwindow* window, int character)
{
// Valid Unicode (ISO 10646) character?
if (!((character >= 32 && character <= 126) || character >= 160))
return;
if (_glfwLibrary.charCallback)
_glfwLibrary.charCallback(window, character);
}
//========================================================================
// Register scroll events
//========================================================================
void _glfwInputScroll(_GLFWwindow* window, int xoffset, int yoffset)
{
window->scrollX += xoffset;
window->scrollY += yoffset;
if (_glfwLibrary.scrollCallback)
_glfwLibrary.scrollCallback(window, xoffset, yoffset);
}
//========================================================================
// Register mouse button clicks
//========================================================================
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action)
{
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
return;
// Register mouse button action
if (action == GLFW_RELEASE && window->stickyMouseButtons)
window->mouseButton[button] = GLFW_STICK;
else
window->mouseButton[button] = (char) action;
if (_glfwLibrary.mouseButtonCallback)
_glfwLibrary.mouseButtonCallback(window, button, action);
// The default is to allow window resizing
_glfwLibrary.hints.resizable = GL_TRUE;
}
@@ -227,6 +151,61 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated)
}
//========================================================================
// Register window position events
//========================================================================
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
{
window->positionX = x;
window->positionY = y;
}
//========================================================================
// Register window size events
//========================================================================
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
{
if (window->width == width && window->height == height)
return;
window->width = width;
window->height = height;
if (_glfwLibrary.windowSizeCallback)
_glfwLibrary.windowSizeCallback(window, width, height);
}
//========================================================================
// Register window size events
//========================================================================
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified)
{
if (window->iconified == iconified)
return;
window->iconified = iconified;
if (_glfwLibrary.windowIconifyCallback)
_glfwLibrary.windowIconifyCallback(window, iconified);
}
//========================================================================
// Register window damage events
//========================================================================
void _glfwInputWindowDamage(_GLFWwindow* window)
{
if (_glfwLibrary.windowRefreshCallback)
_glfwLibrary.windowRefreshCallback(window);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
@@ -271,7 +250,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
wndconfig.mode = mode;
wndconfig.title = title;
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
wndconfig.windowNoResize = _glfwLibrary.hints.windowNoResize ? GL_TRUE : GL_FALSE;
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
@@ -443,8 +422,8 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
case GLFW_STEREO:
_glfwLibrary.hints.stereo = hint;
break;
case GLFW_WINDOW_NO_RESIZE:
_glfwLibrary.hints.windowNoResize = hint;
case GLFW_WINDOW_RESIZABLE:
_glfwLibrary.hints.resizable = hint;
break;
case GLFW_FSAA_SAMPLES:
_glfwLibrary.hints.samples = hint;
@@ -731,8 +710,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
return window->stereo;
case GLFW_REFRESH_RATE:
return window->refreshRate;
case GLFW_WINDOW_NO_RESIZE:
return window->windowNoResize;
case GLFW_WINDOW_RESIZABLE:
return window->resizable;
case GLFW_FSAA_SAMPLES:
return window->samples;
case GLFW_OPENGL_VERSION_MAJOR:
+22 -52
View File
@@ -794,7 +794,7 @@ static GLboolean createWindow(_GLFWwindow* window,
hints->flags = 0;
if (wndconfig->windowNoResize)
if (!wndconfig->resizable)
{
hints->flags |= (PMinSize | PMaxSize);
hints->min_width = hints->max_width = window->width;
@@ -1194,33 +1194,27 @@ static void processSingleEvent(void)
event.xmotion.y != window->X11.cursorPosY)
{
// The mouse cursor was moved and we didn't do it
int x, y;
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (_glfwLibrary.activeWindow != window)
break;
window->mousePosX += event.xmotion.x -
window->X11.cursorPosX;
window->mousePosY += event.xmotion.y -
window->X11.cursorPosY;
x = event.xmotion.x - window->X11.cursorPosX;
y = event.xmotion.y - window->X11.cursorPosY;
}
else
{
window->mousePosX = event.xmotion.x;
window->mousePosY = event.xmotion.y;
x = event.xmotion.x;
y = event.xmotion.y;
}
window->X11.cursorPosX = event.xmotion.x;
window->X11.cursorPosY = event.xmotion.y;
window->X11.cursorCentered = GL_FALSE;
if (_glfwLibrary.mousePosCallback)
{
_glfwLibrary.mousePosCallback(window,
window->mousePosX,
window->mousePosY);
}
_glfwInputCursorMotion(window, x, y);
}
break;
@@ -1236,27 +1230,13 @@ static void processSingleEvent(void)
return;
}
if (event.xconfigure.width != window->width ||
event.xconfigure.height != window->height)
{
// The window was resized
_glfwInputWindowSize(window,
event.xconfigure.width,
event.xconfigure.height);
window->width = event.xconfigure.width;
window->height = event.xconfigure.height;
if (_glfwLibrary.windowSizeCallback)
{
_glfwLibrary.windowSizeCallback(window,
window->width,
window->height);
}
}
if (event.xconfigure.x != window->positionX ||
event.xconfigure.y != window->positionY)
{
window->positionX = event.xconfigure.x;
window->positionY = event.xconfigure.y;
}
_glfwInputWindowPos(window,
event.xconfigure.x,
event.xconfigure.y);
break;
}
@@ -1305,11 +1285,7 @@ static void processSingleEvent(void)
return;
}
window->iconified = GL_FALSE;
if (_glfwLibrary.windowIconifyCallback)
_glfwLibrary.windowIconifyCallback(window, window->iconified);
_glfwInputWindowIconify(window, GL_FALSE);
break;
}
@@ -1323,11 +1299,7 @@ static void processSingleEvent(void)
return;
}
window->iconified = GL_TRUE;
if (_glfwLibrary.windowIconifyCallback)
_glfwLibrary.windowIconifyCallback(window, window->iconified);
_glfwInputWindowIconify(window, GL_TRUE);
break;
}
@@ -1377,9 +1349,7 @@ static void processSingleEvent(void)
return;
}
if (_glfwLibrary.windowRefreshCallback)
_glfwLibrary.windowRefreshCallback(window);
_glfwInputWindowDamage(window);
break;
}
@@ -1421,8 +1391,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
{
_GLFWfbconfig closest;
window->refreshRate = wndconfig->refreshRate;
window->windowNoResize = wndconfig->windowNoResize;
window->refreshRate = wndconfig->refreshRate;
window->resizable = wndconfig->resizable;
initGLXExtensions(window);
@@ -1487,8 +1457,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
// TODO: Probably check for some corner cases here.
window->mousePosX = windowX;
window->mousePosY = windowY;
window->cursorPosX = windowX;
window->cursorPosY = windowY;
}
return GL_TRUE;
@@ -1563,7 +1533,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
&width, &height, &rate);
}
if (window->windowNoResize)
if (!window->resizable)
{
// Update window size restrictions to match new window size
@@ -1730,7 +1700,7 @@ void _glfwPlatformRefreshWindowParams(void)
&dotclock, &modeline);
pixels_per_second = 1000.0f * (float) dotclock;
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
window->refreshRate = (int)(pixels_per_second/pixels_per_frame+0.5);
window->refreshRate = (int) (pixels_per_second / pixels_per_frame + 0.5);
#endif /*_GLFW_HAS_XF86VIDMODE*/
}
else