Exemplo n.º 1
0
void TimeoutProc (caddr_t client_data, XtIntervalId *id)
{
    WmTimer *pPrevTimer;
    WmTimer *pWmTimer;

    
    /*
     * Find out if the timer still needs to be serviced.
     */

    pPrevTimer = NULL;
    pWmTimer = wmGD.wmTimers;
    while (pWmTimer)
    {
	if (pWmTimer->timerId == *id)
	{
	    break;
	}
	pPrevTimer = pWmTimer;
	pWmTimer = pWmTimer->nextWmTimer;
    }

    if (pWmTimer)
    {
	/*
	 * Do the timer related action.
	 */

	switch (pWmTimer->timerType)
	{
	    case TIMER_QUIT:
	    {
		XKillClient (DISPLAY, pWmTimer->timerCD->client);
		break;
	    }

	    case TIMER_RAISE:
	    {
		Boolean sameScreen;

		if ((wmGD.keyboardFocus == pWmTimer->timerCD) &&
		    (pWmTimer->timerCD->focusPriority == 
			(PSD_FOR_CLIENT(pWmTimer->timerCD))->focusPriority) &&
		    (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) &&
		    (pWmTimer->timerCD == GetClientUnderPointer(&sameScreen)))
		{
		    Do_Raise (pWmTimer->timerCD, (ClientListEntry *)NULL, STACK_NORMAL);
		}
		break;
	    }
	}


	/*
	 * Remove the timer from the wm timer list.
	 */

	if (pPrevTimer)
	{
	    pPrevTimer->nextWmTimer = pWmTimer->nextWmTimer;
	}
	else
	{
	    wmGD.wmTimers = pWmTimer->nextWmTimer;
	}
	XtFree ((char *)pWmTimer);
    }

    /*
     * Free up the timer.
     */

    XtRemoveTimeOut (*id);


} /* END OF FUNCTION TimeoutProc */
Exemplo n.º 2
0
void SetKeyboardFocus (ClientData *pCD, long focusFlags)
{
    ClientData *currentFocus;

    
    /*
     * Don't set the keyboard input focus if it is already set to
     * the client window.
     */

    if (wmGD.keyboardFocus == pCD)
    {
	return;
    }
    currentFocus = wmGD.keyboardFocus;
    ACTIVE_PSD->focusPriority++;


    /*
     * If the keyboard input focus policy is "explicit" then reset the
     * selection button event handling.
     */

    if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
    {
	/*
	 * Reset explicit focus selection event tracking on the last focus
	 * window (reset the passive grab on the focus button).
	 */

	if (currentFocus)
	{
	    ResetExplicitSelectHandling (currentFocus);
	    wmGD.keyboardFocus = NULL;
	}
	
	if (pCD && ((pCD->clientState == NORMAL_STATE) ||
		    (pCD->clientState == MAXIMIZED_STATE)))
	{
	    /*
	     * The focus is to be set to a client window (not the root).
	     * Stop explicit focus selection event tracking on the new focus
	     * window.
	     */

	    if (removeSelectGrab)
	    {
	        WmUngrabButton (DISPLAY, FOCUS_SELECT_BUTTON, 0,
		    pCD->clientBaseWin);
	    }
        }
    }
    
    wmGD.keyboardFocus = pCD;


    /*
     * Do focus auto raise if specified.
     */

    if (pCD && pCD->focusAutoRaise)
    {
	if (wmGD.autoRaiseDelay &&
	    (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER))
	{
	    AddWmTimer (TIMER_RAISE, (unsigned long)wmGD.autoRaiseDelay,
		pCD);
	}
	else
	{
	    Boolean sameScreen;

	    if (((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT) &&
		 (!pCD->focusAutoRaiseDisabled)) ||
		((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) &&
		 (pCD == GetClientUnderPointer (&sameScreen))))
	    {
	        Do_Raise (pCD, (ClientListEntry *)NULL, STACK_NORMAL);
	    }
	}
    }


    /*
     * Clear the focus indication if it is set for a client window or icon.
     */

    if (currentFocus)
    {
	ClearFocusIndication (currentFocus,
	    ((focusFlags & REFRESH_LAST_FOCUS) ? True : False));
    }


    /*
     * Install the client window colormap if the colormap focus policy is
     * "keyboard".
     */

    if ((wmGD.colormapFocusPolicy == CMAP_FOCUS_KEYBOARD) &&
	(!(focusFlags & SCREEN_SWITCH_FOCUS)))
    {
	SetColormapFocus (ACTIVE_PSD, pCD);
    }


    /*
     * Set the focus window or icon visual indication.
     */

    if (pCD)
    {
	pCD->focusPriority = ACTIVE_PSD->focusPriority;
	SetFocusIndication (pCD);
    }

} /* END OF FUNCTION SetKeyboardFocus */