Пример #1
0
bool
KeyboardNavigation::initiate (CompAction         *action,
                              CompAction::State  state,
                              CompOption::Vector &option,
                              FocusDirection     direction)
{
    CompWindow *window = screen->findWindow( screen->activeWindow() );

    if (window) {
        /* Don't allow focus change for certain special windows */
        if (window->overrideRedirect() ||
            (window->type() & (CompWindowTypeDesktopMask |
                               CompWindowTypeDockMask)))
        {
            return false;
        }

        DEBUG_LOG("Initiating search for nearest window: " << direction);

        NearestWindow nearestWindow (window, direction);

        screen->forEachWindow( boost::bind(
                &KeyboardNavigation::NearestWindow::inspectWindow,
                &nearestWindow, _1
                ) );

        CompWindow *focusWindow = nearestWindow.result();

        if (focusWindow != NULL) {
            DEBUG_LOG("Found focusWindow: " << focusWindow->id() << " " <<
                      focusWindow->x() << "x" << focusWindow->y());

            focusWindow->moveInputFocusTo();
            focusWindow->activate();

            return true;
        }
        else {
            DEBUG_LOG("Unable to find focus window!");
        }
    }

    return false;
}
Пример #2
0
bool
StackDebugger::checkSanity (CompWindowList &serverWindows, bool verbose)
{
    int current = 0xffffffff;
    int oldCurrent = current;
    bool err = false;

    if (verbose)
	compLogMessage ("stackdebugger", CompLogLevelDebug, "processing new stack --------");

    /* go backwards down the stack */
    for (CompWindowList::reverse_iterator rit = serverWindows.rbegin ();
	 rit != serverWindows.rend (); ++rit)
    {
	CompWindow *w = (*rit);

	/* Override redirect windows set all kinds
	 * of crazy stuff and are required to stack
	 * themselves so skip those */
	if (w->overrideRedirect ())
	    continue;

	/* ignore non-override redirect unmanaged windows */
	if (!w->managed ())
	    continue;

	/* ignore any windows that just got created */
	if (!w->mapNum ())
	    continue;

	/* determine the current layer */
	if (w->type () == CompWindowTypeDockMask)
	{
	    if ((current & DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
			   DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
	    {
		bool fullscreenWindow = false;

		/* search down the stack to check if there is a fullscreen
		 * window, otherwise we are not on the fullscreen layer */
		for (CompWindow *rw = w->prev; rw; rw = rw->prev)
		{
		    if (rw->type () & CompWindowTypeFullscreenMask)
		    {
			fullscreenWindow = true;
			break;
		    }
		}

		/* if there is no fullscreen window, change the layer */
		if (!fullscreenWindow)
		    err |= setCurrentLayer (w->id (), DOCKS, current);
		else
		    err |= setCurrentLayer (w->id (), DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN, current);
	    }
	    else if (w->state () & CompWindowStateBelowMask)
		err |= setCurrentLayer (w->id (), DOCKS_BELOW, current);
	    else
		err |= setCurrentLayer (w->id (), DOCKS, current);
	}
	else if (w->type () == CompWindowTypeFullscreenMask)
	{
	    err |= setCurrentLayer (w->id (), FULLSCREEN, current);
	}
	else if (w->type () == CompWindowTypeDesktopMask)
	{
	    err |= setCurrentLayer (w->id (), DESKTOP, current);
	}
	/* everything else that is not a fullscreen window or a desktop */
	else
	{
	    if (w->state () & CompWindowStateAboveMask)
	    {
		if ((current & KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
			       KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
		{
		    bool fullscreenWindow = false;

		    /* search down the stack to check if there is a fullscreen
		     * window, otherwise we are not on the fullscreen layer */
		    for (CompWindow *rw = w->prev; rw; rw = rw->prev)
		    {
			if (rw->type () & CompWindowTypeFullscreenMask)
			{
			    fullscreenWindow = true;
			    break;
			}
		    }

		    if (!fullscreenWindow)
			err |= setCurrentLayer (w->id (), KEEP_ABOVE, current);
		    else
			err |= setCurrentLayer (w->id (), KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN, current);
		}
		else
		    err |= setCurrentLayer (w->id (), KEEP_ABOVE, current);
	    }
	    else if (w->state () & CompWindowStateBelowMask)
		err |= setCurrentLayer (w->id (), KEEP_BELOW, current);
	    else
	    {
		if ((current & TOPLEVELS_ABOVE_FULLSCREEN) ==
			       TOPLEVELS_ABOVE_FULLSCREEN)
		{
		    bool fullscreenWindow = false;

		    /* search down the stack to check if there is a fullscreen
		     * window, otherwise we are not on the fullscreen layer */
		    for (CompWindow *rw = w->prev; rw; rw = rw->prev)
		    {
			if (rw->type () & CompWindowTypeFullscreenMask)
			{
			    fullscreenWindow = true;
			    break;
			}
		    }

		    if (!fullscreenWindow)
			err |= setCurrentLayer (w->id (), TOPLEVELS, current);
		    else
			err |= setCurrentLayer (w->id (), TOPLEVELS_ABOVE_FULLSCREEN, current);
		}
		else
		    err |= setCurrentLayer (w->id (), TOPLEVELS, current);
	    }
	}

	if ((current & DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
		       DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN");
	}
	else if ((current & KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
			    KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN");
	}
	else if ((current & TOPLEVELS_ABOVE_FULLSCREEN) == TOPLEVELS_ABOVE_FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer TOPLEVELS_ABOVE_FULLSCREEN");
	}
	else if ((current & FULLSCREEN) == FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer FULLSCREEN");
	}
	else if ((current & DOCKS) == DOCKS)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DOCKS");
	}
	else if ((current & KEEP_ABOVE) == KEEP_ABOVE)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer KEEP_ABOVE");
	}
	else if ((current & TOPLEVELS) == TOPLEVELS)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer TOPLEVELS");
	}
	else if ((current & DOCKS_BELOW) == DOCKS_BELOW)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DOCKS_BELOW");
	}
	else if ((current & KEEP_BELOW) == KEEP_BELOW)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer KEEP_BELOW");
	}
	else if ((current & DESKTOP) == DESKTOP)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DESKTOP");
	}

	oldCurrent = current;
    }

    return err;
}