Esempio n. 1
0
/*******************************************************************************
          Name:        XclipsGetc
          Description: Get a character input from user
          Arguments:   log_name -
          Returns:       
*******************************************************************************/
int XclipsGetc(
  void *theEnv,
  char *log_name)
  {
   int quit = False;
   char ch[2];
   String str_list[1];
   int num = 1;
  
   ch[1] = 0;

   /* if unget_buf is not empty return the last character in the buf */

   if (char_counter > 0)
     { return(unget_buf[--char_counter]); }
     
   if (LogLookup(log_name) == NULL)
     { return(EOS); }
 
   while (! quit)
     {
      /* Get an event and if it is a legalimate (cahracter)key press */ 
      /* event print it to the main window, return the character     */
      /* (out of the while loop).                                    */
      /* else, dispatch the event and get another event              */

      XtAppNextEvent(app_con, &TheEvent); /* Get an event */
      XLookupString(&TheEvent.xkey, ch, 1, &TheKeysym, &compose_status);
      if ((TheEvent.type == KeyPress) &&
          (TheEvent.xproperty.window == dialog_text->core.window))
        {
         if ((TheKeysym >= XK_space) && (TheKeysym <= XK_asciitilde))
           {
            str_list[0] = ch;
            InsertClipsString(dialog_text, &TheEvent, str_list,(Cardinal *) &num);
            quit = True;
           }
         else if ((TheKeysym != XK_Linefeed) ? (TheKeysym == XK_Return) : TRUE)
           {
            ch[0] = NEWLINE;
            quit = True;
            XtDispatchEvent(&TheEvent);
           }
         else if ((TheKeysym != XK_Delete) ? (TheKeysym == XK_BackSpace) :TRUE)
           {
            if (RouterData(theEnv)->CommandBufferInputCount != 0)
              {
               ch[0] = BACKSPACE;
               quit = True;
               XtDispatchEvent(&TheEvent);
              }
           }
        }
      else
        { XtDispatchEvent(&TheEvent); }
     }
     
   return((int)ch[0]);
  }
Esempio n. 2
0
int  MessageAvertissementAux(char *message, int typeMessage, Widget widgetMessage, Widget widgetParent)
{
   Widget avrtWidgetParent;
   XEvent avrtEvent;
   Arg args[2];
   XmString label;

   label = XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET);
   XtSetArg(args[0], XmNmessageString, label);
   
   XtSetValues(widgetMessage, args, 1);
   widgetCourant = widgetMessage;

   XmStringFree(label);

   avrtSelectionTerminee = False;
   
   AjusterPositionForme(widgetCourant, widgetParent);

   XtManageChild(widgetCourant);
   FlusherTousLesEvenements();
   CheckColormap(widgetCourant);

   while (!avrtSelectionTerminee)
      {
      XtAppPeekEvent(SuperWidget.contexte, &(avrtEvent));
      switch(avrtEvent.type)
         {
         case ButtonPress:
         avrtWidgetParent =(Widget) TrouverWidgetParent(avrtEvent.xbutton.window);
         if (avrtWidgetParent == widgetParent)
            {
            XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
            XtDispatchEvent(&(avrtEvent));
            }
         else
            {
            XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
            }
         break;
         
         default:
         XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
         XtDispatchEvent(&(avrtEvent));
         break;
         }

      }
   return okCancel;
   }
Esempio n. 3
0
/**************************************************************************
...
**************************************************************************/
void x_simulate_button_click(Widget w)
{
  XButtonEvent ev;
  
  ev.display = XtDisplay(w);
  ev.window = XtWindow(w);
  ev.type=ButtonPress;
  ev.button=Button1;
  ev.x=10;
  ev.y=10;

  XtDispatchEvent((XEvent *)&ev);
  ev.type=ButtonRelease;
  XtDispatchEvent((XEvent *)&ev);
}
Esempio n. 4
0
x_wglwtwrsz()
{
   Dimension largeurMax, hauteurMax;
   Dimension largeurCourante, hauteurCourante;
   
   XGetWindowAttributes(wglDisp, wglWin, &wglWinAttr);
   w = wglWinAttr.width;
   h = wglWinAttr.height;
   largeurCourante = w;
   hauteurCourante = h;

   if (largeurCourante < hauteurCourante)
      largeurMax = hauteurCourante;
   else
      largeurMax = largeurCourante;

   if (hauteurCourante < largeurCourante)
      hauteurMax = largeurCourante;
   else
      hauteurMax = hauteurCourante;

   largeurMax = 150;
   hauteurMax = 150;
   while (w <= largeurMax && h <= hauteurMax)
      {
      x_wglmesagr(messageAgrandir[lng]);
      XtAppNextEvent(SuperWidget.contexte, &wglEvent); 
      XtDispatchEvent(&wglEvent);

      XGetWindowAttributes(wglDisp, wglWin, &wglWinAttr);
      w = wglWinAttr.width;
      h = wglWinAttr.height;
      } 
   }
Esempio n. 5
0
void MessageErreur(char message[])
{
   XEvent avrtEvent;
   Arg args[2];
   XmString label;
   
   Xinit("xrec");
   if (errorWidget  == NULL)
      {
      errorWidget = (Widget) CreateErrorDialog(SuperWidget.topLevel);
      }
   
   label = XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET);
   XtSetArg(args[0], XmNmessageString, label);
   
   XtSetValues(errorWidget, args, 1);
   widgetCourant = errorWidget;
   
   XmStringFree(label);
   
   XtManageChild(errorWidget);
   FlusherTousLesEvenements();

   avrtSelectionTerminee = False;
   while (0 == 0)
      {
      XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
      XtDispatchEvent(&(avrtEvent));
      }
   }
Esempio n. 6
0
// Wait until W is mapped
void wait_until_mapped(Widget w, Widget shell)
{
    XSync(XtDisplay(w), False);
    XmUpdateDisplay(w);

    if (shell == 0)
	shell = find_shell(w);

    if (XtIsRealized(w) && XtIsRealized(shell))
    {
  	XWindowAttributes attr;
	while (XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attr)
	       && attr.map_state != IsViewable)
	{
	    if (XGetWindowAttributes(XtDisplay(shell), XtWindow(shell), &attr)
		&& attr.map_state != IsViewable)
		break;		// Shell is withdrawn or iconic

	    // Wait for exposure event
	    XEvent event;
	    XtAppNextEvent(XtWidgetToApplicationContext(w), &event);
	    XtDispatchEvent(&event);
	}
    }

    XSync(XtDisplay(w), False);
    XmUpdateDisplay(w);
}
Esempio n. 7
0
/*
 * If the application doesn't receive events with timestamp for a long time
 * XtLastTimestampProcessed() will return out-of-date value. This may cause
 * selection handling routines to fail (see BugTraq ID 4085183).
 * This routine is to resolve this problem. It queries the current X server
 * time by appending a zero-length data to a property as prescribed by
 * X11 Reference Manual.
 * Note that this is a round-trip request, so it can be slow. If you know
 * that the Xt timestamp is up-to-date use XtLastTimestampProcessed().
 */
Time
awt_util_getCurrentServerTime() {

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    static Atom _XA_JAVA_TIME_PROPERTY_ATOM = 0;
    Time server_time = 0;

    AWT_LOCK();

    if (_XA_JAVA_TIME_PROPERTY_ATOM == 0) {
        XtAddEventHandler(awt_root_shell, PropertyChangeMask, False,
                          propertyChangeEventHandler, NULL);
        _XA_JAVA_TIME_PROPERTY_ATOM = XInternAtom(awt_display, "_SUNW_JAVA_AWT_TIME", False);
    }

    timeStampUpdated = False;
    XChangeProperty(awt_display, XtWindow(awt_root_shell),
                    _XA_JAVA_TIME_PROPERTY_ATOM, XA_ATOM, 32, PropModeAppend,
                    (unsigned char *)"", 0);
    XFlush(awt_display);

    if (awt_currentThreadIsPrivileged(env)) {
        XEvent event;
        XMaskEvent(awt_display, PropertyChangeMask, &event);
        XtDispatchEvent(&event);
    } else {
        awt_MToolkit_modalWait(isTimeStampUpdated, NULL);
    }
    server_time = XtLastTimestampProcessed(awt_display);

    AWT_UNLOCK();

    return server_time;
}
Esempio n. 8
0
int MwAlertBox(Widget pw, char *text, char *buttons[], int nbuttons)
{
	Widget topbox, buttonbox, label, command;
	int i;
	XtAppContext app_context = XtWidgetToApplicationContext(pw);

	alert = XtVaCreatePopupShell("alert",
		transientShellWidgetClass, pw,
		XtNtitle, _("Alert"),
		(char *)0);
	topbox = XtVaCreateManagedWidget("topbox",
		boxWidgetClass, alert, (char *)0);
	label = XtVaCreateManagedWidget("label",
		labelWidgetClass, topbox,
		(char *)0);
	MwLabelSet(label, text);
	buttonbox = XtVaCreateManagedWidget("buttonbox",
		boxWidgetClass, topbox, (char *)0);
	for (i = 0; i < nbuttons; i++) {
		command = add_button(buttonbox, "command", buttons[i],
			alert_clicked, (XtPointer)i);
	}
	status = MW_WAITING;
	MwCenter(alert);
	XtPopup(alert, XtGrabNonexclusive);
	wm_del(alert);
	while (status == MW_WAITING) {
		XEvent event_return;
		XtAppNextEvent(app_context, &event_return);
		XtDispatchEvent(&event_return);
	}
	XtDestroyWidget(alert);
	return status;
}
Esempio n. 9
0
void XSilChessWindow::DoPainting()
{
	XEvent e;
	char * data;
	XImage * img;
	int i,y,msk;

	if (IsPainting) return;
	if (!ViewWin) return;
	IsPainting=true;
	y=0;
	while (NeedPainting) {
		NeedPainting=false;
		RT.SetWorld(Machine);
		data=(char*)malloc(PixelSize*ViewWidth+1000000);
		img=XCreateImage(Disp,Vsl,VslDepth,ZPixmap,0,data,
		                 ViewWidth,1,8*PixelSize,0);
		for (msk=0x3ff; msk<ViewHeight-1; msk=(msk<<1)|1);
		for (i=0, y%=ViewHeight; i<ViewHeight; i++) {
			while (XtAppPending(App)!=0) {
				XtAppNextEvent(App,&e);
				XtDispatchEvent(&e);
			}
			if (NeedPainting) break;
			RT.RenderScanline(y,data,PixelSize,RedMask,GreenMask,BlueMask);
			XPutImage(Disp,ViewWin,ViewGC,img,0,0,0,y,ViewWidth,1);
			if (i==ViewHeight-1 || (i&7)==0) PaintSel();
			do { y=(y+269779)&msk; } while (y>=ViewHeight);
		}
		PaintSel();
		XFree(img);
		free(data);
	}
	IsPainting=false;
}
Esempio n. 10
0
/*
 *	bXAUERelaxCallback
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Callback to redisplay the UNIT every step of a minimization.
 *	Return TRUE to indicate that the minimization should continue.
 */
static BOOL
bXAUERelaxCallback( Widget wTank )
{
    XEvent		xeEvent;
    BOOL		bContinue;

    /* Redisplay the UNIT in the TANK */


    TankFastRedisplayUnit((TANK) wTank );

    /* If there is an event pending then handle it */

    bContinue = TRUE;
    while ( XtAppPending( SxtacApp ) ) {
        MESSAGE(( "There is an event pending\n" ));
        XtAppNextEvent( SxtacApp, &xeEvent );
        if ( bBasicsInterrupt() ) {
            bContinue = FALSE;
            BasicsResetInterrupt();
        }
        XtDispatchEvent( &xeEvent );
    }

    return(bContinue);
}
Esempio n. 11
0
void xtwitter_xaw_loop(){
    //XtAppMainLoop(context);
    XEvent event;
    while(1){
        XtAppNextEvent(context, &event);
        XtDispatchEvent(&event);
    }
}
Esempio n. 12
0
void
xevents(void)
{
	XEvent event;
	XtInputMask input_mask;
	register TScreen *screen = &term->screen;

	if(screen->scroll_amt)
		FlushScroll(screen);
	/*
	 * process timeouts, relying on the fact that XtAppProcessEvent
	 * will process the timeout and return without blockng on the
	 * XEvent queue.  Other sources i.e. the pty are handled elsewhere
	 * with select().
	 */
	while ((input_mask = XtAppPending(app_con)) & XtIMTimer)
		XtAppProcessEvent(app_con, XtIMTimer);
	/*
	 * If there's no XEvents, don't wait around...
	 */
	if ((input_mask & XtIMXEvent) != XtIMXEvent)
	    return;
	do {
		if (waitingForTrackInfo)
			return;
		XtAppNextEvent (app_con, &event);
		/*
		 * Hack to get around problems with the toolkit throwing away
		 * eventing during the exclusive grab of the menu popup.  By
		 * looking at the event ourselves we make sure that we can
		 * do the right thing.
		 */
		if(OUR_EVENT(event, EnterNotify))
		  DoSpecialEnterNotify (&event.xcrossing);
		else
		if(OUR_EVENT(event, LeaveNotify))
		  DoSpecialLeaveNotify (&event.xcrossing);
		else if ((screen->send_mouse_pos == ANY_EVENT_MOUSE
#if OPT_DEC_LOCATOR
			|| screen->send_mouse_pos == DEC_LOCATOR
#endif	/* OPT_DEC_LOCATOR */
								)
		 && event.xany.type == MotionNotify
		 && event.xcrossing.window == XtWindow(term)) {
		    SendMousePosition((Widget)term, &event);
		    continue;
		}

		if (!event.xany.send_event ||
		    screen->allowSendEvents ||
		    ((event.xany.type != KeyPress) &&
		     (event.xany.type != KeyRelease) &&
		     (event.xany.type != ButtonPress) &&
		     (event.xany.type != ButtonRelease)))
		    XtDispatchEvent(&event);
	} while ((input_mask = XtAppPending(app_con)) & XtIMXEvent);
}
Esempio n. 13
0
void WNavMotif::message_dialog( char *title, char *text)
{
    Widget 	dialog;
    XmString	text_str;
    XmString	title_str;
    Arg		args[9];
    int		i;
    XEvent 	Event;

    text_str = XmStringCreateLocalized( wnav_dialog_convert_text(text));
    title_str = XmStringCreateLocalized( title);
    i = 0;
    XtSetArg( args[i], XmNmessageString, text_str);
    i++;
    XtSetArg( args[i], XmNdialogTitle, title_str);
    i++;
    XtSetArg( args[i], XmNdialogType, XmDIALOG_MESSAGE);
    i++;
    if ( dialog_width && dialog_height)
    {
        XtSetArg( args[i], XmNwidth, dialog_width);
        i++;
        XtSetArg( args[i], XmNheight, dialog_height);
        i++;
        XtSetArg( args[i], XmNx, dialog_x);
        i++;
        XtSetArg( args[i], XmNy, dialog_y);
        i++;
    }

    dialog = XmCreateInformationDialog( parent_wid, (char*) "Info", args, i);
    XmStringFree( text_str);
    XmStringFree( title_str);

    XtUnmanageChild( XmMessageBoxGetChild( dialog, XmDIALOG_HELP_BUTTON));
    XtUnmanageChild( XmMessageBoxGetChild( dialog, XmDIALOG_CANCEL_BUTTON));

    XtAddCallback( dialog, XmNokCallback, wnav_message_dialog_ok, this);

    // Connect the window manager close-button to exit
    flow_AddCloseVMProtocolCb( XtParent(dialog),
                               (XtCallbackProc)wnav_message_dialog_ok, this);

    XtManageChild( dialog);
    XtPopup( XtParent(dialog), XtGrabNone);

    dialog_ok = 0;

    for (;;)
    {
        XtAppNextEvent( XtWidgetToApplicationContext( dialog), &Event);
        XtDispatchEvent( &Event);
        if ( dialog_ok)
            return;
    }
}
Esempio n. 14
0
void VkHypViewer::eventHandler(XEvent *event) {
  // may need to drain away events which occurred while HypView was busy
  int tossEvents = hv->getTossEvents();
  if (tossEvents) {
#ifdef HYPVK
    XtAppContext app = theApplication->appContext();
#else
    XtAppContext app = XtWidgetToApplicationContext (glxarea);
#endif
    XEvent e;
    while (XtAppPending(app)) {
      XtAppNextEvent(app, &e);     // just throw it away
      XtDispatchEvent(&e);
    }
    hv->setTossEvents(0);
    // if one of these ignored events was the rightmouse then 
    // Motif has already handed us input focus. must give it back! 
    XUngrabPointer(XtDisplay(glxarea), CurrentTime);
  }

  switch (event->type) {
  case ButtonPress:
  case ButtonRelease:
    hv->mouse(event->xbutton.button-1, 
	      event->xmotion.state&(Button1Mask|Button2Mask|Button3Mask),
	      event->xmotion.x, event->xmotion.y, 
	      event->xmotion.state&(ShiftMask), 
	      event->xmotion.state&(ControlMask)
	      );
    break;
  case MotionNotify:
    if (event->xmotion.state&(Button1Mask|Button2Mask|Button3Mask)) {
      hv->motion(event->xmotion.x, event->xmotion.y,
		 event->xmotion.state&(ShiftMask), 
		 event->xmotion.state&(ControlMask)
		 );
    } else {
      hv->passive(event->xmotion.x, event->xmotion.y,
		  event->xmotion.state&(ShiftMask), 
		  event->xmotion.state&(ControlMask)
		  );
    }
    break;
  case ConfigureNotify:
    hv->reshape(event->xconfigure.width, event->xconfigure.height);
    break;
  case Expose:
    hv->idle(1);
    hv->drawFrame();
    break;
  }
  // make the idle work right
  if (XtPending()) {
    hv->idle(0);
  }
}
Esempio n. 15
0
File: server.c Progetto: rtoy/cmucl
void serve_client(int socket)
{
    XEvent event;

    XtToolkitInitialize();
    app_context = XtCreateApplicationContext();

    LispAction.string = "Lisp";
    LispAction.proc   = LispActionProc;
    XtAppAddActions(app_context, &LispAction, 1);

    string_token_tag = find_type_entry(ExtRStringToken);
    string_tag = find_type_entry(XtRString);
    xm_string_tag = find_type_entry(XmRXmString);
    enum_tag = find_type_entry(XtREnum);
    int_tag = find_type_entry(XtRInt);
    window_tag = find_type_entry(XtRWindow);
    boolean_tag = find_type_entry(XtRBoolean);
    widget_tag = find_type_entry(XtRWidget);
    function_tag = find_type_entry(XtRFunction);
    callback_reason_tag = find_type_entry(ExtRCallbackReason);
    event_tag = find_type_entry(ExtREvent);
    resource_list_tag = find_type_entry(ExtRResourceList);
    translation_table_tag = find_type_entry(XtRTranslationTable);
    accelerator_table_tag = find_type_entry(XtRAcceleratorTable);
    atom_tag = find_type_entry(XtRAtom);
    font_list_tag = find_type_entry(XmRFontList);
    string_table_tag = find_type_entry(XtRStringTable);
    xm_string_table_tag = find_type_entry(XmRXmStringTable);
    int_list_tag = find_type_entry(ExtRIntList);
    cursor_tag = find_type_entry(XtRCursor);

    client_socket = socket;
    greet_client(socket);

    XtAppAddInput(app_context, socket, (XtPointer)XtInputReadMask,
                  (XtInputCallbackProc)get_input, (XtPointer)NULL);

    XtAppSetErrorHandler(app_context, MyErrorHandler);
    XtAppSetWarningHandler(app_context, MyWarningHandler);

    /* Here is where we want to return on errors */
    if( setjmp(env) ) {
        printf("Attempting to recover from error.\n");
        fflush(stdout);
    }
    while( !terminate_server ) {
        XtAppNextEvent(app_context, &event);
        XtDispatchEvent(&event);
    }

    close(socket);
    XtDestroyApplicationContext(app_context);

    exit(0);
}
Esempio n. 16
0
void processAct(Widget w, XEvent *e, String *params, Cardinal *num_params)
{
    if (app_data.source_editing && w == source_view->source())
    {
	// Process event in source window
	string action = "self-insert";   // Default action
	String *action_params      = 0;
	Cardinal num_action_params = 0;
	if (num_params != 0 && *num_params > 0)
	{
	    action = params[0];
	    action_params = params + 1;
	    num_action_params = *num_params - 1;
	}

	XtCallActionProc(w, action.chars(), e, action_params, num_action_params);
	return;
    }

    if (e->type != KeyPress && e->type != KeyRelease)
	return;			// Forward only keyboard events

    if (!XtIsRealized(gdb_w))
	return;			// We don't have a console yet

    if (app_data.console_has_focus == Off)
	return;			// No forwarding

    if (app_data.console_has_focus == Auto && !have_command_window())
	return;			// The console is closed

    static bool running = false;

    if (running)
	return;			// We have already entered this procedure

    running = true;

#if 0
    clear_isearch();		// Why would this be needed?  -AZ
#endif

    // Give focus to GDB console
    XmProcessTraversal(gdb_w, XmTRAVERSE_CURRENT);

    // Forward event to GDB console
    Window old_window = e->xkey.window;
    e->xkey.window = XtWindow(gdb_w);
    XtDispatchEvent(e);
    e->xkey.window = old_window;

    // Return focus to original widget
    XmProcessTraversal(w, XmTRAVERSE_CURRENT);

    running = false;
}
Esempio n. 17
0
void InitGraphics(int argc, char *argv[])
{
    Dimension width, height;
    XEvent event;
    static String fallback_resources[] = {
        "*xcheck*background: #e0e0e0",
        "*xcheck*fontList: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*",
        "*xcheck*font: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*",
        "*xcheck*XmText.background:  #b0e0c0",
        NULL,
    };

    XtSetLanguageProc(NULL,NULL,NULL);
    toplevel = XtVaAppInitialize(
        &app,"App-Class",
        NULL,0,
        &argc,argv,
        fallback_resources,
        NULL);
    mainWidget = XtVaCreateManagedWidget("mw", xmMainWindowWidgetClass, toplevel, NULL);
    dpy = XtDisplay(mainWidget);
    gc = XCreateGC(dpy,DefaultRootWindow(dpy),(int)NULL,NULL);
    XSetLineAttributes(dpy,gc,2,LineSolid,CapButt,JoinMiter);
    colormap = CreateColorMap(mainWidget);
    menubar = CreateMenuBar(mainWidget);
    workwin = CreateWorkWin(mainWidget);
    message = CreateMessage(mainWidget);
    XtVaSetValues(mainWidget,
        XmNcolormap,colormap,
        XmNmenuBar,menubar,
        XmNworkWindow,workwin,
        XmNmessageWindow,message,
        NULL);
    XtRealizeWidget(toplevel);
    do {
        XtAppNextEvent(app,&event);
        XtDispatchEvent(&event);
    }
    while(event.type != Expose);

    XtVaGetValues(toplevel,XmNheight,&height,XmNwidth,&width,NULL);
    XtVaSetValues(toplevel,
        XmNwidth, width,
        XmNheight, height,
        XmNmaxWidth, width,
        XmNmaxHeight, height,
        XmNminWidth, width,
        XmNminHeight, height,
        XmNallowShellResize, False,
        NULL);
    HandleEvents();

    strcpy(xval[0],"human");
    strcpy(xval[1],"computer");
    strcpy(xval[2],"10.0");
}
Esempio n. 18
0
void HandleEvents(void)
{
#ifdef GRAPHICS
    XEvent event;
    while(XtAppPending(app)) {
        XtAppNextEvent (app, &event); 
        XtDispatchEvent (&event);
    }
#endif
}
Esempio n. 19
0
/* ---
Display a logo, a text and an OK button.
*/
void MwAboutBox(Widget pw, char *pixmap, char *message)
{
	Pixel color;
	Pixmap pm;
	Widget topbox, label, command, image;
	XtAppContext app_context = XtWidgetToApplicationContext(pw);

	XtVaGetValues(pw, XtNbackground, &color, (char *)0);
	pm = MwLoadPixmap(XtDisplay(pw), color, pixmap);
	alert = XtVaCreatePopupShell("about",
		transientShellWidgetClass, pw,
		XtNtitle, _("About"),
		XtNwidth, 400,
		XtNheight, 200,
		(char *)0);
	topbox = XtVaCreateManagedWidget("topbox",
		mwRudegridWidgetClass, alert,
		XtNxLayout, "4 80 4 50% 80 50% 4 80 4",
		XtNyLayout, "4 50% 80 50% 4 22 4",
		(char *)0);
	image = XtVaCreateManagedWidget("image",
		mwImageWidgetClass, topbox,
		XtNbitmap, pm,
		XtNgridx, 1,
		XtNgridy, 2,
		(char *)0);
	label = XtVaCreateManagedWidget("label",
		labelWidgetClass, topbox,
		XtNgridx, 3,
		XtNgridy, 1,
		XtNgridWidth, 7,
		XtNgridHeight, 3,
		(char *)0);
	MwLabelSet(label, message);

	command = XtVaCreateManagedWidget("command",
		commandWidgetClass, topbox,
		XtNgridx, 4,
		XtNgridy, 5,
		XtNlabel, "OK",
		XtNwidth, 80,
		(char *)0);
	XtAddCallback(command, XtNcallback, alert_clicked, 0);

	status = MW_WAITING;
	MwCenter(alert);
	XtPopup(alert, XtGrabNonexclusive);
	wm_del(alert);
	while (status == MW_WAITING) {
		XEvent event_return;
		XtAppNextEvent(app_context, &event_return);
		XtDispatchEvent(&event_return);
	}
	XtDestroyWidget(alert);
}
Esempio n. 20
0
int GXDialog(Widget parent, char *msg, char *deft, char *buttons[],
	     int buttcnt, int DialType)
/*- 
  create and display a dialog, and wait for a response.  Implements its
  own event loop and does not return until there's a response or cancel.
 -*/
{
  Widget dial, DefaultButton;

  DialogDone = FALSE;

  dial = CreateDialog(parent, msg, deft, buttons, buttcnt, 
		      (XtCallbackProc)DialogCB, DialType); 
  /* display the dialog & wait for answer */
  /* moving the pointer to the window and back */
  {
    Window root, child;
    int root_x, root_y;
    int win_x, win_y;
    Dimension x, y, width, height;
    unsigned int mask;

    XQueryPointer(XtDisplay(toplevel), XtWindow(toplevel),
		  &root, &child,
		  &root_x, &root_y,
		  &win_x, &win_y,
		  &mask);
    XtVaGetValues(dial,
		  XmNdefaultButton, &DefaultButton,
		  NULL);
    if (DefaultButton) {

      XtVaGetValues(DefaultButton,
		    XmNwidth, &width,
		    XmNheight, &height,
		    XmNx, &x,
		    XmNy, &y,
		    NULL);

      XWarpPointer(XtDisplay(toplevel), 0, XtWindow(dial), 0, 0, 0, 0, x, y);
      while (DialogDone == FALSE) {
	static XEvent event;
	/*
	  XtAppProcessEvent(app_context, XtIMAll);
	  */
	XtAppNextEvent(app_context, &event);
	XtDispatchEvent(&event);
      }
      XWarpPointer(XtDisplay(toplevel), 0, XtWindow(toplevel), 0, 0,
		   0, 0, win_x, win_y); 
    }
    XtUnmanageChild(dial);
    return (DialogReturn);
  }
}
Esempio n. 21
0
static void combo_text_edit(Widget w, XtPointer p, XEvent *event, Boolean *n)
{
	MwComboWidget cw = (MwComboWidget)XtParent(w);
	char *old = MwTextFieldGetString(w);

	XtAddGrab(w, True, False);
	if (cw->combo.topLevel != None) {
		XtSetKeyboardFocus(cw->combo.topLevel, w);
	}
	XtVaSetValues(w,
		XtNdisplayCaret, True,
		(char *)0);
	combo_status = WAITING;
	while (combo_status == WAITING) {
		int count, bufsiz = 10;
		XEvent event;
		XtAppNextEvent(XtWidgetToApplicationContext(w), &event);
		if (event.type == KeyPress) {
			char buf[12];
			KeySym keysym;
			XKeyEvent kevent = event.xkey;
			count = XLookupString(&kevent,
				buf, bufsiz, &keysym, NULL);
			if (keysym == XK_Escape) combo_status = ABORT;
			else if (keysym == XK_Return) combo_status = DONE;
			else XtDispatchEvent(&event);
		} else {
			XtDispatchEvent(&event);
		}
	}
	XtVaSetValues(w,
		XtNdisplayCaret, False,
		(char *)0);
	XtRemoveGrab(w);
	if (cw->combo.topLevel) {
		XtSetKeyboardFocus(cw->combo.topLevel, None);
	}
	if (combo_status == ABORT)
		MwTextFieldSetString(w, old);
	XtCallCallbackList((Widget)cw, cw->combo.text_callbacks,
		(XtPointer)MwTextFieldGetString(w));
}
Esempio n. 22
0
void XttMotif::xtt_mainloop (XtAppContext AppCtx)
{
  XEvent Event;

  for (;;) {
    XtAppNextEvent( AppCtx, &Event);
    if (Event.type != KeyPress || 
        TkSUCCESS != hotkey_Process( HotkeyHandle, &Event)) 
      XtDispatchEvent( &Event);
  }
}
Esempio n. 23
0
void imagesc(void *data, int x, int y, const char* type,
             double (*transf)(double), const char **colormap, char *title)
{
  static XtAppContext context;
  Widget drawing_area;
  Widget toplevel;
  Atom wm_delete;
  XEvent event;
  XpmImage *xpmImage;
  Boolean exitFlag = False;
  static Display *display = NULL;
  Arg al[10];
  int ac;
  int argc = 0;

  xpmImage = CreateXpmImage(data, x, y, type, transf, colormap);

  /* create the toplevel shell */
  XtToolkitInitialize();
  if (display == NULL) {
    context = XtCreateApplicationContext();
    display = XtOpenDisplay(context, NULL, NULL, "", NULL, 0, &argc, NULL);
  }
  toplevel =XtAppCreateShell(title, "", applicationShellWidgetClass, display, NULL, 0);

  /* set window size. */
  ac=0;
  XtSetArg(al[ac],XmNmaxWidth,  x); ac++;
  XtSetArg(al[ac],XmNmaxHeight, y); ac++;
  XtSetArg(al[ac],XmNminWidth,  x); ac++;
  XtSetArg(al[ac],XmNminHeight, y); ac++;
  XtSetArg(al[ac],XmNdeleteResponse, XmDO_NOTHING); ac++;
  XtSetValues(toplevel,al,ac);

  ac=0;
  drawing_area=XmCreateDrawingArea(toplevel,"drawing_area",al,ac);
  XtManageChild(drawing_area);
  XtAddCallback(drawing_area,XmNexposeCallback,draw_pixmap,(XtPointer) xpmImage);
  XtAddEventHandler(drawing_area, KeyReleaseMask, false, KeyAction, (XtPointer) &exitFlag);
  XtRealizeWidget(toplevel);
  wm_delete = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False);
  XmAddWMProtocolCallback(toplevel, wm_delete, quitCB, (XtPointer) &exitFlag);
  XmActivateWMProtocol(toplevel, wm_delete);

  while (!exitFlag) {
    XtAppNextEvent(context, &event);
    XtDispatchEvent(&event);
  }

  XtDestroyWidget(drawing_area);
  XtDestroyWidget(toplevel);
  free(xpmImage);
}
Esempio n. 24
0
int UIInquireVector(Widget widget, XEvent *event, int x0, int y0, int *x1, int *y1) {
    XSetWindowAttributes xswa;
    XGCValues xgcv;
    static GC gc = (GC) NULL;
    static Cursor cursor[2] = {(Cursor) NULL, (Cursor) NULL};
    static int inLoop, cont, ret;

    if (cursor[0] == (Cursor) NULL) cursor[0] = XCreateFontCursor(XtDisplay(widget), XC_hand2);
    if (cursor[1] == (Cursor) NULL) cursor[1] = XCreateFontCursor(XtDisplay(widget), XC_top_left_arrow);
    if (gc == (GC) NULL) {
        xgcv.function = GXinvert;
        gc = XtGetGC(widget, GCFunction, &xgcv);
    }
    if (inLoop == false) {
        if (event->type != ButtonPress) return (false);
        inLoop = cont = true;
        ret = false;
        xswa.cursor = cursor[0];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        *x1 = event->xbutton.x;
        *y1 = event->xbutton.y;
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        do {
            XtAppNextEvent(UIApplicationContext(), event);
            XtDispatchEvent(event);
        } while (cont);
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        xswa.cursor = cursor[1];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        inLoop = false;
        return (ret);
    }
    else
        switch (event->type) {
            case ButtonRelease:
                xswa.cursor = cursor[1];
                XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
                ret = true;
                cont = false;
                break;
            case MotionNotify:
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                *x1 = event->xmotion.x;
                *y1 = event->xmotion.y;
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                break;
            case LeaveNotify:
                ret = false;
                cont = false;
                break;
        }
    return (false);
}
Esempio n. 25
0
/* force a statusline update, no matter how busy the application is.
   Use this with care (only for important messages).
*/
void
force_statusline_update(void)
{
#ifdef MOTIF
    XmUpdateDisplay(globals.widgets.top_level);
#else
    XEvent event;
    XSync(DISP, False);
    while (XCheckMaskEvent(DISP, ExposureMask, &event))
        XtDispatchEvent(&event);
#endif /* MOTIF */
}
Esempio n. 26
0
File: flush.c Progetto: armnlib/xrec
FlusherTousLesEvenements()
{
   XEvent theEvent;
   
   while (XtAppPending(SuperWidget.contexte))
      {
      XtAppNextEvent(SuperWidget.contexte, &(theEvent));
      XtDispatchEvent(&(theEvent));
      }

   XFlush(XtDisplay(SuperWidget.topLevel)); 
   XSync(XtDisplay(SuperWidget.topLevel), False);
   }
Esempio n. 27
0
void WNavMotif::wge_subwindow_loop( WGe *wge)
{
    XEvent 	Event;

    for (;;) {
        XtAppNextEvent( XtWidgetToApplicationContext( parent_wid), &Event);
        XtDispatchEvent( &Event);

        if ( wge->subwindow_release) {
            wge->subwindow_release = 0;
            break;
        }
    }
}
Esempio n. 28
0
static void
mf_events ()
{
  XEvent event;

  if (XtAppPending (mf_app) != 0)
    {
      while (XtAppPending (mf_app) != 0)
	{
	  XtAppNextEvent (mf_app, &event);
	  XtDispatchEvent (&event);
	}
    }
}
Esempio n. 29
0
/* force a statusline update, no matter how busy the application is.
   Use this with care (only for important messages).
*/
void
force_statusline_update(void)
{
#ifdef STATUSLINE
#ifdef MOTIF
    XmUpdateDisplay(top_level);
#else
    XEvent event;
    XSync(DISP, 0);
    while (XCheckMaskEvent(DISP, ExposureMask, &event))
        XtDispatchEvent(&event);
#endif
#endif    
}
Esempio n. 30
0
File: ssX.c Progetto: q3k/ski
void cmdLoopX(void)
{
    /* eclipse - replace XtAppMainLoop so that we can temporarily    */
    /* disable event processing (when we return from emulated code), */
    /* and reenable the ui when we enter emulated code again         */
    /* XtAppMainLoop(app_context); */

    XEvent Event;
    while( keepXLoopAlive || !getExited() ) {
	// Get event
	XtAppNextEvent(app_context, &Event);
	// Send non-intercepted events to their respective widgets.
	XtDispatchEvent(&Event);
    }
}