diff options
author | onestone <onestone> | 2006-12-13 00:09:48 +0000 |
---|---|---|
committer | onestone <onestone> | 2006-12-13 00:09:48 +0000 |
commit | 5fe27a99f4725202c6c732733bdfd429ae165776 (patch) | |
tree | 49ab9476451b21a80588af8bff99c1025eeaf5a6 /src | |
parent | c01320a62cd4a5dfe36840ed2b7af0a1caf4be91 (diff) | |
download | aquamarine-5fe27a99f4725202c6c732733bdfd429ae165776.tar.gz aquamarine-5fe27a99f4725202c6c732733bdfd429ae165776.tar.bz2 |
aquamarine: Improved performance and memory usage by using KDecoration windows directly
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/aquamarine.cpp | 4 | ||||
-rw-r--r-- | src/decorator.cpp | 157 | ||||
-rw-r--r-- | src/decorator.h | 5 | ||||
-rw-r--r-- | src/defaultDeco.cpp | 704 | ||||
-rw-r--r-- | src/defaultDeco.h | 127 | ||||
-rw-r--r-- | src/utils.cpp | 6 | ||||
-rw-r--r-- | src/utils.h | 2 | ||||
-rw-r--r-- | src/window.cpp | 455 | ||||
-rw-r--r-- | src/window.h | 41 |
10 files changed, 990 insertions, 514 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e6fefd0..65e7a5f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,8 @@ aquamarine_SOURCES = aquamarine.cpp \ window.cpp \ switcher.cpp \ KWinInterface.skel \ - options.cpp + options.cpp \ + defaultDeco.cpp aquamarine_LDADD = $(LIB_KDECORE) -lkdecorations $(BERYLSETTINGS_LIBS) aquamarine_LDFLAGS = $(all_libraries) diff --git a/src/aquamarine.cpp b/src/aquamarine.cpp index 716f263..bcc96e3 100644 --- a/src/aquamarine.cpp +++ b/src/aquamarine.cpp @@ -140,10 +140,6 @@ main (int argc, char **argv) { wmRunning = true; } - if (strcmp(buf,"compiz") == 0) - { - wmRunning = true; - } } if (!wmRunning) diff --git a/src/decorator.cpp b/src/decorator.cpp index 3176512..ea3c6b2 100644 --- a/src/decorator.cpp +++ b/src/decorator.cpp @@ -151,12 +151,8 @@ m_kwinmodule (new KWinModule (this, KWinModule::INFO_ALL)), m_switcher (0) updateDesktopGeometry (); - m_defDeco = - new Aquamarine::Window (qt_xrootwin (), 0, - Aquamarine::Window::DecorationDefault); - m_defDecoActive = - new Aquamarine::Window (qt_xrootwin (), 0, - Aquamarine::Window::DecorationDefaultActive); + m_defDeco = new Aquamarine::DefaultDecoration (false); + m_defDecoActive = new Aquamarine::DefaultDecoration (true); connect (m_kwinmodule, SIGNAL (windowAdded (WId)), SLOT (slotWindowAdded (WId))); @@ -305,16 +301,6 @@ Aquamarine::Decorator::x11EventFilter (XEvent * xevent) client = m_frames[xce->window]; if (!client) break; - QWidget * - widget = client->decoration ()->widget (); - QWidget * - child = widget->childAt (xce->x, xce->y, true); - if (!child) - break; - - QEvent qe (QEvent::Enter); - QApplication::sendEvent (child, &qe); - client->setActiveChild (child); client->updateCursor (QPoint (xce->x, xce->y)); break; } @@ -327,9 +313,6 @@ Aquamarine::Decorator::x11EventFilter (XEvent * xevent) client = m_frames[xce->window]; if (!client) break; - - QEvent qe (QEvent::Leave); - QApplication::sendEvent (client->activeChild (), &qe); XUndefineCursor (qt_xdisplay (), client->frameId ()); break; } @@ -340,64 +323,21 @@ Aquamarine::Decorator::x11EventFilter (XEvent * xevent) Aquamarine::Window * client = 0; if (m_frames.contains (xme->window)) client = m_frames[xme->window]; - if (!client) - break; - QWidget * - widget = client->decoration ()->widget (); - QWidget * - child = widget->childAt (xme->x, xme->y, true); - if (!child) - break; - if (child != client->activeChild ()) - { - QEvent qee (QEvent::Enter); - QEvent qle (QEvent::Leave); - if (client->activeChild ()) - QApplication::sendEvent (client->activeChild (), &qle); - QApplication::sendEvent (child, &qee); - client->setActiveChild (child); - } - QPoint qp (xme->x, xme->y); - if (widget != child) - qp -= QPoint (child->pos ().x (), child->pos ().y ()); - QMouseEvent qme (QEvent::MouseMove, qp, - Qt::NoButton, Qt::NoButton); - QApplication::sendEvent (child, &qme); - - client->updateCursor (QPoint (xme->x, xme->y)); - + if (!client) + { + QMap < WId, Aquamarine::Window * >::ConstIterator it; + for (it = m_windows.begin (); + it != m_windows.end (); ++it) + { + if ((*it)->decoration()->widget()->handle() == xme->window) + client = (*it); + } + } + if (!client) + break; + client->updateCursor (QPoint (xme->x, xme->y)); break; } - case ButtonPress: - case ButtonRelease: - { - XButtonEvent * - xbe = reinterpret_cast < XButtonEvent * >(xevent); - Aquamarine::Window * client = 0; - if (m_frames.contains (xbe->window)) - client = m_frames[xbe->window]; - if (!client) - break; - - QWidget * - widget = client->decoration ()->widget (); - QWidget * - child = widget->childAt (xbe->x, xbe->y, true); - if (!child) - break; - - XButtonEvent * - xbe2 = new XButtonEvent; - memcpy (xbe2, xbe, sizeof (XButtonEvent)); - xbe2->window = child->winId (); - if (widget != child) - { - xbe2->x = xbe->x - child->pos ().x (); - xbe2->y = xbe->y - child->pos ().y (); - } - QApplication::x11ProcessEvent ((XEvent *) xbe2); - return true; - } default: break; } @@ -407,20 +347,13 @@ Aquamarine::Decorator::x11EventFilter (XEvent * xevent) WId Aquamarine::Decorator::fetchFrame (WId window) { - Atom - type; - int - format; - unsigned long - nitems; - unsigned long - bytes_after; - WId * - w; + Atom type; + int format; + unsigned long nitems; + unsigned long bytes_after; + WId *w; WId **ww = &w; - int - err, - result; + int err,result; Aquamarine::trapXError (); @@ -442,8 +375,7 @@ Aquamarine::Decorator::fetchFrame (WId window) return 0; } - WId - rv = *w; + WId rv = *w; XFree (w); if (validWindow(rv)) @@ -458,8 +390,7 @@ Aquamarine::Decorator::reconfigure () kdDebug () << k_funcinfo << endl; m_config->reparseConfiguration (); - unsigned long - changed = m_options->updateSettings (); + unsigned long changed = m_options->updateSettings (); #ifdef HAVE_BERYL_SETTINGS beryl_settings_send_reload_signal(); @@ -506,22 +437,22 @@ Aquamarine::Decorator::slotWindowAdded (WId id) } return; } - WId - frame = fetchFrame (id); + WId frame = fetchFrame (id); Aquamarine::Window * client = 0; for (QMap < WId, Aquamarine::Window * >::ConstIterator it = m_windows.constBegin (); it != m_windows.constEnd (); ++it) { if (it.data ()->winId () == id) { - return; + return; } } - if (frame) + + if (frame) { - if (!m_windows.contains (id)) + if (!m_windows.contains (id)) { - client = new Aquamarine::Window (id, frame); + client = new Aquamarine::Window (id, frame); connect( this, SIGNAL(desktopGeometryChanged()), client, SLOT(slotDesktopGeometryChanged()) ); if (m_kwinmodule->activeWindow () == id) { @@ -535,7 +466,7 @@ Aquamarine::Decorator::slotWindowAdded (WId id) } else { - client = m_windows[id]; + client = m_windows[id]; m_frames.remove (client->frameId ()); m_frames.insert (frame, client); client->updateFrame (frame); @@ -543,7 +474,7 @@ Aquamarine::Decorator::slotWindowAdded (WId id) } else { - if (m_windows.contains (id)) + if (m_windows.contains (id)) { client = m_windows[id]; } @@ -649,10 +580,8 @@ void Aquamarine::Decorator::sendClientMessage (WId w, Atom a, Atom protocol, long data1, long data2, long data3) { - XEvent - ev; - long - mask; + XEvent ev; + long mask; memset (&ev, 0, sizeof (ev)); ev.xclient.type = ClientMessage; @@ -673,14 +602,8 @@ Aquamarine::Decorator::sendClientMessage (WId w, Atom a, Atom protocol, void Aquamarine::Decorator::updateDesktopGeometry () { - int - x, - y; - unsigned int - width, - height, - border, - depth; + int x, y; + unsigned int width, height, border, depth; ::Window root; XGetGeometry (qt_xdisplay (), qt_xrootwin (), &root, &x, &y, &width, &height, &border, &depth); @@ -743,14 +666,8 @@ Aquamarine::Decorator::viewports () void Aquamarine::Decorator::moveToViewport (WId id, int vp) { - int - x, - y; - unsigned int - width, - height, - border, - depth; + int x, y; + unsigned int width, height, border, depth; ::Window root; XGetGeometry (qt_xdisplay (), id, &root, &x, &y, &width, &height, &border, &depth); diff --git a/src/decorator.h b/src/decorator.h index c55d1dc..519e3d1 100644 --- a/src/decorator.h +++ b/src/decorator.h @@ -44,6 +44,7 @@ #include <kdecoration_p.h> #include "window.h" +#include "defaultDeco.h" #include "KWinInterface.h" #define C(name) { 0, XC_ ## name } @@ -136,8 +137,8 @@ namespace Aquamarine bool ready; - Aquamarine::Window * m_defDeco; - Aquamarine::Window * m_defDecoActive; + Aquamarine::DefaultDecoration * m_defDeco; + Aquamarine::DefaultDecoration * m_defDecoActive; QMap < WId, Aquamarine::Window * >m_windows; QMap < WId, Aquamarine::Window * >m_frames; diff --git a/src/defaultDeco.cpp b/src/defaultDeco.cpp new file mode 100644 index 0000000..3f8bad5 --- /dev/null +++ b/src/defaultDeco.cpp @@ -0,0 +1,704 @@ +/* + * 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 (); +} diff --git a/src/defaultDeco.h b/src/defaultDeco.h new file mode 100644 index 0000000..8b97429 --- /dev/null +++ b/src/defaultDeco.h @@ -0,0 +1,127 @@ +/* + * 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_DEFAULT_H +#define AQUAMARINE_DEFAULT_H + +#include <kdecoration_p.h> + +#include <qpixmap.h> +#include <qwidget.h> + +#include "utils.h" +#include "options.h" + +class KDecoration; +class QPopupMenu; + +namespace Aquamarine +{ + + class DefaultDecoration:public QWidget, public KDecorationBridge + { + Q_OBJECT public: + + public: + DefaultDecoration (bool active); + ~DefaultDecoration (); + + // 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 reloadDecoration (); + + private: + void createDecoration (); + void resizeDecoration ( bool force = false ); + + private slots: + void grabChildWidgets (); + void updateWindowProperties (); + + private: + + // window properties + QRect m_geometry; + bool m_active; + QString m_name; + QIconSet m_icons; + + // decoration stuff + KDecoration *m_deco; + QPixmap m_qpixmap; + + }; + +} + +#endif diff --git a/src/utils.cpp b/src/utils.cpp index b944e15..869bb33 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -83,6 +83,8 @@ namespace Aquamarine Atom wm_name; Atom wm_sn; + Atom change_frame_window; + } } @@ -509,4 +511,8 @@ Aquamarine::Atoms::init () char buf[128]; sprintf(buf,"WM_S%d",qt_xscreen()); wm_sn = XInternAtom (xdisplay, buf, false); + + change_frame_window = + XInternAtom (xdisplay, "_BERYL_CHANGE_FRAME_WINDOW", false); + } diff --git a/src/utils.h b/src/utils.h index 508de73..88fb682 100644 --- a/src/utils.h +++ b/src/utils.h @@ -87,6 +87,8 @@ namespace Aquamarine extern Atom wm_name; extern Atom wm_sn; + extern Atom change_frame_window; + void init (); } diff --git a/src/window.cpp b/src/window.cpp index 049035c..a0bf9f4 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -95,100 +95,56 @@ extern Atom net_wm_take_activity; extern struct _cursor cursors[3][3]; -Aquamarine::Window::Window (WId wid, WId frame, DecorationType type): +Aquamarine::Window::Window (WId wid, WId frame): +QWidget(0,0,Qt::WX11BypassWM), m_wid (wid), m_active (false), m_deco (0), m_fakeMaximized (false), m_shapeSet (false), -m_grabChildPending (false), -m_grabChildInProgress (false), -m_updateWindowPending (false), -m_grabAllChildren (false), -m_type (type), m_popup (0), m_advanced_popup (0), m_viewport_menu (0), m_appearance_menu (0), m_brightness_menu (0), m_saturation_menu (0), m_opacity_menu (0) { - if (m_type == DecorationNormal) - { - KWin::WindowInfo wInf = KWin::windowInfo (m_wid, NET::WMState, 0); - m_state = wInf.state (); - - m_name = KWin::readNameProperty (m_wid, XA_WM_NAME); - - m_icons = - QIconSet (KWin::icon (m_wid, 16, 16, TRUE), - KWin::icon (m_wid, 32, 32, TRUE)); - - m_opacity = readWindowPropertyDefault (m_wid, Atoms::opacity, 0xffff); - m_brightness = - readWindowPropertyDefault (m_wid, Atoms::brightness, 0xffff); - m_saturation = - readWindowPropertyDefault (m_wid, Atoms::saturation, 0xffff); - - - updateFrame (frame); - - 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); - - setWState (Qt::WState_Visible); - installEventFilter (this); - - getWindowProtocols (); - createDecoration (); - } - else - { + KWin::WindowInfo wInf = KWin::windowInfo (m_wid, NET::WMState, 0); + m_state = wInf.state (); - m_icons = - QIconSet (KGlobal::iconLoader ()-> - loadIcon ("xapp", KIcon::NoGroup, 16), - KGlobal::iconLoader ()->loadIcon ("xapp", - KIcon::NoGroup, 32)); + m_name = KWin::readNameProperty (m_wid, XA_WM_NAME); - m_name = QString (""); + m_icons = QIconSet (KWin::icon (m_wid, 16, 16, TRUE), + KWin::icon (m_wid, 32, 32, TRUE)); - m_geometry = QRect (50, 50, 200, 100); + m_opacity = readWindowPropertyDefault (m_wid, Atoms::opacity, 0xffff); + m_brightness = + readWindowPropertyDefault (m_wid, Atoms::brightness, 0xffff); + m_saturation = + readWindowPropertyDefault (m_wid, Atoms::saturation, 0xffff); - setWState (Qt::WState_Visible); - installEventFilter (this); - createDecoration (); - if (m_type == DecorationDefaultActive) - m_active = true; - } + setPaletteBackgroundColor( QColor(QRgb (), 0x00000000)); + setEraseColor(QColor(QRgb (), 0x00000000)); + setWState (Qt::WState_Visible); + updateFrame (frame); + + int x, y; + unsigned int width, height, border, depth; - m_activeChild = m_deco->widget (); + ::Window root; + XGetGeometry (qt_xdisplay (), m_wid, &root, &x, &y, &width, &height, + &border, &depth); + m_geometry = QRect (x, y, width, height); + + getWindowProtocols (); + createDecoration (); } Aquamarine::Window::~Window () { - delete - m_deco; - delete - m_popup; + delete m_deco; + delete m_popup; - Atom - my_atom = Atoms::net_window_decor; - if (m_type == DecorationDefault) - my_atom = - XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_NORMAL", FALSE); - else if (m_type == DecorationDefaultActive) - my_atom = - XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_ACTIVE", FALSE); + Atom my_atom = Atoms::net_window_decor; Aquamarine::trapXError (); XWindowAttributes @@ -199,8 +155,6 @@ Aquamarine::Window::~Window () XDeleteProperty (qt_xdisplay (), m_wid, my_atom); } Aquamarine::popXError (); - - } @@ -225,9 +179,7 @@ Aquamarine::Window::isMaximizable () const KDecoration::MaximizeMode Aquamarine::Window::maximizeMode () const { - if (m_type != DecorationNormal) - return MaximizeRestore; - if (m_fakeMaximized) + if (m_fakeMaximized) return MaximizeVertical | MaximizeHorizontal; MaximizeMode cur = ((m_state & NET::MaxVert) @@ -245,9 +197,6 @@ Aquamarine::Window::isMinimizable () const bool Aquamarine::Window::providesContextHelp () const { - if (m_type != DecorationNormal) - return false; - return m_supportContextHelp; } @@ -272,9 +221,6 @@ Aquamarine::Window::isShadeable () const bool Aquamarine::Window::isShade () const { - if (m_type != DecorationNormal) - return false; - return (m_state & NET::Shaded); } @@ -287,18 +233,12 @@ Aquamarine::Window::isSetShade () const bool Aquamarine::Window::keepAbove () const { - if (m_type != DecorationNormal) - return false; - return (m_state & NET::KeepAbove); } bool Aquamarine::Window::keepBelow () const { - if (m_type != DecorationNormal) - return false; - return (m_state & NET::KeepBelow); } @@ -524,9 +464,7 @@ Aquamarine::Window::performWindowOperation (WindowOperation wo) break; case KDecoration::MoveOp: { - // FIXME: not supported in beryl - XEvent - ev; + XEvent ev; ev.xclient.type = ClientMessage; ev.xclient.display = qt_xdisplay (); @@ -589,35 +527,34 @@ Aquamarine::Window::performWindowOperation (WindowOperation wo) void Aquamarine::Window::setMask (const QRegion & reg, int) { - if (m_type != DecorationNormal) - return; - kdDebug () << k_funcinfo << endl; - m_shape = QRegion (reg); - m_shapeSet = true; - int - top, - bottom, - left, - right; - if (m_deco) - { - m_deco->borders (left, right, top, bottom); + QRegion clear = m_shape.subtract(reg); - m_clip = - QRegion (0, 0, m_geometry.width () + left + right, - m_geometry.height () + top + bottom); - } - else + // Decoration has no erase flag so we need to erase old regions + if (!clear.isEmpty()) { - m_clip = QRegion (reg.boundingRect ()); + WId win = m_deco->widget()->handle(); + XGCValues gcv; + gcv.foreground = 0x00000000; + gcv.plane_mask = 0xffffffff; + GC gc = XCreateGC (qt_xdisplay (), win, GCForeground, &gcv); + + QMemArray < QRect > rects = clear.rects (); + QMemArray < QRect >::ConstIterator it; + for (it = rects.begin (); it != rects.end (); ++it) + { + XFillRectangle (qt_xdisplay (), win, gc, it->x (), it->y (), + it->width (), it->height ()); + } + + XFreeGC (qt_xdisplay (), gc); } - m_clip -= QRegion (left, top, m_geometry.width (), m_geometry.height ()); - m_clip -= reg; + m_shape = QRegion (reg); + m_shapeSet = true; - XShapeCombineRegion (qt_xdisplay (), m_frame, ShapeInput, 0, 0, + XShapeCombineRegion (qt_xdisplay (), handle(), ShapeInput, 0, 0, reg.handle (), ShapeSet); } @@ -632,11 +569,7 @@ Aquamarine::Window::geometry () const { if (m_deco) { - int - top, - bottom, - left, - right; + 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); @@ -810,69 +743,6 @@ Aquamarine::Window::grabXServer (bool) { } - -bool -Aquamarine::Window::eventFilter (QObject * watched, QEvent * event) -{ - if (event->type () == QEvent::ChildInserted) - { - QChildEvent * ce = static_cast < QChildEvent * >(event); - if (ce->child () != m_popup) - { - ce->child ()->installEventFilter (this); - // the child might already have childs - // TODO: make this recursive - const QObjectList * list = ce->child ()->children (); - if (list) - { - QObjectListIt - it (*list); - QObject * - grandchild; - while ((grandchild = it.current ()) != 0) - { - ++it; - if (grandchild->isWidgetType ()) - grandchild->installEventFilter (this); - } - } - } - } - if (event->type () == QEvent::Paint && !m_grabChildInProgress) - { - if (watched != m_deco->widget ()) - { - if (!m_pendingChildren.contains(watched)) - m_pendingChildren.append (watched); - if (!m_grabChildPending) - { - m_grabChildPending = true; - QTimer::singleShot (0, this, SLOT(grabChildWidgets())); - } - } - else - { - QRect rect = static_cast < QPaintEvent * >(event)->rect (); - m_grabAllChildren = true; - if (!m_grabChildPending) - { - m_grabChildPending = true; - QTimer::singleShot (0, this, SLOT (grabChildWidgets ())); - } - if (!m_updateWindowPending) - { - m_updateWindowPending = true; - QTimer::singleShot (0, this, - SLOT (updateWindowProperties ())); - } - } - } - - return QWidget::eventFilter (watched, event); -} - - - void Aquamarine::Window::createDecoration () { @@ -882,105 +752,52 @@ Aquamarine::Window::createDecoration () deco = Decorator::pluginManager ()->createDecoration (this); deco->init (); m_deco = deco; + resizeDecoration (); - resizeDecoration ( true ); - - if (m_type == DecorationNormal) - XSelectInput (qt_xdisplay (), m_frame, - defaultMask | ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | EnterWindowMask | LeaveWindowMask); + updateFrame(m_frame); } void -Aquamarine::Window::resizeDecoration ( bool force ) +Aquamarine::Window::resizeDecoration () { - int - top, - bottom, - left, - right; + 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_pending_pixmap.isNull ()) - m_pending_pixmap = - QPixmap (m_geometry.width () + left + right, - m_geometry.height () + top + bottom); - else - m_pending_pixmap.resize (m_geometry.width () + left + right, - m_geometry.height () + top + bottom); - resize (m_geometry.width () + left + right, + move (m_geometry.x() - left, m_geometry.y() - top); + resize (m_geometry.width () + left + right, m_geometry.height () + top + bottom); - QPainter::redirect (m_deco->widget (), &m_pending_pixmap); - m_deco-> - resize (QSize - (m_geometry.width () + left + right, - m_geometry.height () + top + bottom)); - m_deco->widget ()->setShown (true); - QPaintEvent * - e = new QPaintEvent (m_deco->widget ()->rect (), false); - QApplication::postEvent (m_deco->widget (), e); + m_deco->resize (QSize(m_geometry.width () + left + right, + m_geometry.height () + top + bottom)); + + m_deco->widget ()->setShown (true); } void Aquamarine::Window::updateWindowProperties () { - Atom - my_atom = Atoms::net_window_decor; - if (m_type == DecorationDefault) - my_atom = - XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_NORMAL", FALSE); - else if (m_type == DecorationDefaultActive) - my_atom = - XInternAtom (qt_xdisplay (), "_NET_WINDOW_DECOR_ACTIVE", FALSE); - - m_updateWindowPending = false; - QPixmap - delete_me_later; - if (!m_pending_pixmap.isNull ()) - { - delete_me_later = m_qpixmap; - m_qpixmap = m_pending_pixmap; - m_pending_pixmap = QPixmap (); - QPainter::redirect (m_deco->widget (), &m_qpixmap); - } - Pixmap - m_pixmap = m_qpixmap.handle (); - int - top, - bottom, - left, - right; - int - mtop, - mbottom, - mleft, - mright; + WId win = handle(); + + int top, bottom, left, right; + int mtop, mbottom, mleft, mright; m_fakeMaximized = true; m_deco->borders (mleft, mright, mtop, mbottom); m_fakeMaximized = false; m_deco->borders (left, right, top, bottom); + int w_w = m_geometry.width (); + int w_h = m_geometry.height (); - int - w_w = m_geometry.width (); - int - w_h = m_geometry.height (); + long mdata[256]; - long - mdata[256]; + long *data = mdata; - long * - data = mdata; + // TODO: create defines for this + *data++ = 1; - *data++ = DECOR_INTERFACE_VERSION; - memcpy (data++, &m_pixmap, sizeof (m_pixmap)); + memcpy (data++, &win, sizeof (win)); *data++ = left; *data++ = right; @@ -1173,7 +990,7 @@ Aquamarine::Window::updateWindowProperties () Aquamarine::trapXError (); XChangeProperty (qt_xdisplay (), m_wid, - my_atom, + Atoms::net_window_decor, XA_INTEGER, 32, PropModeReplace, (unsigned char *)mdata, 12 + (12 * 9)); @@ -1182,78 +999,6 @@ Aquamarine::Window::updateWindowProperties () } void -Aquamarine::Window::grabChildWidgets () -{ - m_grabChildPending = false; - if (!m_deco) - return; - - QPixmap * activePixmap; - - m_grabChildInProgress = true; - QPainter * p = 0; - if (!m_pending_pixmap.isNull ()) - { - p = new QPainter (&m_pending_pixmap); - activePixmap = &m_pending_pixmap; - } - else - { - p = new QPainter (&m_qpixmap); - activePixmap = &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 () && (m_grabAllChildren || m_pendingChildren.contains(child))) - { - QWidget * wid = static_cast < QWidget * >(child); - childs += wid->rect (); - QPixmap pix = QPixmap::grabWidget (wid); - p->drawPixmap (wid->pos (), pix); - } - } - } - delete p; - QRegion clip = QRegion(m_clip); - if (!m_grabAllChildren) - clip &= childs; - m_grabAllChildren = false; - m_pendingChildren.clear(); - m_grabChildInProgress = false; - - if (m_shapeSet) - { - Pixmap - pix = activePixmap->handle (); - XGCValues - gcv; - gcv.foreground = 0x00000000; - gcv.plane_mask = 0xffffffff; - GC - gc = XCreateGC (qt_xdisplay (), pix, GCForeground, &gcv); - - QMemArray < QRect > rects = clip.rects (); - QMemArray < QRect >::ConstIterator it; - for (it = rects.begin (); it != rects.end (); ++it) - { - XFillRectangle (qt_xdisplay (), pix, gc, it->x (), it->y (), - it->width (), it->height ()); - } - - XFreeGC (qt_xdisplay (), gc); - } -} - -void Aquamarine::Window::setActive (bool active) { m_active = active; @@ -1265,25 +1010,38 @@ void Aquamarine::Window::updateFrame (WId frame) { m_frame = frame; - XSelectInput (qt_xdisplay (), m_frame, - defaultMask | ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | EnterWindowMask | LeaveWindowMask); - if (m_shapeSet) - XShapeCombineRegion (qt_xdisplay (), m_frame, ShapeInput, 0, 0, - m_shape.handle (), ShapeSet); + if (m_deco && frame != handle()) + { + XEvent ev; + + memset (&ev, 0, sizeof (ev)); + ev.xclient.type = ClientMessage; + ev.xclient.window = m_wid; + ev.xclient.message_type = Atoms::change_frame_window; + ev.xclient.format = 32; + ev.xclient.data.l[0] = handle(); + ev.xclient.data.l[1] = TRUE; + ev.xclient.data.l[2] = 0; + ev.xclient.data.l[3] = 0; + ev.xclient.data.l[4] = 0; + + XSendEvent (qt_xdisplay (), qt_xrootwin(), False, + SubstructureRedirectMask | SubstructureNotifyMask, &ev); + } + if (m_deco && frame == handle()) + { + updateWindowProperties (); + XSelectInput (qt_xdisplay (), m_frame, + defaultMask | ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | EnterWindowMask | LeaveWindowMask); + } } void Aquamarine::Window::updateWindowGeometry () { - int - x, - y; - unsigned int - width, - height, - border, - depth; + int x, y; + unsigned int width, height, border, depth; ::Window root; XGetGeometry (qt_xdisplay (), m_wid, &root, &x, &y, &width, &height, &border, &depth); @@ -1340,11 +1098,8 @@ Aquamarine::Window::updateCursor (QPoint pos) void Aquamarine::Window::getWindowProtocols () { - Atom * - p; - int - i, - n; + Atom *p; + int i, n; m_supportDeleteWindow = false; m_supportTakeFocus = false; @@ -1457,7 +1212,7 @@ Aquamarine::Window::updateState () if (stateChange & NET::Max) { m_deco->maximizeChange (); - resizeDecoration (true); + resizeDecoration (); } if (stateChange & NET::KeepAbove && !(m_state & NET::KeepAbove)) m_deco->emitKeepAboveChanged (m_state & NET::KeepAbove); diff --git a/src/window.h b/src/window.h index 7929796..0eec076 100644 --- a/src/window.h +++ b/src/window.h @@ -46,17 +46,9 @@ namespace Aquamarine { Q_OBJECT public: - enum DecorationType - { - DecorationNormal, - DecorationDefault, - DecorationDefaultActive - }; - public: - Window (WId wid, WId frame, DecorationType type = - DecorationNormal); - ~Window (); + Window (WId wid, WId frame); + ~Window (); // KDecorationBridge methods virtual bool isActive () const; @@ -74,8 +66,7 @@ namespace Aquamarine virtual bool keepBelow () const; virtual bool isMovable () const; virtual bool isResizable () const; - virtual NET:: - WindowType windowType (unsigned long supported_types) const; + virtual NET::WindowType windowType (unsigned long supported_types) const; virtual QIconSet icon () const; virtual QString caption () const; virtual void processMousePressEvent (QMouseEvent *); @@ -106,7 +97,6 @@ namespace Aquamarine virtual void helperShowHide (bool); virtual void grabXServer (bool grab); - void setActive (bool active); void updateFrame (WId frame); void updateWindowGeometry (); @@ -121,14 +111,6 @@ namespace Aquamarine { return m_deco; } - QWidget *activeChild () const - { - return m_activeChild; - } - void setActiveChild (QWidget * child) - { - m_activeChild = child; - } void moveWindow (QMouseEvent * qme); @@ -154,9 +136,6 @@ namespace Aquamarine readWindowPropertyDefault (m_wid, Atoms::saturation, 0xffff); } - protected: - virtual bool eventFilter (QObject * watched, QEvent * event); - private: enum WindowAppearance { @@ -177,12 +156,11 @@ namespace Aquamarine private: void createDecoration (); - void resizeDecoration ( bool force = false ); + void resizeDecoration (); void getWindowProtocols (); void performMouseCommand( Options::MouseCommand, QMouseEvent *qme ); private slots: - void grabChildWidgets (); void updateWindowProperties (); void slotPopupActivated (int id); void slotPopupAboutToShow (); @@ -213,15 +191,6 @@ namespace Aquamarine // shape stuff bool m_shapeSet; QRegion m_shape; - QRegion m_clip; - - // event handling stuff - QWidget *m_activeChild; - bool m_grabChildPending; - bool m_grabChildInProgress; - bool m_updateWindowPending; - bool m_grabAllChildren; - QValueList<QObject*> m_pendingChildren; // window handling bool m_supportDeleteWindow; @@ -230,8 +199,6 @@ namespace Aquamarine bool m_supportContextHelp; bool m_supportPing; - DecorationType m_type; - // window menu QPopupMenu *m_popup; QPopupMenu *m_advanced_popup; |