diff --git a/geometry.cpp b/geometry.cpp
index ad5ac12a58..a03f9e559b 100644
--- a/geometry.cpp
+++ b/geometry.cpp
@@ -793,6 +793,17 @@ void Workspace::updateTopMenuGeometry( Client* c )
updateTopMenuGeometry( *it );
}
+// When kwin crashes, windows will not be gravitated back to their original position
+// and will remain offset by the size of the decoration. So when restarting, fix this
+// (the property with the size of the frame remains on the window after the crash).
+void Workspace::fixPositionAfterCrash( Window w, const XWindowAttributes& attr )
+ {
+ NETWinInfo i( display(), w, rootWindow(), NET::WMFrameExtents );
+ NETStrut frame = i.frameExtents();
+ if( frame.left != 0 || frame.top != 0 )
+ XMoveWindow( display(), w, attr.x - frame.left, attr.y - frame.top );
+ }
+
//********************************************
// Client
//********************************************
diff --git a/workspace.cpp b/workspace.cpp
index f6972e2f29..20f068ab90 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -40,6 +40,7 @@ along with this program. If not, see .
#include
#include
#include
+#include
#include
#include "client.h"
@@ -388,6 +389,7 @@ void Workspace::init()
Window root_return, parent_return;
Window* wins;
XQueryTree( display(), rootWindow(), &root_return, &parent_return, &wins, &nwins );
+ bool fixoffset = KCmdLineArgs::parsedArgs()->getOption( "crashes" ).toInt() > 0;
for( i = 0; i < nwins; i++ )
{
XWindowAttributes attr;
@@ -400,7 +402,11 @@ void Workspace::init()
if( topmenu_space && topmenu_space->winId() == wins[i] )
continue;
if( attr.map_state != IsUnmapped )
+ {
+ if( fixoffset )
+ fixPositionAfterCrash( wins[ i ], attr );
createClient( wins[i], true );
+ }
}
if( wins )
XFree( (void*)( wins ));
diff --git a/workspace.h b/workspace.h
index 7fdf6a32d5..c77610cb3d 100644
--- a/workspace.h
+++ b/workspace.h
@@ -569,6 +569,7 @@ class Workspace : public QObject, public KDecorationDefines
void setupTopMenuHandling();
void updateTopMenuGeometry( Client* c = NULL );
void updateToolWindows( bool also_hide );
+ void fixPositionAfterCrash( Window w, const XWindowAttributes& attr );
/// This is the right way to create a new client
Client* createClient( Window w, bool is_mapped );