Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty

This commit is contained in:
Kovid Goyal 2020-06-02 17:05:02 +05:30
commit f548e795d5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 27 additions and 17 deletions

10
glfw/x11_init.c vendored
View File

@ -64,9 +64,8 @@ static Atom getAtomIfSupported(Atom* supportedAtoms,
static void detectEWMH(void) static void detectEWMH(void)
{ {
// First we read the _NET_SUPPORTING_WM_CHECK property on the root window // First we read the _NET_SUPPORTING_WM_CHECK property on the root window
Window* windowFromRoot = NULL;
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window Window* windowFromRoot = NULL;
if (!_glfwGetWindowPropertyX11(_glfw.x11.root, if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
_glfw.x11.NET_SUPPORTING_WM_CHECK, _glfw.x11.NET_SUPPORTING_WM_CHECK,
XA_WINDOW, XA_WINDOW,
@ -93,6 +92,7 @@ static void detectEWMH(void)
_glfwReleaseErrorHandlerX11(); _glfwReleaseErrorHandlerX11();
// If the property exists, it should contain the XID of the window // If the property exists, it should contain the XID of the window
if (*windowFromRoot != *windowFromChild) if (*windowFromRoot != *windowFromChild)
{ {
XFree(windowFromRoot); XFree(windowFromRoot);
@ -103,13 +103,14 @@ static void detectEWMH(void)
XFree(windowFromRoot); XFree(windowFromRoot);
XFree(windowFromChild); XFree(windowFromChild);
// We are now fairly sure that an EWMH-compliant window manager is running // We are now fairly sure that an EWMH-compliant WM is currently running
// We can now start querying the WM about what features it supports by // We can now start querying the WM about what features it supports by
// looking in the _NET_SUPPORTED property on the root window // looking in the _NET_SUPPORTED property on the root window
// It should contain a list of supported EWMH protocol and state atoms // It should contain a list of supported EWMH protocol and state atoms
Atom* supportedAtoms = NULL; Atom* supportedAtoms = NULL;
const unsigned long atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root, const unsigned long atomCount =
_glfwGetWindowPropertyX11(_glfw.x11.root,
_glfw.x11.NET_SUPPORTED, _glfw.x11.NET_SUPPORTED,
XA_ATOM, XA_ATOM,
(unsigned char**) &supportedAtoms); (unsigned char**) &supportedAtoms);
@ -506,6 +507,7 @@ static int errorHandler(Display *display, XErrorEvent* event)
{ {
if (_glfw.x11.display != display) if (_glfw.x11.display != display)
return 0; return 0;
_glfw.x11.errorCode = event->error_code; _glfw.x11.errorCode = event->error_code;
return 0; return 0;
} }

27
glfw/x11_monitor.c vendored
View File

@ -241,7 +241,8 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
if (_glfwCompareVideoModes(&current, best) == 0) if (_glfwCompareVideoModes(&current, best) == 0)
return; return;
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRScreenResources* sr =
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
@ -289,7 +290,8 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
if (monitor->x11.oldMode == None) if (monitor->x11.oldMode == None)
return; return;
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRScreenResources* sr =
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
XRRSetCrtcConfig(_glfw.x11.display, XRRSetCrtcConfig(_glfw.x11.display,
@ -321,9 +323,10 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr =
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
if (ci) if (ci)
{ {
if (xpos) if (xpos)
@ -333,6 +336,7 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
XRRFreeCrtcInfo(ci); XRRFreeCrtcInfo(ci);
} }
XRRFreeScreenResources(sr); XRRFreeScreenResources(sr);
} }
} }
@ -352,8 +356,8 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr =
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
areaX = ci->x; areaX = ci->x;
@ -446,7 +450,8 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRScreenResources* sr =
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
@ -493,17 +498,19 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr =
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
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);
XRRFreeCrtcInfo(ci); XRRFreeCrtcInfo(ci);
} }
XRRFreeScreenResources(sr); XRRFreeScreenResources(sr);
} }
else else

1
glfw/x11_window.c vendored
View File

@ -2414,6 +2414,7 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
{ {
return maximized; return maximized;
} }
const unsigned long count = const unsigned long count =
_glfwGetWindowPropertyX11(window->x11.handle, _glfwGetWindowPropertyX11(window->x11.handle,
_glfw.x11.NET_WM_STATE, _glfw.x11.NET_WM_STATE,