mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 02:02:14 +02:00
Propagate failures to get video mode
This commit is contained in:
@@ -618,9 +618,13 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
bool _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||||
{
|
{
|
||||||
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
||||||
|
if (!native) {
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to query display mode");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
|
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
|
||||||
CGDisplayModeRelease(native);
|
CGDisplayModeRelease(native);
|
||||||
}
|
}
|
||||||
|
|||||||
2
glfw/internal.h
vendored
2
glfw/internal.h
vendored
@@ -686,7 +686,7 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
|||||||
float* xscale, float* yscale);
|
float* xscale, float* yscale);
|
||||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height);
|
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height);
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
|
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
bool _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||||
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
|
|||||||
2
glfw/monitor.c
vendored
2
glfw/monitor.c
vendored
@@ -445,7 +445,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
_glfwPlatformGetVideoMode(monitor, &monitor->currentMode);
|
if (!_glfwPlatformGetVideoMode(monitor, &monitor->currentMode)) return NULL;
|
||||||
return &monitor->currentMode;
|
return &monitor->currentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
glfw/wl_monitor.c
vendored
8
glfw/wl_monitor.c
vendored
@@ -195,9 +195,13 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
return monitor->modes;
|
return monitor->modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
bool _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
{
|
{
|
||||||
*mode = monitor->modes[monitor->wl.currentMode];
|
if (monitor->modeCount > monitor->wl.currentMode) {
|
||||||
|
*mode = monitor->modes[monitor->wl.currentMode];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor UNUSED, GLFWgammaramp* ramp UNUSED)
|
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor UNUSED, GLFWgammaramp* ramp UNUSED)
|
||||||
|
|||||||
10
glfw/x11_monitor.c
vendored
10
glfw/x11_monitor.c
vendored
@@ -494,8 +494,8 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
bool _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) {
|
||||||
{
|
bool ok = false;
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
XRRScreenResources* sr =
|
XRRScreenResources* sr =
|
||||||
@@ -505,8 +505,10 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
|||||||
if (ci)
|
if (ci)
|
||||||
{
|
{
|
||||||
const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
|
const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
|
||||||
if (mi) // mi can be NULL if the monitor has been disconnected
|
if (mi) { // mi can be NULL if the monitor has been disconnected
|
||||||
*mode = vidmodeFromModeInfo(mi, ci);
|
*mode = vidmodeFromModeInfo(mi, ci);
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
}
|
}
|
||||||
@@ -515,6 +517,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ok = true;
|
||||||
mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
|
mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
|
||||||
mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
|
mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
|
||||||
mode->refreshRate = 0;
|
mode->refreshRate = 0;
|
||||||
@@ -522,6 +525,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
|||||||
_glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
|
_glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
|
||||||
&mode->redBits, &mode->greenBits, &mode->blueBits);
|
&mode->redBits, &mode->greenBits, &mode->blueBits);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
|
|||||||
@@ -1823,6 +1823,7 @@ static PyObject*
|
|||||||
primary_monitor_size(PYNOARG) {
|
primary_monitor_size(PYNOARG) {
|
||||||
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
|
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
|
||||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||||
|
if (mode == NULL) { PyErr_SetString(PyExc_ValueError, "Failed to get video mode for primary monitor"); return NULL; }
|
||||||
return Py_BuildValue("ii", mode->width, mode->height);
|
return Py_BuildValue("ii", mode->width, mode->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user