aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/tkZinc.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index 88b10d9..b065698 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -916,19 +916,30 @@ ZnGLMakeCurrent(Display *dpy,
ZnGLContextEntry *ce;
ce = ZnGetGLContext(dpy);
-#ifdef _WIN32
if (!wi) {
/* Get a zinc widget from the context struct
* for this display. If no more are left,
* returns, nothing can be done. This can
- * happend only when freeing images or fonts
+ * happen only when freeing images or fonts
* after the last zinc on a given display has
- * been deleted. In this case the context has
- * been already deleted, freeing all resources
- * including textures.
+ * been deleted. In this case the context should
+ * be deleted, freeing all resources including
+ * textures.
*/
- return NULL;
+ ZnWInfo **wip = ZnListArray(ce->widgets);
+ int i, num = ZnListSize(ce->widgets);
+
+ for (i = 0; i <num; i++, wip++) {
+ if ((*wip)->win != NULL) {
+ wi = *wip;
+ break;
+ }
+ }
+ if (!wi) {
+ return NULL;
+ }
}
+#ifdef _WIN32
ce->hwnd = Tk_GetHWND(Tk_WindowId(wi->win));
ce->hdc = GetDC(ce->hwnd);
SetPixelFormat(ce->hdc, ce->ipixel, &ce->pfd);
@@ -937,8 +948,7 @@ ZnGLMakeCurrent(Display *dpy,
fprintf(stderr, "Can't make the GL context current: %d\n", GetLastError());
}
#else
- glXMakeCurrent(dpy, wi?Tk_WindowId(wi->win):DefaultRootWindow(dpy),
- ce->context);
+ glXMakeCurrent(dpy, Tk_WindowId(wi->win), ce->context);
#endif
return ce;
}
@@ -8075,7 +8085,7 @@ Destroy(char *mem_ptr) /* Info about the widget. */
* though). Thus it has been limited to WIN for
* the time being.
*/
-#ifdef _WIN32
+#if 1 /*def _WIN32*/
if (ZnListSize(ce->widgets) == 0) {
ZnGLContextEntry *prev, *next;
/*printf("Freeing a GL context\n");*/