summaryrefslogtreecommitdiff
path: root/src/decorator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/decorator.cpp')
-rw-r--r--src/decorator.cpp1542
1 files changed, 869 insertions, 673 deletions
diff --git a/src/decorator.cpp b/src/decorator.cpp
index 535684e..7986190 100644
--- a/src/decorator.cpp
+++ b/src/decorator.cpp
@@ -1,29 +1,28 @@
/*
- * 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.
- *
- */
+* 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.
+*
+*/
#include <qglobal.h>
@@ -34,11 +33,14 @@
#include <kglobal.h>
#include <kwinmodule.h>
#include <klocale.h>
+#include <kcommondecoration.h>
#include <kwin.h>
-
+#include <qwidgetlist.h>
#include <qpoint.h>
-#include "switcher.h"
+#include <X11/Xlib.h>
+#include <X11/extensions/Xcomposite.h>
+
#include "decorator.h"
#include "options.h"
#include "utils.h"
@@ -46,755 +48,949 @@
#include <stdio.h>
-#ifdef HAVE_BERYL_SETTINGS
+decor_context_t Aquamarine::Decorator::mDefaultContext;
+decor_shadow_t *Aquamarine::Decorator::mNoBorderShadow = 0;
+decor_shadow_t *Aquamarine::Decorator::mDefaultShadow = 0;
+Aquamarine::PluginManager *Aquamarine::Decorator::mPlugins = 0;
+Aquamarine::Options *Aquamarine::Decorator::mOptions = 0;
+NETRootInfo *Aquamarine::Decorator::mRootInfo;
+WId Aquamarine::Decorator::mActiveId;
+decor_shadow_options_t Aquamarine::Decorator::mShadowOptions;
+
+QSize Aquamarine::Decorator::mDesktop;
+QPoint Aquamarine::Decorator::mViewport;
+QSize Aquamarine::Decorator::mRootSize;
-extern "C" {
-#include <beryl-settings.h>
-}
-#endif
-
-#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)
-
-Aquamarine::PluginManager * Aquamarine::Decorator::m_plugins = 0;
-Aquamarine::Options * Aquamarine::Decorator::m_options = 0;
-QSize
- Aquamarine::Decorator::m_desktop;
-QPoint
- Aquamarine::Decorator::m_viewport;
-QSize
- Aquamarine::Decorator::m_rootSize;
-
-extern Time
- qt_x_time;
-
-struct _cursor
- cursors[3][3] = {
- {C (top_left_corner), C (top_side), C (top_right_corner)},
- {C (left_side), C (left_ptr), C (right_side)},
- {C (bottom_left_corner), C (bottom_side), C (bottom_right_corner)}
+extern Time qt_x_time;
+
+struct _cursor cursors[3][3] = {
+ { C (top_left_corner), C (top_side), C (top_right_corner) },
+ { C (left_side), C (left_ptr), C (right_side) },
+ { C (bottom_left_corner), C (bottom_side), C (bottom_right_corner) }
};
+Aquamarine::PluginManager::PluginManager (KConfig *config): KDecorationPlugins (config)
+{
+ // taken from KWin
+ defaultPlugin = (QPixmap::defaultDepth () > 8) ? "kwin3_plastik" : "kwin3_quartz";
+}
-Aquamarine::PluginManager::PluginManager (KConfig * config):
-KDecorationPlugins (config)
+Aquamarine::Decorator::Decorator (void) : DCOPObject ("KWinInterface"),
+ KApplication (),
+ mConfig (0),
+ mKWinModule (new KWinModule (this, KWinModule::INFO_ALL)),
+ mCompositeWindow (0)
{
- // taken from KWin
- defaultPlugin =
- (QPixmap::defaultDepth () > 8) ? "kwin3_plastik" : "kwin3_quartz";
+ KGlobal::locale()->insertCatalogue("kdelibs");
+ KGlobal::locale()->setActiveCatalogue("aquamarine");
+
+ mReady = false;
+ mRestart = false;
+
+ int event, error;
+
+ DCOPClient *client;
+ int i, j;
+
+ mRootInfo = new NETRootInfo (qt_xdisplay (), 0);
+
+ mActiveId = 0;
+
+ Atoms::init ();
+
+ if (!XDamageQueryExtension (qt_xdisplay (), &event, &error))
+ {
+ fprintf (stderr, "Damage extension is missing on display \"%s\"\n",
+ DisplayString (qt_xdisplay ()));
+ return;
+ }
+
+ mActiveWM = XGetSelectionOwner(qt_xdisplay(),Atoms::wmSn);
+ if (mActiveWM == None)
+ return;
+ XSelectInput (qt_xdisplay(), mActiveWM, StructureNotifyMask);
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs ();
+
+ Time timestamp;
+ int status = decor_acquire_dm_session (qt_xdisplay (), 0, "Aquamarine",
+ args->isSet ("replace"),&timestamp);
+
+ if (status != DECOR_ACQUIRE_STATUS_SUCCESS)
+ {
+ if (status == DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING)
+ {
+ fprintf (stderr,
+ "Could not acquire decoration manager "
+ "selection on screen %d display \"%s\"\n",
+ 0, DisplayString (qt_xdisplay ()));
+ }
+ else if (status == DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING)
+ {
+ fprintf (stderr,
+ "Screen %d on display \"%s\" already "
+ "has a decoration manager; try using the "
+ "--replace option to replace the current "
+ "decoration manager.\n",
+ 0, DisplayString (qt_xdisplay ()));
+ }
+ return;
+ }
+
+ decor_set_dm_check_hint (qt_xdisplay (), 0);
+
+ mConfig = new KConfig ("kwinrc");
+ mConfig->setGroup ("Style");
+
+ mOptions = new Aquamarine::Options (mConfig);
+ mPlugins = new PluginManager (mConfig);
+
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ if (cursors[i][j].shape != XC_left_ptr)
+ cursors[i][j].cursor =
+ XCreateFontCursor (qt_xdisplay (), cursors[i][j].shape);
+ }
+ }
+
+ client = dcopClient ();
+ client->registerAs ("kwin", false);
+ client->setDefaultObject ("KWinInterface");
+
+ mShadowOptions.shadow_radius = (Settings::drawShadows())?
+ Settings::shadowRadius():0;
+ mShadowOptions.shadow_opacity = Settings::shadowOpacity() / 100.0;
+ mShadowOptions.shadow_offset_x = Settings::shadowOffsetX();
+ mShadowOptions.shadow_offset_y = Settings::shadowOffsetY();
+ mShadowOptions.shadow_color[0] = Settings::shadowColor().red() * 0x101;
+ mShadowOptions.shadow_color[1] = Settings::shadowColor().green() * 0x101;
+ mShadowOptions.shadow_color[2] = Settings::shadowColor().blue() * 0x101;
+ mShadowOptions.shadow_color[3] = 0xffff;
+
+ mCompositeWindow = new QWidget (0, "AquamarineCompositeWidget",
+ Qt::WType_TopLevel | Qt::WStyle_NoBorder |
+ Qt::WX11BypassWM);
+
+ mCompositeWindow->setGeometry (QRect (-ROOT_OFF_X, -ROOT_OFF_Y, 1, 1));
+ mCompositeWindow->show ();
+
+ XCompositeRedirectSubwindows (qt_xdisplay (), mCompositeWindow->winId (),
+ CompositeRedirectManual);
+
+ if (!enableDecorations (timestamp, event))
+ {
+ fprintf (stderr, "Could not enable decorations on display \"%s\"\n",
+ DisplayString (qt_xdisplay ()));
+ return;
+ }
+
+ updateDesktopGeometry ();
+
+ mReady = true;
}
+Aquamarine::Decorator::~Decorator (void)
+{
+ QMap <WId, Aquamarine::Window *>::ConstIterator it;
+
+ for (it = mClients.begin (); it != mClients.end (); it++)
+ delete (*it);
+
+ if (mDecorNormal)
+ delete mDecorNormal;
+ if (mDecorActive)
+ delete mDecorActive;
-Aquamarine::Decorator::Decorator (Display * dpy, Qt::HANDLE visual, Qt::HANDLE colormap):
-DCOPObject ("KWinInterface"),
-KApplication (dpy, visual, colormap),
-m_defDeco (0),
-m_defDecoActive (0),
-m_activeWindow (0),
-m_config (0),
-m_kwinmodule (new KWinModule (this, KWinModule::INFO_ALL)), m_switcher (0)
+ /* XXX: mCompositeWindow is not deleted, some plugins seem to rely on
+ it not being deleted... not sure what to do about this. */
+
+ delete mOptions;
+ delete mPlugins;
+ delete mConfig;
+ delete mKWinModule;
+ delete mRootInfo;
+}
+
+bool Aquamarine::Decorator::enableDecorations (Time timestamp, int damageEvent)
{
-// delete KGlobal::_locale;
-// KGlobal::_locale = new KLocale( "kwin" , NULL );
-// KGlobal::locale()->insertCatalogue("aquamarine");
- KGlobal::locale()->insertCatalogue("kdelibs");
- KGlobal::locale()->setActiveCatalogue("aquamarine");
+ QValueList <WId>::ConstIterator it;
+
+ mDmSnTimestamp = timestamp;
+ mDamageEvent = damageEvent;
+
+ if (!pluginManager ()->loadPlugin (""))
+ return false;
+
+ updateShadow ();
- ready = false;
- m_restart = false;
-
- m_plugins = NULL;
- m_options = NULL;
-
- Atoms::init ();
-
- m_activeWM = XGetSelectionOwner(qt_xdisplay(),Atoms::wm_sn);
- if (m_activeWM == None)
- return;
- XSelectInput (qt_xdisplay(), m_activeWM, StructureNotifyMask);
-
- KCmdLineArgs *
- args = KCmdLineArgs::parsedArgs ();
- bool
- replace = args->isSet ("replace");
- ready = acquireDmSession (qt_xdisplay (), qt_xscreen (), replace);
- if (!ready)
- return;
-
- set_dm_check_hint (qt_xscreen ());
-
- m_config = new KConfig ("kwinrc");
- m_config->setGroup ("Style");
-
- connect (this, SIGNAL (settingsChanged (int)),
- SLOT (slotSettingsChanged (int)));
-
- QString
- decoName;
- if (args->isSet ("deco"))
- decoName = args->getOption ("deco");
- if (!decoName.startsWith ("kwin3_") && !decoName.isEmpty ())
- decoName = "kwin3_" + decoName;
-
- m_options = new Aquamarine::Options (m_config);
- m_plugins = new PluginManager (m_config);
- kdDebug () << "loading plugin: " << decoName << endl;
- bool
- rv = pluginManager ()->loadPlugin (decoName);
- kdDebug () << "plugin loaded: " << rv << endl;
-
- updateDesktopGeometry ();
-
- m_defDeco = new Aquamarine::DefaultDecoration (false);
- m_defDecoActive = new Aquamarine::DefaultDecoration (true);
- m_defShadow = (Settings::drawShadows())? new Aquamarine::DefaultShadow () : NULL;
-
- connect (m_kwinmodule, SIGNAL (windowAdded (WId)),
- SLOT (slotWindowAdded (WId)));
- connect (m_kwinmodule, SIGNAL (windowRemoved (WId)),
- SLOT (slotWindowRemoved (WId)));
- connect (m_kwinmodule, SIGNAL (activeWindowChanged (WId)),
- SLOT (slotActiveWindowChanged (WId)));
- connect (m_kwinmodule,
- SIGNAL (windowChanged (WId, const unsigned long *)),
- SLOT (slotWindowChanged (WId, const unsigned long *)));
-
- QValueList < WId >::ConstIterator it;
- for (it = m_kwinmodule->windows ().begin ();
- it != m_kwinmodule->windows ().end (); ++it)
- {
- slotWindowAdded ((*it));
- }
-
-
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- if (cursors[i][j].shape != XC_left_ptr)
- cursors[i][j].cursor =
- XCreateFontCursor (qt_xdisplay (), cursors[i][j].shape);
- }
- }
-
- connect( this, SIGNAL(appearanceChanged()), SLOT(reconfigure()) );
+ mDecorNormal = new Aquamarine::Window (mCompositeWindow, qt_xrootwin (),
+ 0, Window::Default);
+ mDecorActive = new Aquamarine::Window (mCompositeWindow, qt_xrootwin (),
+ 0, Window::DefaultActive);
+
+ connect (mKWinModule, SIGNAL (windowAdded (WId)),
+ SLOT (handleWindowAdded (WId)));
+ connect (mKWinModule, SIGNAL (windowRemoved (WId)),
+ SLOT (handleWindowRemoved (WId)));
+ connect (mKWinModule, SIGNAL (activeWindowChanged (WId)),
+ SLOT (handleActiveWindowChanged (WId)));
+ connect (mKWinModule, SIGNAL (windowChanged (WId, const unsigned long *)),
+ SLOT (handleWindowChanged (WId, const unsigned long *)));
+
+ connect (&mIdleTimer, SIGNAL (timeout ()), SLOT (processDamage ()));
+
+ mActiveId = mKWinModule->activeWindow ();
+
+ it = mKWinModule->windows ().begin ();
+ for (; it != mKWinModule->windows ().end (); it++)
+ handleWindowAdded ((*it));
+
+ connect (this, SIGNAL (appearanceChanged ()), SLOT (reconfigure ()));
(void) QApplication::desktop (); // trigger creation of desktop widget
// select for client messages
XSelectInput (qt_xdisplay(), qt_xrootwin (),
- StructureNotifyMask | PropertyChangeMask);
+ StructureNotifyMask | PropertyChangeMask);
+
+ return true;
+}
+
+void Aquamarine::Decorator::updateDefaultShadow (Aquamarine::Window *w)
+{
+ bool uniqueHorzShape, uniqueVertShape;
+
+ if (mDefaultShadow)
+ {
+ decor_shadow_destroy (qt_xdisplay (), mDefaultShadow);
+ mDefaultShadow = NULL;
+ }
+
+ w->getShapeInfo (&uniqueHorzShape, &uniqueVertShape);
+
+ /* only return shadow if decoration doesn't use a unique shape */
+ if (uniqueHorzShape || uniqueVertShape)
+ return;
+
+ mDefaultContext = *w->context ();
+ mDefaultShadow = w->shadow ();
+
+ if (mDefaultShadow)
+ decor_shadow_reference (mDefaultShadow);
+}
+
+void Aquamarine::Decorator::updateAllShadowOptions (void)
+{
+ mShadowOptions.shadow_radius = (Settings::drawShadows())?
+ Settings::shadowRadius():0;
+ mShadowOptions.shadow_opacity = Settings::shadowOpacity() / 100.0;
+ mShadowOptions.shadow_offset_x = Settings::shadowOffsetX();
+ mShadowOptions.shadow_offset_y = Settings::shadowOffsetY();
+ mShadowOptions.shadow_color[0] = Settings::shadowColor().red() * 0x101;
+ mShadowOptions.shadow_color[1] = Settings::shadowColor().green() * 0x101;
+ mShadowOptions.shadow_color[2] = Settings::shadowColor().blue() * 0x101;
}
-Aquamarine::Decorator::~Decorator ()
+void Aquamarine::Decorator::updateShadow (void)
{
- QMap < WId, Aquamarine::Window * >::ConstIterator it;
- for (it = m_windows.begin ();
- it != m_windows.end (); ++it)
- {
- delete (*it);
- }
- delete
- m_defDeco;
- delete
- m_defDecoActive;
- delete m_defShadow;
- delete
- m_options;
- delete
- m_plugins;
- delete
- m_config;
- delete
- m_switcher;
- delete
- m_kwinmodule;
- if (dm_window != None) XDestroyWindow(qt_xdisplay(),dm_window);
- dm_window = None;
+ Display *xdisplay = qt_xdisplay ();
+ Screen *xscreen = ScreenOfDisplay (xdisplay, qt_xscreen ());
+ decor_context_t context;
+
+ if (mDefaultShadow)
+ {
+ decor_shadow_destroy (xdisplay, mDefaultShadow);
+ mDefaultShadow = NULL;
+ }
+
+ if (mNoBorderShadow)
+ decor_shadow_destroy (xdisplay, mNoBorderShadow);
+
+ mNoBorderShadow = decor_shadow_create (xdisplay,
+ xscreen,
+ 1, 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, 0, 0, 0,
+ &mShadowOptions,
+ &context,
+ decor_draw_simple,
+ 0);
+
+ if (mNoBorderShadow)
+ {
+ decor_extents_t extents = { 0, 0, 0, 0 };
+ long data[256];
+ decor_quad_t quads[N_QUADS_MAX];
+ int nQuad;
+ decor_layout_t layout;
+
+ decor_get_default_layout (&context, 1, 1, &layout);
+
+ nQuad = decor_set_lSrStSbS_window_quads (quads, &context, &layout);
+
+ decor_quads_to_property (data, mNoBorderShadow->pixmap,
+ &extents, &extents,
+ 0, 0, quads, nQuad);
+
+ Aquamarine::trapXError ();
+ XChangeProperty (qt_xdisplay (), qt_xrootwin (),
+ Atoms::netWindowDecorBare,
+ XA_INTEGER,
+ 32, PropModeReplace, (unsigned char *) data,
+ BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad);
+ Aquamarine::popXError ();
+ }
}
-bool
-Aquamarine::Decorator::x11EventFilter (XEvent * xevent)
+void Aquamarine::Decorator::processDamage (void)
{
- WId
- xid = 0;
+ QMap <WId, Aquamarine::Window *>::ConstIterator it;
+ mDecorNormal->processDamage ();
+ mDecorActive->processDamage ();
- switch (xevent->type)
- {
+ for (it = mClients.constBegin (); it != mClients.constEnd (); it++)
+ it.data ()->processDamage ();
+}
+
+bool Aquamarine::Decorator::x11EventFilter (XEvent *xevent)
+{
+ Aquamarine::Window *client;
+ int status;
+
+ switch (xevent->type) {
case MapNotify:
{
- Aquamarine::Window * client = 0;
- if (m_frames.contains (xevent->xmap.window))
- client = m_frames[xevent->xmap.window];
- if (!client)
- break;
- client->setMapping(true);
+ XMapEvent *xme = reinterpret_cast <XMapEvent *> (xevent);
+
+ if (mWindows.contains (xme->window))
+ client = mWindows[xme->window];
+ else if (mDecorNormal->winId () == xme->window)
+ client = mDecorNormal;
+ else if (mDecorActive->winId () == xme->window)
+ client = mDecorActive;
+ else
+ break;
+
+ if (client->handleMap ())
+ {
+ if (!mIdleTimer.isActive ())
+ mIdleTimer.start (0, TRUE);
+ }
break;
}
- case UnmapNotify:
+ case ConfigureNotify:
{
- Aquamarine::Window * client = 0;
- if (m_frames.contains (xevent->xunmap.window))
- client = m_frames[xevent->xunmap.window];
- if (!client)
- break;
- client->setMapping(false);
+ XConfigureEvent *xce = reinterpret_cast <XConfigureEvent *> (xevent);
+
+ if (mFrames.contains (xce->window))
+ mFrames[xce->window]->updateFrame (xce->window);
+
+ if (mWindows.contains (xce->window))
+ client = mWindows[xce->window];
+ else if (mDecorNormal->winId () == xce->window)
+ client = mDecorNormal;
+ else if (mDecorActive->winId () == xce->window)
+ client = mDecorActive;
+ else
+ break;
+
+ if (client->handleConfigure ())
+ {
+ if (!mIdleTimer.isActive ())
+ mIdleTimer.start (0, TRUE);
+ }
break;
}
- case DestroyNotify:
- if (xevent->xdestroywindow.window == m_activeWM)
- {
- m_restart = true;
- KApplication::exit(0);
- }
- break;
- case SelectionRequest:
- handleSelectionRequest (xevent);
- break;
- case SelectionClear:
- if (xevent->xselectionclear.selection == Atoms::dm_sn)
- {
- m_restart = false;
- KApplication::exit(0);
- }
- break;
- case ConfigureNotify:
- {
- XConfigureEvent *
- xce = reinterpret_cast < XConfigureEvent * >(xevent);
- Aquamarine::Window * client = 0;
- if (m_frames.contains (xce->window))
- client = m_frames[xce->window];
- if (!client)
- break;
- client->updateFrame (xce->window);
- }
- case PropertyNotify:
- if (xevent->xproperty.atom == Atoms::net_frame_window)
- {
- xid = xevent->xproperty.window;
- slotWindowAdded (xid);
- }
- if (xevent->xproperty.atom == Atoms::select_window)
- {
- xid = xevent->xproperty.window;
- if (!m_switcher || m_switcher->xid () != xid)
- slotWindowAdded (xid);
- m_switcher->update ();
-
- }
- if (xevent->xproperty.atom == Atoms::net_desktop_geometry
- || xevent->xproperty.atom == Atoms::net_desktop_viewport)
- {
- updateDesktopGeometry ();
- }
- if (xevent->xproperty.atom == Atoms::opacity)
- {
- Aquamarine::Window * client = 0;
- if (m_windows.contains (xevent->xproperty.window))
- client = m_windows[xevent->xproperty.window];
- if (client)
- client->updateOpacity ();
- }
- if (xevent->xproperty.atom == Atoms::brightness)
- {
- Aquamarine::Window * client = 0;
- if (m_windows.contains (xevent->xproperty.window))
- client = m_windows[xevent->xproperty.window];
- if (client)
- client->updateBrightness ();
- }
- if (xevent->xproperty.atom == Atoms::saturation)
- {
- Aquamarine::Window * client = 0;
- if (m_windows.contains (xevent->xproperty.window))
- client = m_windows[xevent->xproperty.window];
- if (client)
- client->updateSaturation ();
- }
- break;
- case EnterNotify:
- {
- XCrossingEvent *
- xce = reinterpret_cast < XCrossingEvent * >(xevent);
- Aquamarine::Window * client = 0;
- if (m_frames.contains (xce->window))
- client = m_frames[xce->window];
- if (!client)
- break;
- client->updateCursor (QPoint (xce->x, xce->y));
- break;
- }
- case LeaveNotify:
- {
- XCrossingEvent *
- xce = reinterpret_cast < XCrossingEvent * >(xevent);
- Aquamarine::Window * client = 0;
- if (m_frames.contains (xce->window))
- client = m_frames[xce->window];
- if (!client)
- break;
- XUndefineCursor (qt_xdisplay (), client->frameId ());
- break;
- }
- case MotionNotify:
- {
- XMotionEvent *
- xme = reinterpret_cast < XMotionEvent * >(xevent);
- Aquamarine::Window * client = 0;
- if (m_frames.contains (xme->window))
- client = m_frames[xme->window];
- if (!client)
+ case DestroyNotify:
+ if (xevent->xdestroywindow.window == mActiveWM)
{
- 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);
- }
+ mRestart = true;
+ KApplication::exit(0);
}
- if (!client)
- break;
- client->updateCursor (QPoint (xme->x, xme->y));
- break;
- }
- case ClientMessage:
- if (xevent->xclient.message_type == Atoms::toolkitActionAtom)
- {
- long action;
-
- action = xevent->xclient.data.l[0];
- if ((Atom)action == Atoms::toolkitActionWindowMenuAtom)
+ break;
+ case SelectionRequest:
+ decor_handle_selection_request (qt_xdisplay (), xevent, mDmSnTimestamp);
+ break;
+ case SelectionClear:
+ status = decor_handle_selection_clear (qt_xdisplay (),
+ xevent, 0);
+ if (status == DECOR_SELECTION_GIVE_UP)
+ KApplication::exit (0);
+ break;
+ case PropertyNotify:
+ if (xevent->xproperty.atom == Atoms::netFrameWindow)
{
- if (m_windows.contains (xevent->xclient.window))
+ handleWindowAdded (xevent->xproperty.window);
+ }
+ else if (xevent->xproperty.atom == Atoms::switchSelectWindow)
{
- QPoint pos;
-
- Aquamarine::Window * client = m_windows[xevent->xclient.window];
-
- if (xevent->xclient.data.l[2])
+ if (!mClients.contains (xevent->xproperty.window))
{
- pos = QPoint (xevent->xclient.data.l[3],
- xevent->xclient.data.l[4]);
+ handleWindowAdded (xevent->xproperty.window);
}
else
{
- pos = client->geometry ().topLeft ();
- }
+ WId id;
- client->showWindowMenu (pos);
+ if (Aquamarine::readWindowProperty (xevent->xproperty.window,
+ Atoms::switchSelectWindow,
+ (long *) &id))
+ mClients[xevent->xproperty.window]->updateSelected (id);
+ }
}
+ else if (xevent->xproperty.atom == Atoms::netWmWindowOpacity)
+ {
+ if (mClients.contains (xevent->xproperty.window))
+ mClients[xevent->xproperty.window]->updateOpacity ();
}
- else if ((Atom)action == Atoms::toolkitActionMainMenuAtom)
+ else if (xevent->xproperty.atom == Atoms::netWmWindowBrightness)
{
- dcopClient ()->send ("kicker",
- "kicker",
- "showKMenu()",
- QByteArray ());
+ if (mClients.contains (xevent->xproperty.window))
+ mClients[xevent->xproperty.window]->updateBrightness ();
}
- else if ((Atom)action == Atoms::toolkitActionRunDialogAtom)
+ else if (xevent->xproperty.atom == Atoms::netWmWindowSaturation)
{
- dcopClient ()->send ("kdesktop",
- "KDesktopIface",
- "popupExecuteCommand()",
- QByteArray ());
+ if (mClients.contains (xevent->xproperty.window))
+ mClients[xevent->xproperty.window]->updateSaturation ();
}
- else if ((Atom)action == Atoms::toolkitActionForceQuitDialogAtom)
+ else if (xevent->xproperty.atom == Atoms::netDesktopGeometry
+ || xevent->xproperty.atom == Atoms::netDesktopViewport)
{
- if (m_windows.contains (xevent->xclient.window))
+ updateDesktopGeometry ();
+ }
+ break;
+ case EnterNotify:
+ {
+ XCrossingEvent *xce = reinterpret_cast <XCrossingEvent *> (xevent);
+ QWidget *widget, *child;
+
+ if (!mFrames.contains (xce->window))
+ break;
+
+ client = mFrames[xce->window];
+
+ widget = client->decoration ()->widget ();
+ child = widget->childAt (xce->x, xce->y, true);
+ if (child)
{
- Time timestamp = xevent->xclient.data.l[1];
+ QEvent qe (QEvent::Enter);
- Aquamarine::Window * client = m_windows[xevent->xclient.window];
+ QApplication::sendEvent (child, &qe);
- if (xevent->xclient.data.l[2])
- client->showKillProcessDialog (timestamp);
- else
- client->hideKillProcessDialog ();
+ client->setActiveChild (child);
+ client->updateCursor (QPoint (xce->x, xce->y));
}
+ break;
+ }
+ case LeaveNotify:
+ {
+ XCrossingEvent *xce = reinterpret_cast <XCrossingEvent *> (xevent);
+
+ if (mFrames.contains (xce->window))
+ {
+ QEvent qe (QEvent::Leave);
+
+ client = mFrames[xce->window];
+
+ QApplication::sendEvent (client->activeChild (), &qe);
+
+ XUndefineCursor (qt_xdisplay (), client->frameId ());
}
+ break;
}
+ case MotionNotify:
+ {
+ XMotionEvent *xme = reinterpret_cast < XMotionEvent * >(xevent);
+ QWidget *widget, *child;
+
+ if (!mFrames.contains (xme->window))
+ break;
+
+ client = mFrames[xme->window];
+
+ widget = client->decoration ()->widget ();
+ child = widget->childAt (xme->x, xme->y, true);
+ if (child)
+ {
+ QPoint qp (xme->x, xme->y);
+
+ 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);
+ }
+
+ 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));
+ }
+ break;
+ }
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ XButtonEvent *xbe = reinterpret_cast <XButtonEvent *>(xevent);
+ QWidget *widget, *child;
+
+ if (!mFrames.contains (xbe->window))
+ break;
+
+ client = mFrames[xbe->window];
+
+ widget = client->decoration ()->widget ();
+ child = widget->childAt (xbe->x, xbe->y, true);
+
+ if (child)
+ {
+ XButtonEvent xbe2 = *xbe;
+
+ 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;
+ }
+ break;
+ }
+ case ClientMessage:
+ if (xevent->xclient.message_type == Atoms::toolkitActionAtom)
+ {
+ unsigned long action;
+
+ action = xevent->xclient.data.l[0];
+ if (action == Atoms::toolkitActionWindowMenuAtom)
+ {
+ if (mClients.contains (xevent->xclient.window))
+ {
+ QPoint pos;
+
+ client = mClients[xevent->xclient.window];
+
+ if (xevent->xclient.data.l[2])
+ {
+ pos = QPoint (xevent->xclient.data.l[3],
+ xevent->xclient.data.l[4]);
+ }
+ else
+ {
+ pos = client->clientGeometry ().topLeft ();
+ }
+
+ client->showWindowMenu (pos);
+ }
+ }
+ else if (action == Atoms::toolkitActionMainMenuAtom)
+ {
+ dcopClient ()->send ("kicker",
+ "kicker",
+ "showKMenu()",
+ QByteArray ());
+ }
+ else if (action == Atoms::toolkitActionRunDialogAtom)
+ {
+ dcopClient ()->send ("kdesktop",
+ "KDesktopIface",
+ "popupExecuteCommand()",
+ QByteArray ());
+ }
+ else if (action == Atoms::toolkitActionForceQuitDialogAtom)
+ {
+ if (mClients.contains (xevent->xclient.window))
+ {
+ Time timestamp = xevent->xclient.data.l[1];
+
+ client = mClients[xevent->xclient.window];
+
+ if (xevent->xclient.data.l[2])
+ client->showKillProcessDialog (timestamp);
+ else
+ client->hideKillProcessDialog ();
+ }
+ }
+ }
+ break;
+ default:
+ if (xevent->type == mDamageEvent + XDamageNotify)
+ {
+ XDamageNotifyEvent *xde =
+ reinterpret_cast <XDamageNotifyEvent *>(xevent);
+
+ if (mWindows.contains (xde->drawable))
+ client = mWindows[xde->drawable];
+ else if (mDecorNormal->winId () == xde->drawable)
+ client = mDecorNormal;
+ else if (mDecorActive->winId () == xde->drawable)
+ client = mDecorActive;
+ else
+ break;
+
+ client->addDamageRect (xde->area.x,
+ xde->area.y,
+ xde->area.width,
+ xde->area.height);
+
+ if (client->pixmapId ())
+ {
+ if (!mIdleTimer.isActive ())
+ mIdleTimer.start (0, TRUE);
+ }
+
+ return true;
+ }
break;
- default:
- break;
- }
- return KApplication::x11EventFilter (xevent);
-}
+ }
-WId
-Aquamarine::Decorator::fetchFrame (WId window)
-{
- Atom type;
- int format;
- unsigned long nitems;
- unsigned long bytes_after;
- WId *w;
- WId **ww = &w;
- int err,result;
-
- Aquamarine::trapXError ();
-
- type = None;
- result = XGetWindowProperty (qt_xdisplay (),
- window,
- Atoms::net_frame_window,
- 0, LONG_MAX,
- False, XA_WINDOW, &type, &format, &nitems,
- &bytes_after, (unsigned char **)ww);
- err = Aquamarine::popXError ();
-
- if (err || result != Success)
- return 0;
-
- if (type != XA_WINDOW)
- {
- XFree (w);
- return 0;
- }
-
- WId rv = *w;
- XFree (w);
-
- if (validWindow(rv))
- return rv;
- else
- return 0;
+ return KApplication::x11EventFilter (xevent);
}
void
-Aquamarine::Decorator::reconfigure ()
+Aquamarine::Decorator::reconfigure (void)
{
- kdDebug () << k_funcinfo << endl;
+ unsigned long changed;
Settings::self()->config()->reparseConfiguration();
Settings::self()->readConfig();
- m_config->reparseConfiguration ();
- unsigned long changed = m_options->updateSettings ();
+ updateAllShadowOptions();
- for (QMap < WId, Aquamarine::Window * >::ConstIterator it =
- m_windows.constBegin (); it != m_windows.constEnd (); ++it)
- it.data ()->updateConfig ();
+ mConfig->reparseConfiguration ();
+ changed = mOptions->updateSettings ();
- if (m_defShadow)
- delete m_defShadow;
- m_defShadow = (Settings::drawShadows())? new Aquamarine::DefaultShadow () : NULL;
+ updateShadow ();
-#ifdef HAVE_BERYL_SETTINGS
- beryl_settings_send_reload_signal();
-#endif
+ if (mPlugins->reset (changed))
+ {
+ QMap < WId, Aquamarine::Window * >::ConstIterator it;
- if (m_plugins->reset (changed))
- {
- for (QMap < WId, Aquamarine::Window * >::ConstIterator it =
- m_windows.constBegin (); it != m_windows.constEnd (); ++it)
- it.data ()->reloadDecoration ();
- m_defDeco->reloadDecoration ();
- m_defDecoActive->reloadDecoration ();
- m_plugins->destroyPreviousPlugin ();
- }
-}
+ mDecorNormal->reloadDecoration ();
+ mDecorActive->reloadDecoration ();
-void
-Aquamarine::Decorator::slotSettingsChanged (int)
-{
- kdDebug () << k_funcinfo << endl;
-#ifdef HAVE_BERYL_SETTINGS
- beryl_settings_send_reload_signal();
-#endif
+ for (it = mClients.constBegin (); it != mClients.constEnd (); it++)
+ it.data ()->reloadDecoration ();
+
+ mPlugins->destroyPreviousPlugin ();
+ }
+ else
+ {
+ QMap < WId, Aquamarine::Window * >::ConstIterator it;
+
+ mDecorNormal->updateShadow ();
+ mDecorActive->updateShadow ();
+
+ for (it = mClients.constBegin (); it != mClients.constEnd (); it++)
+ it.data ()->updateShadow ();
+ }
}
void
-Aquamarine::Decorator::slotWindowAdded (WId id)
+Aquamarine::Decorator::handleWindowAdded (WId id)
{
- kdDebug () << k_funcinfo << endl;
- if (!validWindow(id)) return;
- Aquamarine::trapXError ();
- XSelectInput (qt_xdisplay (), id, defaultMask);
- if (Aquamarine::popXError ())
- return;
- if (Aquamarine::readWindowProperty (id, Atoms::select_window, NULL))
- {
- if (!m_switcher)
- m_switcher = new Switcher (id);
- if (m_switcher->xid () != id)
- {
- delete
- m_switcher;
- m_switcher = new Switcher (id);
- }
- return;
- }
- 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;
- }
- }
-
- KWin::WindowInfo wInfo = KWin::windowInfo (id, NET::WMWindowType, 0);
-
- switch (wInfo.windowType (~0)) {
- case NET::Normal:
- case NET::Dialog:
- case NET::Toolbar:
- case NET::Menu:
- case NET::Utility:
- case NET::Splash:
- /* decorate these window types */
- break;
- default:
- return;
+ QMap <WId, Aquamarine::Window *>::ConstIterator it;
+ Aquamarine::Window *client = 0;
+ WId select, frame = 0;
+ Aquamarine::Window::Type type;
+ unsigned int width, height, border, depth;
+ int x, y;
+ XID root;
+ QWidgetList *widgets;
+
+ /* avoid adding any of our own top level windows */
+ widgets = QApplication::topLevelWidgets ();
+ if (widgets)
+ {
+ for (QWidgetListIt it (*widgets); it.current (); ++it)
+ {
+ if (it.current ()->winId () == id)
+ {
+ delete widgets;
+ return;
+ }
+ }
+
+ delete widgets;
}
+ Aquamarine::trapXError ();
+ XGetGeometry (qt_xdisplay (), id, &root, &x, &y, &width, &height,
+ &border, &depth);
+ if (Aquamarine::popXError ())
+ return;
+
+ Aquamarine::readWindowProperty (id, Atoms::netFrameWindow, (long *) &frame);
+ if (Aquamarine::readWindowProperty (id, Atoms::switchSelectWindow,
+ (long *) &select))
+ {
+ type = Aquamarine::Window::Switcher;
+ }
+ else
+ {
+ KWin::WindowInfo wInfo = KWin::windowInfo (id, NET::WMWindowType, 0);
+
+ switch (wInfo.windowType (~0)) {
+ case NET::Normal:
+ case NET::Dialog:
+ case NET::Toolbar:
+ case NET::Menu:
+ case NET::Utility:
+ case NET::Splash:
+ case NET::Unknown:
+ /* decorate these window types */
+ break;
+ default:
+ return;
+ }
+
+ type = Aquamarine::Window::Normal;
+ }
+
+ Aquamarine::trapXError ();
+ XSelectInput (qt_xdisplay (), id, StructureNotifyMask | PropertyChangeMask);
+ Aquamarine::popXError ();
+
if (frame)
- {
- if (!m_windows.contains (id))
- {
- client = new Aquamarine::Window (id, frame);
- connect( this, SIGNAL(desktopGeometryChanged()), client, SLOT(slotDesktopGeometryChanged()) );
- if (m_kwinmodule->activeWindow () == id)
- {
- if (m_activeWindow)
- m_activeWindow->setActive (false);
- m_activeWindow = client;
- client->setActive(true);
- }
- m_windows.insert (id, client);
- m_frames.insert (frame, client);
- }
- else
- {
- client = m_windows[id];
- m_frames.remove (client->frameId ());
- m_frames.insert (frame, client);
- client->updateFrame (frame);
- }
- }
- else
- {
- if (m_windows.contains (id))
- {
- client = m_windows[id];
- }
- if (client)
- {
- m_windows.remove (client->windowId ());
- m_frames.remove (client->frameId ());
- delete
- client;
- }
- }
+ {
+ if (!mClients.contains (id))
+ {
+ client = new Aquamarine::Window (mCompositeWindow, id, frame, type,
+ x, y,
+ width + border * 2,
+ height + border * 2);
+ connect( this, SIGNAL(desktopGeometryChanged()), client,
+ SLOT(handleDesktopGeometryChanged()) );
+
+ mClients.insert (id, client);
+ mWindows.insert (client->winId (), client);
+ mFrames.insert (frame, client);
+ }
+ else
+ {
+ client = mClients[id];
+ mFrames.remove (client->frameId ());
+ mFrames.insert (frame, client);
+
+ client->updateFrame (frame);
+ }
+ }
+ else if (type == Aquamarine::Window::Switcher)
+ {
+ if (!mClients.contains (id))
+ {
+ client = new Aquamarine::Window (mCompositeWindow, id, 0, type,
+ x, y,
+ width + border * 2,
+ height + border * 2);
+ mClients.insert (id, client);
+ mWindows.insert (client->winId (), client);
+ }
+ }
+ else
+ {
+ if (mClients.contains (id))
+ client = mClients[id];
+
+ if (client)
+ {
+ mClients.remove (client->windowId ());
+ mWindows.remove (client->winId ());
+ mFrames.remove (client->frameId ());
+
+ delete client;
+ }
+ }
}
void
-Aquamarine::Decorator::slotWindowRemoved (WId id)
+Aquamarine::Decorator::handleWindowRemoved (WId id)
{
- kdDebug () << k_funcinfo << endl;
- Aquamarine::Window * window = 0;
- if (m_windows.contains (id))
- {
- window = m_windows[id];
- }
- else if (m_frames.contains (id))
- {
- window = m_frames[id];
- }
- if (window)
- {
- m_windows.remove (window->windowId ());
- m_frames.remove (window->frameId ());
- if (m_activeWindow == window)
- m_activeWindow = 0;
- delete
- window;
- }
- if (m_switcher && m_switcher->xid () == id)
- {
- delete
- m_switcher;
- m_switcher = NULL;
- }
+ Aquamarine::Window *window = 0;
+
+ if (mClients.contains (id))
+ window = mClients[id];
+ else if (mFrames.contains (id))
+ window = mFrames[id];
+
+ if (window)
+ {
+ mClients.remove (window->windowId ());
+ mWindows.remove (window->winId ());
+ mFrames.remove (window->frameId ());
+
+ delete window;
+ }
}
void
-Aquamarine::Decorator::slotActiveWindowChanged (WId id)
+Aquamarine::Decorator::handleActiveWindowChanged (WId id)
{
- kdDebug () << k_funcinfo << endl;
-
- Aquamarine::Window * newActiveWindow = 0;
- if (m_windows.contains (id))
- newActiveWindow = m_windows[id];
-
- if (newActiveWindow && newActiveWindow != m_activeWindow)
- {
- if (m_activeWindow)
- {
- Aquamarine::trapXError ();
- XWindowAttributes
- attr;
- if (XGetWindowAttributes
- (qt_xdisplay (), m_activeWindow->windowId (), &attr)
- && !Aquamarine::popXError ())
- m_activeWindow->setActive (false);
- }
- newActiveWindow->setActive (true);
- }
- m_activeWindow = newActiveWindow;
+ if (id != mActiveId)
+ {
+ Aquamarine::Window *newActiveWindow = 0;
+ Aquamarine::Window *oldActiveWindow = 0;
+
+ if (mClients.contains (id))
+ newActiveWindow = mClients[id];
+
+ if (mClients.contains (mActiveId))
+ oldActiveWindow = mClients[mActiveId];
+
+ mActiveId = id;
+
+ if (oldActiveWindow)
+ oldActiveWindow->handleActiveChange ();
+
+ if (newActiveWindow)
+ newActiveWindow->handleActiveChange ();
+ }
}
void
-Aquamarine::Decorator::slotWindowChanged (WId id,
- const unsigned long *properties)
+Aquamarine::Decorator::handleWindowChanged (WId id,
+ const unsigned long *properties)
{
- Aquamarine::Window * client = 0;
- if (m_windows.contains (id))
- client = m_windows[id];
-
- if (properties[0] & NET::WMName)
- {
- if (client)
- client->updateName ();
- }
- if (properties[0] & NET::WMState)
- {
- if (client)
- client->updateState ();
- }
- if (properties[0] & NET::WMIcon)
- {
- if (client)
- client->updateIcons ();
- }
- if (properties[0] & NET::WMGeometry)
- {
- if (m_switcher && m_switcher->xid () == id)
- m_switcher->updateGeometry ();
- if (client)
- client->updateWindowGeometry ();
- }
+ Aquamarine::Window *client;
+
+ if (!mClients.contains (id))
+ return;
+
+ client = mClients[id];
+
+ if (properties[0] & NET::WMName)
+ client->updateName ();
+ if (properties[0] & NET::WMState)
+ client->updateState ();
+ if (properties[0] & NET::WMIcon)
+ client->updateIcons ();
+ if (properties[0] & NET::WMGeometry)
+ client->updateWindowGeometry ();
}
void
-Aquamarine::Decorator::sendClientMessage (WId w, Atom a, Atom protocol,
- long data1, long data2, long data3)
+Aquamarine::Decorator::sendClientMessage (WId eventWid,
+ WId wid,
+ Atom atom,
+ Atom value,
+ long data1,
+ long data2,
+ long data3)
{
- XEvent ev;
- long mask;
-
- memset (&ev, 0, sizeof (ev));
- ev.xclient.type = ClientMessage;
- ev.xclient.window = w;
- ev.xclient.message_type = a;
- ev.xclient.format = 32;
- ev.xclient.data.l[0] = protocol;
- ev.xclient.data.l[1] = qt_x_time;
- ev.xclient.data.l[2] = data1;
- ev.xclient.data.l[3] = data2;
- ev.xclient.data.l[4] = data3;
- mask = 0L;
- if (w == qt_xrootwin ())
- mask = SubstructureRedirectMask;
- XSendEvent (qt_xdisplay (), w, False, mask, &ev);
+ XEvent ev;
+ long mask = 0;
+
+ memset (&ev, 0, sizeof (ev));
+
+ ev.xclient.type = ClientMessage;
+ ev.xclient.window = wid;
+ ev.xclient.message_type = atom;
+ ev.xclient.format = 32;
+
+ ev.xclient.data.l[0] = value;
+ ev.xclient.data.l[1] = qt_x_time;
+ ev.xclient.data.l[2] = data1;
+ ev.xclient.data.l[3] = data2;
+ ev.xclient.data.l[4] = data3;
+
+ if (eventWid == qt_xrootwin ())
+ mask = SubstructureRedirectMask | SubstructureNotifyMask;
+
+ Aquamarine::trapXError ();
+ XSendEvent (qt_xdisplay (), eventWid, false, mask, &ev);
+ Aquamarine::popXError ();
}
-void
-Aquamarine::Decorator::updateDesktopGeometry ()
+void Aquamarine::Decorator::updateDesktopGeometry ()
{
- int x, y;
- unsigned int width, height, border, depth;
- ::Window root;
- XGetGeometry (qt_xdisplay (), qt_xrootwin (), &root, &x, &y, &width,
- &height, &border, &depth);
- m_rootSize = QSize (width, height);
-
- int
- num_val;
- void *
- values =
- readXProperty (qt_xrootwin (), Atoms::net_desktop_geometry,
- XA_CARDINAL, &num_val);
-
- if (values)
- {
- unsigned long *
- val = (unsigned long *)values;
- m_desktop = QSize (val[0], val[1]);
- XFree (val);
- }
- else
- {
- m_desktop = QSize (m_rootSize.width (), m_rootSize.height ());
- }
- values =
- readXProperty (qt_xrootwin (), Atoms::net_desktop_viewport,
- XA_CARDINAL, &num_val);
-
- if (values)
- {
- unsigned long *
- val = (unsigned long *)values;
- m_viewport = QPoint (val[0], val[1]);
- XFree (val);
- }
- else
- {
- m_viewport = QPoint (0, 0);
- }
-
- emit desktopGeometryChanged();
+ int x, y;
+ unsigned int width, height, border, depth;
+ ::Window root;
+ XGetGeometry (qt_xdisplay (), qt_xrootwin (), &root, &x, &y, &width,
+ &height, &border, &depth);
+ mRootSize = QSize (width, height);
+
+ int num_val;
+ void *values = readXProperty (qt_xrootwin (), Atoms::netDesktopGeometry,
+ XA_CARDINAL, &num_val);
+
+ if (values)
+ {
+ unsigned long *
+ val = (unsigned long *)values;
+ mDesktop = QSize (val[0], val[1]);
+ XFree (val);
+ }
+ else
+ {
+ mDesktop = QSize (mRootSize.width (), mRootSize.height ());
+ }
+ values = readXProperty (qt_xrootwin (), Atoms::netDesktopViewport,
+ XA_CARDINAL, &num_val);
+
+ if (values)
+ {
+ unsigned long *val = (unsigned long *)values;
+ mViewport = QPoint (val[0], val[1]);
+ XFree (val);
+ }
+ else
+ {
+ mViewport = QPoint (0, 0);
+ }
+
+ emit desktopGeometryChanged();
}
-int
-Aquamarine::Decorator::onViewport (QPoint pos)
+
+int Aquamarine::Decorator::onViewport (QPoint pos)
{
- return (((pos.y () +
- m_viewport.y ()) / m_rootSize.height ()) * (m_desktop.width () /
- m_rootSize.
- width ())) +
- ((pos.x () + m_viewport.x ()) / m_rootSize.width ()) + 1;
+ return (((pos.y () +
+ mViewport.y ()) / mRootSize.height ()) * (mDesktop.width () /
+ mRootSize.
+ width ())) +
+ ((pos.x () + mViewport.x ()) / mRootSize.width ()) + 1;
}
-QSize
-Aquamarine::Decorator::viewports ()
+QSize Aquamarine::Decorator::viewports ()
{
- return QSize ((m_desktop.width () / m_rootSize.width ()),
- (m_desktop.height () / m_rootSize.height ()));
+ return QSize ((mDesktop.width () / mRootSize.width ()),
+ (mDesktop.height () / mRootSize.height ()));
}
-void
-Aquamarine::Decorator::moveToViewport (WId id, int vp)
+void Aquamarine::Decorator::moveToViewport (WId id, int vp)
{
- int x, y;
- unsigned int width, height, border, depth;
- ::Window root;
- XGetGeometry (qt_xdisplay (), id, &root, &x, &y, &width, &height, &border,
- &depth);
- if (vp <= 0) vp+= (m_desktop.width () / m_rootSize.width ()) * (m_desktop.height () / m_rootSize.height ());
- vp = ((vp - 1) % ((m_desktop.width () / m_rootSize.width ()) * (m_desktop.height () / m_rootSize.height ()))) + 1;
- int
- offsetX = m_rootSize.width () * ((vp - 1) % viewports ().width ());
- int
- offsetY = m_rootSize.height () * ((vp - 1) / viewports ().width ());
- XMoveWindow (qt_xdisplay (), id, x + offsetX - m_viewport.x (),
- y + offsetY - m_viewport.y ());
+ int x, y;
+ unsigned int width, height, border, depth;
+ ::Window root;
+ XGetGeometry (qt_xdisplay (), id, &root, &x, &y, &width, &height, &border,
+ &depth);
+ if (vp <= 0) vp+= (mDesktop.width () / mRootSize.width ()) * (mDesktop.height () / mRootSize.height ());
+ vp = ((vp - 1) % ((mDesktop.width () / mRootSize.width ()) * (mDesktop.height () / mRootSize.height ()))) + 1;
+ int offsetX = mRootSize.width () * ((vp - 1) % viewports ().width ());
+ int offsetY = mRootSize.height () * ((vp - 1) / viewports ().width ());
+ XMoveWindow (qt_xdisplay (), id, x + offsetX - mViewport.x (),
+ y + offsetY - mViewport.y ());
}