コード例 #1
0
ファイル: Ident.c プロジェクト: Remmy/afterstep
/**********************************************************************
 * If no application window was indicated on the command line, prompt
 * the user to select one
 *********************************************************************/
Window
get_target_window ()
{
	XEvent eventp;
	int val = -10, trials;
	Window target = None;

	trials = 0;
	while ((trials < 100) && (val != GrabSuccess))
    {
		val = XGrabPointer (dpy, Scr.Root, True,
				  		   	ButtonReleaseMask,
			  				GrabModeAsync, GrabModeAsync, Scr.Root,
			  				XCreateFontCursor (dpy, XC_crosshair),
			  				CurrentTime);
      	if( val != GrabSuccess )
			sleep_a_little (100);
		trials++;
    }
  	if (val != GrabSuccess)
    {
    	show_error( "Couldn't grab the cursor!\n", MyName);
      	DeadPipe(0);
    }
  	XMaskEvent (dpy, ButtonReleaseMask, &eventp);
  	XUngrabPointer (dpy, CurrentTime);
  	ASSync(0);
  	target = eventp.xbutton.window;
	LOCAL_DEBUG_OUT( "window = %lX, root = %lX, subwindow = %lX", 
					 eventp.xbutton.window, eventp.xbutton.root, eventp.xbutton.subwindow );
  	if( eventp.xbutton.subwindow != None )
    	target = eventp.xbutton.subwindow;
	return target;
}
コード例 #2
0
ファイル: complex.c プロジェクト: rn10950/FVWM95-Updated
/*****************************************************************************
 *
 * Waits Scr.ClickTime, or until it is evident that the user is not
 * clicking, but is moving the cursor
 *
 ****************************************************************************/
Bool IsClick(int x, int y, unsigned EndMask, XEvent * d)
{
    int xcurrent, ycurrent, total = 0;
    Time t0;
    extern Time lastTimestamp;

    xcurrent = x;
    ycurrent = y;
    t0 = lastTimestamp;

    while ((total < Scr.ClickTime) &&
            (x - xcurrent < 3) && (x - xcurrent > -3) &&
            (y - ycurrent < 3) && (y - ycurrent > -3) &&
            ((lastTimestamp - t0) < Scr.ClickTime)) {
        sleep_a_little(20000);
        total += 20;
        if (XCheckMaskEvent(dpy, EndMask, d)) {
            StashEventTime(d);
            return True;
        }
        if (XCheckMaskEvent(dpy, ButtonMotionMask | PointerMotionMask, d)) {
            xcurrent = d->xmotion.x_root;
            ycurrent = d->xmotion.y_root;
            StashEventTime(d);
        }
    }
    return False;
}
コード例 #3
0
ファイル: misc.c プロジェクト: morgant/mlvwm
void DrawErrMsgOnMenu( char *str1, char *str2 )
{
	char *str;
	static int call=0;
	int wait_s;

	call++;
	str = calloc( strlen(str1)+strlen(str2)+1, 1 );
	sprintf( str, "%s%s", str1, str2 );
	if( call<5 )	XBell( dpy, 30 );
	DrawStringMenuBar( str );
	wait_s = 3000000-call/5*500000;
	wait_s = wait_s>0? wait_s : 300000;
	sleep_a_little( wait_s );
	free( str );
}