From d32d8bf9386626f1fa1b987e06d79d8af29a61df Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 31 Oct 2018 11:10:44 -0300 Subject: [PATCH] Fix color problems with overlays (fix #1914) There were two problems: 1) Overlays weren't using the screen color space, so restoring the pixels were modifying the original saved area 2) A custom cursor (when "Use native cursors" option were enabled) was using overlays, when we could use a native custom cursor anyway (without overlays) --- src/ui/overlay.cpp | 8 ++++++-- src/ui/system.cpp | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ui/overlay.cpp b/src/ui/overlay.cpp index 50b487f5e..2cc0f1788 100644 --- a/src/ui/overlay.cpp +++ b/src/ui/overlay.cpp @@ -78,8 +78,12 @@ void Overlay::captureOverlappedArea(os::Surface* screen) if (!m_surface) return; - if (!m_overlap) - m_overlap = os::instance()->createSurface(m_surface->width(), m_surface->height()); + if (!m_overlap) { + // Use the same color space for the overlay as in the screen + m_overlap = os::instance()->createSurface(m_surface->width(), + m_surface->height(), + screen->colorSpace()); + } os::SurfaceLock lock(m_overlap); screen->blitTo(m_overlap, m_pos.x, m_pos.y, 0, 0, diff --git a/src/ui/system.cpp b/src/ui/system.cpp index 470ffed37..bd40ee012 100644 --- a/src/ui/system.cpp +++ b/src/ui/system.cpp @@ -82,8 +82,7 @@ static bool update_custom_native_cursor(const Cursor* cursor) bool result = false; // Check if we can use a custom native mouse in this platform - if (!use_native_mouse_cursor && - support_native_custom_cursor && + if (support_native_custom_cursor && mouse_display) { if (cursor) { result = mouse_display->setNativeMouseCursor( @@ -167,7 +166,8 @@ static void update_mouse_cursor() } // Try to use a custom native cursor if it's possible - if (!update_custom_native_cursor(cursor)) { + if (nativeCursor == os::kNoCursor && + !update_custom_native_cursor(cursor)) { // Or an overlay as last resource update_mouse_overlay(cursor); }