Xorg problem: What happened to XRaiseWindow?

Ernest L. Williams Jr. ernesto at ornl.gov
Fri Jan 20 09:56:57 UTC 2006


Hi,

When calling XRaiseWindow under Fedora, it does come to foreground when
covered by another window, hmmm?  This used to work especially in RHEL
3.  However, it does not work in FC5T2 or RHEL 4.

Please any ideas on this one?


I will show the simple code that reproduces the behaviour:
================ 1.c ======================================
/* ---------------------------------------------
 *
 * This application creates a main window and raises it
 * approximately every 3 seconds. The only menu option
 * is "exit".
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <math.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <wait.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>

#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/AtomMgr.h>
#include <Xm/Protocols.h>
#include <Xm/MainW.h>
#include <Xm/PushB.h>
#include <Xm/CascadeB.h>
#include <Xm/RowColumn.h>

static int g_exit = 0;

void exit_cb (
  Widget w,
  XtPointer client,
  XtPointer call )
{

int *flag = (int *) client;

  printf( "exit_cb callback function was invoked\n" );

  *flag = 1;

}

int main (
  int argc,
  char **argv
) {

XtAppContext app;
Display *display;
Widget appTop, mainWin, menuBar, filePullDown, fileCascade, exitB;
XmString menuStr, str;
XEvent Xev;
int result, isXEvent, n, count;
struct timespec req, rem;
Atom wm_delete_window;

  XtToolkitInitialize();
  app = XtCreateApplicationContext();

  display = XtOpenDisplay( app, NULL, NULL, "test", NULL, 0, &argc,
   argv );

  appTop = XtVaAppCreateShell( NULL, "test",
applicationShellWidgetClass,
   display,
   XmNiconic, False,
   XmNmappedWhenManaged, True,
   NULL );

  mainWin = XtVaCreateManagedWidget( "main", xmMainWindowWidgetClass,
   appTop,
   XmNscrollBarDisplayPolicy, XmAS_NEEDED,
   XmNscrollingPolicy, XmAUTOMATIC,
   NULL );

  menuBar = XmCreateMenuBar( mainWin, "menubar", NULL, 0 );

  filePullDown = XmCreatePulldownMenu( menuBar, "file", NULL, 0 );

  menuStr = XmStringCreateLocalized( "file" );
  fileCascade = XtVaCreateManagedWidget( "filemenu",
xmCascadeButtonWidgetClass,
   menuBar,
   XmNlabelString, menuStr,
   XmNmnemonic, 'f',
   XmNsubMenuId, filePullDown,
   NULL );
  XmStringFree( menuStr );

  str = XmStringCreateLocalized( "exit" );
  exitB = XtVaCreateManagedWidget( "pb", xmPushButtonWidgetClass,
   filePullDown,
   XmNlabelString, str,
   NULL );
  XmStringFree( str );
  XtAddCallback( exitB, XmNactivateCallback, exit_cb,
   (XtPointer) &g_exit );

  XtManageChild( menuBar );

  XtRealizeWidget( appTop );

  wm_delete_window = XmInternAtom( display, "WM_DELETE_WINDOW", False );
  XmAddWMProtocolCallback( appTop, wm_delete_window,
   exit_cb, (XtPointer) &g_exit );
  XtVaSetValues( appTop, XmNdeleteResponse, XmDO_NOTHING, NULL );

  //-------------------------------------------

  n = 0;

  while ( !g_exit ) {

    count = 1000;

    do {
      result = XtAppPending( app );
      if ( result ) {
        isXEvent = XtAppPeekEvent( app, &Xev );
        if ( isXEvent ) {
          if ( Xev.type != Expose ) {
            XtAppProcessEvent( app, result );
          }
          else {
            XtAppProcessEvent( app, result );
          }
        }
        else { // process all timer or alternate events
          XtAppProcessEvent( app, result );
        }
      }
      count--;
    } while ( result && count );

    req.tv_sec = 0;
    req.tv_nsec = 100000000;
    nanosleep( &req, &rem );

    // raise window approx every 3 seconds
    n++;
    if ( n == 30 ) {
      n = 0;
      printf( "call XRaiseWindow\n" );
      XRaiseWindow( display, XtWindow(appTop) );
    }

  }

  return 0;

}
==========================================================


============ makefile ====================================
CFLAGS = -Wall -O0 -g
LDFLAGS = -g

all : 1

1 : 1.o
        g++ $(LDFLAGS) -o 1 \
        -L/usr/X11R6/lib \
        -lXm -lXt -lX11 \
        1.o

1.o : 1.c
        cc $(CFLAGS) -o 1.o -c 1.c
==========================================================

Thanks,
Ernest L. Williams Jr.






More information about the test mailing list