示例#1
0
文件: MwDialog.c 项目: UlricE/Mowitz
void MwStderrRedir(Widget pw)
{
	int fd[2];

	pipe(fd);
	XtAppAddInput(XtWidgetToApplicationContext(pw),
		fd[0], (XtPointer)XtInputReadMask,
		(XtInputCallbackProc)stderr_input, pw);
	dup2(fd[1], 2);
	close(fd[1]);
}
示例#2
0
static void 
error(Widget w, char *string)
{
    char buf[100];
#ifdef __GLX_MOTIF
    sprintf (buf, "SoGLwMDrawingArea: %s\n", string);
#else
    sprintf (buf, "SoGLwDrawingArea: %s\n", string);
#endif
    XtAppError(XtWidgetToApplicationContext(w), buf);
}
示例#3
0
文件: Eyes.c 项目: aosm/X11
/* ARGSUSED */
static void draw_it (
     XtPointer client_data,
     XtIntervalId *id)		/* unused */
{
        EyesWidget	w = (EyesWidget)client_data;
	Window		rep_root, rep_child;
	int		rep_rootx, rep_rooty;
	unsigned int	rep_mask;
	int		dx, dy;
	TPoint		mouse;
	Display		*dpy = XtDisplay (w);
	Window		win = XtWindow (w);
	TPoint		newpupil[2];
	XPoint		xnewpupil, xpupil;

	if (XtIsRealized((Widget)w)) {
    		XQueryPointer (dpy, win, &rep_root, &rep_child,
 			&rep_rootx, &rep_rooty, &dx, &dy, &rep_mask);
		mouse.x = Tx(dx, dy, &w->eyes.t);
		mouse.y = Ty(dx, dy, &w->eyes.t);
		if (!TPointEqual (mouse, w->eyes.mouse)) {
			computePupils (mouse, newpupil);
			xpupil.x = Xx(w->eyes.pupil[0].x, w->eyes.pupil[0].y, &w->eyes.t);
			xpupil.y = Xy(w->eyes.pupil[0].x, w->eyes.pupil[0].y, &w->eyes.t);
			xnewpupil.x =  Xx(newpupil[0].x, newpupil[0].y, &w->eyes.t);
			xnewpupil.y =  Xy(newpupil[0].x, newpupil[0].y, &w->eyes.t);
			if (!XPointEqual (xpupil, xnewpupil)) {
			    if (w->eyes.pupil[0].x != -1000 || w->eyes.pupil[0].y != -1000)
				eyeBall (w, w->eyes.centerGC, 0);
			    w->eyes.pupil[0] = newpupil[0];
			    eyeBall (w, w->eyes.pupGC, 0);
			}
			xpupil.x = Xx(w->eyes.pupil[1].x, w->eyes.pupil[1].y, &w->eyes.t);
			xpupil.y = Xy(w->eyes.pupil[1].x, w->eyes.pupil[1].y, &w->eyes.t);
			xnewpupil.x =  Xx(newpupil[1].x, newpupil[1].y, &w->eyes.t);
			xnewpupil.y =  Xy(newpupil[1].x, newpupil[1].y, &w->eyes.t);
			if (!XPointEqual (xpupil, xnewpupil)) {
			    if (w->eyes.pupil[1].x != -1 || w->eyes.pupil[1].y != -1)
				eyeBall (w, w->eyes.centerGC, 1);
			    w->eyes.pupil[1] = newpupil[1];
			    eyeBall (w, w->eyes.pupGC, 1);
			}
			w->eyes.mouse = mouse;
			w->eyes.update = 0;
		} else {
			if (delays[w->eyes.update + 1] != 0)
				++w->eyes.update;
		}
	}
	w->eyes.interval_id =
		XtAppAddTimeOut(XtWidgetToApplicationContext((Widget) w),
				delays[w->eyes.update], draw_it, (XtPointer)w);
} /* draw_it */
示例#4
0
// Select a file
static void select_file(const string& /* question */, string& reply)
{
    gdbOpenFileCB(find_shell(), 0, 0);

    open_file_reply = "";
    while (open_file_reply.empty() 
	   && gdb->running() && !gdb->isReadyWithPrompt())
	XtAppProcessEvent(XtWidgetToApplicationContext(gdb_w), XtIMAll);

    // Found a reply - return
    reply = open_file_reply + "\n";
}
示例#5
0
int child_start(Widget top, char *cmd, void (*cb)(int) )
{
    int hc = child_init(cmd, 0);
    struct child_stat *child = mls(CLIST, hc);
    child->cb = cb;
    child_exec(hc);
    child->id = XtAppAddInput(XtWidgetToApplicationContext(top),
                              child_read_fd(hc),
                              (XtPointer)  (XtInputReadMask),
                              child_input_cb,(XtPointer) hc );
    return hc;
}
示例#6
0
void SubGraphsMotif::trace_scan( SubGraphsMotif *subgraphs)
{
  int time = 200;

  if ( subgraphs->trace_started) {
    brow_TraceScan( subgraphs->brow->ctx);

    ((SubGraphsMotif *)subgraphs)->trace_timerid = XtAppAddTimeOut(
	XtWidgetToApplicationContext( subgraphs->brow_widget), time,
	(XtTimerCallbackProc)SubGraphsMotif::trace_scan, subgraphs);
  }
}
示例#7
0
static void
ShapeError(Widget w)
{
    String params[1];
    Cardinal num_params = 1;

    params[0] = XtName(w);
  XtAppWarningMsg(XtWidgetToApplicationContext(w),
		     "shapeUnknown", "xmuReshapeWidget", "XmuLibrary",
		     "Unsupported shape style for Command widget \"%s\"",
		  params, &num_params);
}
示例#8
0
/*!
* \ingroup	HGU_GL
* \brief	Calls the trackball animation function without setting
*		the trackball mode to HGUglwCANVASTB_MODE_ANIMATION so
*		that a single update is done.
* \param	givenW			Widget instance.
*/
void		HGUglwCanvasTbUpdate(Widget givenW)
{
  HGUglwCanvasTbWidget tbW;

  if(givenW)
  {
    tbW = (HGUglwCanvasTbWidget )givenW;
    (void )XtAppAddTimeOut(XtWidgetToApplicationContext(givenW),
			   1,
    			   HGUglwCanvasTbAnimateFn,
    			   (XtPointer )tbW);
  }
}
示例#9
0
/* ARGSUSED */
static void draw_it (
     XtPointer client_data,
     XtIntervalId *id)		/* unused */
{
        EyesWidget	w = (EyesWidget)client_data;

	if (XtIsRealized((Widget)w)) {
	        draw_it_core(w);
	}
	w->eyes.interval_id =
		XtAppAddTimeOut(XtWidgetToApplicationContext((Widget) w),
				delays[w->eyes.update], draw_it, (XtPointer)w);
} /* draw_it */
示例#10
0
void WNavMotif::trace_scan( WNavMotif *wnav)
{
    int time = 1000;

    if ( wnav->trace_started)
    {
        brow_TraceScan( wnav->brow->ctx);

        wnav->trace_timerid = XtAppAddTimeOut(
                                  XtWidgetToApplicationContext(wnav->brow_widget) , time,
                                  (XtTimerCallbackProc)WNavMotif::trace_scan, wnav);
    }
}
示例#11
0
static void DeletePlotterHP(Agent *plotter, void *client_data, void *)
{
    // Plotter has died - delete memory
    XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
		    DeletePlotterCB, XtPointer(plotter));

    plotter->removeHandler(Died, DeletePlotterHP, client_data);

    PlotWindowInfo *plot = (PlotWindowInfo *)client_data;
    assert(plot->plotter == 0 || plot->plotter == plotter);
    plot->plotter = 0;
    popdown_plot_shell(plot);
}
示例#12
0
void WFoeMotif::popdown_pop( Widget w, WFoe *foe, XmAnyCallbackStruct *data)
{
  XtIntervalId		TimerID;

  if ( foe->popupmenu_node != 0) {
    /* Wait some time and take away select if nobody
       else has done that */
    TimerID = XtAppAddTimeOut( 
	        XtWidgetToApplicationContext(((WFoeMotif *)foe)->parent_wid),
		300, (XtTimerCallbackProc)reset_current_node, foe);
  }
  foe->normal_cursor();	
}
示例#13
0
void AttrNavMotif::trace_scan( AttrNav *attrnav)
{
    int time = 200;

    if ( attrnav->trace_started)
    {
        brow_TraceScan( attrnav->brow->ctx);

        ((AttrNavMotif *)attrnav)->trace_timerid = XtAppAddTimeOut(
                    XtWidgetToApplicationContext( ((AttrNavMotif *)attrnav)->brow_widget) , time,
                    (XtTimerCallbackProc)AttrNavMotif::trace_scan, attrnav);
    }
}
示例#14
0
void WGreMotif::trace_scan( WGreMotif *gre)
{
  if ( gre->trace_started)
  {


    flow_TraceScan( gre->flow_ctx);

    gre->trace_timerid = XtAppAddTimeOut(
	XtWidgetToApplicationContext(gre->flow_widget) ,500,
	(XtTimerCallbackProc)trace_scan, gre);
  }
}
示例#15
0
文件: List.c 项目: aosm/X11
static void
XawListResize(Widget w)
{
    Dimension width, height;

    width = XtWidth(w);
    height = XtHeight(w);

    if (Layout(w, False, False, &width, &height))
	XtAppWarning(XtWidgetToApplicationContext(w),
		     "List Widget: Size changed when it shouldn't "
		     "have when resising.");
}
示例#16
0
static void gdbEditDoneHP(Agent *edit_agent, void *, void *)
{
    // Editor has terminated: reload current source file

    XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
		    gdbDeleteEditAgent, 
		    XtPointer(edit_agent));

    gdbReloadSourceCB(gdb_w, 0, 0);

    edit_agent->removeHandler(InputEOF, gdbEditDoneHP);
    edit_agent->removeHandler(Died,     gdbEditDoneHP);
}
示例#17
0
static void wdanav_trace_scan( WdaNavMotif *wdanav)
{
    int time = 200;

    if ( wdanav->trace_started)
    {
        brow_TraceScan( wdanav->brow->ctx);

        wdanav->trace_timerid = XtAppAddTimeOut(
                                    XtWidgetToApplicationContext(wdanav->brow_widget) , time,
                                    (XtTimerCallbackProc)wdanav_trace_scan, wdanav);
    }
}
示例#18
0
static
void   UngrabKeyOrButton (
    Widget	widget,
    int		keyOrButton,
    Modifiers	modifiers,
    Boolean	isKeyboard)
{
    XtServerGrabRec 	tempGrab;
    XtPerWidgetInput	pwi;

    XtCheckSubclass(widget, coreWidgetClass,
		    "in XtUngrabKey or XtUngrabButton");

    /* Build a temporary grab list entry */
    tempGrab.widget = widget;
    tempGrab.modifiers = modifiers;
    tempGrab.keybut = keyOrButton;
    tempGrab.hasExt = False;

    LOCK_PROCESS;
    pwi = _XtGetPerWidgetInput(widget, FALSE);
    UNLOCK_PROCESS;
    /*
     * if there is no entry in the context manager then somethings wrong
     */
    if (!pwi)
      {
	  XtAppWarningMsg(XtWidgetToApplicationContext(widget),
		       "invalidGrab", "ungrabKeyOrButton", XtCXtToolkitError,
		       "Attempt to remove nonexistent passive grab",
		       (String *)NULL, (Cardinal *)NULL);
	  return;
      }

    if (XtIsRealized(widget))
      {
	  if (isKeyboard)
	    XUngrabKey(widget->core.screen->display,
		       keyOrButton, (unsigned int)modifiers,
		       widget->core.window);
	  else
	    XUngrabButton(widget->core.screen->display,
			  keyOrButton, (unsigned int)modifiers,
			  widget->core.window);
      }


    /* Delete all entries which are encompassed by the specified grab. */
    DeleteServerGrabFromList(isKeyboard ? &pwi->keyList : &pwi->ptrList,
			     &tempGrab);
}
示例#19
0
// Veto key-based cursor movements before current line
void gdbMotionCB(Widget, XtPointer, XtPointer call_data)
{
    if (private_gdb_output)
	return;

    XmTextVerifyCallbackStruct *change = 
	(XmTextVerifyCallbackStruct *)call_data;

    if (isearch_state != ISEARCH_NONE)
    {
	if (!isearch_motion_ok)
	{
	    XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
			    clear_isearch_after_motion, XtPointer(0));
	}
	isearch_motion_ok = false;
    }

    if (change->event != 0
	&& (change->event->type == KeyPress 
	    || change->event->type == KeyRelease))
    {
	if (change->newInsert < promptPosition)
	{
	    // We are before the current prompt: don't change the cursor
	    // position if a key was pressed.
#if 0
	    // With Motif, this causes a core dump on Solaris.  - AZ
	    change->doit = false;
#else
	    // Make it a no-op.
	    XtCallActionProc(gdb_w, "beep", change->event, 0, 0);
	    XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
			    move_to_end_of_line, 0);
#endif
	}
    }
}
示例#20
0
文件: GetValues.c 项目: aosm/X11libs
void XtGetValues(
    register Widget   w,
    register ArgList  args,
    register Cardinal num_args)
{
    WidgetClass wc;
    int targ;
    XtAppContext app = XtWidgetToApplicationContext(w);

    if (num_args == 0) return;
    if ((args == NULL) && (num_args != 0)) {
	XtAppErrorMsg(app,
		"invalidArgCount","xtGetValues",XtCXtToolkitError,
            "Argument count > 0 on NULL argument list in XtGetValues",
              (String *)NULL, (Cardinal *)NULL);
    }

    LOCK_APP(app);
    wc = XtClass(w);
    LOCK_PROCESS;
    /* Get widget values */
    targ = GetValues((char*)w, (XrmResourceList *) wc->core_class.resources,
	wc->core_class.num_resources, args, num_args);
    UNLOCK_PROCESS;
    if (targ != -1 && XtIsWidget(w)) {
	XtTranslations translations = _XtGetTranslationValue(w);
	_XtCopyToArg((char*)&translations, &args[targ].value,
		     sizeof(XtTranslations));
    }

    /* Get constraint values if necessary */
    /* constraints may be NULL if constraint_size==0 */
    if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)) &&
	w->core.constraints) {
	ConstraintWidgetClass cwc
	    = (ConstraintWidgetClass) XtClass(XtParent(w));
	LOCK_PROCESS;
	GetValues((char*)w->core.constraints,
		  (XrmResourceList *)(cwc->constraint_class.resources),
		  cwc->constraint_class.num_resources, args, num_args);
	UNLOCK_PROCESS;
    }
    /* Notify any class procedures that we have performed get_values */
    CallGetValuesHook(wc, w, args, num_args);

    /* Notify constraint get_values if necessary */
    if (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)))
	CallConstraintGetValuesHook(XtClass(XtParent(w)), w, args,num_args);
    UNLOCK_APP(app);
} /* XtGetValues */
示例#21
0
/*
** PopDownBugPatch
**
** Under some circumstances, popping down a dialog and its parent in
** rapid succession causes a crash.  This routine delays and
** processs events until receiving a ReparentNotify event.
** (I have no idea why a ReparentNotify event occurs at all, but it does
** mark the point where it is safe to destroy or pop down the parent, and
** it might have something to do with the bug.)  There is a failsafe in
** the form of a ~1.5 second timeout in case no ReparentNotify arrives.
** Use this sparingly, only when real crashes are observed, and periodically
** check to make sure that it is still necessary.
*/
void PopDownBugPatch(Widget w)
{
    time_t stopTime;

    stopTime = time(NULL) + 1;
    while (time(NULL) <= stopTime) {
    	XEvent event;
    	XtAppContext context = XtWidgetToApplicationContext(w);
    	XtAppPeekEvent(context, &event);
    	if (event.xany.type == ReparentNotify)
    	    return;
    	XtAppProcessEvent(context, XtIMAll);
    }
}
示例#22
0
/*ARGSUSED*/
static void
HintsTimer(XtPointer closure, XtIntervalId *id)
{
    Arg args[1];
    xedit_hints *hints = (xedit_hints*)closure;

    hints->cur_hint = rand() % hints->num_hints;

    XtSetArg(args[0], XtNlabel, hints->hints[hints->cur_hint]);
    XtSetValues(hintswindow, args, 1);

    hints->timer = XtAppAddTimeOut(XtWidgetToApplicationContext(topwindow),
				   hints->interval, HintsTimer, closure);
}
示例#23
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;
        }
    }
}
示例#24
0
static void motTimerRun(Ihandle *n)
{
  unsigned int time_ms;

  if(number(n) > 0) /* timer already started */
    return;
  
  time_ms = IupGetInt(n, IUP_TIME);
  if(time_ms > 0)
  {
    XtAppContext context = XtWidgetToApplicationContext(iupmot_initialwidget);
    number(n) = XtAppAddTimeOut(context, time_ms, motTimerProc, (XtPointer) n);
  }
}
示例#25
0
static void
StartHints(void)
{
    char *str, *p;
    unsigned i, len;
    xedit_hints *hints = &(app_resources.hints);

    /* if resource was not set, or was overriden */
    if (hints->resource == NULL || !*hints->resource)
	return;

    randomize();

    if (hints->interval < MIN_HINT_INTERVAL)
	hints->interval = DEF_HINT_INTERVAL;
    hints->interval *= 1000;
    hints->hints = (char**)XtMalloc(sizeof(char*));
    hints->hints[hints->cur_hint = 0] = p = hints->resource;
    hints->num_hints = 1;

    while ((p = strchr(p, '\n')) != NULL) {
	if (*++p == '\0')
	    break;
	hints->hints = (char**)
	    XtRealloc((char*)hints->hints,
		      sizeof(char*) * (hints->num_hints + 1));
	hints->hints[hints->num_hints++] = p;
    }

    /* make a private copy of the resource values, so that one can change
     * the Xrm database safely.
     */
    for (i = 0; i < hints->num_hints; i++) {
	if ((p = strchr(hints->hints[i], '\n')) != NULL)
	    len = p - hints->hints[i];
	else
	    len = strlen(hints->hints[i]);
	if (len > MAX_HINT_LEN)
	    len = MAX_HINT_LEN;
	str = XtMalloc(len + 1);
	strncpy(str, hints->hints[i], len);
	str[len] = '\0';
	hints->hints[i] = str;
    }

    hints->timer = XtAppAddTimeOut(XtWidgetToApplicationContext(topwindow),
				   hints->interval, HintsTimer,
				   (XtPointer)hints);
}
示例#26
0
int child_startv(Widget top, int cmd_m, void (*cb)(int) )
{
    int l = m_len(cmd_m);
    int i;
    int hc = child_init(STR(cmd_m,0), 0);
    struct child_stat *child = mls(CLIST, hc);
    child->cb = cb;
    for(i=1;i<l;i++) v_kset(child->args, STR(cmd_m, i), -1 );
    child_exec(hc);
    child->id = XtAppAddInput(XtWidgetToApplicationContext(top),
                              child_read_fd(hc),
                              (XtPointer)  (XtInputReadMask),
                              child_input_cb,(XtPointer) hc );
    return hc;
}
示例#27
0
文件: Resources.c 项目: aosm/X11libs
void _XtCopyFromParent(
    Widget      widget,
    int		offset,
    XrmValue    *value)
{
    if (widget->core.parent == NULL) {
	XtAppWarningMsg(XtWidgetToApplicationContext(widget),
		"invalidParent","xtCopyFromParent",XtCXtToolkitError,
                  "CopyFromParent must have non-NULL parent",
		  (String *)NULL, (Cardinal *)NULL);
        value->addr = NULL;
        return;
    }
    value->addr = (XPointer)(((char *)widget->core.parent) + offset);
} /* _XtCopyFromParent */
示例#28
0
void
AutoWait( int count )
{

    AutoTimeOut = True;

    XtAppAddTimeOut(XtWidgetToApplicationContext(Shell1),
		    count * 1000,
		    AutoTimeoutProc,
		    NULL);

    while (AutoTimeOut == True)
	xisSynchronize();

}
示例#29
0
void WNavMotif::wge_modal_loop( WGe *wge)
{
    XEvent 	Event;

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

        if ( wge->terminated) {
            appl.remove( (void *)wge);
            delete wge;
            break;
        }
    }
}
示例#30
0
void WaitNoExposes (Widget w)
{
  XEvent	event;
  Display *	display;
  XtAppContext	app;
  Window	win;

  win	  = XtWindow(w);
  display = XtDisplay(w);
  app     = XtWidgetToApplicationContext(w);
  XFlush(display);
  while (XCheckTypedWindowEvent(display, win, ExposureMask, &event)) {
    XtAppNextEvent(app, &event);
    XtDispatchEvent(&event);
  }
}