summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aquamarine.cpp18
-rw-r--r--src/decorator.cpp65
-rw-r--r--src/utils.cpp9
-rw-r--r--src/utils.h1
-rw-r--r--src/window.cpp138
-rw-r--r--src/window.h2
6 files changed, 148 insertions, 85 deletions
diff --git a/src/aquamarine.cpp b/src/aquamarine.cpp
index 2920dc1..8ee8485 100644
--- a/src/aquamarine.cpp
+++ b/src/aquamarine.cpp
@@ -57,6 +57,11 @@ main (int argc, char **argv)
{
char *display = 0;
Display *dpy = XOpenDisplay (display);
+ if (!dpy)
+ {
+ qWarning ("cannot connect to X server ");
+ exit (1);
+ }
int screen = DefaultScreen (dpy);
KCmdLineArgs::init (argc, argv, "aquamarine", I18N_NOOP ("Aquamarine"),
@@ -74,12 +79,7 @@ main (int argc, char **argv)
int rv = 1;
do
{
-
- if (!dpy)
- {
- qWarning ("cannot connect to X server ");
- exit (1);
- }
+ Aquamarine::trapXError();
Bool wmRunning = false;
do
@@ -132,10 +132,10 @@ main (int argc, char **argv)
printf("New Window Manager\n");
foundWM = true;
}
- } while (xev.type == ClientMessage &&
- xev.xclient.message_type == manager &&
- (Atom)xev.xclient.data.l[1] == wm_sn);
+ } while (!foundWM);
}
+ Aquamarine::popXError(dpy);
+
} while (!wmRunning);
Aquamarine::Decorator *app = new Aquamarine::Decorator();
diff --git a/src/decorator.cpp b/src/decorator.cpp
index 8e61c8c..58c8c7c 100644
--- a/src/decorator.cpp
+++ b/src/decorator.cpp
@@ -84,6 +84,7 @@ Aquamarine::Decorator::Decorator (void) : DCOPObject ("KWinInterface"),
{
KGlobal::locale()->insertCatalogue("kdelibs");
KGlobal::locale()->setActiveCatalogue("aquamarine");
+ XSync (qt_xdisplay(), false);
mReady = false;
mRestart = false;
@@ -109,7 +110,9 @@ Aquamarine::Decorator::Decorator (void) : DCOPObject ("KWinInterface"),
mActiveWM = XGetSelectionOwner(qt_xdisplay(),Atoms::wmSn);
if (mActiveWM == None)
return;
+ Aquamarine::trapXError ();
XSelectInput (qt_xdisplay(), mActiveWM, StructureNotifyMask);
+ if (Aquamarine::popXError ()) return;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs ();
@@ -137,7 +140,6 @@ Aquamarine::Decorator::Decorator (void) : DCOPObject ("KWinInterface"),
}
return;
}
-
decor_set_dm_check_hint (qt_xdisplay (), 0);
mConfig = new KConfig ("kwinrc");
@@ -199,26 +201,73 @@ Aquamarine::Decorator::~Decorator (void)
for (it = mClients.begin (); it != mClients.end (); it++)
delete (*it);
+ mClients.clear ();
+ mFrames.clear ();
+ mWindows.clear ();
+
if (mDefaultShadow)
{
decor_shadow_destroy (qt_xdisplay (), mDefaultShadow);
mDefaultShadow = NULL;
}
+ if (mNoBorderShadow)
+ {
+ decor_shadow_destroy (qt_xdisplay (), mNoBorderShadow);
+ mNoBorderShadow = NULL;
+ Aquamarine::trapXError ();
+ XDeleteProperty (qt_xdisplay (), qt_xrootwin (),
+ Atoms::netWindowDecorBare);
+ Aquamarine::popXError ();
+ }
+
if (mDecorNormal)
+ {
delete mDecorNormal;
+ mDecorNormal = NULL;
+ }
if (mDecorActive)
+ {
delete mDecorActive;
+ mDecorActive = NULL;
+ }
- /* XXX: mCompositeWindow is not deleted, some plugins seem to rely on
- it not being deleted... not sure what to do about this. */
+ if (mOptions)
+ {
+ delete mOptions;
+ mOptions = NULL;
+ }
- delete mOptions;
- delete mPlugins;
- delete mConfig;
- delete mKWinModule;
- delete mRootInfo;
+ if (mPlugins)
+ {
+ delete mPlugins;
+ mPlugins = NULL;
+ }
+
+ if (mConfig)
+ {
+ delete mConfig;
+ mConfig = NULL;
+ }
+
+ if (mKWinModule)
+ {
+ delete mKWinModule;
+ mKWinModule = NULL;
+ }
+
+ if (mRootInfo)
+ {
+ delete mRootInfo;
+ mRootInfo = NULL;
+ }
+
+ if (mCompositeWindow)
+ {
+ delete mCompositeWindow;
+ mCompositeWindow = 0;
+ }
}
bool Aquamarine::Decorator::enableDecorations (Time timestamp, int damageEvent)
diff --git a/src/utils.cpp b/src/utils.cpp
index 0aebc12..02768c2 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -79,14 +79,19 @@ void Aquamarine::trapXError (void)
oldErrorHandler = XSetErrorHandler (xErrorHandler);
}
-int Aquamarine::popXError (void)
+int Aquamarine::popXError (Display *dpy)
{
- XSync (qt_xdisplay(), false);
+ XSync (dpy, false);
XSetErrorHandler (oldErrorHandler);
return trappedErrorCode;
}
+int Aquamarine::popXError (void)
+{
+ return popXError(qt_xdisplay());
+}
+
void *Aquamarine::readXProperty (WId window,
Atom property,
Atom type,
diff --git a/src/utils.h b/src/utils.h
index e71a73c..714cd07 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -63,6 +63,7 @@ namespace Aquamarine
void trapXError (void);
int popXError (void);
+ int popXError (Display *dpy);
bool eventFilter (void *message, long *result);
void *readXProperty (WId window, Atom property, Atom type, int *items);
bool readWindowProperty (long wId, long property, long *value);
diff --git a/src/window.cpp b/src/window.cpp
index e07456f..405269e 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -74,6 +74,7 @@ Aquamarine::Window::Window (QWidget *parent, WId clientId, WId frame, Type type,
mShapeSet (false),
mUniqueHorzShape (false),
mUniqueVertShape (false),
+ mInitialized (true),
mPopup (0),
mAdvancedMenu (0),
mDesktopMenu (0),
@@ -729,22 +730,24 @@ Aquamarine::Window::createDecoration (void)
KDecoration *decor;
if (mDecor)
- return;
+ return;
decor = Decorator::pluginManager ()->createDecoration (this);
decor->init ();
mDecor = decor;
+ mInitialized = false;
+
if (mType == Normal && mFrame)
{
- Aquamarine::trapXError ();
- XSelectInput (qt_xdisplay (), mFrame,
- StructureNotifyMask | PropertyChangeMask |
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
- EnterWindowMask | LeaveWindowMask);
- if (Aquamarine::popXError ())
- return;
+ Aquamarine::trapXError ();
+ XSelectInput (qt_xdisplay (), mFrame,
+ StructureNotifyMask | PropertyChangeMask |
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
+ EnterWindowMask | LeaveWindowMask);
+ if (Aquamarine::popXError ())
+ return;
}
resizeDecoration (true);
@@ -1073,11 +1076,11 @@ Aquamarine::Window::updateShadow (void)
mTexturePicture,
&mLayout);
- if (mPixmap)
+ if (mPixmap && mDecor)
{
/* hm, update or repaint doesn't seem to do it */
- mDecor->widget ()->hide ();
- mDecor->widget ()->show ();
+ mDecor->widget ()->hide ();
+ mDecor->widget ()->show ();
}
mUpdateProperty = true;
@@ -1148,7 +1151,7 @@ Aquamarine::Window::resizeDecoration (bool force)
if (!force)
{
- if (w == width () && h == height ())
+ if (w == width () && h == height ())
return FALSE;
}
@@ -1159,40 +1162,40 @@ Aquamarine::Window::resizeDecoration (bool force)
if (mType != Normal && mType != Switcher)
{
- Display *xdisplay = qt_xdisplay ();
- Screen *xscreen = ScreenOfDisplay (xdisplay, qt_xscreen ());
- decor_shadow_t *tmpShadow;
- decor_context_t c;
-
- /* XXX: we have to create a temporary shadow to get the client
- geometry. libdecoration should be fixed so it's able to just
- fill out a context struct and not necessarily generate a
- shadow for this purpose. */
- tmpShadow = decor_shadow_create (xdisplay,
- xscreen,
- 1, 1,
- mBorder.left,
- mBorder.right,
- mBorder.top,
- mBorder.bottom,
- mBorder.left,
- mBorder.right,
- mBorder.top,
- mBorder.bottom,
- Aquamarine::Decorator::shadowOptions (),
- &c,
- decor_draw_simple,
- (void *) 0);
-
- decor_shadow_destroy (xdisplay, tmpShadow);
-
- w = c.left_corner_space + 1 + c.right_corner_space;
-
- /* most styles render something useful at least 30 px width */
- if (w < 30)
- w = 30;
-
- mGeometry = QRect (50, 50, w,
+ Display *xdisplay = qt_xdisplay ();
+ Screen *xscreen = ScreenOfDisplay (xdisplay, qt_xscreen ());
+ decor_shadow_t *tmpShadow;
+ decor_context_t c;
+
+ /* XXX: we have to create a temporary shadow to get the client
+ geometry. libdecoration should be fixed so it's able to just
+ fill out a context struct and not necessarily generate a
+ shadow for this purpose. */
+ tmpShadow = decor_shadow_create (xdisplay,
+ xscreen,
+ 1, 1,
+ mBorder.left,
+ mBorder.right,
+ mBorder.top,
+ mBorder.bottom,
+ mBorder.left,
+ mBorder.right,
+ mBorder.top,
+ mBorder.bottom,
+ Aquamarine::Decorator::shadowOptions (),
+ &c,
+ decor_draw_simple,
+ (void *) 0);
+
+ decor_shadow_destroy (xdisplay, tmpShadow);
+
+ w = c.left_corner_space + 1 + c.right_corner_space;
+
+ /* most styles render something useful at least 30 px width */
+ if (w < 30)
+ w = 30;
+
+ mGeometry = QRect (50, 50, w,
c.top_corner_space + 1 + c.bottom_corner_space);
}
@@ -1201,14 +1204,14 @@ Aquamarine::Window::resizeDecoration (bool force)
if (mPixmap)
{
- XFreePixmap (qt_xdisplay (), mPixmap);
- mPixmap = None;
+ XFreePixmap (qt_xdisplay (), mPixmap);
+ mPixmap = None;
}
if (mPicture)
{
- XRenderFreePicture (qt_xdisplay (), mPicture);
- mPicture = 0;
+ XRenderFreePicture (qt_xdisplay (), mPicture);
+ mPicture = 0;
}
setGeometry (QRect (mGeometry.x () + ROOT_OFF_X - mBorder.left,
@@ -1217,32 +1220,34 @@ Aquamarine::Window::resizeDecoration (bool force)
if (mMapped)
{
- mPendingConfigure++;
+ mPendingConfigure++;
}
else
{
- mPendingMap = 1;
+ mPendingMap = 1;
- show ();
+ show ();
- mMapped = true;
+ mMapped = true;
- /* XXX: is there a more appropriate way to achieve this?
- add WType_TopLevel flag so that visualRect isn't clipped
- to parent. */
- setWFlags (getWFlags () | WType_TopLevel);
+ /* XXX: is there a more appropriate way to achieve this?
+ add WType_TopLevel flag so that visualRect isn't clipped
+ to parent. */
+ setWFlags (getWFlags () | WType_TopLevel);
- if (mDamageId != winId ())
- {
- mDamageId = winId ();
- XDamageCreate (qt_xdisplay (), mDamageId,
- XDamageReportRawRectangles);
- }
+ if (mDamageId != winId ())
+ {
+ mDamageId = winId ();
+ XDamageCreate (qt_xdisplay (), mDamageId,
+ XDamageReportRawRectangles);
+ }
}
mDecor->resize (QSize (w, h));
mDecor->widget ()->show ();
+ mInitialized = true;
+
return TRUE;
}
@@ -1415,7 +1420,8 @@ Aquamarine::Window::updateFrame (WId frame)
StructureNotifyMask | PropertyChangeMask |
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
EnterWindowMask | LeaveWindowMask);
- Aquamarine::popXError ();
+ if (!Aquamarine::popXError () && !mInitialized)
+ resizeDecoration(true);
}
void
@@ -1554,7 +1560,7 @@ Aquamarine::Window::handleDesktopPopupActivated (int id)
setDesktop (id);
else
{
- setDesktop ((desktop () == NET::OnAllDesktops) ?
+ setDesktop ((desktop () == NET::OnAllDesktops) ?
KWin::currentDesktop() : NET::OnAllDesktops);
}
}
diff --git a/src/window.h b/src/window.h
index e9521f3..5752fd4 100644
--- a/src/window.h
+++ b/src/window.h
@@ -261,6 +261,8 @@ class Window:public QWidget, public KDecorationBridge {
bool mSupportTakeFocus;
bool mSupportContextHelp;
+ bool mInitialized;
+
QPopupMenu *mPopup;
QPopupMenu *mAdvancedMenu;
QPopupMenu *mDesktopMenu;