KWinLibraries
KDecoration Class Reference
[KWin decorations library]
#include <kdecoration.h>

Detailed Description
This is the base class for a decoration object.It provides functions that give various information about the decorated window, and also provides pure virtual functions for controlling the decoration that every decoration should implement.
Definition at line 357 of file kdecoration.h.
Public Slots | |
void | closeWindow () |
void | emitKeepAboveChanged (bool above) |
void | emitKeepBelowChanged (bool below) |
void | maximize (MaximizeMode mode) |
void | maximize (Qt::MouseButtons button) |
void | minimize () |
void | setDesktop (int desktop) |
void | setKeepAbove (bool set) |
void | setKeepBelow (bool set) |
void | setShade (bool set) |
void | showContextHelp () |
void | titlebarDblClickOperation () |
void | titlebarMouseWheelOperation (int delta) |
void | toggleOnAllDesktops () |
Signals | |
void | keepAboveChanged (bool) |
void | keepBelowChanged (bool) |
Public Member Functions | |
virtual void | activeChange ()=0 |
virtual void | borders (int &left, int &right, int &top, int &bottom) const =0 |
QString | caption () const |
virtual void | captionChange ()=0 |
void | clearMask () |
void | createMainWidget (Qt::WFlags flags=0) |
int | desktop () const |
virtual void | desktopChange ()=0 |
virtual bool | drawbound (const QRect &geom, bool clear) |
KDecorationFactory * | factory () const |
QRect | geometry () const |
void | grabXServer () |
int | height () const |
QIcon | icon () const |
virtual void | iconChange ()=0 |
QRect | iconGeometry () const |
virtual void | init ()=0 |
QWidget * | initialParentWidget () const |
Qt::WFlags | initialWFlags () const |
bool | isActive () const |
bool | isCloseable () const |
bool | isMaximizable () const |
bool | isMinimizable () const |
bool | isModal () const |
bool | isMovable () const |
bool | isOnAllDesktops () const |
bool | isPreview () const |
bool | isResizable () const |
bool | isSetShade () const |
bool | isShade () const |
bool | isShadeable () const |
KDecoration (KDecorationBridge *bridge, KDecorationFactory *factory) | |
bool | keepAbove () const |
bool | keepBelow () const |
virtual void | maximizeChange ()=0 |
MaximizeMode | maximizeMode () const |
virtual QSize | minimumSize () const =0 |
virtual Position | mousePosition (const QPoint &p) const =0 |
void | performWindowOperation (WindowOperation op) |
void | processMousePressEvent (QMouseEvent *e) |
bool | providesContextHelp () const |
virtual void | reset (unsigned long changed) |
virtual void | resize (const QSize &s)=0 |
void | setMainWidget (QWidget *) |
void | setMask (const QRegion ®, int mode=0) |
virtual void | shadeChange ()=0 |
void | showWindowMenu (QPoint pos) |
void | showWindowMenu (const QRect &pos) |
void | ungrabXServer () |
QRegion | unobscuredRegion (const QRegion &r) const |
const QWidget * | widget () const |
QWidget * | widget () |
int | width () const |
virtual bool | windowDocked (Position side) |
WId | windowId () const |
NET::WindowType | windowType (unsigned long supported_types) const |
virtual | ~KDecoration () |
Static Public Member Functions | |
static const KDecorationOptions * | options () |
Constructor & Destructor Documentation
KDecoration::KDecoration | ( | KDecorationBridge * | bridge, | |
KDecorationFactory * | factory | |||
) |
Constructs a KDecoration object.
Both the arguments are passed from KDecorationFactory. Note that the initialization code of the decoration should be done in the init() method.
Definition at line 60 of file kdecoration.cpp.
KDecoration::~KDecoration | ( | ) | [virtual] |
Member Function Documentation
virtual void KDecoration::activeChange | ( | ) | [pure virtual] |
This function is called whenever the window either becomes or stops being active.
Use isActive() to find out the current state.
virtual void KDecoration::borders | ( | int & | left, | |
int & | right, | |||
int & | top, | |||
int & | bottom | |||
) | const [pure virtual] |
This function should return the distance from each window side to the inner window.
The sizes may depend on the state of the decorated window, such as whether it's shaded. Decorations often turn off their bottom border when the window is shaded, and turn off their left/right/bottom borders when the window is maximized and moving and resizing of maximized windows is disabled. This function mustn't do any repaints or resizes. Also, if the sizes returned by this function don't match the real values, this may result in drawing errors or other problems.
QString KDecoration::caption | ( | ) | const |
Returns the decorated window's caption that should be shown in the titlebar.
Definition at line 192 of file kdecoration.cpp.
virtual void KDecoration::captionChange | ( | ) | [pure virtual] |
This function is called whenever the caption changes.
Use caption() to get it.
void KDecoration::clearMask | ( | ) |
void KDecoration::closeWindow | ( | ) | [slot] |
This function can be called by the decoration to request closing of the decorated window.
Note that closing the window also involves destroying the decoration. IMPORTANT: This function may destroy the current decoration object, just like showWindowMenu().
Definition at line 252 of file kdecoration.cpp.
void KDecoration::createMainWidget | ( | Qt::WFlags | flags = 0 |
) |
Convenience functions that creates and sets a main widget as necessary.
In such case, it's usually needed to install an event filter on the main widget to receive important events on it.
- Parameters:
-
flags Additional widget flags for the main widget. Note that only flags that affect widget drawing are allowed. Window type flags like WX11BypassWM or WStyle_NoBorder are forbidden.
Definition at line 79 of file kdecoration.cpp.
int KDecoration::desktop | ( | ) | const |
Returns the number of the virtual desktop the decorated window is currently on (including NET::OnAllDesktops for being on all desktops).
Definition at line 137 of file kdecoration.cpp.
virtual void KDecoration::desktopChange | ( | ) | [pure virtual] |
This function is called whenever the desktop for the window changes.
Use desktop() or isOnAllDesktops() to find out the current desktop on which the window is.
bool KDecoration::drawbound | ( | const QRect & | geom, | |
bool | clear | |||
) | [virtual] |
This function may be reimplemented to provide custom bound drawing for transparent moving or resizing of the window.
False should be returned if the default implementation should be used. Note that if you e.g. paint the outline using a 5 pixels wide line, you should compensate for the 2 pixels that would make the window look larger. It is the decoration's responsibility to do the painting, using e.g. code like:
Display* dpy = QX11Info::display(); XGCValues xgc; xgc.function = GXxor; xgc.foreground = WhitePixel( dpy, DefaultScreen( dpy )); xgc.line_width = width; xgc.subwindow_mode = IncludeInferiors; GC gc = XCreateGC( dpy, DefaultRootWindow( dpy ), GCFunction | GCForeground | GCLineWidth | GCSubwindowMode, &xgc ); XDrawRectangle( dpy, DefaultRootWindow( dpy ), gc, r.x(), r.y(), r.width(), r.height()); XFreeGC( dpy, gc );
- Parameters:
-
geom The geometry at this the bound should be drawn clear true if the bound should be cleared (when doing the usual XOR painting this argument can be simply ignored)
- See also:
- geometry()
Definition at line 325 of file kdecoration.cpp.
void KDecoration::emitKeepAboveChanged | ( | bool | above | ) | [slot] |
Definition at line 315 of file kdecoration.cpp.
void KDecoration::emitKeepBelowChanged | ( | bool | below | ) | [slot] |
Definition at line 320 of file kdecoration.cpp.
QRect KDecoration::geometry | ( | ) | const |
void KDecoration::grabXServer | ( | ) |
Performs X server grab.
It is safe to call it several times in a row.
Definition at line 339 of file kdecoration.cpp.
QIcon KDecoration::icon | ( | ) | const |
Returns an icon set with the decorated window's icon.
Definition at line 187 of file kdecoration.cpp.
virtual void KDecoration::iconChange | ( | ) | [pure virtual] |
This function is called whenever the window icon changes.
Use icon() to get it.
QRect KDecoration::iconGeometry | ( | ) | const |
Returns the icon geometry for the window, i.e.
the geometry of the taskbar entry. This is used mainly for window minimize animations. Note that the geometry may be null.
Definition at line 237 of file kdecoration.cpp.
virtual void KDecoration::init | ( | ) | [pure virtual] |
This function is called immediately after the decoration object is created.
Due to some technical reasons, initialization should be done here instead of in the constructor.
QWidget * KDecoration::initialParentWidget | ( | ) | const |
The parent widget that should be used for the main widget.
Definition at line 97 of file kdecoration.cpp.
Qt::WFlags KDecoration::initialWFlags | ( | ) | const |
The flags that should be used when creating the main widget.
It is possible to add more flags when creating the main widget, but only flags that affect widget drawing are allowed. Window type flags like WX11BypassWM or WStyle_NoBorder are forbidden.
Definition at line 102 of file kdecoration.cpp.
bool KDecoration::isActive | ( | ) | const |
Returns true if the decorated window is currently active.
Definition at line 107 of file kdecoration.cpp.
bool KDecoration::isCloseable | ( | ) | const |
Returns true if the decoration window can be closed by the user.
Definition at line 112 of file kdecoration.cpp.
bool KDecoration::isMaximizable | ( | ) | const |
Returns true if the decorated window can be maximized.
Definition at line 117 of file kdecoration.cpp.
bool KDecoration::isMinimizable | ( | ) | const |
Returns true if the decorated window can be minimized by the user.
Definition at line 127 of file kdecoration.cpp.
bool KDecoration::isModal | ( | ) | const |
Returns true if the decoration window is modal (usually a modal dialog).
Definition at line 142 of file kdecoration.cpp.
bool KDecoration::isMovable | ( | ) | const |
Returns true if the decorated window can be moved by the user.
Definition at line 172 of file kdecoration.cpp.
bool KDecoration::isPreview | ( | ) | const |
If this function returns true, the decorated window is used as a preview e.g.
in the configuration module. In such case, the decoration can e.g. show some information in the window area.
Definition at line 227 of file kdecoration.cpp.
bool KDecoration::isResizable | ( | ) | const |
Returns true if the decorated window can be resized by the user.
Definition at line 177 of file kdecoration.cpp.
bool KDecoration::isSetShade | ( | ) | const |
Returns true if the decorated window was set to be shaded.
This function returns also true if the window is e.g. hover unshaded, so it doesn't always correspond to the actual window state.
- See also:
- isShade
Definition at line 157 of file kdecoration.cpp.
bool KDecoration::isShade | ( | ) | const |
Returns true if the decorated window is currently shaded.
If the window is e.g. hover unshaded, it's not considered to be shaded. This function should not be used for the shade titlebar button, use isSetShade() instead.
- See also:
- isSetShade
Definition at line 152 of file kdecoration.cpp.
bool KDecoration::isShadeable | ( | ) | const |
bool KDecoration::keepAbove | ( | ) | const |
Returns true if the decorated window should be kept above other windows.
Definition at line 162 of file kdecoration.cpp.
void KDecoration::keepAboveChanged | ( | bool | ) | [signal] |
This signal is emitted whenever the window's keep-above state changes.
bool KDecoration::keepBelow | ( | ) | const |
Returns true if the decorated window should be kept below other windows.
Definition at line 167 of file kdecoration.cpp.
void KDecoration::keepBelowChanged | ( | bool | ) | [signal] |
This signal is emitted whenever the window's keep-below state changes.
void KDecoration::maximize | ( | MaximizeMode | mode | ) | [slot] |
Set the maximize mode of the decorated window.
- Parameters:
-
mode The maximization mode to be set.
Definition at line 262 of file kdecoration.cpp.
void KDecoration::maximize | ( | Qt::MouseButtons | button | ) | [slot] |
Definition at line 257 of file kdecoration.cpp.
virtual void KDecoration::maximizeChange | ( | ) | [pure virtual] |
This function is called whenever the maximalization state of the window changes.
Use maximizeMode() to get the current state.
KDecoration::MaximizeMode KDecoration::maximizeMode | ( | ) | const |
Returns the current maximization mode of the decorated window.
Note that only fully maximized windows should be treated as "maximized" (e.g. if the maximize button has only two states).
Definition at line 122 of file kdecoration.cpp.
void KDecoration::minimize | ( | ) | [slot] |
virtual QSize KDecoration::minimumSize | ( | ) | const [pure virtual] |
This function should return the minimum required size for the decoration.
Note that the returned size shouldn't be too large, because it will be used to keep the decorated window at least as large.
KDecoration::Position KDecoration::mousePosition | ( | const QPoint & | p | ) | const [pure virtual] |
This function should return mouse cursor position in the decoration.
Positions at the edge will result in window resizing with mouse button pressed, center position will result in moving.
Definition at line 349 of file kdecoration.cpp.
const KDecorationOptions * KDecoration::options | ( | ) | [static] |
Returns the KDecorationOptions object, which is used to access configuration settings for the decoration.
Definition at line 74 of file kdecoration.cpp.
void KDecoration::performWindowOperation | ( | WindowOperation | op | ) |
This function performs the given window operation.
This function may destroy the current decoration object, just like showWindowMenu().
Definition at line 212 of file kdecoration.cpp.
void KDecoration::processMousePressEvent | ( | QMouseEvent * | e | ) |
This function is the default handler for mouse events.
All mouse events that are not handled by the decoration itself should be passed to it in order to make work operations like window resizing by dragging borders etc.
Definition at line 197 of file kdecoration.cpp.
bool KDecoration::providesContextHelp | ( | ) | const |
Return true if the decorated window can show context help (i.e.
the decoration should provide the context help button).
Definition at line 132 of file kdecoration.cpp.
void KDecoration::reset | ( | unsigned long | changed | ) | [virtual] |
This function is called to reset the decoration on settings changes.
It is usually invoked by calling KDecorationFactory::resetDecorations().
- Parameters:
-
changed Specifies which settings were changed, given by the SettingXXX masks
Definition at line 335 of file kdecoration.cpp.
virtual void KDecoration::resize | ( | const QSize & | s | ) | [pure virtual] |
This method is called by kwin when the style should resize the decoration window.
The usual implementation is to resize the main widget of the decoration to the given size.
- Parameters:
-
s Specifies the new size of the decoration window.
void KDecoration::setDesktop | ( | int | desktop | ) | [slot] |
Moves the window to the given desktop.
Use NET::OnAllDesktops for making the window appear on all desktops.
Definition at line 277 of file kdecoration.cpp.
void KDecoration::setKeepAbove | ( | bool | set | ) | [slot] |
Sets or reset keeping this window above others.
- Parameters:
-
set Whether to keep the window above others
Definition at line 305 of file kdecoration.cpp.
void KDecoration::setKeepBelow | ( | bool | set | ) | [slot] |
Sets or reset keeping this window below others.
- Parameters:
-
set Whether to keep the window below others
Definition at line 310 of file kdecoration.cpp.
void KDecoration::setMainWidget | ( | QWidget * | w | ) |
This should be the first function called in init() to specify the main widget of the decoration.
The widget should be created with parent specified by initialParentWidget() and flags specified by initialWFlags().
Definition at line 89 of file kdecoration.cpp.
void KDecoration::setMask | ( | const QRegion & | reg, | |
int | mode = 0 | |||
) |
If the decoration is non-rectangular, this function needs to be called to set the shape of the decoration.
- Parameters:
-
reg The shape of the decoration. mode The X11 values Unsorted, YSorted, YXSorted and YXBanded that specify the sorting of the rectangles, default value is Unsorted.
Definition at line 217 of file kdecoration.cpp.
void KDecoration::setShade | ( | bool | set | ) | [slot] |
Shades or unshades the decorated window.
- Parameters:
-
set Whether the window should be shaded
Definition at line 300 of file kdecoration.cpp.
virtual void KDecoration::shadeChange | ( | ) | [pure virtual] |
This function is called whenever the window is shaded or unshaded.
Use isShade() to get the current state.
void KDecoration::showContextHelp | ( | ) | [slot] |
Start showing context help in the window (i.e.
the mouse will enter the what's this mode).
Definition at line 272 of file kdecoration.cpp.
void KDecoration::showWindowMenu | ( | QPoint | pos | ) |
void KDecoration::showWindowMenu | ( | const QRect & | pos | ) |
This function invokes the window operations menu.
- Parameters:
-
pos specifies the place on the screen where the menu should show up. The menu pops up at the bottom-left corner of the specified rectangle, unless there is no space, in which case the menu is displayed above the rectangle.
- Note:
- Decorations that enable a double-click operation for the menu button must ensure to call showWindowMenu() with the pos rectangle set to the menu button geometry. IMPORTANT: As a result of this function, the decoration object that called it may be destroyed after the function returns. This means that the decoration object must either return immediately after calling showWindowMenu(), or it must use KDecorationFactory::exists() to check it's still valid. For example, the code handling clicks on the menu button should look similarly like this:
KDecorationFactory* f = factory(); // needs to be saved before showWindowMenu( button[MenuButton]->mapToGlobal( menuPoint )); if( !f->exists( this )) // destroyed, return immediately return; button[MenuButton]->setDown(false);
Definition at line 202 of file kdecoration.cpp.
void KDecoration::titlebarDblClickOperation | ( | ) | [slot] |
This function performs the operation configured as titlebar double click operation.
Definition at line 290 of file kdecoration.cpp.
void KDecoration::titlebarMouseWheelOperation | ( | int | delta | ) | [slot] |
This function performs the operation configured as titlebar wheel mouse operation.
- Parameters:
-
delta the mouse wheel delta
Definition at line 295 of file kdecoration.cpp.
void KDecoration::toggleOnAllDesktops | ( | ) | [slot] |
This function toggles the on-all-desktops state of the decorated window.
Definition at line 282 of file kdecoration.cpp.
void KDecoration::ungrabXServer | ( | ) |
Ungrabs X server (if the number of ungrab attempts matches the number of grab attempts).
Definition at line 344 of file kdecoration.cpp.
Returns the intersection of the given region with the region left unobscured by the windows stacked above the current one.
You can use this function to, for example, try to keep the titlebar visible if there is a hole available. The region returned is in the coordinate space of the decoration.
- Parameters:
-
r The region you want to check for holes
Definition at line 242 of file kdecoration.cpp.
bool KDecoration::windowDocked | ( | Position | side | ) | [virtual] |
Definition at line 330 of file kdecoration.cpp.
WId KDecoration::windowId | ( | ) | const |
Returns the handle of the window that is being decorated.
It is possible the returned value will be 0. IMPORTANT: This function is meant for special purposes, and it usually should not be used. The main purpose is finding out additional information about the window's state. Also note that different kinds of windows are decorated: Toplevel windows managed by the window manager, test window in the window manager decoration module, and possibly also other cases. Careless abuse of this function will usually sooner or later lead to problems.
Definition at line 247 of file kdecoration.cpp.
NET::WindowType KDecoration::windowType | ( | unsigned long | supported_types | ) | const |
This function returns the window type of the decorated window.
The argument to this function is a mask of all window types the decoration knows about (as the list of valid window types is extended over time, and fallback types are specified in order to support older code). For a description of all window types, see the definition of the NET::WindowType type. Note that some window types never have decorated windows.
An example of usage:
const unsigned long supported_types = NET::NormalMask | NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask; NET::WindowType type = windowType( supported_types ); if( type == NET::Utility || type == NET::Menu || type == NET::Toolbar ) // ... use smaller decorations for tool window types else // ... use normal decorations
Definition at line 182 of file kdecoration.cpp.
The documentation for this class was generated from the following files: