Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions ng/Togl2.1/togl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3018,7 +3018,6 @@ Togl_MakeWindow(Tk_Window tkwin, Window parent, ClientData instanceData)

dpy = Tk_Display(tkwin);
scrnum = Tk_ScreenNumber(tkwin);

/*
* Windows and Mac OS X need the window created before OpenGL context
* is created. So do that now and set the window variable.
Expand Down Expand Up @@ -3140,7 +3139,7 @@ Togl_MakeWindow(Tk_Window tkwin, Window parent, ClientData instanceData)
goto error;
}
#endif
#if defined(TOGL_WGL) || defined(TOGL_AGL) || defined(TOGL_NSOPENGL)
#if defined(TOGL_WGL)
if (togl->VisInfo == NULL) {
/*
* Create a new OpenGL rendering context. And check to share lists.
Expand Down Expand Up @@ -3417,7 +3416,6 @@ Togl_MakeWindow(Tk_Window tkwin, Window parent, ClientData instanceData)
DescribePixelFormat(togl->tglGLHdc, (int) togl->PixelFormat, sizeof (pfd),
&pfd);
#endif

/*
* find a colormap
*/
Expand All @@ -3432,7 +3430,8 @@ Togl_MakeWindow(Tk_Window tkwin, Window parent, ClientData instanceData)
cmap = DefaultColormap(dpy, scrnum);
}
#elif defined(TOGL_AGL) || defined(TOGL_NSOPENGL)
cmap = DefaultColormap(dpy, scrnum);
/* macOS: get colormap from Tk */
cmap = Tk_Colormap(tkwin);
#endif
} else {
/* Colormap for CI mode */
Expand All @@ -3457,10 +3456,11 @@ Togl_MakeWindow(Tk_Window tkwin, Window parent, ClientData instanceData)
#elif defined(TOGL_WGL)
cmap = Win32CreateCiColormap(togl);
#elif defined(TOGL_AGL) || defined(TOGL_NSOPENGL)
/* need to figure out how to do this correctly on Mac... */
cmap = DefaultColormap(dpy, scrnum);
/* macOS: use Tk default colormap */
cmap = Tk_Colormap(tkwin);
#endif
} else {
#if defined(TOGL_X11)
if (togl->VisInfo->visual == DefaultVisual(dpy, scrnum)) {
/* share default/root colormap */
cmap = Tk_Colormap(tkwin);
Expand All @@ -3470,14 +3470,25 @@ Togl_MakeWindow(Tk_Window tkwin, Window parent, ClientData instanceData)
XRootWindow(dpy, togl->VisInfo->screen),
togl->VisInfo->visual, AllocNone);
}
#else
/* Windows, AGL, NSOPENGL: use Tk default colormap */
cmap = Tk_Colormap(tkwin);
#endif
}
}

/* Make sure Tk knows to switch to the new colormap when the cursor is over
* this window when running in color index mode. */
#if defined(TOGL_X11)
(void) Tk_SetWindowVisual(tkwin, togl->VisInfo->visual,
togl->VisInfo->depth, cmap);

#elif defined(TOGL_WGL)
/* Windows: use default visual */
(void) Tk_SetWindowVisual(tkwin, DefaultVisual(dpy, scrnum),
DefaultDepth(dpy, scrnum), cmap);
#elif defined(TOGL_AGL) || defined(TOGL_NSOPENGL)
/* Macos: use Tk default colormap */
#endif
#ifdef TOGL_WGL
/* Install the colormap */
SelectPalette(togl->tglGLHdc, ((TkWinColormap *) cmap)->palette, TRUE);
Expand Down