summaryrefslogtreecommitdiff
path: root/src/window.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.h')
-rw-r--r--src/window.h479
1 files changed, 261 insertions, 218 deletions
diff --git a/src/window.h b/src/window.h
index e3f757e..a38d66d 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1,243 +1,286 @@
/*
- * Aquamarine the KDE window decorator
- *
- * Copyright (c) 2006 Dennis Kasprzyk <onestone@beryl-project.org>
- * Copyright (c) 2006 Volker Krause <vkrause@kde.org>
- *
- * Uses code of:
- * Emerald window decorator (www.beryl-project.org)
- * gtk-window-decorator (www.freedesktop.org/wiki/Software/Compiz)
- * KWin window manager (www.kde.org)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef AQUAMARINE_WINDOW_H
-#define AQUAMARINE_WINDOW_H
+* Aquamarine the KDE window decorator
+*
+* Copyright (c) 2006 Dennis Kasprzyk <onestone@beryl-project.org>
+* Copyright (c) 2006 Volker Krause <vkrause@kde.org>
+* Copyright (c) 2006 David Reveman <davidr@novell.com>
+*
+* Uses code of:
+* KWin window manager (www.kde.org)
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#ifndef _WINDOW_H
+#define _WINDOW_H
#include <kdecoration_p.h>
#include <qpixmap.h>
#include <qwidget.h>
-#include <X11/extensions/Xrender.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xdamage.h>
+
+
+//#include <beryl-decoration.h>
+#include "libdeco.h"
#include "utils.h"
#include "options.h"
+
+class KProcess;
class KDecoration;
class QPopupMenu;
-class KProcess;
namespace Aquamarine
{
-
- class Window:public QWidget, public KDecorationBridge
- {
- Q_OBJECT public:
-
- public:
- Window (WId wid, WId frame);
- ~Window ();
-
- // KDecorationBridge methods
- virtual bool isActive () const;
- virtual bool isCloseable () const;
- virtual bool isMaximizable () const;
- virtual MaximizeMode maximizeMode () const;
- virtual bool isMinimizable () const;
- virtual bool providesContextHelp () const;
- virtual int desktop () const;
- virtual bool isModal () const;
- virtual bool isShadeable () const;
- virtual bool isShade () const;
- virtual bool isSetShade () const;
- virtual bool keepAbove () const;
- virtual bool keepBelow () const;
- virtual bool isMovable () const;
- virtual bool isResizable () const;
- virtual NET::WindowType windowType (unsigned long supported_types) const;
- virtual QIconSet icon () const;
- virtual QString caption () const;
- virtual void processMousePressEvent (QMouseEvent *);
- virtual void showWindowMenu (const QRect &);
- virtual void showWindowMenu (QPoint);
- virtual void performWindowOperation (WindowOperation);
- virtual void setMask (const QRegion &, int);
- virtual bool isPreview () const;
- virtual QRect geometry () const;
- virtual QRect iconGeometry () const;
- virtual QRegion unobscuredRegion (const QRegion & r) const;
- virtual QWidget *workspaceWidget () const;
- virtual WId windowId () const;
- virtual void closeWindow ();
- virtual void maximize (MaximizeMode mode);
- virtual void minimize ();
- virtual void showContextHelp ();
- virtual void setDesktop (int desktop);
- virtual void titlebarDblClickOperation ();
- virtual void titlebarMouseWheelOperation (int delta);
- virtual void setShade (bool set);
- virtual void setKeepAbove (bool);
- virtual void setKeepBelow (bool);
-
- virtual int currentDesktop () const;
- virtual QWidget *initialParentWidget () const;
- virtual Qt::WFlags initialWFlags () const;
- virtual void helperShowHide (bool);
- virtual void grabXServer (bool grab);
-
- void setActive (bool active);
- void updateFrame (WId frame);
- void updateWindowGeometry ();
-
- void updateCursor (QPoint pos);
-
- WId frameId () const
- {
- return m_frame;
- }
- KDecoration *decoration () const
- {
- return m_deco;
- }
-
- void moveWindow (QMouseEvent * qme);
-
- void reloadDecoration ();
- void updateConfig ();
-
- void updateState ();
- void updateName ();
- void updateIcons ();
-
- void updateOpacity ()
- {
- m_opacity =
- readWindowPropertyDefault (m_wid, Atoms::opacity, 0xffff);
- }
- void updateBrightness ()
- {
- m_brightness =
- readWindowPropertyDefault (m_wid, Atoms::brightness, 0xffff);
- }
- void updateSaturation ()
- {
- m_saturation =
- readWindowPropertyDefault (m_wid, Atoms::saturation, 0xffff);
- }
-
- void setMapping (bool map);
-
+class Window:public QWidget, public KDecorationBridge {
+ Q_OBJECT public:
+
+ enum Type
+ {
+ Normal,
+ Switcher,
+ Default,
+ DefaultActive
+ };
+
+ public:
+ Window (QWidget *parent, WId clientId, WId frame, Type type,
+ int x = 0, int y = 0, int w = 1, int h = 1);
+ ~Window (void);
+
+ virtual bool isActive (void) const;
+ virtual bool isCloseable (void) const;
+ virtual bool isMaximizable (void) const;
+ virtual MaximizeMode maximizeMode (void) const;
+ virtual bool isMinimizable (void) const;
+ virtual bool providesContextHelp (void) const;
+ virtual int desktop (void) const;
+ virtual bool isModal (void) const;
+ virtual bool isShadeable (void) const;
+ virtual bool isShade (void) const;
+ virtual bool isSetShade (void) const;
+ virtual bool keepAbove (void) const;
+ virtual bool keepBelow (void) const;
+ virtual bool isMovable (void) const;
+ virtual bool isResizable (void) const;
+ virtual NET::WindowType
+ windowType (unsigned long supported_types) const;
+ virtual QIconSet icon (void) const;
+ virtual QString caption (void) const;
+ virtual void processMousePressEvent (QMouseEvent *);
+ virtual void showWindowMenu (const QRect &);
+ virtual void showWindowMenu (QPoint);
+ virtual void performWindowOperation (WindowOperation);
+ virtual void setMask (const QRegion &, int);
+ virtual bool isPreview (void) const;
+ virtual QRect geometry (void) const;
+ virtual QRect iconGeometry (void) const;
+ virtual QRegion unobscuredRegion (const QRegion & r) const;
+ virtual QWidget *workspaceWidget (void) const;
+ virtual WId windowId (void) const;
+ virtual void closeWindow (void);
+ virtual void maximize (MaximizeMode mode);
+ virtual void minimize (void);
+ virtual void showContextHelp (void);
+ virtual void setDesktop (int desktop);
+ virtual void titlebarDblClickOperation (void);
+ virtual void titlebarMouseWheelOperation (int delta);
+ virtual void setShade (bool set);
+ virtual void setKeepAbove (bool);
+ virtual void setKeepBelow (bool);
+ virtual int currentDesktop (void) const;
+ virtual QWidget *initialParentWidget (void) const;
+ virtual Qt::WFlags initialWFlags (void) const;
+ virtual void helperShowHide (bool);
+ virtual void grabXServer (bool grab);
+
+ void handleActiveChange (void);
+ void updateFrame (WId frame);
+ void updateWindowGeometry (void);
+ void updateCursor (QPoint pos);
+ void updateSelected (WId selected);
+ WId frameId (void) const
+ {
+ return mFrame;
+ }
+ KDecoration *decoration (void) const
+ {
+ return mDecor;
+ }
+ QWidget *activeChild (void) const
+ {
+ return mActiveChild;
+ }
+ void setActiveChild (QWidget * child)
+ {
+ mActiveChild = child;
+ }
+ QRegion *getShape (void)
+ {
+ if (mShapeSet)
+ return &mShape;
+
+ return NULL;
+ }
+ void getShapeInfo (bool *horz, bool *vert)
+ {
+ *horz = mUniqueHorzShape;
+ *vert = mUniqueVertShape;
+ }
+ void moveWindow (QMouseEvent *qme);
+ void reloadDecoration (void);
+ void updateState (void);
+ void updateName (void);
+ void updateIcons (void);
+
+ Drawable pixmapId (void) const
+ {
+ return mPixmap;
+ }
+ void addDamageRect (int x, int y, int w, int h)
+ {
+ mDamage += QRegion (x, y, w, h);
+ }
+ bool handleMap (void);
+ bool handleConfigure (void);
+ void processDamage (void);
+ decor_context_t *context (void)
+ {
+ return &mContext;
+ }
+ decor_shadow_t *shadow (void)
+ {
+ return mShadow;
+ }
+ QRect clientGeometry (void);
void showKillProcessDialog (Time timestamp);
void hideKillProcessDialog (void);
- protected:
- virtual bool eventFilter (QObject * watched, QEvent * event);
-
- private:
- enum WindowAppearance
- {
- ResetValues,
- ChangeOpacity25,
- ChangeOpacity50,
- ChangeOpacity75,
- ChangeOpacity100,
- ChangeBrightness25,
- ChangeBrightness50,
- ChangeBrightness75,
- ChangeBrightness100,
- ChangeSaturation25,
- ChangeSaturation50,
- ChangeSaturation75,
- ChangeSaturation100
- };
-
- private:
- void createDecoration ();
- void resizeDecoration ();
- void getWindowProtocols ();
- void performMouseCommand( Options::MouseCommand, QMouseEvent *qme );
- XFixed *createGaussianKernel (int *r_size);
- void setPictureTransform (Picture p, int dx, int dy);
- void renderShadow ();
- void renderShadow (QRegion reg);
-
- private slots:
- void updateWindow ();
- void updateWindowProperties ();
- void slotPopupActivated (int id);
- void slotPopupAboutToShow ();
- void slotChangeViewport (int id);
- void slotAppearanceChange (int id);
- void slotDesktopGeometryChanged ();
+ void updateShadow (void);
+
+ void updateOpacity ()
+ {
+ mOpacity =
+ readPropertyShort (mClientId, Atoms::netWmWindowOpacity, 0xffff);
+ }
+ void updateBrightness ()
+ {
+ mBrightness =
+ readPropertyShort (mClientId, Atoms::netWmWindowBrightness, 0xffff);
+ }
+ void updateSaturation ()
+ {
+ mSaturation =
+ readPropertyShort (mClientId, Atoms::netWmWindowSaturation, 0xffff);
+ }
+
+ private:
+ enum WindowAppearance
+ {
+ ResetValues,
+ ChangeOpacity25,
+ ChangeOpacity50,
+ ChangeOpacity75,
+ ChangeOpacity100,
+ ChangeBrightness25,
+ ChangeBrightness50,
+ ChangeBrightness75,
+ ChangeBrightness100,
+ ChangeSaturation25,
+ ChangeSaturation50,
+ ChangeSaturation75,
+ ChangeSaturation100
+ };
+
+ private:
+ void createDecoration (void);
+
+ bool resizeDecoration (bool force = false);
+ void updateProperty (void);
+ void getWindowProtocols (void);
+ void performMouseCommand (Aquamarine::Options::MouseCommand command,
+ QMouseEvent *qme);
+ NET::Direction positionToDirection (int pos);
+ Cursor positionToCursor (QPoint pos);
+ void rebindPixmap (void);
+
+
+ private slots:
+ void handlePopupActivated (int id);
+ void handleDesktopPopupActivated (int id);
+ void handlePopupAboutToShow (void);
void handleProcessKillerExited (void);
-
- private:
- WId m_wid;
- WId m_frame;
-
- // window properties
- QRect m_geometry;
- bool m_active;
- QString m_name;
- QIconSet m_icons;
-
- unsigned short m_opacity;
- unsigned short m_brightness;
- unsigned short m_saturation;
-
- // decoration stuff
- KDecoration *m_deco;
- Pixmap m_currentPixmap;
- bool m_updatePixmap;
- bool m_mapped;
- bool m_fakeMaximized;
-
- // shape stuff
- bool m_shapeSet;
- QRegion m_shape;
- QRegion m_shapeChange;
-
- // window handling
- bool m_supportDeleteWindow;
- bool m_supportTakeFocus;
- bool m_supportTakeActivity;
- bool m_supportContextHelp;
- bool m_supportPing;
-
- // window menu
- QPopupMenu *m_popup;
- QPopupMenu *m_advanced_popup;
- QPopupMenu *m_viewport_menu;
- QPopupMenu *m_appearance_menu;
- QPopupMenu *m_brightness_menu;
- QPopupMenu *m_saturation_menu;
- QPopupMenu *m_opacity_menu;
-
- unsigned long m_state;
-
- // shadow
- QRect m_soffset;
- int m_sradius;
- short m_scolor[4];
-
+ void handleChangeViewport (int id);
+ void handleDesktopGeometryChanged ();
+ void handleAppearanceChange (int id);
+
+
+ private:
+ Type mType;
+ WId mFrame;
+ WId mClientId;
+ WId mSelectedId;
+ QRect mGeometry;
+ QString mName;
+ QIconSet mIcons;
+ decor_extents_t mBorder;
+ KDecoration *mDecor;
+ QPixmap mTexturePixmap;
+ QPixmap mTexturePixmapBuffer;
+ Pixmap mPixmap;
+ QRegion mDamage;
+ WId mDamageId;
+ decor_layout_t mLayout;
+ decor_context_t mContext;
+ decor_shadow_t *mShadow;
+ Picture mPicture;
+ Picture mTexturePicture;
+ Picture mDecorationPicture;
+ bool mUpdateProperty;
+ bool mShapeSet;
+ bool mUniqueHorzShape;
+ bool mUniqueVertShape;
+ QRegion mShape;
+ QWidget *mActiveChild;
+ bool mSupportTakeFocus;
+ bool mSupportContextHelp;
+
+ QPopupMenu *mPopup;
+ QPopupMenu *mAdvancedMenu;
+ QPopupMenu *mDesktopMenu;
+ QPopupMenu *mViewportMenu;
+ QPopupMenu *mAppearanceMenu;
+ QPopupMenu *mBrightnessMenu;
+ QPopupMenu *mSaturationMenu;
+ QPopupMenu *mOpacityMenu;
+
+ unsigned long mState;
+ bool mMapped;
+ int mPendingMap;
+ int mPendingConfigure;
KProcess *mProcessKiller;
- };
+ unsigned short mOpacity;
+ unsigned short mBrightness;
+ unsigned short mSaturation;
+ };
}
#endif