Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / kwin / lib / kdecoration.h
blob15dec4c2fd6b8b32958a1803c999e898af38eb27
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 ******************************************************************/
25 #ifndef KDECORATION_H
26 #define KDECORATION_H
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
37 class KConfig;
39 /** @defgroup kdecoration KWin decorations library */
41 /** @addtogroup kdecoration */
42 /** @{ */
44 class KDecorationOptionsPrivate;
45 class KDecorationBridge;
46 class KDecorationPrivate;
47 class KDecorationFactory;
49 /**
50 * This class provides a namespace for all decoration related classes.
51 * All shared types are defined here.
53 class KWIN_EXPORT KDecorationDefines
55 public:
56 /**
57 * These values represent positions inside an area
59 enum Position
60 { // without prefix, they'd conflict with Qt::TopLeftCorner etc. :(
61 PositionCenter = 0x00,
62 PositionLeft = 0x01,
63 PositionRight = 0x02,
64 PositionTop = 0x04,
65 PositionBottom = 0x08,
66 PositionTopLeft = PositionLeft | PositionTop,
67 PositionTopRight = PositionRight | PositionTop,
68 PositionBottomLeft = PositionLeft | PositionBottom,
69 PositionBottomRight = PositionRight | PositionBottom
71 /**
72 * Maximize mode. These values specify how a window is maximized.
74 // these values are written to session files, don't change the order
75 enum MaximizeMode
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
84 enum WindowOperation
86 MaximizeOp = 5000,
87 RestoreOp,
88 MinimizeOp,
89 MoveOp,
90 UnrestrictedMoveOp,
91 ResizeOp,
92 UnrestrictedResizeOp,
93 CloseOp,
94 OnAllDesktopsOp,
95 ShadeOp,
96 KeepAboveOp,
97 KeepBelowOp,
98 OperationsOp,
99 WindowRulesOp,
100 ToggleStoreSettingsOp = WindowRulesOp, ///< @obsolete
101 HMaximizeOp,
102 VMaximizeOp,
103 LowerOp,
104 FullScreenOp,
105 NoBorderOp,
106 NoOp,
107 SetupWindowShortcutOp,
108 ApplicationRulesOp
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.
115 enum ColorType
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.
130 enum
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.
144 enum BorderSize
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()
160 enum Ability
162 // announce
163 AbilityAnnounceButtons = 0, ///< decoration supports AbilityButton* values (always use)
164 AbilityAnnounceColors = 1, ///< decoration supports AbilityColor* values (always use)
165 // buttons
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
177 // colors
178 AbilityColorTitleBack = 2000, ///< decoration supports titlebar background color
179 AbilityColorTitleFore = 2001, ///< decoration supports titlebar foreground color
180 AbilityColorTitleBlend = 2002, ///< decoration supports second titlebar background color
181 AbilityColorFrame = 2010, ///< decoration supports frame color
182 AbilityColorHandle = 2011, ///< decoration supports resize handle color
183 AbilityColorButtonBack = 2020, ///< decoration supports button background color
184 AbilityColorButtonFore = 2021, ///< decoration supports button foreground color
185 // TODO colors for individual button types
186 ABILITY_DUMMY = 10000000
189 enum Requirement { REQUIREMENT_DUMMY = 1000000 };
192 class KDecorationProvides
193 : public KDecorationDefines
195 public:
196 virtual ~KDecorationProvides(){}
197 virtual bool provides( Requirement req ) = 0;
201 * This class holds various configuration settings for the decoration.
202 * It is accessible from the decorations either as KDecoration::options()
203 * or KDecorationFactory::options().
205 class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
207 public:
208 KDecorationOptions();
209 virtual ~KDecorationOptions();
211 * Call to update settings when the config changes. Return value is
212 * a combination of Setting* (SettingColors, etc.) that have changed.
213 * @since 4.0.1
215 unsigned long updateSettings( KConfig* config );
217 * Returns the color that should be used for the given part of the decoration.
218 * The changed flags for this setting is SettingColors.
220 * @param type The requested color type.
221 * @param active Whether the color should be for active or inactive windows.
223 QColor color(ColorType type, bool active=true) const;
225 * Returns a palette using the given decoration color as the background.
226 * The changed flags for this setting is SettingColors.
228 * @param type The requested color type.
229 * @param active Whether to return the color for active or inactive windows.
231 QPalette palette(ColorType type, bool active=true) const;
233 * Returns the active or inactive decoration font.
234 * The changed flags for this setting is SettingFont.
236 * @param active Whether to return the color for active or inactive windows.
237 * @param small If @a true, returns a font that's suitable for tool windows.
239 QFont font(bool active=true, bool small = false) const;
241 * Returns @a true if the style should use custom button positions
242 * The changed flags for this setting is SettingButtons.
244 * @see titleButtonsLeft
245 * @see titleButtonsRight
247 bool customButtonPositions() const;
249 * If customButtonPositions() returns true, titleButtonsLeft
250 * returns which buttons should be on the left side of the titlebar from left
251 * to right. Characters in the returned string have this meaning :
252 * @li 'M' menu button
253 * @li 'S' on_all_desktops button
254 * @li 'H' quickhelp button
255 * @li 'I' minimize ( iconify ) button
256 * @li 'A' maximize button
257 * @li 'X' close button
258 * @li 'F' keep_above_others button
259 * @li 'B' keep_below_others button
260 * @li 'L' shade button
261 * @li 'R' resize button
262 * @li '_' spacer
264 * The default ( which is also returned if customButtonPositions returns false )
265 * is "MS".
266 * Unknown buttons in the returned string must be ignored.
267 * The changed flags for this setting is SettingButtons.
269 QString titleButtonsLeft() const;
271 * Returns the default left button sequence
273 static QString defaultTitleButtonsLeft();
275 * If customButtonPositions() returns true, titleButtonsRight
276 * returns which buttons should be on the right side of the titlebar from left
277 * to right. Characters in the return string have the same meaning like
278 * in titleButtonsLeft().
280 * The default ( which is also returned if customButtonPositions returns false )
281 * is "HIAX".
282 * Unknown buttons in the returned string must be ignored.
283 * The changed flags for this setting is SettingButtons.
285 QString titleButtonsRight() const;
287 * Returns the default right button sequence.
289 static QString defaultTitleButtonsRight();
291 * @returns true if the style should use tooltips for window buttons
292 * The changed flags for this setting is SettingTooltips.
294 bool showTooltips() const;
297 * The preferred border size selected by the user, e.g. for accessibility
298 * reasons, or when using high resolution displays. It's up to the decoration
299 * to decide which borders or if any borders at all will obey this setting.
300 * It is guaranteed that the returned value will be one of those
301 * returned by KDecorationFactory::borderSizes(), so if that one hasn't been
302 * reimplemented, BorderNormal is always returned.
303 * The changed flags for this setting is SettingBorder.
304 * @param factory the decoration factory used
306 BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
309 * When this functions returns false, moving and resizing of maximized windows
310 * is not allowed, and therefore the decoration is allowed to turn off (some of)
311 * its borders.
312 * The changed flags for this setting is SettingButtons.
314 bool moveResizeMaximizedWindows() const;
317 * @internal
319 WindowOperation operationMaxButtonClick( Qt::MouseButtons button ) const;
322 * @internal
324 virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
326 protected:
327 /** @internal */
328 void setOpMaxButtonLeftClick( WindowOperation op );
329 /** @internal */
330 void setOpMaxButtonRightClick( WindowOperation op );
331 /** @internal */
332 void setOpMaxButtonMiddleClick( WindowOperation op );
333 /** @internal */
334 void setBorderSize( BorderSize bs );
335 /** @internal */
336 void setCustomButtonPositions( bool b );
337 /** @internal */
338 void setTitleButtonsLeft( const QString& b );
339 /** @internal */
340 void setTitleButtonsRight( const QString& b );
341 private:
343 * @internal
345 KDecorationOptionsPrivate* d;
350 * This is the base class for a decoration object. It provides functions
351 * that give various information about the decorated window, and also
352 * provides pure virtual functions for controlling the decoration that
353 * every decoration should implement.
355 class KWIN_EXPORT KDecoration
356 : public QObject, public KDecorationDefines
358 Q_OBJECT
359 public:
361 * Constructs a KDecoration object. Both the arguments are passed from
362 * KDecorationFactory. Note that the initialization code of the decoration
363 * should be done in the init() method.
365 KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
367 * Destroys the KDecoration.
369 virtual ~KDecoration();
371 // requests from decoration
374 * Returns the KDecorationOptions object, which is used to access
375 * configuration settings for the decoration.
377 static const KDecorationOptions* options();
379 * Returns @a true if the decorated window is currently active.
381 bool isActive() const;
383 * Returns @a true if the decoration window can be closed by the user.
385 bool isCloseable() const;
387 * Returns @a true if the decorated window can be maximized.
389 bool isMaximizable() const;
391 * Returns the current maximization mode of the decorated window.
392 * Note that only fully maximized windows should be treated
393 * as "maximized" (e.g. if the maximize button has only two states).
395 MaximizeMode maximizeMode() const;
397 * Returns @a true if the decorated window can be minimized by the user.
399 bool isMinimizable() const;
401 * Return @a true if the decorated window can show context help
402 * (i.e. the decoration should provide the context help button).
404 bool providesContextHelp() const;
406 * Returns the number of the virtual desktop the decorated window
407 * is currently on (including NET::OnAllDesktops for being on all
408 * desktops).
410 int desktop() const;
412 * Convenience function that returns @a true if the window is on all
413 * virtual desktops.
415 bool isOnAllDesktops() const; // convenience
417 * Returns @a true if the decoration window is modal (usually a modal dialog).
419 bool isModal() const;
421 * Returns @a true if the decorated window can be shaded.
423 bool isShadeable() const;
425 * Returns @a true if the decorated window is currently shaded.
426 * If the window is e.g. hover unshaded, it's not considered to be shaded.
427 * This function should not be used for the shade titlebar button, use
428 * @ref isSetShade() instead.
430 * @see isSetShade
432 bool isShade() const;
434 * Returns @a true if the decorated window was set to be shaded. This function
435 * returns also true if the window is e.g. hover unshaded, so it doesn't
436 * always correspond to the actual window state.
438 * @see isShade
440 bool isSetShade() const;
442 * Returns @a true if the decorated window should be kept above other windows.
444 bool keepAbove() const;
446 * Returns @a true if the decorated window should be kept below other windows.
448 bool keepBelow() const;
450 * Returns @a true if the decorated window can be moved by the user.
452 bool isMovable() const;
454 * Returns @a true if the decorated window can be resized by the user.
456 bool isResizable() const;
458 * This function returns the window type of the decorated window.
459 * The argument to this function is a mask of all window types
460 * the decoration knows about (as the list of valid window types
461 * is extended over time, and fallback types are specified in order
462 * to support older code). For a description of all window types,
463 * see the definition of the NET::WindowType type. Note that
464 * some window types never have decorated windows.
466 * An example of usage:
467 * @code
468 * const unsigned long supported_types = NET::NormalMask | NET::DesktopMask
469 * | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
470 * | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask;
472 * NET::WindowType type = windowType( supported_types );
474 * if( type == NET::Utility || type == NET::Menu || type == NET::Toolbar )
475 * // ... use smaller decorations for tool window types
476 * else
477 * // ... use normal decorations
478 * @endcode
480 NET::WindowType windowType( unsigned long supported_types ) const;
482 * Returns an icon set with the decorated window's icon.
484 QIcon icon() const;
486 * Returns the decorated window's caption that should be shown in the titlebar.
488 QString caption() const;
490 * This function invokes the window operations menu.
491 * \param pos specifies the place on the screen where the menu should
492 * show up. The menu pops up at the bottom-left corner of the specified
493 * rectangle, unless there is no space, in which case the menu is
494 * displayed above the rectangle.
496 * \note Decorations that enable a double-click operation for the menu
497 * button must ensure to call \a showWindowMenu() with the \a pos
498 * rectangle set to the menu button geometry.
499 * IMPORTANT: As a result of this function, the decoration object that
500 * called it may be destroyed after the function returns. This means
501 * that the decoration object must either return immediately after
502 * calling showWindowMenu(), or it must use
503 * KDecorationFactory::exists() to check it's still valid. For example,
504 * the code handling clicks on the menu button should look similarly
505 * like this:
507 * \code
508 * KDecorationFactory* f = factory(); // needs to be saved before
509 * showWindowMenu( button[MenuButton]->mapToGlobal( menuPoint ));
510 * if( !f->exists( this )) // destroyed, return immediately
511 * return;
512 * button[MenuButton]->setDown(false);
513 * \endcode
515 void showWindowMenu( const QRect &pos );
518 * Overloaded version of the above.
520 void showWindowMenu( QPoint pos );
522 * This function performs the given window operation. This function may destroy
523 * the current decoration object, just like showWindowMenu().
525 void performWindowOperation( WindowOperation op );
527 * If the decoration is non-rectangular, this function needs to be called
528 * to set the shape of the decoration.
530 * @param reg The shape of the decoration.
531 * @param mode The X11 values Unsorted, YSorted, YXSorted and YXBanded that specify
532 * the sorting of the rectangles, default value is Unsorted.
534 void setMask( const QRegion& reg, int mode = 0 );
536 * This convenience function resets the shape mask.
538 void clearMask(); // convenience
540 * If this function returns @a true, the decorated window is used as a preview
541 * e.g. in the configuration module. In such case, the decoration can e.g.
542 * show some information in the window area.
544 bool isPreview() const;
546 * Returns the geometry of the decoration.
548 QRect geometry() const;
550 * Returns the icon geometry for the window, i.e. the geometry of the taskbar
551 * entry. This is used mainly for window minimize animations. Note that
552 * the geometry may be null.
554 QRect iconGeometry() const;
556 * Returns the intersection of the given region with the region left
557 * unobscured by the windows stacked above the current one. You can use
558 * this function to, for example, try to keep the titlebar visible if
559 * there is a hole available. The region returned is in the coordinate
560 * space of the decoration.
561 * @param r The region you want to check for holes
563 QRegion unobscuredRegion( const QRegion& r ) const;
565 * Returns the handle of the window that is being decorated. It is possible
566 * the returned value will be 0.
567 * IMPORTANT: This function is meant for special purposes, and it
568 * usually should not be used. The main purpose is finding out additional
569 * information about the window's state. Also note that different kinds
570 * of windows are decorated: Toplevel windows managed by the window manager,
571 * test window in the window manager decoration module, and possibly also
572 * other cases.
573 * Careless abuse of this function will usually sooner or later lead
574 * to problems.
576 WId windowId() const;
578 * Convenience function that returns the width of the decoration.
580 int width() const; // convenience
582 * Convenience function that returns the height of the decoration.
584 int height() const; // convenience
586 * This function is the default handler for mouse events. All mouse events
587 * that are not handled by the decoration itself should be passed to it
588 * in order to make work operations like window resizing by dragging borders etc.
590 void processMousePressEvent( QMouseEvent* e );
592 // requests to decoration
595 * This function is called immediately after the decoration object is created.
596 * Due to some technical reasons, initialization should be done here
597 * instead of in the constructor.
599 virtual void init() = 0; // called once right after created
602 * This function should return mouse cursor position in the decoration.
603 * Positions at the edge will result in window resizing with mouse button
604 * pressed, center position will result in moving.
606 virtual Position mousePosition( const QPoint& p ) const = 0;
609 * This function should return the distance from each window side to the inner
610 * window. The sizes may depend on the state of the decorated window, such as
611 * whether it's shaded. Decorations often turn off their bottom border when the
612 * window is shaded, and turn off their left/right/bottom borders when
613 * the window is maximized and moving and resizing of maximized windows is disabled.
614 * This function mustn't do any repaints or resizes. Also, if the sizes returned
615 * by this function don't match the real values, this may result in drawing errors
616 * or other problems.
618 * @see KDecorationOptions::moveResizeMaximizedWindows()
620 // mustn't do any repaints, resizes or anything like that
621 virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
623 * This method is called by kwin when the style should resize the decoration window.
624 * The usual implementation is to resize the main widget of the decoration to the
625 * given size.
627 * @param s Specifies the new size of the decoration window.
629 virtual void resize( const QSize& s ) = 0;
631 * This function should return the minimum required size for the decoration.
632 * Note that the returned size shouldn't be too large, because it will be
633 * used to keep the decorated window at least as large.
635 virtual QSize minimumSize() const = 0;
637 * This function is called whenever the window either becomes or stops being active.
638 * Use isActive() to find out the current state.
640 virtual void activeChange() = 0;
642 * This function is called whenever the caption changes. Use caption() to get it.
644 virtual void captionChange() = 0;
646 * This function is called whenever the window icon changes. Use icon() to get it.
648 virtual void iconChange() = 0;
650 * This function is called whenever the maximalization state of the window changes.
651 * Use maximizeMode() to get the current state.
653 virtual void maximizeChange() = 0;
655 * This function is called whenever the desktop for the window changes. Use
656 * desktop() or isOnAllDesktops() to find out the current desktop
657 * on which the window is.
659 virtual void desktopChange() = 0;
661 * This function is called whenever the window is shaded or unshaded. Use
662 * isShade() to get the current state.
664 virtual void shadeChange() = 0;
665 Q_SIGNALS:
667 * This signal is emitted whenever the window's keep-above state changes.
669 void keepAboveChanged( bool );
671 * This signal is emitted whenever the window's keep-below state changes.
673 void keepBelowChanged( bool );
674 public:
676 * This function may be reimplemented to provide custom bound drawing
677 * for transparent moving or resizing of the window.
678 * @a False should be returned if the default implementation should be used.
679 * Note that if you e.g. paint the outline using a 5 pixels wide line,
680 * you should compensate for the 2 pixels that would make the window
681 * look larger.
682 * It is the decoration's responsibility to do the painting, using
683 * e.g. code like:
684 * @code
685 * Display* dpy = QX11Info::display();
686 * XGCValues xgc;
687 * xgc.function = GXxor;
688 * xgc.foreground = WhitePixel( dpy, DefaultScreen( dpy ));
689 * xgc.line_width = width;
690 * xgc.subwindow_mode = IncludeInferiors;
691 * GC gc = XCreateGC( dpy, DefaultRootWindow( dpy ),
692 * GCFunction | GCForeground | GCLineWidth | GCSubwindowMode, &xgc );
693 * XDrawRectangle( dpy, DefaultRootWindow( dpy ), gc, r.x(), r.y(), r.width(), r.height());
694 * XFreeGC( dpy, gc );
695 * @endcode
697 * @param geom The geometry at this the bound should be drawn
698 * @param clear @a true if the bound should be cleared (when doing the usual XOR
699 * painting this argument can be simply ignored)
701 * @see geometry()
703 virtual bool drawbound( const QRect& geom, bool clear );
705 * @internal Reserved.
707 // TODO position will need also values for top+left+bottom etc. docking ?
708 virtual bool windowDocked( Position side );
710 * This function is called to reset the decoration on settings changes.
711 * It is usually invoked by calling KDecorationFactory::resetDecorations().
713 * @param changed Specifies which settings were changed, given by the SettingXXX masks
715 virtual void reset( unsigned long changed );
717 // special
720 * This should be the first function called in init() to specify
721 * the main widget of the decoration. The widget should be created
722 * with parent specified by initialParentWidget() and flags
723 * specified by initialWFlags().
725 void setMainWidget( QWidget* );
727 * Convenience functions that creates and sets a main widget as necessary.
728 * In such case, it's usually needed to install an event filter
729 * on the main widget to receive important events on it.
731 * @param flags Additional widget flags for the main widget. Note that only
732 * flags that affect widget drawing are allowed. Window type flags
733 * like WX11BypassWM or WStyle_NoBorder are forbidden.
735 void createMainWidget( Qt::WFlags flags = 0 );
737 * The parent widget that should be used for the main widget.
739 QWidget* initialParentWidget() const;
741 * The flags that should be used when creating the main widget.
742 * It is possible to add more flags when creating the main widget, but only flags
743 * that affect widget drawing are allowed. Window type flags like WX11BypassWM
744 * or WStyle_NoBorder are forbidden.
746 Qt::WFlags initialWFlags() const;
748 * Returns the main widget for the decoration.
750 QWidget* widget();
752 * Returns the main widget for the decoration.
754 const QWidget* widget() const;
756 * Returns the factory that created this decoration.
758 KDecorationFactory* factory() const;
760 * Performs X server grab. It is safe to call it several times in a row.
762 void grabXServer();
764 * Ungrabs X server (if the number of ungrab attempts matches the number of grab attempts).
766 void ungrabXServer();
767 public Q_SLOTS:
768 // requests from decoration
771 * This function can be called by the decoration to request
772 * closing of the decorated window. Note that closing the window
773 * also involves destroying the decoration.
774 * IMPORTANT: This function may destroy the current decoration object,
775 * just like showWindowMenu().
777 void closeWindow();
779 * Changes the maximize mode of the decorated window. This function should
780 * be preferred to the other maximize() overload for reacting on clicks
781 * on the maximize titlebar button.
783 void maximize( Qt::MouseButtons button );
785 * Set the maximize mode of the decorated window.
786 * @param mode The maximization mode to be set.
788 void maximize( MaximizeMode mode );
790 * Minimize the decorated window.
792 void minimize();
794 * Start showing context help in the window (i.e. the mouse will enter
795 * the what's this mode).
797 void showContextHelp();
799 * Moves the window to the given desktop. Use NET::OnAllDesktops for making
800 * the window appear on all desktops.
802 void setDesktop( int desktop );
804 * This function toggles the on-all-desktops state of the decorated window.
806 void toggleOnAllDesktops(); // convenience
808 * This function performs the operation configured as titlebar double click
809 * operation.
811 void titlebarDblClickOperation();
813 * This function performs the operation configured as titlebar wheel mouse
814 * operation.
815 * @param delta the mouse wheel delta
817 void titlebarMouseWheelOperation( int delta );
819 * Shades or unshades the decorated window.
820 * @param set Whether the window should be shaded
822 void setShade( bool set );
824 * Sets or reset keeping this window above others.
825 * @param set Whether to keep the window above others
827 void setKeepAbove( bool set );
829 * Sets or reset keeping this window below others.
830 * @param set Whether to keep the window below others
832 void setKeepBelow( bool set );
834 * @internal
836 void emitKeepAboveChanged( bool above );
838 * @internal
840 void emitKeepBelowChanged( bool below );
841 private:
842 KDecorationBridge* bridge_;
843 QWidget* w_;
844 KDecorationFactory* factory_;
845 friend class KDecorationOptions; // for options_
846 static KDecorationOptions* options_;
847 KDecorationPrivate* d;
850 inline
851 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
853 return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
856 inline
857 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
859 return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
862 inline
863 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
865 return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
868 inline QWidget* KDecoration::widget()
870 return w_;
873 inline const QWidget* KDecoration::widget() const
875 return w_;
878 inline KDecorationFactory* KDecoration::factory() const
880 return factory_;
883 inline bool KDecoration::isOnAllDesktops() const
885 return desktop() == NET::OnAllDesktops;
888 inline int KDecoration::width() const
890 return geometry().width();
893 inline int KDecoration::height() const
895 return geometry().height();
898 /** @} */
900 #endif