summaryrefslogtreecommitdiff
path: root/src/defaultDeco.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/defaultDeco.cpp')
-rw-r--r--src/defaultDeco.cpp704
1 files changed, 0 insertions, 704 deletions
diff --git a/src/defaultDeco.cpp b/src/defaultDeco.cpp
deleted file mode 100644
index 3f8bad5..0000000
--- a/src/defaultDeco.cpp
+++ /dev/null
@@ -1,704 +0,0 @@
-/*
- * 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.
- *
- */
-
-#include "defaultDeco.h"
-#include "decorator.h"
-#include "options.h"
-#include "utils.h"
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/extensions/Xcomposite.h>
-#include <X11/extensions/shape.h>
-
-#include <fixx11h.h>
-
-#include <kdebug.h>
-#include <kglobal.h>
-#include <kglobalsettings.h>
-#include <klocale.h>
-#include <kiconloader.h>
-#include <kdecoration.h>
-#include <kwin.h>
-#include <klocale.h>
-
-
-#include <qapplication.h>
-#include <qlayout.h>
-#include <qevent.h>
-#include <qpainter.h>
-#include <qobjectlist.h>
-#include <qwidget.h>
-#include <qstring.h>
-#include <qtimer.h>
-#include <qcursor.h>
-#include <qpopupmenu.h>
-
-#define GRAVITY_WEST (1 << 0)
-#define GRAVITY_EAST (1 << 1)
-#define GRAVITY_NORTH (1 << 2)
-#define GRAVITY_SOUTH (1 << 3)
-
-#define XX_MASK (1 << 12)
-#define XY_MASK (1 << 13)
-#define YX_MASK (1 << 14)
-#define YY_MASK (1 << 15)
-
-#define CLAMP_HORZ (1 << 0)
-#define CLAMP_VERT (1 << 1)
-
-#define WM_MOVERESIZE_SIZE_TOPLEFT 0
-#define WM_MOVERESIZE_SIZE_TOP 1
-#define WM_MOVERESIZE_SIZE_TOPRIGHT 2
-#define WM_MOVERESIZE_SIZE_RIGHT 3
-#define WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
-#define WM_MOVERESIZE_SIZE_BOTTOM 5
-#define WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
-#define WM_MOVERESIZE_SIZE_LEFT 7
-#define WM_MOVERESIZE_MOVE 8
-#define WM_MOVERESIZE_SIZE_KEYBOARD 9
-#define WM_MOVERESIZE_MOVE_KEYBOARD 10
-
-extern Atom net_window_decor;
-extern Atom net_wm_moveresize;
-
-extern Atom wm_protocols;
-extern Atom wm_delete_window;
-extern Atom wm_take_focus;
-extern Atom net_wm_context_help;
-extern Atom net_wm_ping;
-extern Atom net_wm_take_activity;
-
-extern struct _cursor cursors[3][3];
-
-Aquamarine::DefaultDecoration::DefaultDecoration (bool active):
-m_active (active),
-m_deco (0)
-{
-
-
- m_icons =
- QIconSet (KGlobal::iconLoader ()->
- loadIcon ("xapp", KIcon::NoGroup, 16),
- KGlobal::iconLoader ()->loadIcon ("xapp",
- KIcon::NoGroup, 32));
-
- m_name = QString ("");
-
- m_geometry = QRect (50, 50, 200, 100);
-
- setWState (Qt::WState_Visible);
-
- createDecoration ();
-}
-
-Aquamarine::DefaultDecoration::~DefaultDecoration ()
-{
- delete
- m_deco;
-
- Atom my_atom = XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_NORMAL", FALSE);
- if (m_active)
- my_atom = XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_ACTIVE", FALSE);
-
- Aquamarine::trapXError ();
- XDeleteProperty (qt_xdisplay (), qt_xrootwin (), my_atom);
- Aquamarine::popXError ();
-}
-
-
-
-bool
-Aquamarine::DefaultDecoration::isActive () const
-{
- return m_active;
-}
-
-bool
-Aquamarine::DefaultDecoration::isCloseable () const
-{
- return false;
-}
-
-bool
-Aquamarine::DefaultDecoration::isMaximizable () const
-{
- return false;
-}
-
-KDecoration::MaximizeMode Aquamarine::DefaultDecoration::maximizeMode () const
-{
- return MaximizeRestore;
-}
-
-bool
-Aquamarine::DefaultDecoration::isMinimizable () const
-{
- return false;
-}
-
-bool
-Aquamarine::DefaultDecoration::providesContextHelp () const
-{
- return false;
-}
-
-int
-Aquamarine::DefaultDecoration::desktop () const
-{
- return 1;
-}
-
-bool
-Aquamarine::DefaultDecoration::isModal () const
-{
- return false;
-}
-
-bool
-Aquamarine::DefaultDecoration::isShadeable () const
-{
- return false;
-}
-
-bool
-Aquamarine::DefaultDecoration::isShade () const
-{
- return false;
-}
-
-bool
-Aquamarine::DefaultDecoration::isSetShade () const
-{
- return isShade ();
-}
-
-bool
-Aquamarine::DefaultDecoration::keepAbove () const
-{
- return false;
-}
-
-bool
-Aquamarine::DefaultDecoration::keepBelow () const
-{
- return false;
-}
-
-bool
-Aquamarine::DefaultDecoration::isMovable () const
-{
- return false;
-}
-
-NET::WindowType Aquamarine::DefaultDecoration::windowType (unsigned long) const
-{
- return NET::Normal;
-}
-
-bool
-Aquamarine::DefaultDecoration::isResizable () const
-{
- return false;
-}
-
-QIconSet
-Aquamarine::DefaultDecoration::icon () const
-{
- return m_icons;
-}
-
-QString
-Aquamarine::DefaultDecoration::caption () const
-{
- return m_name;
-}
-
-void
-Aquamarine::DefaultDecoration::showWindowMenu (QPoint)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::showWindowMenu (const QRect &)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::processMousePressEvent (QMouseEvent *)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::performWindowOperation (WindowOperation)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::setMask (const QRegion &, int)
-{
-}
-
-bool
-Aquamarine::DefaultDecoration::isPreview () const
-{
- return false;
-}
-
-QRect
-Aquamarine::DefaultDecoration::geometry () const
-{
- if (m_deco)
- {
- int
- top,
- bottom,
- left,
- right;
- m_deco->borders (left, right, top, bottom);
- return QRect (0, 0, m_geometry.width () + left + right,
- m_geometry.height () + top + bottom);
- }
- return m_geometry;
-}
-
-QRect
-Aquamarine::DefaultDecoration::iconGeometry () const
-{
- return QRect ();
-}
-
-QRegion
-Aquamarine::DefaultDecoration::unobscuredRegion (const QRegion & r) const
-{
- return r;
-}
-
-QWidget *
-Aquamarine::DefaultDecoration::workspaceWidget () const
-{
- return 0;
-}
-
-WId
-Aquamarine::DefaultDecoration::windowId () const
-{
- return qt_xrootwin();
-}
-
-void
-Aquamarine::DefaultDecoration::closeWindow ()
-{
-}
-
-void
-Aquamarine::DefaultDecoration::maximize (MaximizeMode)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::minimize ()
-{
-}
-
-void
-Aquamarine::DefaultDecoration::showContextHelp ()
-{
-}
-
-void
-Aquamarine::DefaultDecoration::titlebarDblClickOperation ()
-{
-}
-
-void
-Aquamarine::DefaultDecoration::setDesktop (int)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::setKeepBelow (bool)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::setKeepAbove (bool)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::setShade (bool)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::titlebarMouseWheelOperation (int)
-{
-}
-
-int
-Aquamarine::DefaultDecoration::currentDesktop () const
-{
- return 1;
-}
-
-QWidget *
-Aquamarine::DefaultDecoration::initialParentWidget () const
-{
- return const_cast < DefaultDecoration * >(this);
-}
-
-Qt::WFlags Aquamarine::DefaultDecoration::initialWFlags () const
-{
- return 0;
-}
-
-void
-Aquamarine::DefaultDecoration::helperShowHide (bool)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::grabXServer (bool)
-{
-}
-
-void
-Aquamarine::DefaultDecoration::createDecoration ()
-{
- if (m_deco)
- return;
- KDecoration *
- deco = Decorator::pluginManager ()->createDecoration (this);
- deco->init ();
- m_deco = deco;
-
- resizeDecoration ( true );
- grabChildWidgets ();
- updateWindowProperties ();
-}
-
-void
-Aquamarine::DefaultDecoration::resizeDecoration ( bool force )
-{
- int
- top,
- bottom,
- left,
- right;
- m_deco->borders (left, right, top, bottom);
- move (m_geometry.x() - left, m_geometry.y() - top);
- if (!force && m_qpixmap.width () == (m_geometry.width () + left + right)
- && m_qpixmap.height () == (m_geometry.height () + top + bottom))
- return;
-
- if (m_qpixmap.isNull ())
- m_qpixmap =
- QPixmap (m_geometry.width () + left + right,
- m_geometry.height () + top + bottom);
- else
- m_qpixmap.resize (m_geometry.width () + left + right,
- m_geometry.height () + top + bottom);
- resize (m_geometry.width () + left + right,
- m_geometry.height () + top + bottom);
- QPainter::redirect (m_deco->widget (), &m_qpixmap);
- m_deco->
- resize (QSize
- (m_geometry.width () + left + right,
- m_geometry.height () + top + bottom));
- m_deco->widget ()->setShown (true);
-
-}
-
-void
-Aquamarine::DefaultDecoration::updateWindowProperties ()
-{
- Atom my_atom = XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_NORMAL", FALSE);
- if (m_active)
- my_atom = XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_ACTIVE", FALSE);
-
- Pixmap m_pixmap = m_qpixmap.handle ();
-
- int top, bottom, left, right;
- m_deco->borders (left, right, top, bottom);
-
- int
- w_w = m_geometry.width ();
- int
- w_h = m_geometry.height ();
-
- long
- mdata[256];
-
- long *
- data = mdata;
-
- *data++ = 0;
- memcpy (data++, &m_pixmap, sizeof (m_pixmap));
-
- *data++ = left;
- *data++ = right;
- *data++ = top;
- *data++ = bottom;
-
- *data++ = left;
- *data++ = right;
- *data++ = top;
- *data++ = bottom;
-
- *data++ = 0;
- *data++ = 0;
-
- // TOP LEFT
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_NORTH | GRAVITY_WEST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = -left;
- *data++ = -top;
- *data++ = 0;
- *data++ = 0;
- *data++ = left;
- *data++ = top;
- *data++ = 0;
- *data++ = 0;
-
- // TOP RIGHT
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_EAST) << 0) |
- ((GRAVITY_NORTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = 0;
- *data++ = -top;
- *data++ = right;
- *data++ = 0;
- *data++ = right;
- *data++ = top;
- *data++ = left + w_w;
- *data++ = 0;
-
- // BOTTOM LEFT
- *data++ =
- ((GRAVITY_SOUTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_WEST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = -left;
- *data++ = 0;
- *data++ = 0;
- *data++ = bottom;
- *data++ = left;
- *data++ = bottom;
- *data++ = 0;
- *data++ = w_h + top;
-
- // BOTTOM RIGHT
- *data++ =
- ((GRAVITY_SOUTH | GRAVITY_EAST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = 0;
- *data++ = 0;
- *data++ = right;
- *data++ = bottom;
- *data++ = right;
- *data++ = bottom;
- *data++ = left + w_w;
- *data++ = w_h + top;
-
- // TOP CENTER
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_NORTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = 0;
- *data++ = -top;
- *data++ = 0;
- *data++ = 0;
- *data++ = w_w;
- *data++ = top;
- *data++ = left;
- *data++ = 0;
-
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_NORTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (CLAMP_HORZ << 10) | (YY_MASK);
-
- *data++ = w_w;
- *data++ = -top;
- *data++ = 0;
- *data++ = 0;
- *data++ = SHRT_MAX;
- *data++ = top;
- *data++ = left + w_w;
- *data++ = 0;
-
- // BOTTOM CENTER
- *data++ =
- ((GRAVITY_SOUTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = 0;
- *data++ = 0;
- *data++ = 0;
- *data++ = bottom;
- *data++ = w_w;
- *data++ = bottom;
- *data++ = left;
- *data++ = w_h + top;
-
- *data++ =
- ((GRAVITY_SOUTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (CLAMP_HORZ << 10) | (YY_MASK);
-
- *data++ = w_w;
- *data++ = 0;
- *data++ = 0;
- *data++ = bottom;
- *data++ = SHRT_MAX;
- *data++ = bottom;
- *data++ = left + w_w;
- *data++ = w_h + top;
-
- //LEFT
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_WEST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = -left;
- *data++ = 0;
- *data++ = 0;
- *data++ = 0;
- *data++ = left;
- *data++ = w_h;
- *data++ = 0;
- *data++ = top;
-
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_WEST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_WEST) << 4) |
- (0 << 8) | (CLAMP_VERT << 10) | (XX_MASK);
-
- *data++ = -left;
- *data++ = w_h;
- *data++ = 0;
- *data++ = 0;
- *data++ = left;
- *data++ = SHRT_MAX;
- *data++ = 0;
- *data++ = top + w_h;
-
- //RIGHT
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_EAST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (0 << 10) | (XX_MASK) | (YY_MASK);
-
- *data++ = 0;
- *data++ = 0;
- *data++ = right;
- *data++ = 0;
- *data++ = right;
- *data++ = w_h;
- *data++ = w_w + left;
- *data++ = top;
-
- *data++ =
- ((GRAVITY_NORTH | GRAVITY_EAST) << 0) |
- ((GRAVITY_SOUTH | GRAVITY_EAST) << 4) |
- (0 << 8) | (CLAMP_VERT << 10) | (XX_MASK);
-
- *data++ = 0;
- *data++ = w_h;
- *data++ = right;
- *data++ = 0;
- *data++ = right;
- *data++ = SHRT_MAX;
- *data++ = w_w + left;
- *data++ = top + w_h;
-
- Aquamarine::trapXError ();
- XChangeProperty (qt_xdisplay (), qt_xrootwin(),
- my_atom,
- XA_INTEGER,
- 32, PropModeReplace, (unsigned char *)mdata,
- 12 + (12 * 9));
- Aquamarine::popXError ();
- XSync (qt_xdisplay (), FALSE);
-}
-
-void
-Aquamarine::DefaultDecoration::grabChildWidgets ()
-{
- if (!m_deco)
- return;
-
- QPaintEvent *
- e = new QPaintEvent (m_deco->widget ()->rect (), false);
- QApplication::sendEvent (m_deco->widget (), e);
-
- QPainter * p = 0;
-
- p = new QPainter (&m_qpixmap);
-
- QRegion childs;
-
- const QObjectList * children = m_deco->widget ()->children ();
- if (children)
- {
- QObjectListIt it (*children);
- QObject * child;
- while ((child = it.current ()) != 0)
- {
- ++it;
- if (child->isWidgetType ())
- {
- QWidget * wid = static_cast < QWidget * >(child);
- childs += wid->rect ();
- QPixmap pix = QPixmap::grabWidget (wid);
- p->drawPixmap (wid->pos (), pix);
- }
- }
- }
- delete p;
-}
-
-void
-Aquamarine::DefaultDecoration::reloadDecoration ()
-{
- delete m_deco;
- m_deco = 0;
- createDecoration ();
-}