summaryrefslogtreecommitdiff
path: root/src/switcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/switcher.cpp')
-rw-r--r--src/switcher.cpp349
1 files changed, 0 insertions, 349 deletions
diff --git a/src/switcher.cpp b/src/switcher.cpp
deleted file mode 100644
index 02523fb..0000000
--- a/src/switcher.cpp
+++ /dev/null
@@ -1,349 +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 "switcher.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 <kiconloader.h>
-#include <kdecoration.h>
-#include <kwin.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>
-
-#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)
-
-extern Atom net_window_decor;
-
-extern Atom select_window_atom;
-
-#define TOP 10
-#define BOTTOM 50
-#define LEFT 10
-#define RIGHT 10
-
-#define BACKGROUND 0xd7bfbfbf
-
-Aquamarine::Switcher::Switcher (WId wid):
-m_wid (wid)
-{
- updateGeometry ();
-}
-
-Aquamarine::Switcher::~Switcher ()
-{
-
-}
-
-void
-Aquamarine::Switcher::updateGeometry ()
-{
- int
- x,
- y;
- unsigned int
- width,
- height,
- border,
- depth;
- ::Window root;
- XGetGeometry (qt_xdisplay (), m_wid, &root, &x, &y, &width, &height,
- &border, &depth);
- m_geometry = QRect (x, y, width, height);
- m_qpixmap = QPixmap (width + LEFT + RIGHT, height + TOP + BOTTOM);
-
-
- Aquamarine::readWindowProperty (m_wid, Atoms::select_window,
- (long *)&m_selected);
- m_sName = KWin::readNameProperty (m_selected, XA_WM_NAME);
-
-
- XSetWindowBackground (qt_xdisplay (), m_wid, BACKGROUND);
- XClearWindow (qt_xdisplay (), m_wid);
- XSync (qt_xdisplay (), FALSE);
-
-
- Pixmap pix = m_qpixmap.handle ();
- XGCValues gcv;
- gcv.foreground = 0x00000000;
- gcv.plane_mask = 0xffffffff;
- GC gc = XCreateGC (qt_xdisplay (), pix, GCForeground, &gcv);
-
- XFillRectangle (qt_xdisplay (), pix, gc, 0, 0,
- width + LEFT + RIGHT, height + TOP + BOTTOM);
-
- XFreeGC (qt_xdisplay (), gc);
-
- QPainter
- p (&m_qpixmap);
-
- QBrush
- b1 (QColor (0, BACKGROUND));
-
- p.setPen (Qt::black);
- p.setBrush (b1);
- p.drawRoundRect (0, 0, m_qpixmap.width (), m_qpixmap.height (),
- (8 * m_qpixmap.height ()) / m_qpixmap.width (), 8);
-
- QFont
- font (Aquamarine::Decorator::options ()->font (true));
- p.setFont (font);
- QFontMetrics
- fm = p.fontMetrics ();
- while (fm.width (m_sName) > m_geometry.width ())
- {
- m_sName.truncate (m_sName.length () - 6);
- m_sName += "...";
- }
-
- p.drawText ((m_qpixmap.width () - fm.width (m_sName)) / 2,
- TOP + m_geometry.height () + 5 + fm.ascent (), m_sName);
-
- updateWindowProperties ();
-}
-
-void
-Aquamarine::Switcher::update ()
-{
- Aquamarine::readWindowProperty (m_wid, Atoms::select_window,
- (long *)&m_selected);
- m_sName = KWin::readNameProperty (m_selected, XA_WM_NAME);
-
- QPainter
- p (&m_qpixmap);
-
- QBrush
- b1 (QColor (0, BACKGROUND));
- p.setPen (Qt::NoPen);
- p.setBrush (b1);
- p.drawRect (LEFT, TOP + m_geometry.height (), m_geometry.width (), 30);
-
- QFont
- font (Aquamarine::Decorator::options ()->font (true));
- p.setFont (font);
- QFontMetrics
- fm = p.fontMetrics ();
- while (fm.width (m_sName) > m_geometry.width ())
- {
- m_sName.truncate (m_sName.length () - 6);
- m_sName += "...";
- }
-
- p.drawText ((m_qpixmap.width () - fm.width (m_sName)) / 2,
- TOP + m_geometry.height () + 5 + fm.ascent (), m_sName);
-
- updateWindowProperties ();
-}
-
-void
-Aquamarine::Switcher::updateWindowProperties ()
-{
-
- Pixmap
- m_pixmap = m_qpixmap.handle ();
-
- int
- w_w = m_geometry.width ();
- int
- w_h = m_geometry.height ();
-
- long
- mdata[256];
-
- long *
- data = mdata;
-
- *data++ = DECOR_INTERFACE_VERSION;
- 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
- *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;
-
- *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_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
-
- *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;
-
- *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_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;
-
- //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;
-
- //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;
-
- XChangeProperty (qt_xdisplay (), m_wid,
- Atoms::net_window_decor,
- XA_INTEGER,
- 32, PropModeReplace, (unsigned char *)mdata,
- 12 + (8 * 9));
- XSync (qt_xdisplay (), FALSE);
-}