From 04f07af1732722add251dd7f7d16aa8325eab5e2 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 24 Aug 2015 11:56:40 -0300 Subject: [PATCH] Fix problem leaving dirty areas in the screen when we move a window --- src/ui/graphics.cpp | 8 ++------ src/ui/manager.cpp | 5 +++++ src/ui/manager.h | 6 ++---- src/ui/move_region.cpp | 11 ++++++++--- src/ui/overlay.cpp | 18 ++++++++---------- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/ui/graphics.cpp b/src/ui/graphics.cpp index 122a80268..f19c1b8eb 100644 --- a/src/ui/graphics.cpp +++ b/src/ui/graphics.cpp @@ -37,12 +37,8 @@ Graphics::~Graphics() { // If we were drawing in the screen surface, we mark these regions // as dirty for the final flip. - if (m_surface == she::instance()->defaultDisplay()->getSurface()) { - gfx::Region& dirty = Manager::getDirtyRegion(); - Manager::getDirtyRegion().createUnion( - Manager::getDirtyRegion(), - gfx::Region(m_dirtyBounds)); - } + if (m_surface == she::instance()->defaultDisplay()->getSurface()) + Manager::getDefault()->dirtyRect(m_dirtyBounds); } int Graphics::width() const diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index c81a1bc0a..3a394760e 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -875,6 +875,11 @@ bool Manager::isFocusMovementKey(Message* msg) return false; } +void Manager::dirtyRect(const gfx::Rect& bounds) +{ + m_dirtyRegion.createUnion(m_dirtyRegion, gfx::Region(bounds)); +} + /* configures the window for begin the loop */ void Manager::_openWindow(Window* window) { diff --git a/src/ui/manager.h b/src/ui/manager.h index 602b68a0c..dfce609ea 100644 --- a/src/ui/manager.h +++ b/src/ui/manager.h @@ -31,10 +31,6 @@ namespace ui { return m_defaultManager; } - static gfx::Region& getDirtyRegion() { - return m_dirtyRegion; - } - Manager(); ~Manager(); @@ -89,6 +85,8 @@ namespace ui { bool isFocusMovementKey(Message* msg); + void dirtyRect(const gfx::Rect& bounds); + void _openWindow(Window* window); void _closeWindow(Window* window, bool redraw_background); diff --git a/src/ui/move_region.cpp b/src/ui/move_region.cpp index 2763f5a5d..46b5c28cf 100644 --- a/src/ui/move_region.cpp +++ b/src/ui/move_region.cpp @@ -35,8 +35,12 @@ void move_region(Manager* manager, const Region& region, int dx, int dy) // Blit directly screen to screen. if (nrects == 1) { - Rect rc = region[0]; + gfx::Rect rc = region[0]; lock->scrollTo(rc, dx, dy); + + rc.offset(dx, dy); + Manager::getDefault()->dirtyRect(rc); + } // Blit saving areas and copy them. else if (nrects > 1) { @@ -56,11 +60,12 @@ void move_region(Manager* manager, const Region& region, int dx, int dy) } for (c=0, it=begin; it != end; ++it, ++c) { - const Rect& rc = *it; + gfx::Rect rc((*it).x+dx, (*it).y+dy, (*it).w, (*it).h); sur = images[c]; { she::ScopedSurfaceLock surlock(sur); - surlock->blitTo(lock, 0, 0, rc.x+dx, rc.y+dy, rc.w, rc.h); + surlock->blitTo(lock, 0, 0, rc.x, rc.y, rc.w, rc.h); + manager->dirtyRect(rc); } sur->dispose(); } diff --git a/src/ui/overlay.cpp b/src/ui/overlay.cpp index e7f81ab41..a5e531f6d 100644 --- a/src/ui/overlay.cpp +++ b/src/ui/overlay.cpp @@ -63,11 +63,10 @@ void Overlay::drawOverlay(she::LockedSurface* screen) she::ScopedSurfaceLock lockedSurface(m_surface); screen->drawRgbaSurface(lockedSurface, m_pos.x, m_pos.y); - Manager::getDirtyRegion().createUnion( - Manager::getDirtyRegion(), - gfx::Region(gfx::Rect(m_pos.x, m_pos.y, - m_surface->width(), - m_surface->height()))); + Manager::getDefault()->dirtyRect( + gfx::Rect(m_pos.x, m_pos.y, + m_surface->width(), + m_surface->height())); } void Overlay::moveOverlay(const gfx::Point& newPos) @@ -100,11 +99,10 @@ void Overlay::restoreOverlappedArea(she::LockedSurface* screen) lock->blitTo(screen, 0, 0, m_pos.x, m_pos.y, m_overlap->width(), m_overlap->height()); - Manager::getDirtyRegion().createUnion( - Manager::getDirtyRegion(), - gfx::Region(gfx::Rect(m_pos.x, m_pos.y, - m_overlap->width(), - m_overlap->height()))); + Manager::getDefault()->dirtyRect( + gfx::Rect(m_pos.x, m_pos.y, + m_overlap->width(), + m_overlap->height())); } }