X11WindowSystem: improved surface resize handling
authorMichael Schuldt <michael.schuldt@bmw.de>
Tue, 26 Mar 2013 10:16:41 +0000 (03:16 -0700)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Wed, 3 Jul 2013 14:02:21 +0000 (16:02 +0200)
Signed-off-by: Michael Schuldt <michael.schuldt@bmw.de>
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp

index 88a53b0..72feff4 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "Log.h"
 #include "Layer.h"
+#include "Rectangle.h"
 #include <time.h>
 #include <sys/time.h>
 #include <X11/Xlib.h>
@@ -263,8 +264,6 @@ void X11WindowSystem::configureSurfaceWindow(Window window)
     if (isWindowValid(window))
     {
         LOG_DEBUG("X11WindowSystem", "Updating window " << window);
-        UnMapWindow(window);
-        MapWindow(window);
         XWindowAttributes att;
         XGetWindowAttributes(x11Display, window, &att);
         int winWidth = att.width;
@@ -284,11 +283,28 @@ void X11WindowSystem::configureSurfaceWindow(Window window)
 
         LOG_DEBUG("X11WindowSystem", "Updating surface " << surface->getID());
 
-        surface->OriginalSourceHeight = winHeight;
-        surface->OriginalSourceWidth = winWidth;
+        if (surface->OriginalSourceHeight != winHeight || surface->OriginalSourceWidth != winWidth)
+        {
+            surface->OriginalSourceHeight = winHeight;
+            surface->OriginalSourceWidth = winWidth;
+
+            surface->damaged = false; // Waiting for damage event to get updated content
+            surface->m_surfaceResized = true /*surface->synchronized*/;
+
+            Rectangle newDestination = surface->getDestinationRegion();
+            newDestination.width = surface->OriginalSourceWidth;
+            newDestination.height = surface->OriginalSourceHeight;
+            surface->setDestinationRegion(newDestination);
+
+            Rectangle newSource = surface->getSourceRegion();
+            newSource.width = surface->OriginalSourceWidth;
+            newSource.height = surface->OriginalSourceHeight;
+            surface->setSourceRegion(newSource);
+        }
+
+        UnMapWindow(window);
+        MapWindow(window);
 
-        surface->damaged = false; // Waiting for damage event to get updated content
-        surface->m_surfaceResized = true /*surface->synchronized*/;
         LOG_DEBUG("X11WindowSystem", "Done Updating window " << window);
     }
 }