mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
Merge branch 'master' of github.com:elmindreda/glfw
This commit is contained in:
commit
26abe0a6e3
|
@ -413,6 +413,8 @@ extern "C" {
|
|||
#define GLFW_OPENGL_ROBUSTNESS 0x00022006
|
||||
#define GLFW_RESIZABLE 0x00022007
|
||||
#define GLFW_VISIBLE 0x00022008
|
||||
#define GLFW_POSITION_X 0x00022009
|
||||
#define GLFW_POSITION_Y 0x0002200A
|
||||
|
||||
/* GLFW_CLIENT_API tokens */
|
||||
#define GLFW_OPENGL_API 0x00000001
|
||||
|
@ -432,8 +434,7 @@ extern "C" {
|
|||
#define GLFW_CURSOR_MODE 0x00030001
|
||||
#define GLFW_STICKY_KEYS 0x00030002
|
||||
#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
|
||||
#define GLFW_SYSTEM_KEYS 0x00030004
|
||||
#define GLFW_KEY_REPEAT 0x00030005
|
||||
#define GLFW_KEY_REPEAT 0x00030004
|
||||
|
||||
/* GLFW_CURSOR_MODE values */
|
||||
#define GLFW_CURSOR_NORMAL 0x00040001
|
||||
|
@ -536,8 +537,6 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow window);
|
|||
GLFWAPI void glfwSetWindowTitle(GLFWwindow window, const char* title);
|
||||
GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height);
|
||||
GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height);
|
||||
GLFWAPI void glfwGetWindowPos(GLFWwindow window, int* xpos, int* ypos);
|
||||
GLFWAPI void glfwSetWindowPos(GLFWwindow window, int xpos, int ypos);
|
||||
GLFWAPI void glfwIconifyWindow(GLFWwindow window);
|
||||
GLFWAPI void glfwRestoreWindow(GLFWwindow window);
|
||||
GLFWAPI void glfwShowWindow(GLFWwindow window);
|
||||
|
|
|
@ -13,7 +13,7 @@ set(common_SOURCES clipboard.c fullscreen.c gamma.c init.c input.c
|
|||
if (_GLFW_COCOA_NSGL)
|
||||
set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} cocoa_clipboard.m cocoa_fullscreen.m
|
||||
cocoa_gamma.c cocoa_init.m cocoa_input.m cocoa_joystick.m
|
||||
cocoa_gamma.c cocoa_init.m cocoa_joystick.m
|
||||
cocoa_opengl.m cocoa_time.c cocoa_window.m)
|
||||
|
||||
if (GLFW_NATIVE_API)
|
||||
|
@ -25,7 +25,7 @@ if (_GLFW_COCOA_NSGL)
|
|||
elseif (_GLFW_WIN32_WGL)
|
||||
set(glfw_HEADERS ${common_HEADERS} win32_platform.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} win32_clipboard.c win32_fullscreen.c
|
||||
win32_gamma.c win32_init.c win32_input.c win32_joystick.c
|
||||
win32_gamma.c win32_init.c win32_joystick.c
|
||||
win32_opengl.c win32_time.c win32_window.c)
|
||||
|
||||
if (GLFW_NATIVE_API)
|
||||
|
@ -34,7 +34,7 @@ elseif (_GLFW_WIN32_WGL)
|
|||
elseif (_GLFW_X11_GLX)
|
||||
set(glfw_HEADERS ${common_HEADERS} x11_platform.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_fullscreen.c
|
||||
x11_gamma.c x11_init.c x11_input.c x11_joystick.c
|
||||
x11_gamma.c x11_init.c x11_joystick.c
|
||||
x11_keysym2unicode.c x11_opengl.c x11_time.c x11_window.c)
|
||||
|
||||
if (GLFW_NATIVE_API)
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
//========================================================================
|
||||
// GLFW - An OpenGL library
|
||||
// Platform: Cocoa
|
||||
// API Version: 3.0
|
||||
// WWW: http://www.glfw.org/
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//========================================================================
|
||||
// Enable and disable system keys
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window)
|
||||
{
|
||||
// This is checked in cocoa_window.m; no action needed here
|
||||
}
|
||||
|
||||
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window)
|
||||
{
|
||||
// This is checked in cocoa_window.m; no action needed here
|
||||
|
||||
// Note that it may not be possible to disable things like Exposé
|
||||
// except in full-screen mode.
|
||||
}
|
||||
|
|
@ -455,8 +455,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||
|
||||
if ([event modifierFlags] & NSCommandKeyMask)
|
||||
{
|
||||
if (window->systemKeys)
|
||||
[super keyDown:event];
|
||||
[super keyDown:event];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -686,7 +685,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||
styleMask = NSBorderlessWindowMask;
|
||||
|
||||
window->NS.object = [[NSWindow alloc]
|
||||
initWithContentRect:NSMakeRect(0, 0, window->width, window->height)
|
||||
initWithContentRect:NSMakeRect(wndconfig->positionX, wndconfig->positionY, window->width, window->height)
|
||||
styleMask:styleMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
|
@ -1006,27 +1005,6 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set the window position
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
NSRect contentRect =
|
||||
[window->NS.object contentRectForFrameRect:[window->NS.object frame]];
|
||||
|
||||
// We assume here that the client code wants to position the window within the
|
||||
// screen the window currently occupies
|
||||
NSRect screenRect = [[window->NS.object screen] visibleFrame];
|
||||
contentRect.origin = NSMakePoint(screenRect.origin.x + x,
|
||||
screenRect.origin.y + screenRect.size.height -
|
||||
y - contentRect.size.height);
|
||||
|
||||
[window->NS.object setFrame:[window->NS.object frameRectForContentRect:contentRect]
|
||||
display:YES];
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Iconify the window
|
||||
//========================================================================
|
||||
|
|
23
src/input.c
23
src/input.c
|
@ -115,24 +115,6 @@ static void setStickyMouseButtons(_GLFWwindow* window, int enabled)
|
|||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set system keys for the specified window
|
||||
//========================================================================
|
||||
|
||||
static void setSystemKeys(_GLFWwindow* window, int enabled)
|
||||
{
|
||||
if (window->systemKeys == enabled)
|
||||
return;
|
||||
|
||||
if (enabled)
|
||||
_glfwPlatformEnableSystemKeys(window);
|
||||
else
|
||||
_glfwPlatformDisableSystemKeys(window);
|
||||
|
||||
window->systemKeys = enabled;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set key repeat for the specified window
|
||||
//========================================================================
|
||||
|
@ -295,8 +277,6 @@ GLFWAPI int glfwGetInputMode(GLFWwindow handle, int mode)
|
|||
return window->stickyKeys;
|
||||
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||
return window->stickyMouseButtons;
|
||||
case GLFW_SYSTEM_KEYS:
|
||||
return window->systemKeys;
|
||||
case GLFW_KEY_REPEAT:
|
||||
return window->keyRepeat;
|
||||
default:
|
||||
|
@ -331,9 +311,6 @@ GLFWAPI void glfwSetInputMode(GLFWwindow handle, int mode, int value)
|
|||
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||
setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE);
|
||||
break;
|
||||
case GLFW_SYSTEM_KEYS:
|
||||
setSystemKeys(window, value ? GL_TRUE : GL_FALSE);
|
||||
break;
|
||||
case GLFW_KEY_REPEAT:
|
||||
setKeyRepeat(window, value ? GL_TRUE : GL_FALSE);
|
||||
break;
|
||||
|
|
|
@ -107,6 +107,8 @@ struct _GLFWhints
|
|||
GLboolean glDebug;
|
||||
int glProfile;
|
||||
int glRobustness;
|
||||
int positionX;
|
||||
int positionY;
|
||||
};
|
||||
|
||||
|
||||
|
@ -123,6 +125,8 @@ struct _GLFWwndconfig
|
|||
int refreshRate;
|
||||
GLboolean resizable;
|
||||
GLboolean visible;
|
||||
int positionX;
|
||||
int positionY;
|
||||
int clientAPI;
|
||||
int glMajor;
|
||||
int glMinor;
|
||||
|
@ -182,7 +186,6 @@ struct _GLFWwindow
|
|||
GLboolean stickyKeys;
|
||||
GLboolean stickyMouseButtons;
|
||||
GLboolean keyRepeat;
|
||||
GLboolean systemKeys; // system keys enabled flag
|
||||
int cursorPosX, cursorPosY;
|
||||
int cursorMode;
|
||||
double scrollX, scrollY;
|
||||
|
@ -290,7 +293,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndcon
|
|||
void _glfwPlatformDestroyWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y);
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
//========================================================================
|
||||
// GLFW - An OpenGL library
|
||||
// Platform: Win32
|
||||
// API version: 3.0
|
||||
// WWW: http://www.glfw.org/
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Low level keyboard hook (system callback) function
|
||||
// Used to disable system keys under Windows NT
|
||||
//========================================================================
|
||||
|
||||
static LRESULT CALLBACK keyboardHook(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
BOOL syskeys = FALSE;
|
||||
PKBDLLHOOKSTRUCT p;
|
||||
|
||||
// We are only looking for keyboard events - interpret lParam as a
|
||||
// pointer to a KBDLLHOOKSTRUCT
|
||||
p = (PKBDLLHOOKSTRUCT) lParam;
|
||||
|
||||
if (nCode == HC_ACTION)
|
||||
{
|
||||
// We have a keyboard event
|
||||
|
||||
switch (wParam)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
// Detect: ALT+TAB, ALT+ESC, ALT+F4, CTRL+ESC,
|
||||
// LWIN, RWIN, APPS (mysterious menu key)
|
||||
syskeys = (p->vkCode == VK_TAB &&
|
||||
p->flags & LLKHF_ALTDOWN) ||
|
||||
(p->vkCode == VK_ESCAPE &&
|
||||
p->flags & LLKHF_ALTDOWN) ||
|
||||
(p->vkCode == VK_F4 &&
|
||||
p->flags & LLKHF_ALTDOWN) ||
|
||||
(p->vkCode == VK_ESCAPE &&
|
||||
(GetKeyState(VK_CONTROL) & 0x8000)) ||
|
||||
p->vkCode == VK_LWIN ||
|
||||
p->vkCode == VK_RWIN ||
|
||||
p->vkCode == VK_APPS;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Was it a system key combination (e.g. ALT+TAB)?
|
||||
if (syskeys)
|
||||
{
|
||||
_GLFWwindow* window = _glfwLibrary.activeWindow;
|
||||
|
||||
// Pass the key event to our window message loop
|
||||
if (window)
|
||||
PostMessage(window->Win32.handle, (UINT) wParam, p->vkCode, 0);
|
||||
|
||||
// We've taken care of it - don't let the system know about this
|
||||
// key event
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's a harmless key press, let the system deal with it
|
||||
return CallNextHookEx(_glfwLibrary.Win32.keyboardHook, nCode, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//========================================================================
|
||||
// Enable system keys
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(window);
|
||||
|
||||
if (_glfwLibrary.Win32.keyboardHook != NULL)
|
||||
{
|
||||
UnhookWindowsHookEx(_glfwLibrary.Win32.keyboardHook);
|
||||
_glfwLibrary.Win32.keyboardHook = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Disable system keys
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(window);
|
||||
|
||||
_glfwLibrary.Win32.keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL,
|
||||
keyboardHook,
|
||||
_glfwLibrary.Win32.instance,
|
||||
0);
|
||||
}
|
||||
|
|
@ -176,7 +176,6 @@ typedef struct _GLFWlibraryWin32
|
|||
{
|
||||
HINSTANCE instance; // Instance of the application
|
||||
ATOM classAtom; // Window class atom
|
||||
HHOOK keyboardHook; // Keyboard hook handle
|
||||
DWORD foregroundLockTimeout;
|
||||
char* clipboardString;
|
||||
|
||||
|
|
|
@ -772,7 +772,11 @@ static int createWindow(_GLFWwindow* window,
|
|||
if (window->mode == GLFW_FULLSCREEN)
|
||||
wa.left = wa.top = 0;
|
||||
else
|
||||
{
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0);
|
||||
wa.left += wndconfig->positionX;
|
||||
wa.top += wndconfig->positionY;
|
||||
}
|
||||
|
||||
wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
|
||||
if (!wideTitle)
|
||||
|
@ -1054,23 +1058,6 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set the window position
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
GetClientRect(window->Win32.handle, &rect);
|
||||
AdjustWindowRectEx(&rect, window->Win32.dwStyle, FALSE, window->Win32.dwExStyle);
|
||||
|
||||
SetWindowPos(window->Win32.handle, HWND_TOP,
|
||||
x + rect.left, y + rect.top, 0, 0,
|
||||
SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Window iconification
|
||||
//========================================================================
|
||||
|
|
63
src/window.c
63
src/window.c
|
@ -238,6 +238,8 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
|||
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
|
||||
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
|
||||
wndconfig.visible = _glfwLibrary.hints.visible ? GL_TRUE : GL_FALSE;
|
||||
wndconfig.positionX = _glfwLibrary.hints.positionX;
|
||||
wndconfig.positionY = _glfwLibrary.hints.positionY;
|
||||
wndconfig.clientAPI = _glfwLibrary.hints.clientAPI;
|
||||
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
|
||||
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
|
||||
|
@ -295,7 +297,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
|||
window->mode = mode;
|
||||
window->resizable = wndconfig.resizable;
|
||||
window->cursorMode = GLFW_CURSOR_NORMAL;
|
||||
window->systemKeys = GL_TRUE;
|
||||
|
||||
// Open the actual window and create its context
|
||||
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig))
|
||||
|
@ -369,6 +370,10 @@ void glfwDefaultWindowHints(void)
|
|||
_glfwLibrary.hints.resizable = GL_TRUE;
|
||||
_glfwLibrary.hints.visible = GL_TRUE;
|
||||
|
||||
// The default window position is the upper left corner of the screen
|
||||
_glfwLibrary.hints.positionX = 0;
|
||||
_glfwLibrary.hints.positionY = 0;
|
||||
|
||||
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
|
||||
_glfwLibrary.hints.redBits = 8;
|
||||
_glfwLibrary.hints.greenBits = 8;
|
||||
|
@ -437,6 +442,12 @@ GLFWAPI void glfwWindowHint(int target, int hint)
|
|||
case GLFW_VISIBLE:
|
||||
_glfwLibrary.hints.visible = hint;
|
||||
break;
|
||||
case GLFW_POSITION_X:
|
||||
_glfwLibrary.hints.positionX = hint;
|
||||
break;
|
||||
case GLFW_POSITION_Y:
|
||||
_glfwLibrary.hints.positionY = hint;
|
||||
break;
|
||||
case GLFW_FSAA_SAMPLES:
|
||||
_glfwLibrary.hints.samples = hint;
|
||||
break;
|
||||
|
@ -586,52 +597,6 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
|
|||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Get the window position
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* xpos, int* ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xpos != NULL)
|
||||
*xpos = window->positionX;
|
||||
|
||||
if (ypos != NULL)
|
||||
*ypos = window->positionY;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set the window position
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->mode == GLFW_FULLSCREEN || window->iconified)
|
||||
{
|
||||
// TODO: Figure out if this is an error
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Window iconification
|
||||
//========================================================================
|
||||
|
@ -747,6 +712,10 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
|||
return window->resizable;
|
||||
case GLFW_VISIBLE:
|
||||
return window->visible;
|
||||
case GLFW_POSITION_X:
|
||||
return window->positionX;
|
||||
case GLFW_POSITION_Y:
|
||||
return window->positionY;
|
||||
case GLFW_CLIENT_API:
|
||||
return window->clientAPI;
|
||||
case GLFW_OPENGL_VERSION_MAJOR:
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
//========================================================================
|
||||
// GLFW - An OpenGL library
|
||||
// Platform: X11
|
||||
// API version: 3.0
|
||||
// WWW: http://www.glfw.org/
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//========================================================================
|
||||
// Enable system keys
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window)
|
||||
{
|
||||
if (window->X11.keyboardGrabbed)
|
||||
{
|
||||
XUngrabKeyboard(_glfwLibrary.X11.display, CurrentTime);
|
||||
window->X11.keyboardGrabbed = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Disable system keys
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window)
|
||||
{
|
||||
if (XGrabKeyboard(_glfwLibrary.X11.display, window->X11.handle,
|
||||
True, GrabModeAsync, GrabModeAsync, CurrentTime)
|
||||
== GrabSuccess)
|
||||
{
|
||||
window->X11.keyboardGrabbed = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -135,12 +135,17 @@ typedef struct _GLFWwindowX11
|
|||
|
||||
// Various platform specific internal variables
|
||||
GLboolean overrideRedirect; // True if window is OverrideRedirect
|
||||
GLboolean keyboardGrabbed; // True if keyboard is currently grabbed
|
||||
GLboolean cursorGrabbed; // True if cursor is currently grabbed
|
||||
GLboolean cursorHidden; // True if cursor is currently hidden
|
||||
GLboolean cursorCentered; // True if cursor was moved since last poll
|
||||
int cursorPosX, cursorPosY;
|
||||
|
||||
// Window position hint (commited the first time the window is shown)
|
||||
GLboolean windowPosSet; // False until the window position has
|
||||
// been set
|
||||
int positionX; // The window position to be set the
|
||||
int positionY; // first time the window is shown
|
||||
|
||||
} _GLFWwindowX11;
|
||||
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||
|
||||
window->X11.handle = XCreateWindow(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.root,
|
||||
0, 0, // Position
|
||||
wndconfig->positionX, wndconfig->positionY,
|
||||
window->width, window->height,
|
||||
0, // Border width
|
||||
visual->depth, // Color depth
|
||||
|
@ -136,6 +136,12 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||
_glfwSetError(GLFW_PLATFORM_ERROR, "X11: Failed to create window");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Request a window position to be set once the window is shown
|
||||
// (see _glfwPlatformShowWindow)
|
||||
window->X11.windowPosSet = GL_FALSE;
|
||||
window->X11.positionX = wndconfig->positionX;
|
||||
window->X11.positionY = wndconfig->positionY;
|
||||
}
|
||||
|
||||
if (window->mode == GLFW_FULLSCREEN && !_glfwLibrary.X11.hasEWMH)
|
||||
|
@ -1006,16 +1012,6 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set the window position.
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
XMoveWindow(_glfwLibrary.X11.display, window->X11.handle, x, y);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Window iconification
|
||||
//========================================================================
|
||||
|
@ -1060,6 +1056,15 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
|
|||
{
|
||||
XMapRaised(_glfwLibrary.X11.display, window->X11.handle);
|
||||
XFlush(_glfwLibrary.X11.display);
|
||||
|
||||
// Set the window position the first time the window is shown
|
||||
// Note: XMoveWindow has no effect before the window has been mapped.
|
||||
if (!window->X11.windowPosSet)
|
||||
{
|
||||
XMoveWindow(_glfwLibrary.X11.display, window->X11.handle,
|
||||
window->X11.positionX, window->X11.positionY);
|
||||
window->X11.windowPosSet = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
|
||||
// These must match the input mode defaults
|
||||
static GLboolean keyrepeat = GL_FALSE;
|
||||
static GLboolean systemkeys = GL_TRUE;
|
||||
static GLboolean closeable = GL_TRUE;
|
||||
|
||||
// Event index
|
||||
|
@ -320,15 +319,6 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||
break;
|
||||
}
|
||||
|
||||
case GLFW_KEY_S:
|
||||
{
|
||||
systemkeys = !systemkeys;
|
||||
glfwSetInputMode(window, GLFW_SYSTEM_KEYS, systemkeys);
|
||||
|
||||
printf("(( system keys %s ))\n", systemkeys ? "enabled" : "disabled");
|
||||
break;
|
||||
}
|
||||
|
||||
case GLFW_KEY_C:
|
||||
{
|
||||
closeable = !closeable;
|
||||
|
@ -393,7 +383,6 @@ int main(void)
|
|||
printf("Window size should be %ix%i\n", width, height);
|
||||
|
||||
printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled");
|
||||
printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled");
|
||||
|
||||
printf("Main loop starting\n");
|
||||
|
||||
|
|
|
@ -51,10 +51,12 @@ static int window_close_callback(GLFWwindow window)
|
|||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static GLFWwindow open_window(const char* title, GLFWwindow share)
|
||||
static GLFWwindow open_window(const char* title, GLFWwindow share, int posX, int posY)
|
||||
{
|
||||
GLFWwindow window;
|
||||
|
||||
glfwWindowHint(GLFW_POSITION_X, posX);
|
||||
glfwWindowHint(GLFW_POSITION_Y, posY);
|
||||
window = glfwCreateWindow(WIDTH, HEIGHT, GLFW_WINDOWED, title, share);
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
@ -125,7 +127,6 @@ static void draw_quad(GLuint texture)
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
GLuint texture;
|
||||
int x, y;
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
|
@ -133,7 +134,7 @@ int main(int argc, char** argv)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
windows[0] = open_window("First", NULL);
|
||||
windows[0] = open_window("First", NULL, 0, 0);
|
||||
if (!windows[0])
|
||||
{
|
||||
fprintf(stderr, "Failed to open first GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||
|
@ -147,7 +148,8 @@ int main(int argc, char** argv)
|
|||
// It will then be shared with the second context, created below
|
||||
texture = create_texture();
|
||||
|
||||
windows[1] = open_window("Second", windows[0]);
|
||||
// Put the second window to the right of the first one
|
||||
windows[1] = open_window("Second", windows[0], WIDTH + 50, 0);
|
||||
if (!windows[1])
|
||||
{
|
||||
fprintf(stderr, "Failed to open second GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||
|
@ -161,10 +163,6 @@ int main(int argc, char** argv)
|
|||
glColor3f(0.6f, 0.f, 0.6f);
|
||||
glfwCopyContext(windows[0], windows[1], GL_CURRENT_BIT);
|
||||
|
||||
// Put the second window to the right of the first one
|
||||
glfwGetWindowPos(windows[0], &x, &y);
|
||||
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
|
||||
|
||||
while (!closed)
|
||||
{
|
||||
glfwMakeContextCurrent(windows[0]);
|
||||
|
|
|
@ -89,6 +89,8 @@ int main(void)
|
|||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
glfwWindowHint(GLFW_POSITION_X, 200 + 250 * i);
|
||||
glfwWindowHint(GLFW_POSITION_Y, 200);
|
||||
threads[i].window = glfwCreateWindow(200, 200,
|
||||
GLFW_WINDOWED,
|
||||
threads[i].title,
|
||||
|
@ -100,8 +102,6 @@ int main(void)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200);
|
||||
|
||||
if (thrd_create(&threads[i].id, thread_main, threads + i) !=
|
||||
thrd_success)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,8 @@ int main(void)
|
|||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
glfwWindowHint(GLFW_POSITION_X, 100 + (i & 1) * 300);
|
||||
glfwWindowHint(GLFW_POSITION_Y, 100 + (i >> 1) * 300);
|
||||
windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL);
|
||||
if (!windows[i])
|
||||
{
|
||||
|
@ -70,8 +72,6 @@ int main(void)
|
|||
(GLclampf) (i >> 1),
|
||||
i ? 0.f : 1.f,
|
||||
0.f);
|
||||
|
||||
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
|
||||
}
|
||||
|
||||
while (running)
|
||||
|
|
Loading…
Reference in New Issue
Block a user