mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Cleanup
Allow window creation despite video mode setting failure. Video mode setting failure is ignored the rest of the time and the desired video mode has never been a hard constraint anyway.
This commit is contained in:
parent
f940a97500
commit
1d75b205cb
@ -287,7 +287,7 @@ void _glfwPollMonitorsNS(void)
|
|||||||
|
|
||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//
|
//
|
||||||
GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
{
|
{
|
||||||
CFArrayRef modes;
|
CFArrayRef modes;
|
||||||
CFIndex count, i;
|
CFIndex count, i;
|
||||||
@ -299,7 +299,7 @@ GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
best = _glfwChooseVideoMode(monitor, desired);
|
best = _glfwChooseVideoMode(monitor, desired);
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return GLFW_TRUE;
|
return;
|
||||||
|
|
||||||
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
||||||
|
|
||||||
@ -332,15 +332,6 @@ GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
|
|
||||||
CFRelease(modes);
|
CFRelease(modes);
|
||||||
CVDisplayLinkRelease(link);
|
CVDisplayLinkRelease(link);
|
||||||
|
|
||||||
if (!native)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Cocoa: Monitor mode list changed");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the previously saved (original) video mode
|
// Restore the previously saved (original) video mode
|
||||||
|
@ -164,6 +164,6 @@ typedef struct _GLFWtimerNS
|
|||||||
void _glfwInitTimerNS(void);
|
void _glfwInitTimerNS(void);
|
||||||
|
|
||||||
void _glfwPollMonitorsNS(void);
|
void _glfwPollMonitorsNS(void);
|
||||||
GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ static float transformY(float y)
|
|||||||
|
|
||||||
// Make the specified window and its video mode active on its monitor
|
// Make the specified window and its video mode active on its monitor
|
||||||
//
|
//
|
||||||
static GLFWbool acquireMonitor(_GLFWwindow* window)
|
static void acquireMonitor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
const GLFWbool status = _glfwSetVideoModeNS(window->monitor, &window->videoMode);
|
_glfwSetVideoModeNS(window->monitor, &window->videoMode);
|
||||||
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
||||||
const NSRect frame = NSMakeRect(bounds.origin.x,
|
const NSRect frame = NSMakeRect(bounds.origin.x,
|
||||||
transformY(bounds.origin.y + bounds.size.height),
|
transformY(bounds.origin.y + bounds.size.height),
|
||||||
@ -150,7 +150,6 @@ static GLFWbool acquireMonitor(_GLFWwindow* window)
|
|||||||
[window->ns.object setFrame:frame display:YES];
|
[window->ns.object setFrame:frame display:YES];
|
||||||
|
|
||||||
_glfwInputMonitorWindow(window->monitor, window);
|
_glfwInputMonitorWindow(window->monitor, window);
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the window and restore the original video mode
|
// Remove the window and restore the original video mode
|
||||||
@ -1178,8 +1177,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwPlatformShowWindow(window);
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfwPlatformFocusWindow(window);
|
||||||
if (!acquireMonitor(window))
|
acquireMonitor(window);
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (wndconfig->centerCursor)
|
if (wndconfig->centerCursor)
|
||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
|
@ -241,7 +241,7 @@ void _glfwPollMonitorsWin32(void)
|
|||||||
|
|
||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//
|
//
|
||||||
GLFWbool _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
{
|
{
|
||||||
GLFWvidmode current;
|
GLFWvidmode current;
|
||||||
const GLFWvidmode* best;
|
const GLFWvidmode* best;
|
||||||
@ -251,7 +251,7 @@ GLFWbool _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desire
|
|||||||
best = _glfwChooseVideoMode(monitor, desired);
|
best = _glfwChooseVideoMode(monitor, desired);
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return GLFW_TRUE;
|
return;
|
||||||
|
|
||||||
ZeroMemory(&dm, sizeof(dm));
|
ZeroMemory(&dm, sizeof(dm));
|
||||||
dm.dmSize = sizeof(dm);
|
dm.dmSize = sizeof(dm);
|
||||||
@ -270,7 +270,9 @@ GLFWbool _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desire
|
|||||||
NULL,
|
NULL,
|
||||||
CDS_FULLSCREEN,
|
CDS_FULLSCREEN,
|
||||||
NULL);
|
NULL);
|
||||||
if (result != DISP_CHANGE_SUCCESSFUL)
|
if (result == DISP_CHANGE_SUCCESSFUL)
|
||||||
|
monitor->win32.modeChanged = GLFW_TRUE;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
const char* description = "Unknown error";
|
const char* description = "Unknown error";
|
||||||
|
|
||||||
@ -292,12 +294,7 @@ GLFWbool _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desire
|
|||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Win32: Failed to set video mode: %s",
|
"Win32: Failed to set video mode: %s",
|
||||||
description);
|
description);
|
||||||
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor->win32.modeChanged = GLFW_TRUE;
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the previously saved (original) video mode
|
// Restore the previously saved (original) video mode
|
||||||
|
@ -398,7 +398,7 @@ void _glfwUpdateKeyNamesWin32(void);
|
|||||||
void _glfwInitTimerWin32(void);
|
void _glfwInitTimerWin32(void);
|
||||||
|
|
||||||
void _glfwPollMonitorsWin32(void);
|
void _glfwPollMonitorsWin32(void);
|
||||||
GLFWbool _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||||
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
||||||
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
||||||
|
|
||||||
|
@ -473,10 +473,9 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
// Make the specified window and its video mode active on its monitor
|
// Make the specified window and its video mode active on its monitor
|
||||||
//
|
//
|
||||||
static GLFWbool acquireMonitor(_GLFWwindow* window)
|
static void acquireMonitor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
GLFWvidmode mode;
|
||||||
GLFWbool status;
|
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
|
|
||||||
if (!_glfw.win32.acquiredMonitorCount)
|
if (!_glfw.win32.acquiredMonitorCount)
|
||||||
@ -484,7 +483,7 @@ static GLFWbool acquireMonitor(_GLFWwindow* window)
|
|||||||
if (!window->monitor->window)
|
if (!window->monitor->window)
|
||||||
_glfw.win32.acquiredMonitorCount++;
|
_glfw.win32.acquiredMonitorCount++;
|
||||||
|
|
||||||
status = _glfwSetVideoModeWin32(window->monitor, &window->videoMode);
|
_glfwSetVideoModeWin32(window->monitor, &window->videoMode);
|
||||||
|
|
||||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
||||||
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
|
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
|
||||||
@ -494,7 +493,6 @@ static GLFWbool acquireMonitor(_GLFWwindow* window)
|
|||||||
SWP_NOACTIVATE | SWP_NOCOPYBITS);
|
SWP_NOACTIVATE | SWP_NOCOPYBITS);
|
||||||
|
|
||||||
_glfwInputMonitorWindow(window->monitor, window);
|
_glfwInputMonitorWindow(window->monitor, window);
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the window and restore the original video mode
|
// Remove the window and restore the original video mode
|
||||||
@ -1240,8 +1238,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwPlatformShowWindow(window);
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfwPlatformFocusWindow(window);
|
||||||
if (!acquireMonitor(window))
|
acquireMonitor(window);
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (wndconfig->centerCursor)
|
if (wndconfig->centerCursor)
|
||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
|
@ -216,7 +216,7 @@ void _glfwPollMonitorsX11(void)
|
|||||||
|
|
||||||
// Set the current video mode for the specified monitor
|
// Set the current video mode for the specified monitor
|
||||||
//
|
//
|
||||||
GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
@ -231,7 +231,7 @@ GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
best = _glfwChooseVideoMode(monitor, desired);
|
best = _glfwChooseVideoMode(monitor, desired);
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return GLFW_TRUE;
|
return;
|
||||||
|
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
@ -269,16 +269,7 @@ GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
XRRFreeOutputInfo(oi);
|
XRRFreeOutputInfo(oi);
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
|
|
||||||
if (!native)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"X11: Monitor mode list changed");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the saved (original) video mode for the specified monitor
|
// Restore the saved (original) video mode for the specified monitor
|
||||||
|
@ -425,7 +425,7 @@ typedef struct _GLFWcursorX11
|
|||||||
|
|
||||||
|
|
||||||
void _glfwPollMonitorsX11(void);
|
void _glfwPollMonitorsX11(void);
|
||||||
GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||||
void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
|
Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
|
||||||
|
@ -1076,10 +1076,8 @@ static const char* getSelectionString(Atom selection)
|
|||||||
|
|
||||||
// Make the specified window and its video mode active on its monitor
|
// Make the specified window and its video mode active on its monitor
|
||||||
//
|
//
|
||||||
static GLFWbool acquireMonitor(_GLFWwindow* window)
|
static void acquireMonitor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
GLFWbool status;
|
|
||||||
|
|
||||||
if (_glfw.x11.saver.count == 0)
|
if (_glfw.x11.saver.count == 0)
|
||||||
{
|
{
|
||||||
// Remember old screen saver settings
|
// Remember old screen saver settings
|
||||||
@ -1097,7 +1095,7 @@ static GLFWbool acquireMonitor(_GLFWwindow* window)
|
|||||||
if (!window->monitor->window)
|
if (!window->monitor->window)
|
||||||
_glfw.x11.saver.count++;
|
_glfw.x11.saver.count++;
|
||||||
|
|
||||||
status = _glfwSetVideoModeX11(window->monitor, &window->videoMode);
|
_glfwSetVideoModeX11(window->monitor, &window->videoMode);
|
||||||
|
|
||||||
if (window->x11.overrideRedirect)
|
if (window->x11.overrideRedirect)
|
||||||
{
|
{
|
||||||
@ -1113,7 +1111,6 @@ static GLFWbool acquireMonitor(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputMonitorWindow(window->monitor, window);
|
_glfwInputMonitorWindow(window->monitor, window);
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the window and restore the original video mode
|
// Remove the window and restore the original video mode
|
||||||
@ -1977,8 +1974,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwPlatformShowWindow(window);
|
||||||
updateWindowMode(window);
|
updateWindowMode(window);
|
||||||
if (!acquireMonitor(window))
|
acquireMonitor(window);
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (wndconfig->centerCursor)
|
if (wndconfig->centerCursor)
|
||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
|
Loading…
Reference in New Issue
Block a user