Got a soln for the issue… Given the name of the window, we can remove its decorations… Here is the sample code.
Compile with :
gcc -g -I/usr/include/GL -I/usr/X11R6/include -L/usr/lib/ -L/usr/X11R6/lib/ -o glutWindowWithoutDecorations glutWindowWithoutDecorations.c -lglut -lGLU -lGL -lXext -lX11 -lXm -lXi -lGLw
/********************************************
Code : glutWindowWithoutDecorations.c
*******************************************/
#include <glut.h>
#include<Xm/Xm.h>
#include <Xm/MwmUtil.h>
#include<stdio.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include <GL/GLwMDrawA.h> / Motif OpenGL drawing area. */
float angle = 0.0;
static String fallbackResources[] = {
“glxareawidth: 300”, “glxareaheight: 300”,
“framex: 20”, “framey: 20”,
“frametopOffset: 20”, “framebottomOffset: 20”,
“framerightOffset: 20”, “frameleftOffset: 20”,
“frameshadowType: SHADOW_IN”, NULL
};
static int snglBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 12, GLX_RED_SIZE, 1, None};
static int dblBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 12, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, None};
Bool doubleBuffer = True;
Display *dpy;
int screen;
XVisualInfo *visinfo;
GLXContext glxcontext;
Colormap cmap;
XtAppContext app;
void OnIdle() {
glutShowWindow();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(0.0, 0.0, 1.0); /* blue /
glVertex2i(0, 0);
glColor3f(0.0, 1.0, 0.0); / green /
glVertex2i(200, 200);
glColor3f(1.0, 0.0, 0.0); / red /
glVertex2i(20, 200);
glEnd();
glFlush(); / Single buffered, so needs a flush. */
}
Colormap getShareableColormap(XVisualInfo * vi)
{
Status status;
XStandardColormap *standardCmaps;
Colormap cmap;
int i, numCmaps;
/* Be lazy; using DirectColor too involved for this example. /
#if defined(CH) | | defined(__cplusplus)
if (vi->c_class != TrueColor)
#else
if (vi->class != TrueColor)
#endif
XtAppError(app, “no support for non-TrueColor visual”);
/ If no standard colormap but TrueColor, just make an
unshared one. /
status = XmuLookupStandardColormap(dpy, vi->screen, vi->visualid,
vi->depth, XA_RGB_DEFAULT_MAP,
False, / Replace. /
True); / Retain. */
if (status == 1) {
status = XGetRGBColormaps(dpy, RootWindow(dpy, vi->screen),
&standardCmaps, &numCmaps, XA_RGB_DEFAULT_MAP);
if (status == 1)
for (i = 0; i < numCmaps; i++)
if (standardCmaps[i].visualid == vi->visualid) {
cmap = standardCmaps[i].colormap;
XFree(standardCmaps);
return cmap;
}
}
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
return cmap;
}
Window getWindowIdFromName(Display *dpy, Window level, char *name)
{
Window *children;
Window dmy;
Window root;
Window id;
char *window_name;
int i;
int no_of_children;
if (0 == XQueryTree(dpy, level, &dmy, &dmy, &children, &no_of_children))
return 0;
for (i=0; i<no_of_children; i++)
{
if (XFetchName(dpy,children[i], &window_name))
{
if (strcmp (name, window_name)) XFree(window_name);
else
{
XFree(window_name);
return children[i];
}
}
else
{
if (id = getWindowIdFromName(dpy, children[i], name))
return id;
}
}
return 0;
}
int main(int argc, char **argv)
{
Widget w;
Window window, root, id;
XSetWindowAttributes swattr;
PropMwmHints motf_prop;
Atom motf_atom;
/* Section to make a glut Window called “single traiangle”*/
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB);
if (! glutGet(GLUT_DISPLAY_MODE_POSSIBLE))
glutInitDisplayMode(GLUT_INDEX);
glutCreateWindow(“single triangle”);
/* Now that window is created, Get its window ID from the name “single triangle”*/
if (NULL == (dpy = XOpenDisplay(NULL)))
printf (“Could not open display”);
root = DefaultRootWindow(dpy);
/* we must get id from name string */
if (0 == (id = getWindowIdFromName(dpy, root, "single triangle")))
printf ("Invalid window name");
printf("ID = %d
", id);
// This is the window id of “single triangle” … can check with xwininfo -id <num>
/* Now we need to get permission to modify Window properties.
Check reasoning in http://tronche.com/gui/x/xlib/window/attributes/override-redirect.html*/
swattr.override_redirect = 1;
XChangeWindowAttributes( dpy, id, CWOverrideRedirect, &swattr);
/* Now set the flags for FUNCTIONS and DECORATIONS of the Window to null and apply*/
motf_atom = XInternAtom(dpy, “_MOTIF_WM_HINTS”, False);
motf_prop.flags = 0;
XChangeProperty(dpy, id, motf_atom, motf_atom,32,PropModeReplace,
(unsigned char *)&motf_prop, PROP_MWM_HINTS_ELEMENTS);
/* Now back to glut… start the MainLoop */
glutDisplayFunc(display);
glutIdleFunc( OnIdle );
glutMainLoop();
return 0;
}
/**** End of Code ****/
Amjad