KWin
Loading...
Searching...
No Matches
Public Types | Public Slots | Public Member Functions | List of all members
KWin::FocusChain Class Reference

Singleton class to handle the various focus chains. More...

#include <focuschain.h>

Inheritance diagram for KWin::FocusChain:

Public Types

enum  Change { MakeFirst , MakeLast , Update , MakeFirstMinimized = MakeFirst }
 

Public Slots

void remove (KWin::Window *window)
 Removes window from all focus chains.
 
void setSeparateScreenFocus (bool enabled)
 
void setActiveWindow (KWin::Window *window)
 
void setCurrentDesktop (VirtualDesktop *desktop)
 
void addDesktop (VirtualDesktop *desktop)
 
void removeDesktop (VirtualDesktop *desktop)
 

Public Member Functions

 FocusChain ()=default
 
void update (Window *window, Change change)
 Updates the position of the window according to the requested change in the focus chain.
 
void moveAfterWindow (Window *window, Window *reference)
 Moves window behind the reference Window in all focus chains.
 
WindowgetForActivation (VirtualDesktop *desktop) const
 Finds the best Window to become the new active Window in the focus chain for the given virtual desktop.
 
WindowgetForActivation (VirtualDesktop *desktop, Output *output) const
 Finds the best Window to become the new active Window in the focus chain for the given virtual desktop on the given screen.
 
bool contains (Window *window) const
 Checks whether the most recently used focus chain contains the given window.
 
bool contains (Window *window, VirtualDesktop *desktop) const
 Checks whether the focus chain for the given desktop contains the given window.
 
WindownextMostRecentlyUsed (Window *reference) const
 Queries the most recently used focus chain for the next Window after the given reference Window.
 
WindownextForDesktop (Window *reference, VirtualDesktop *desktop) const
 Queries the focus chain for desktop for the next Window in relation to the given reference Window.
 
WindowfirstMostRecentlyUsed () const
 Returns the first Window in the most recently used focus chain. First Window in this case means really the first Window in the chain and not the most recently used Window.
 
bool isUsableFocusCandidate (Window *window, Window *prev) const
 

Detailed Description

Singleton class to handle the various focus chains.

A focus chain is a list of Windows containing information on which Window should be activated.

Internally this FocusChain holds multiple independent chains. There is one chain of most recently used Windows which is primarily used by TabBox to build up the list of Windows for navigation. The chains are organized as a normal QList of Windows with the most recently used Window being the last item of the list, that is a LIFO like structure.

In addition there is one chain for each virtual desktop which is used to determine which Window should get activated when the user switches to another virtual desktop.

Furthermore this class contains various helper methods for the two different kind of chains.

Definition at line 38 of file focuschain.h.

Member Enumeration Documentation

◆ Change

Enumerator
MakeFirst 
MakeLast 
Update 
MakeFirstMinimized 

Definition at line 42 of file focuschain.h.

Constructor & Destructor Documentation

◆ FocusChain()

KWin::FocusChain::FocusChain ( )
explicitdefault

Member Function Documentation

◆ addDesktop

void KWin::FocusChain::addDesktop ( VirtualDesktop * desktop)
slot

Definition at line 26 of file focuschain.cpp.

◆ contains() [1/2]

bool KWin::FocusChain::contains ( Window * window) const
inline

Checks whether the most recently used focus chain contains the given window.

Does not consider the per-desktop focus chains.

Parameters
windowThe Window to look for.
Returns
bool true if the most recently used focus chain contains window, false otherwise.

Definition at line 209 of file focuschain.h.

◆ contains() [2/2]

bool KWin::FocusChain::contains ( Window * window,
VirtualDesktop * desktop ) const

Checks whether the focus chain for the given desktop contains the given window.

Does not consider the most recently used focus chain.

Parameters
windowThe Window to look for.
desktopThe virtual desktop whose focus chain should be used
Returns
bool true if the focus chain for desktop contains window, false otherwise.

Definition at line 229 of file focuschain.cpp.

◆ firstMostRecentlyUsed()

Window * KWin::FocusChain::firstMostRecentlyUsed ( ) const

Returns the first Window in the most recently used focus chain. First Window in this case means really the first Window in the chain and not the most recently used Window.

Returns
:X11Window *The first Window in the most recently used chain.

Definition at line 170 of file focuschain.cpp.

◆ getForActivation() [1/2]

Window * KWin::FocusChain::getForActivation ( VirtualDesktop * desktop) const

Finds the best Window to become the new active Window in the focus chain for the given virtual desktop.

In case that separate screen focus is used only Windows on the current screen are considered. If no Window for activation is found null is returned.

Parameters
desktopThe virtual desktop to look for a Window for activation
Returns
:X11Window *The Window which could be activated or null if there is none.

Definition at line 39 of file focuschain.cpp.

◆ getForActivation() [2/2]

Window * KWin::FocusChain::getForActivation ( VirtualDesktop * desktop,
Output * output ) const

Finds the best Window to become the new active Window in the focus chain for the given virtual desktop on the given screen.

This method makes only sense to use if separate screen focus is used. If separate screen focus is disabled the screen is ignored. If no Window for activation is found null is returned.

Parameters
desktopThe virtual desktop to look for a Window for activation
outputThe screen to constrain the search on with separate screen focus
Returns
:X11Window *The Window which could be activated or null if there is none.

Definition at line 44 of file focuschain.cpp.

◆ isUsableFocusCandidate()

bool KWin::FocusChain::isUsableFocusCandidate ( Window * window,
Window * prev ) const

Definition at line 194 of file focuschain.cpp.

◆ moveAfterWindow()

void KWin::FocusChain::moveAfterWindow ( Window * window,
Window * reference )

Moves window behind the reference Window in all focus chains.

Parameters
windowThe Window to move in the chains
referenceThe Window behind which the window should be moved
Returns
void

Definition at line 132 of file focuschain.cpp.

◆ nextForDesktop()

Window * KWin::FocusChain::nextForDesktop ( Window * reference,
VirtualDesktop * desktop ) const

Queries the focus chain for desktop for the next Window in relation to the given reference Window.

The method finds the first usable Window which is not the reference Window. If no Window can be found null is returned

Parameters
referenceThe reference Window which should not be returned
desktopThe virtual desktop whose focus chain should be used
Returns
:X11Window *The next usable Window or null if none can be found.

Definition at line 199 of file focuschain.cpp.

◆ nextMostRecentlyUsed()

Window * KWin::FocusChain::nextMostRecentlyUsed ( Window * reference) const

Queries the most recently used focus chain for the next Window after the given reference Window.

The navigation wraps around the borders of the chain. That is if the reference Window is the last item of the focus chain, the first Window will be returned.

If the reference Window cannot be found in the focus chain, the first element of the focus chain is returned.

Parameters
referenceThe start point in the focus chain to search
Returns
:X11Window *The relatively next Window in the most recently used chain.

Definition at line 178 of file focuschain.cpp.

◆ remove

void KWin::FocusChain::remove ( KWin::Window * window)
slot

Removes window from all focus chains.

Parameters
windowThe Window to remove from all focus chains.
Returns
void

Definition at line 16 of file focuschain.cpp.

◆ removeDesktop

void KWin::FocusChain::removeDesktop ( VirtualDesktop * desktop)
slot

Definition at line 31 of file focuschain.cpp.

◆ setActiveWindow

void KWin::FocusChain::setActiveWindow ( KWin::Window * window)
inlineslot

Definition at line 219 of file focuschain.h.

◆ setCurrentDesktop

void KWin::FocusChain::setCurrentDesktop ( VirtualDesktop * desktop)
inlineslot

Definition at line 224 of file focuschain.h.

◆ setSeparateScreenFocus

void KWin::FocusChain::setSeparateScreenFocus ( bool enabled)
inlineslot

Definition at line 214 of file focuschain.h.

◆ update()

void KWin::FocusChain::update ( Window * window,
FocusChain::Change change )

Updates the position of the window according to the requested change in the focus chain.

This method affects both the most recently used focus chain and the per virtual desktop focus chain.

In case the window does no longer want to get focus, it is removed from all chains. In case the window is on all virtual desktops it is ensured that it is present in each of the virtual desktops focus chain. In case it's on exactly one virtual desktop it is ensured that it is only in the focus chain for that virtual desktop.

Depending on change the Window is inserted at different positions in the focus chain. In case of MakeFirst it is moved to the first position of the chain, in case of MakeLast it is moved to the last position of the chain. In all other cases it depends on whether the window is the currently active Window. If it is the active Window it becomes the first Window in the chain, otherwise it is inserted at the second position that is directly after the currently active Window.

Parameters
windowThe Window which should be moved inside the chains.
changeWhere to move the Window
Returns
void

Definition at line 62 of file focuschain.cpp.


The documentation for this class was generated from the following files: