From 12fd68a0dc661074ccf7b3d074138329a241bc3c Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 16 Apr 2021 14:25:16 -0400 Subject: [PATCH] glx: Return the right GLX opcode in synthetic MakeCurrent errors If you're trying to figure out why an operation failed it helps if the error matches the function you thought you called. Reviewed-by: Eric Anholt Part-of: --- src/glx/glxcurrent.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index a388df7a78d..ee93114161c 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -172,7 +172,8 @@ glXGetCurrentDrawable(void) */ static Bool MakeContextCurrent(Display * dpy, GLXDrawable draw, - GLXDrawable read, GLXContext gc_user) + GLXDrawable read, GLXContext gc_user, + int opcode) { struct glx_context *gc = (struct glx_context *) gc_user; struct glx_context *oldGC = __glXGetCurrentContext(); @@ -197,7 +198,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, /* can't have only one be 0 */ if (!!draw != !!read) { __glXUnlock(); - __glXSendError(dpy, BadMatch, None, X_GLXMakeContextCurrent, True); + __glXSendError(dpy, BadMatch, None, opcode, True); return False; } @@ -220,8 +221,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, if (gc->vtable->bind(gc, oldGC, draw, read) != Success) { __glXSetCurrentContextNull(); __glXUnlock(); - __glXSendError(dpy, GLXBadContext, None, X_GLXMakeContextCurrent, - False); + __glXSendError(dpy, GLXBadContext, None, opcode, False); return GL_FALSE; } @@ -248,19 +248,22 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, return GL_TRUE; } - _GLX_PUBLIC Bool glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc) { - return MakeContextCurrent(dpy, draw, draw, gc); + return MakeContextCurrent(dpy, draw, draw, gc, X_GLXMakeCurrent); } -_GLX_PUBLIC -GLX_ALIAS(Bool, glXMakeCurrentReadSGI, - (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), - (dpy, d, r, ctx), MakeContextCurrent) +_GLX_PUBLIC Bool +glXMakeContextCurrent(Display *dpy, GLXDrawable d, GLXDrawable r, + GLXContext ctx) +{ + return MakeContextCurrent(dpy, d, r, ctx, X_GLXMakeContextCurrent); +} -_GLX_PUBLIC -GLX_ALIAS(Bool, glXMakeContextCurrent, - (Display * dpy, GLXDrawable d, GLXDrawable r, - GLXContext ctx), (dpy, d, r, ctx), MakeContextCurrent) +_GLX_PUBLIC Bool +glXMakeCurrentReadSGI(Display *dpy, GLXDrawable d, GLXDrawable r, + GLXContext ctx) +{ + return MakeContextCurrent(dpy, d, r, ctx, X_GLXvop_MakeCurrentReadSGI); +}