Begun integrating monitor and window.

This commit is contained in:
Camilla Berglund
2012-09-27 21:37:36 +02:00
parent 7aaeb6955b
commit 1be1636326
32 changed files with 106 additions and 112 deletions

View File

@@ -674,7 +674,9 @@ static GLboolean createWindow(_GLFWwindow* window,
{
unsigned int styleMask = 0;
if (wndconfig->mode == GLFW_WINDOWED)
if (wndconfig->monitor)
styleMask = NSBorderlessWindowMask;
else
{
styleMask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask;
@@ -682,8 +684,6 @@ static GLboolean createWindow(_GLFWwindow* window,
if (wndconfig->resizable)
styleMask |= NSResizableWindowMask;
}
else
styleMask = NSBorderlessWindowMask;
window->NS.object = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0, 0, window->width, window->height)
@@ -788,7 +788,7 @@ static GLboolean createContext(_GLFWwindow* window,
ADD_ATTR(NSOpenGLPFADoubleBuffer);
if (wndconfig->mode == GLFW_FULLSCREEN)
if (wndconfig->monitor)
{
ADD_ATTR(NSOpenGLPFANoRecovery);
ADD_ATTR2(NSOpenGLPFAScreenMask,
@@ -919,7 +919,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
[window->NSGL.context setView:[window->NS.object contentView]];
if (wndconfig->mode == GLFW_FULLSCREEN)
if (wndconfig->monitor)
{
int bpp = colorBits + fbconfig->alphaBits;
@@ -952,7 +952,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
[window->NS.object orderOut:nil];
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
[[window->NS.object contentView] exitFullScreenModeWithOptions:nil];
@@ -1121,7 +1121,7 @@ void _glfwPlatformWaitEvents( void )
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
{
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
CGPoint globalPoint = CGPointMake(x, y);
CGDisplayMoveCursorToPoint(CGMainDisplayID(), globalPoint);

View File

@@ -129,6 +129,7 @@ struct _GLFWwndconfig
GLboolean glDebug;
int glProfile;
int glRobustness;
_GLFWmonitor* monitor;
_GLFWwindow* share;
};
@@ -176,6 +177,7 @@ struct _GLFWwindow
GLboolean visible; // GL_TRUE if this window is visible
int refreshRate; // monitor refresh rate
void* userPointer;
_GLFWmonitor* monitor;
// Window input state
GLboolean stickyKeys;

View File

@@ -156,12 +156,20 @@ void _glfwInputMonitorChange(void)
for (i = 0; i < _glfwLibrary.monitorCount; i++)
{
_GLFWwindow* window;
if (_glfwLibrary.monitors[i] == NULL)
continue;
// This monitor is no longer connected
_glfwLibrary.monitorCallback(_glfwLibrary.monitors[i],
GLFW_MONITOR_DISCONNECTED);
for (window = _glfwLibrary.windowListHead; window; window = window->next)
{
if (window->monitor == _glfwLibrary.monitors[i])
window->monitor = NULL;
}
}
_glfwDestroyMonitors();

View File

@@ -344,7 +344,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
showCursor(window);
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
if (!iconified)
{
@@ -367,7 +367,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
captureCursor(window);
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
if (!_glfwLibrary.Win32.monitor.modeChanged)
{
@@ -400,7 +400,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case SC_SCREENSAVE:
case SC_MONITORPOWER:
{
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
// We are running in fullscreen mode, so disallow
// screen saver and screen blanking
@@ -738,7 +738,7 @@ static int createWindow(_GLFWwindow* window,
dwExStyle = WS_EX_APPWINDOW;
// Set window style, depending on fullscreen mode
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
dwStyle |= WS_POPUP;
@@ -775,7 +775,7 @@ static int createWindow(_GLFWwindow* window,
// Adjust window position to working area (e.g. if the task bar is at
// the top of the display). Fullscreen windows are always opened in
// the upper left corner regardless of the desktop working area.
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
wa.left = wa.top = 0;
else
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0);
@@ -866,7 +866,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
return GL_FALSE;
}
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
int bpp = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits;
if (bpp < 15 || bpp >= 24)
@@ -962,7 +962,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
return GL_FALSE;
}
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
// Place the window above all topmost windows
_glfwPlatformShowWindow(window);
@@ -982,7 +982,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
destroyWindow(window);
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
if (_glfwLibrary.Win32.monitor.modeChanged)
{
@@ -1021,7 +1021,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
GLboolean sizeChanged = GL_FALSE;
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
if (width > window->width || height > window->height)
{

View File

@@ -224,7 +224,8 @@ void _glfwInputWindowCloseRequest(_GLFWwindow* window)
//========================================================================
GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
int mode, const char* title,
const char* title,
GLFWmonitor monitor,
GLFWwindow share)
{
_GLFWfbconfig fbconfig;
@@ -257,7 +258,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
fbconfig.samples = Max(_glfwLibrary.hints.samples, 0);
// Set up desired window config
wndconfig.mode = mode;
wndconfig.title = title;
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
@@ -268,6 +268,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
wndconfig.glProfile = _glfwLibrary.hints.glProfile;
wndconfig.glRobustness = _glfwLibrary.hints.glRobustness ? GL_TRUE : GL_FALSE;
wndconfig.monitor = (_GLFWmonitor*) monitor;
wndconfig.share = share;
// Reset to default values for the next call
@@ -280,13 +281,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
// Save the currently current context so it can be restored later
previous = glfwGetCurrentContext();
if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN)
{
_glfwSetError(GLFW_INVALID_ENUM,
"glfwCreateWindow: Invalid window mode");
return GL_FALSE;
}
// Check width & height
if (width > 0 && height <= 0)
{
@@ -320,10 +314,10 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
// Remember window settings
window->width = width;
window->height = height;
window->mode = mode;
window->resizable = wndconfig.resizable;
window->cursorMode = GLFW_CURSOR_NORMAL;
window->systemKeys = GL_TRUE;
window->monitor = (_GLFWmonitor*) monitor;
// Open the actual window and create its context
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig))
@@ -364,10 +358,10 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
// The GLFW specification states that fullscreen windows have the cursor
// captured by default
if (mode == GLFW_FULLSCREEN)
if (wndconfig.monitor)
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
if (mode == GLFW_WINDOWED && wndconfig.visible)
if (wndconfig.monitor == NULL && wndconfig.visible)
glfwShowWindow(window);
return window;
@@ -570,7 +564,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
_glfwPlatformSetWindowSize(window, width, height);
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
// Refresh window parameters (may have changed due to changed video
// modes)
@@ -615,7 +609,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
return;
}
if (window->mode == GLFW_FULLSCREEN || window->iconified)
if (window->monitor || window->iconified)
{
// TODO: Figure out if this is an error
return;
@@ -665,7 +659,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
_glfwPlatformRestoreWindow(window);
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
_glfwPlatformRefreshWindowParams(window);
}
@@ -684,7 +678,7 @@ GLFWAPI void glfwShowWindow(GLFWwindow handle)
return;
}
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
return;
_glfwPlatformShowWindow(window);
@@ -705,7 +699,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow handle)
return;
}
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
return;
_glfwPlatformHideWindow(window);

View File

@@ -107,7 +107,7 @@ static GLboolean createWindow(_GLFWwindow* window,
ExposureMask | FocusChangeMask | VisibilityChangeMask |
EnterWindowMask | LeaveWindowMask;
if (wndconfig->mode == GLFW_WINDOWED)
if (!wndconfig->monitor)
{
// The /only/ reason for setting the background pixel here is that
// otherwise our window won't get any decorations on systems using
@@ -138,7 +138,7 @@ static GLboolean createWindow(_GLFWwindow* window,
}
}
if (window->mode == GLFW_FULLSCREEN && !_glfwLibrary.X11.hasEWMH)
if (window->monitor && !_glfwLibrary.X11.hasEWMH)
{
// This is the butcher's way of removing window decorations
// Setting the override-redirect attribute on a window makes the window
@@ -851,7 +851,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
}
#endif /*_GLFW_HAS_XRANDR*/
if (wndconfig->mode == GLFW_FULLSCREEN)
if (wndconfig->monitor)
{
_glfwPlatformShowWindow(window);
enterFullscreenMode(window);
@@ -887,7 +887,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
leaveFullscreenMode(window);
_glfwDestroyContext(window);
@@ -959,7 +959,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
rate = window->refreshRate;
if (window->mode == GLFW_FULLSCREEN)
if (window->monitor)
{
// Get the closest matching video mode for the specified window size
mode = _glfwGetClosestVideoMode(&width, &height, &rate);
@@ -979,15 +979,17 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
XFree(hints);
}
// Change window size before changing fullscreen mode?
if (window->mode == GLFW_FULLSCREEN && (width > window->width))
if (window->monitor)
{
XResizeWindow(_glfwLibrary.X11.display, window->X11.handle, width, height);
sizeChanged = GL_TRUE;
}
// Change window size before changing fullscreen mode?
if (width > window->width)
{
XResizeWindow(_glfwLibrary.X11.display,
window->X11.handle,
width, height);
sizeChanged = GL_TRUE;
}
if (window->mode == GLFW_FULLSCREEN)
{
// Change video mode, keeping current refresh rate
_glfwSetVideoModeMODE(mode, window->refreshRate);
}