1 /*****************************************************************
2 This file is part of the KDE project.
4 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 ******************************************************************/
28 #include <QtGui/QColor>
29 #include <QtGui/QFont>
30 #include <QtCore/QObject>
31 #include <QtGui/QIcon>
32 #include <netwm_def.h>
33 #include <QtGui/QMouseEvent>
35 #define KWIN_EXPORT KDE_EXPORT
39 /** @defgroup kdecoration KWin decorations library */
41 /** @addtogroup kdecoration */
44 class KDecorationOptionsPrivate
;
45 class KDecorationBridge
;
46 class KDecorationPrivate
;
47 class KDecorationFactory
;
50 * This class provides a namespace for all decoration related classes.
51 * All shared types are defined here.
53 class KWIN_EXPORT KDecorationDefines
57 * These values represent positions inside an area
60 { // without prefix, they'd conflict with Qt::TopLeftCorner etc. :(
61 PositionCenter
= 0x00,
65 PositionBottom
= 0x08,
66 PositionTopLeft
= PositionLeft
| PositionTop
,
67 PositionTopRight
= PositionRight
| PositionTop
,
68 PositionBottomLeft
= PositionLeft
| PositionBottom
,
69 PositionBottomRight
= PositionRight
| PositionBottom
72 * Maximize mode. These values specify how a window is maximized.
74 // these values are written to session files, don't change the order
77 MaximizeRestore
= 0, ///< The window is not maximized in any direction.
78 MaximizeVertical
= 1, ///< The window is maximized vertically.
79 MaximizeHorizontal
= 2, ///< The window is maximized horizontally.
80 /// Equal to @p MaximizeVertical | @p MaximizeHorizontal
81 MaximizeFull
= MaximizeVertical
| MaximizeHorizontal
100 ToggleStoreSettingsOp
= WindowRulesOp
, ///< @obsolete
107 SetupWindowShortcutOp
,
111 * Basic color types that should be recognized by all decoration styles.
112 * Decorations are not required to implement all the colors, but for the ones that
113 * are implemented the color setting for them should be obeyed.
117 ColorTitleBar
, ///< The color for the titlebar
118 ColorTitleBlend
, ///< The blend color for the titlebar
119 ColorFont
, ///< The titlebar text color
120 ColorButtonBg
, ///< The color to use for the titlebar buttons
121 ColorFrame
, ///< The color for the window frame (border)
122 ColorHandle
, ///< The color for the resize handle
123 NUM_COLORS
///< @internal This value may change, do not use
127 * These flags specify which settings changed when rereading settings.
128 * Each setting in class KDecorationOptions specifies its matching flag.
132 SettingDecoration
= 1 << 0, ///< The decoration was changed
133 SettingColors
= 1 << 1, ///< The color palette was changed
134 SettingFont
= 1 << 2, ///< The titlebar font was changed
135 SettingButtons
= 1 << 3, ///< The button layout was changed
136 SettingTooltips
= 1 << 4, ///< The tooltip setting was changed
137 SettingBorder
= 1 << 5 ///< The border size setting was changed
141 * Border size. KDecorationOptions::preferredBorderSize() returns
142 * one of these values.
146 BorderTiny
, ///< Minimal borders
147 BorderNormal
, ///< Standard size borders, the default setting
148 BorderLarge
, ///< Larger borders
149 BorderVeryLarge
, ///< Very large borders
150 BorderHuge
, ///< Huge borders
151 BorderVeryHuge
, ///< Very huge borders
152 BorderOversized
, ///< Oversized borders
153 BordersCount
///< @internal
157 * Used to find out which features the decoration supports.
158 * @see KDecorationFactory::supports()
163 AbilityAnnounceButtons
= 0, ///< decoration supports AbilityButton* values (always use)
164 AbilityAnnounceColors
= 1, ///< decoration supports AbilityColor* values (always use)
166 AbilityButtonMenu
= 1000, ///< decoration supports the menu button
167 AbilityButtonOnAllDesktops
= 1001, ///< decoration supports the on all desktops button
168 AbilityButtonSpacer
= 1002, ///< decoration supports inserting spacers between buttons
169 AbilityButtonHelp
= 1003, ///< decoration supports what's this help button
170 AbilityButtonMinimize
= 1004, ///< decoration supports a minimize button
171 AbilityButtonMaximize
= 1005, ///< decoration supports a maximize button
172 AbilityButtonClose
= 1006, ///< decoration supports a close button
173 AbilityButtonAboveOthers
= 1007, ///< decoration supports an above button
174 AbilityButtonBelowOthers
= 1008, ///< decoration supports a below button
175 AbilityButtonShade
= 1009, ///< decoration supports a shade button
176 AbilityButtonResize
= 1010, ///< decoration supports a resize button
178 AbilityColorTitleBack
= 2000, ///< decoration supports titlebar background color
179 ABILITYCOLOR_FIRST
= AbilityColorTitleBack
, ///< @internal
180 AbilityColorTitleFore
= 2001, ///< decoration supports titlebar foreground color
181 AbilityColorTitleBlend
= 2002, ///< decoration supports second titlebar background color
182 AbilityColorFrame
= 2010, ///< decoration supports frame color
183 AbilityColorHandle
= 2011, ///< decoration supports resize handle color
184 AbilityColorButtonBack
= 2020, ///< decoration supports button background color
185 AbilityColorButtonFore
= 2021, ///< decoration supports button foreground color
186 ABILITYCOLOR_END
, ///< @internal
188 AbilityCompositingShadow
= 3000, ///< decoration supports window shadows
189 // TODO colors for individual button types
190 ABILITY_DUMMY
= 10000000
193 enum Requirement
{ REQUIREMENT_DUMMY
= 1000000 };
197 * Decoration shadow type.
201 ShadowBorderedActive
= 0, ///< Active shadow of decorated windows
202 ShadowBorderedInactive
, ///< Inctive shadow of decorated windows
203 ShadowBorderlessActive
, ///< Active shadow of undecorated windows
204 ShadowBorderlessInactive
, ///< Inctive shadow of undecorated windows
205 ShadowOther
///< Shadow of all other windows (Menus, comboboxes, tooltips, etc.)
208 class KDecorationProvides
209 : public KDecorationDefines
212 virtual ~KDecorationProvides(){}
213 virtual bool provides( Requirement req
) = 0;
217 * This class holds various configuration settings for the decoration.
218 * It is accessible from the decorations either as KDecoration::options()
219 * or KDecorationFactory::options().
221 class KWIN_EXPORT KDecorationOptions
: public KDecorationDefines
224 KDecorationOptions();
225 virtual ~KDecorationOptions();
227 * Call to update settings when the config changes. Return value is
228 * a combination of Setting* (SettingColors, etc.) that have changed.
231 unsigned long updateSettings( KConfig
* config
);
233 * Returns the color that should be used for the given part of the decoration.
234 * The changed flags for this setting is SettingColors.
236 * @param type The requested color type.
237 * @param active Whether the color should be for active or inactive windows.
239 QColor
color(ColorType type
, bool active
=true) const;
241 * Returns a palette using the given decoration color as the background.
242 * The changed flags for this setting is SettingColors.
244 * @param type The requested color type.
245 * @param active Whether to return the color for active or inactive windows.
247 QPalette
palette(ColorType type
, bool active
=true) const;
249 * Returns the active or inactive decoration font.
250 * The changed flags for this setting is SettingFont.
252 * @param active Whether to return the color for active or inactive windows.
253 * @param small If @a true, returns a font that's suitable for tool windows.
255 QFont
font(bool active
=true, bool small
= false) const;
257 * Returns @a true if the style should use custom button positions
258 * The changed flags for this setting is SettingButtons.
260 * @see titleButtonsLeft
261 * @see titleButtonsRight
263 bool customButtonPositions() const;
265 * If customButtonPositions() returns true, titleButtonsLeft
266 * returns which buttons should be on the left side of the titlebar from left
267 * to right. Characters in the returned string have this meaning :
268 * @li 'M' menu button
269 * @li 'S' on_all_desktops button
270 * @li 'H' quickhelp button
271 * @li 'I' minimize ( iconify ) button
272 * @li 'A' maximize button
273 * @li 'X' close button
274 * @li 'F' keep_above_others button
275 * @li 'B' keep_below_others button
276 * @li 'L' shade button
277 * @li 'R' resize button
280 * The default ( which is also returned if customButtonPositions returns false )
282 * Unknown buttons in the returned string must be ignored.
283 * The changed flags for this setting is SettingButtons.
285 QString
titleButtonsLeft() const;
287 * Returns the default left button sequence
289 static QString
defaultTitleButtonsLeft();
291 * If customButtonPositions() returns true, titleButtonsRight
292 * returns which buttons should be on the right side of the titlebar from left
293 * to right. Characters in the return string have the same meaning like
294 * in titleButtonsLeft().
296 * The default ( which is also returned if customButtonPositions returns false )
298 * Unknown buttons in the returned string must be ignored.
299 * The changed flags for this setting is SettingButtons.
301 QString
titleButtonsRight() const;
303 * Returns the default right button sequence.
305 static QString
defaultTitleButtonsRight();
307 * @returns true if the style should use tooltips for window buttons
308 * The changed flags for this setting is SettingTooltips.
310 bool showTooltips() const;
313 * The preferred border size selected by the user, e.g. for accessibility
314 * reasons, or when using high resolution displays. It's up to the decoration
315 * to decide which borders or if any borders at all will obey this setting.
316 * It is guaranteed that the returned value will be one of those
317 * returned by KDecorationFactory::borderSizes(), so if that one hasn't been
318 * reimplemented, BorderNormal is always returned.
319 * The changed flags for this setting is SettingBorder.
320 * @param factory the decoration factory used
322 BorderSize
preferredBorderSize( KDecorationFactory
* factory
) const;
325 * When this functions returns false, moving and resizing of maximized windows
326 * is not allowed, and therefore the decoration is allowed to turn off (some of)
328 * The changed flags for this setting is SettingButtons.
330 bool moveResizeMaximizedWindows() const;
335 WindowOperation
operationMaxButtonClick( Qt::MouseButtons button
) const;
340 virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
344 void setOpMaxButtonLeftClick( WindowOperation op
);
346 void setOpMaxButtonRightClick( WindowOperation op
);
348 void setOpMaxButtonMiddleClick( WindowOperation op
);
350 void setBorderSize( BorderSize bs
);
352 void setCustomButtonPositions( bool b
);
354 void setTitleButtonsLeft( const QString
& b
);
356 void setTitleButtonsRight( const QString
& b
);
361 KDecorationOptionsPrivate
* d
;
366 * This is the base class for a decoration object. It provides functions
367 * that give various information about the decorated window, and also
368 * provides pure virtual functions for controlling the decoration that
369 * every decoration should implement.
371 class KWIN_EXPORT KDecoration
372 : public QObject
, public KDecorationDefines
377 * Constructs a KDecoration object. Both the arguments are passed from
378 * KDecorationFactory. Note that the initialization code of the decoration
379 * should be done in the init() method.
381 KDecoration( KDecorationBridge
* bridge
, KDecorationFactory
* factory
);
383 * Destroys the KDecoration.
385 virtual ~KDecoration();
387 // requests from decoration
390 * Returns the KDecorationOptions object, which is used to access
391 * configuration settings for the decoration.
393 static const KDecorationOptions
* options();
395 * Returns @a true if the decorated window is currently active.
397 bool isActive() const;
399 * Returns @a true if the decoration window can be closed by the user.
401 bool isCloseable() const;
403 * Returns @a true if the decorated window can be maximized.
405 bool isMaximizable() const;
407 * Returns the current maximization mode of the decorated window.
408 * Note that only fully maximized windows should be treated
409 * as "maximized" (e.g. if the maximize button has only two states).
411 MaximizeMode
maximizeMode() const;
413 * Returns @a true if the decorated window can be minimized by the user.
415 bool isMinimizable() const;
417 * Return @a true if the decorated window can show context help
418 * (i.e. the decoration should provide the context help button).
420 bool providesContextHelp() const;
422 * Returns the number of the virtual desktop the decorated window
423 * is currently on (including NET::OnAllDesktops for being on all
428 * Convenience function that returns @a true if the window is on all
431 bool isOnAllDesktops() const; // convenience
433 * Returns @a true if the decoration window is modal (usually a modal dialog).
435 bool isModal() const;
437 * Returns @a true if the decorated window can be shaded.
439 bool isShadeable() const;
441 * Returns @a true if the decorated window is currently shaded.
442 * If the window is e.g. hover unshaded, it's not considered to be shaded.
443 * This function should not be used for the shade titlebar button, use
444 * @ref isSetShade() instead.
448 bool isShade() const;
450 * Returns @a true if the decorated window was set to be shaded. This function
451 * returns also true if the window is e.g. hover unshaded, so it doesn't
452 * always correspond to the actual window state.
456 bool isSetShade() const;
458 * Returns @a true if the decorated window should be kept above other windows.
460 bool keepAbove() const;
462 * Returns @a true if the decorated window should be kept below other windows.
464 bool keepBelow() const;
466 * Returns @a true if the decorated window can be moved by the user.
468 bool isMovable() const;
470 * Returns @a true if the decorated window can be resized by the user.
472 bool isResizable() const;
474 * This function returns the window type of the decorated window.
475 * The argument to this function is a mask of all window types
476 * the decoration knows about (as the list of valid window types
477 * is extended over time, and fallback types are specified in order
478 * to support older code). For a description of all window types,
479 * see the definition of the NET::WindowType type. Note that
480 * some window types never have decorated windows.
482 * An example of usage:
484 * const unsigned long supported_types = NET::NormalMask | NET::DesktopMask
485 * | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
486 * | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask;
488 * NET::WindowType type = windowType( supported_types );
490 * if( type == NET::Utility || type == NET::Menu || type == NET::Toolbar )
491 * // ... use smaller decorations for tool window types
493 * // ... use normal decorations
496 NET::WindowType
windowType( unsigned long supported_types
) const;
498 * Returns an icon set with the decorated window's icon.
502 * Returns the decorated window's caption that should be shown in the titlebar.
504 QString
caption() const;
506 * This function invokes the window operations menu.
507 * \param pos specifies the place on the screen where the menu should
508 * show up. The menu pops up at the bottom-left corner of the specified
509 * rectangle, unless there is no space, in which case the menu is
510 * displayed above the rectangle.
512 * \note Decorations that enable a double-click operation for the menu
513 * button must ensure to call \a showWindowMenu() with the \a pos
514 * rectangle set to the menu button geometry.
515 * IMPORTANT: As a result of this function, the decoration object that
516 * called it may be destroyed after the function returns. This means
517 * that the decoration object must either return immediately after
518 * calling showWindowMenu(), or it must use
519 * KDecorationFactory::exists() to check it's still valid. For example,
520 * the code handling clicks on the menu button should look similarly
524 * KDecorationFactory* f = factory(); // needs to be saved before
525 * showWindowMenu( button[MenuButton]->mapToGlobal( menuPoint ));
526 * if( !f->exists( this )) // destroyed, return immediately
528 * button[MenuButton]->setDown(false);
531 void showWindowMenu( const QRect
&pos
);
534 * Overloaded version of the above.
536 void showWindowMenu( QPoint pos
);
538 * This function performs the given window operation. This function may destroy
539 * the current decoration object, just like showWindowMenu().
541 void performWindowOperation( WindowOperation op
);
543 * If the decoration is non-rectangular, this function needs to be called
544 * to set the shape of the decoration.
546 * @param reg The shape of the decoration.
547 * @param mode The X11 values Unsorted, YSorted, YXSorted and YXBanded that specify
548 * the sorting of the rectangles, default value is Unsorted.
550 void setMask( const QRegion
& reg
, int mode
= 0 );
552 * This convenience function resets the shape mask.
554 void clearMask(); // convenience
556 * If this function returns @a true, the decorated window is used as a preview
557 * e.g. in the configuration module. In such case, the decoration can e.g.
558 * show some information in the window area.
560 bool isPreview() const;
562 * Returns the geometry of the decoration.
564 QRect
geometry() const;
566 * Returns the icon geometry for the window, i.e. the geometry of the taskbar
567 * entry. This is used mainly for window minimize animations. Note that
568 * the geometry may be null.
570 QRect
iconGeometry() const;
572 * Returns the intersection of the given region with the region left
573 * unobscured by the windows stacked above the current one. You can use
574 * this function to, for example, try to keep the titlebar visible if
575 * there is a hole available. The region returned is in the coordinate
576 * space of the decoration.
577 * @param r The region you want to check for holes
579 QRegion
unobscuredRegion( const QRegion
& r
) const;
581 * Returns the handle of the window that is being decorated. It is possible
582 * the returned value will be 0.
583 * IMPORTANT: This function is meant for special purposes, and it
584 * usually should not be used. The main purpose is finding out additional
585 * information about the window's state. Also note that different kinds
586 * of windows are decorated: Toplevel windows managed by the window manager,
587 * test window in the window manager decoration module, and possibly also
589 * Careless abuse of this function will usually sooner or later lead
592 WId
windowId() const;
594 * Convenience function that returns the width of the decoration.
596 int width() const; // convenience
598 * Convenience function that returns the height of the decoration.
600 int height() const; // convenience
602 * This function is the default handler for mouse events. All mouse events
603 * that are not handled by the decoration itself should be passed to it
604 * in order to make work operations like window resizing by dragging borders etc.
606 void processMousePressEvent( QMouseEvent
* e
);
608 // requests to decoration
611 * This function is called immediately after the decoration object is created.
612 * Due to some technical reasons, initialization should be done here
613 * instead of in the constructor.
615 virtual void init() = 0; // called once right after created
618 * This function should return mouse cursor position in the decoration.
619 * Positions at the edge will result in window resizing with mouse button
620 * pressed, center position will result in moving.
622 virtual Position
mousePosition( const QPoint
& p
) const = 0;
625 * This function should return the distance from each window side to the inner
626 * window. The sizes may depend on the state of the decorated window, such as
627 * whether it's shaded. Decorations often turn off their bottom border when the
628 * window is shaded, and turn off their left/right/bottom borders when
629 * the window is maximized and moving and resizing of maximized windows is disabled.
630 * This function mustn't do any repaints or resizes. Also, if the sizes returned
631 * by this function don't match the real values, this may result in drawing errors
634 * @see KDecorationOptions::moveResizeMaximizedWindows()
636 // mustn't do any repaints, resizes or anything like that
637 virtual void borders( int& left
, int& right
, int& top
, int& bottom
) const = 0;
639 * This method is called by kwin when the style should resize the decoration window.
640 * The usual implementation is to resize the main widget of the decoration to the
643 * @param s Specifies the new size of the decoration window.
645 virtual void resize( const QSize
& s
) = 0;
647 * This function should return the minimum required size for the decoration.
648 * Note that the returned size shouldn't be too large, because it will be
649 * used to keep the decorated window at least as large.
651 virtual QSize
minimumSize() const = 0;
653 * This function is called whenever the window either becomes or stops being active.
654 * Use isActive() to find out the current state.
656 virtual void activeChange() = 0;
658 * This function is called whenever the caption changes. Use caption() to get it.
660 virtual void captionChange() = 0;
662 * This function is called whenever the window icon changes. Use icon() to get it.
664 virtual void iconChange() = 0;
666 * This function is called whenever the maximalization state of the window changes.
667 * Use maximizeMode() to get the current state.
669 virtual void maximizeChange() = 0;
671 * This function is called whenever the desktop for the window changes. Use
672 * desktop() or isOnAllDesktops() to find out the current desktop
673 * on which the window is.
675 virtual void desktopChange() = 0;
677 * This function is called whenever the window is shaded or unshaded. Use
678 * isShade() to get the current state.
680 virtual void shadeChange() = 0;
683 * This signal is emitted whenever the window's keep-above state changes.
685 void keepAboveChanged( bool );
687 * This signal is emitted whenever the window's keep-below state changes.
689 void keepBelowChanged( bool );
692 * This function may be reimplemented to provide custom bound drawing
693 * for transparent moving or resizing of the window.
694 * @a False should be returned if the default implementation should be used.
695 * Note that if you e.g. paint the outline using a 5 pixels wide line,
696 * you should compensate for the 2 pixels that would make the window
698 * It is the decoration's responsibility to do the painting, using
701 * Display* dpy = QX11Info::display();
703 * xgc.function = GXxor;
704 * xgc.foreground = WhitePixel( dpy, DefaultScreen( dpy ));
705 * xgc.line_width = width;
706 * xgc.subwindow_mode = IncludeInferiors;
707 * GC gc = XCreateGC( dpy, DefaultRootWindow( dpy ),
708 * GCFunction | GCForeground | GCLineWidth | GCSubwindowMode, &xgc );
709 * XDrawRectangle( dpy, DefaultRootWindow( dpy ), gc, r.x(), r.y(), r.width(), r.height());
710 * XFreeGC( dpy, gc );
713 * @param geom The geometry at this the bound should be drawn
714 * @param clear @a true if the bound should be cleared (when doing the usual XOR
715 * painting this argument can be simply ignored)
719 virtual bool drawbound( const QRect
& geom
, bool clear
);
721 * @internal Reserved.
723 // TODO position will need also values for top+left+bottom etc. docking ?
724 virtual bool windowDocked( Position side
);
726 * This function is called to reset the decoration on settings changes.
727 * It is usually invoked by calling KDecorationFactory::resetDecorations().
729 * @param changed Specifies which settings were changed, given by the SettingXXX masks
731 virtual void reset( unsigned long changed
);
736 * This should be the first function called in init() to specify
737 * the main widget of the decoration. The widget should be created
738 * with parent specified by initialParentWidget() and flags
739 * specified by initialWFlags().
741 void setMainWidget( QWidget
* );
743 * Convenience functions that creates and sets a main widget as necessary.
744 * In such case, it's usually needed to install an event filter
745 * on the main widget to receive important events on it.
747 * @param flags Additional widget flags for the main widget. Note that only
748 * flags that affect widget drawing are allowed. Window type flags
749 * like WX11BypassWM or WStyle_NoBorder are forbidden.
751 void createMainWidget( Qt::WFlags flags
= 0 );
753 * The parent widget that should be used for the main widget.
755 QWidget
* initialParentWidget() const;
757 * The flags that should be used when creating the main widget.
758 * It is possible to add more flags when creating the main widget, but only flags
759 * that affect widget drawing are allowed. Window type flags like WX11BypassWM
760 * or WStyle_NoBorder are forbidden.
762 Qt::WFlags
initialWFlags() const;
764 * Returns the main widget for the decoration.
768 * Returns the main widget for the decoration.
770 const QWidget
* widget() const;
772 * Returns the factory that created this decoration.
774 KDecorationFactory
* factory() const;
776 * Performs X server grab. It is safe to call it several times in a row.
780 * Ungrabs X server (if the number of ungrab attempts matches the number of grab attempts).
782 void ungrabXServer();
784 // requests from decoration
787 * This function can be called by the decoration to request
788 * closing of the decorated window. Note that closing the window
789 * also involves destroying the decoration.
790 * IMPORTANT: This function may destroy the current decoration object,
791 * just like showWindowMenu().
795 * Changes the maximize mode of the decorated window. This function should
796 * be preferred to the other maximize() overload for reacting on clicks
797 * on the maximize titlebar button.
799 void maximize( Qt::MouseButtons button
);
801 * Set the maximize mode of the decorated window.
802 * @param mode The maximization mode to be set.
804 void maximize( MaximizeMode mode
);
806 * Minimize the decorated window.
810 * Start showing context help in the window (i.e. the mouse will enter
811 * the what's this mode).
813 void showContextHelp();
815 * Moves the window to the given desktop. Use NET::OnAllDesktops for making
816 * the window appear on all desktops.
818 void setDesktop( int desktop
);
820 * This function toggles the on-all-desktops state of the decorated window.
822 void toggleOnAllDesktops(); // convenience
824 * This function performs the operation configured as titlebar double click
827 void titlebarDblClickOperation();
829 * This function performs the operation configured as titlebar wheel mouse
831 * @param delta the mouse wheel delta
833 void titlebarMouseWheelOperation( int delta
);
835 * Shades or unshades the decorated window.
836 * @param set Whether the window should be shaded
838 void setShade( bool set
);
840 * Sets or reset keeping this window above others.
841 * @param set Whether to keep the window above others
843 void setKeepAbove( bool set
);
845 * Sets or reset keeping this window below others.
846 * @param set Whether to keep the window below others
848 void setKeepBelow( bool set
);
852 void emitKeepAboveChanged( bool above
);
856 void emitKeepBelowChanged( bool below
);
858 KDecorationBridge
* bridge_
;
860 KDecorationFactory
* factory_
;
861 friend class KDecorationOptions
; // for options_
862 friend class KDecorationUnstable
; // for bridge_
863 static KDecorationOptions
* options_
;
864 KDecorationPrivate
* d
;
868 * @warning THIS CLASS IS UNSTABLE AND WILL ONLY BE SUPPORTED IN KDE 4.2!
870 class KWIN_EXPORT KDecorationUnstable
875 KDecorationUnstable( KDecorationBridge
* bridge
, KDecorationFactory
* factory
);
876 virtual ~KDecorationUnstable();
879 * This function should return the positions of the shadow quads to be rendered.
880 * All positions are relative to the window's top-left corner. Only "bordered"
881 * windows will call this method.
883 virtual QList
<QRect
> shadowQuads( ShadowType type
) const;
885 * This function should return the desired opacity of the shadow.
887 virtual double shadowOpacity( ShadowType type
) const;
889 * This function should return the desired brightness of the shadow.
891 virtual double shadowBrightness( ShadowType type
) const;
893 * This function should return the desired saturation of the shadow.
895 virtual double shadowSaturation( ShadowType type
) const;
898 * Force a repaint of the shadow. Automatically called when the window changes states.
900 void repaintShadow();
902 * Returns @a true if compositing is enabled (Currently useless to decorations,
903 * use \a shadowsActive() instead).
905 bool compositingActive() const;
907 * Returns @a true if compositing is enabled and the shadow effect is activated
908 * by the current user.
910 bool shadowsActive() const;
912 * Returns the opacity that the decoration will be rendered at.
914 double opacity() const;
918 KDecorationDefines::MaximizeMode
operator^( KDecorationDefines::MaximizeMode m1
, KDecorationDefines::MaximizeMode m2
)
920 return KDecorationDefines::MaximizeMode( int(m1
) ^ int(m2
) );
924 KDecorationDefines::MaximizeMode
operator&( KDecorationDefines::MaximizeMode m1
, KDecorationDefines::MaximizeMode m2
)
926 return KDecorationDefines::MaximizeMode( int(m1
) & int(m2
) );
930 KDecorationDefines::MaximizeMode
operator|( KDecorationDefines::MaximizeMode m1
, KDecorationDefines::MaximizeMode m2
)
932 return KDecorationDefines::MaximizeMode( int(m1
) | int(m2
) );
935 inline QWidget
* KDecoration::widget()
940 inline const QWidget
* KDecoration::widget() const
945 inline KDecorationFactory
* KDecoration::factory() const
950 inline bool KDecoration::isOnAllDesktops() const
952 return desktop() == NET::OnAllDesktops
;
955 inline int KDecoration::width() const
957 return geometry().width();
960 inline int KDecoration::height() const
962 return geometry().height();