Re: Window doesn't become active
Re: Window doesn't become active
- Subject: Re: Window doesn't become active
- From: Jeremy Huddleston <email@hidden>
- Date: Fri, 06 Apr 2012 11:34:36 -0700
Does your application use GLw? My guess would be it's an issue with GLw, and I don't really know that API.
Since this is happening with XQuartz, Ubuntu, and Solaris, I suggest you ask on a more general-purpose list like email@hidden
On Apr 6, 2012, at 11:10 AM, "Ray, Jeffrey R. {Jeff}(DFRC-ME)" <email@hidden> wrote:
> Hiya,
>
> This bug has dogged me for years, so now I'm appealing to smarter people.
> If this isn't an appropriate place to ask, please tell me where I should
> take this.
>
> I have a multi-platform application. It creates a single window which I
> draw to using OpenGL. For the most part, it work correctly on OSX/Carbon,
> Win7, Redhat Linux, and others). However, on a small number of X11
> platforms (OSX/X11, Ubuntu, Solaris), I cannot get the window into the
> foreground. The border retains the "inactive" shading, keystrokes are
> ignored (actually, remain with the active window), clicking on the window
> to bring it to the foreground doesn't work, etc. Aside from this, the
> application runs correctly. But I need to get the application to go to
> the foreground, because I need to receive keystrokes.
>
> Below is a small X11 application I found on the internet that shows this
> same behavior. It is small enough that, hopefully, someone will spot the
> error, which should tell me what I need to do different in my application.
>
> Thanks in advance.
>
> -j
>
>
>
> Note that this application uses the drawing area widget, which no longer
> seems to be on my mac, so I use a private copy from the darwin source
> stuck into a local GL directory:
>
> www.opensource.apple.com/source/X11server/X11server-48/mesa/Mesa-6.5.2/src/
> glw/GLwDrawA.c
> www.opensource.apple.com/source/X11server/X11server-48/mesa/Mesa-6.5.2/src/
> glw/GLwDrawA.h
> www.opensource.apple.com/source/X11server/X11server-48/mesa/Mesa-6.5.2/src/
> glw/GLwDrawAP.h
>
> mixedGLX.c:
>
> // compile with
> // gcc -lGLU -lGL -lGLw -lXt -o mixedGLX mixedGLX.c
> // on osx, use
> // cd GL ; gcc -I/usr/X11/include -c -o GLwDrawA.o GLwDrawA.c ; cd ..
> // gcc -I/usr/X11/include -L/usr/X11/lib -lGLU -lGL GL/GLwDrawA.o -lX11
> -lXt -o mixedGLX mixedGLX.c
>
> #include <X11/Shell.h>
> #include <X11/keysym.h>
> #include <X11/StringDefs.h>
> #include "GL/GLwDrawA.h"
>
> #include <GL/gl.h>
> #include <GL/glu.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> static void input(Widget, XtPointer, XtPointer);
> static void draw_scene_callback (Widget, XtPointer, XtPointer);
> static void do_resize(Widget, XtPointer, XtPointer);
> static void init_window(Widget, XtPointer, XtPointer);
>
> static GLXContext glx_context;
>
> int main(int argc, char** argv)
> {
> Arg args[20];
> int n;
> Widget glw, toplevel;
> static XtAppContext app_context;
> static String fallback_resources[] = {
> "*glwidget*width: 300",
> "*glwidget*height: 300",
> "*glwidget*rgba: TRUE",
> "*glwidget*doublebuffer: TRUE",
> "*glwidget*allocateBackground: TRUE",
> NULL
> };
>
> toplevel = XtOpenApplication(&app_context, "Mixed", NULL, 0, &argc,
> argv, fallback_resources, applicationShellWidgetClass, NULL, 0);
>
> n = 0;
> // XtSetArg(args[n], GLwNvisualInfo, visInfo); n++;
> // XtSetArg(args[n], XtNcolormap, colormap); n++;
> // XtSetArg(args[n], XtNx, x); n++;
> // XtSetArg(args[n], XtNy, y); n++;
> // XtSetArg(args[n], XtNwidth, w); n++;
> // XtSetArg(args[n], XtNheight, h); n++;
>
> glw = XtCreateManagedWidget(
> "glwidget",
> glwDrawingAreaWidgetClass,
> toplevel,
> args,
> n
> );
>
> XtManageChild (glw);
> XtAddCallback(glw, GLwNexposeCallback, draw_scene_callback,
> (XtPointer) NULL);
> XtAddCallback(glw, GLwNresizeCallback, do_resize, (XtPointer) NULL);
> XtAddCallback(glw, GLwNginitCallback, init_window, (XtPointer) NULL);
> XtAddCallback(glw, GLwNinputCallback, input, (XtPointer) NULL);
>
> XtRealizeWidget(toplevel);
> XtAppMainLoop(app_context);
>
> return 0;
> }
>
> static int rotation = 0;
>
> void spin (void)
> {
> rotation = (rotation + 5) % 360;
> }
>
> static void draw_scene (Widget w)
> {
> GLUquadricObj *quadObj;
>
> glClear(GL_COLOR_BUFFER_BIT);
> glColor3f (1.0, 1.0, 1.0);
> glPushMatrix();
> glTranslatef (0.0, 0.0, -5.0);
> glRotatef ((GLfloat) rotation, 1.0, 0.0, 0.0);
>
> glPushMatrix ();
> glRotatef (90.0, 1.0, 0.0, 0.0);
> glTranslatef (0.0, 0.0, -1.0);
> quadObj = gluNewQuadric ();
> gluQuadricDrawStyle (quadObj, GLU_LINE);
> gluCylinder (quadObj, 1.0, 1.0, 2.0, 12, 2);
> glPopMatrix ();
>
> glPopMatrix();
> glFlush();
> glXSwapBuffers (XtDisplay(w), XtWindow(w));
> }
>
> /* Process all Input callbacks*/
> static void input(Widget w, XtPointer client_data,
> XtPointer call)
> {
> char buffer[1];
> KeySym keysym;
> GLwDrawingAreaCallbackStruct *call_data;
>
> call_data = (GLwDrawingAreaCallbackStruct *) call;
>
> switch(call_data->event->type)
> {
> case KeyRelease:
> /* It is necessary to convert the keycode to a
> * keysym before it is possible to check if it is
> * an escape.
> */
> if (XLookupString( (XKeyEvent *) call_data->event,
> buffer, 1, &keysym,
> (XComposeStatus *) NULL ) == 1
> && keysym == (KeySym) XK_Escape)
> exit(0);
> break;
>
> case ButtonPress:
> switch (call_data->event->xbutton.button)
> {
> case Button1:
> spin();
> draw_scene(w);
> break;
> }
> break;
>
> default:
> break;
> }
> }
>
> static void draw_scene_callback(Widget w, XtPointer client_data, XtPointer
> call)
> {
> static char firstTime = 0x1;
> GLwDrawingAreaCallbackStruct *call_data;
>
> call_data = (GLwDrawingAreaCallbackStruct *) call;
> GLwDrawingAreaMakeCurrent(w, glx_context);
>
> if (firstTime) {
> glViewport(0, 0, call_data->width,call_data->height);
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> gluPerspective(65.0, (float) call_data->width /
> (float)call_data->height, 1.0, 20.0);
> glMatrixMode(GL_MODELVIEW);
> glLoadIdentity();
> firstTime = 0;
> }
> draw_scene (w);
> }
>
> static void do_resize(Widget w, XtPointer client_data,
> XtPointer call)
> {
> GLwDrawingAreaCallbackStruct *call_data;
>
> call_data = (GLwDrawingAreaCallbackStruct *) call;
>
> GLwDrawingAreaMakeCurrent(w, glx_context);
> glViewport(0, 0, call_data->width, call_data->height);
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> gluPerspective(65.0, (GLfloat) call_data->width /
> (GLfloat)call_data->height, 1.0, 20.0);
> glMatrixMode(GL_MODELVIEW);
> glLoadIdentity();
> }
>
> static void init_window(Widget w, XtPointer client_data,
> XtPointer call_data)
> {
> Arg args[1];
> XVisualInfo *vi;
> GLUquadricObj *quadObj;
>
> XtSetArg(args[0], GLwNvisualInfo, &vi);
> XtGetValues(w, args, 1);
> glx_context = glXCreateContext(XtDisplay(w), vi, 0, False);
> }
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------
> Jeff Ray M/S 4840A Official Correspondence Only:
> NASA email@hidden
> Dryden Flight Research Center email@hidden
> P. O. Box 273
> Edwards, CA 93523-0273 All Others: email@hidden
> (661) 276-3754
>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> X11-users mailing list (email@hidden)
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden