[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 28 06:28:27 UTC 2020


 vcl/unx/gtk3/gtk3gtkdata.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 99e924f3faab58076221c7be326c697cb2dcf047
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Oct 27 15:17:01 2020 +0000
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 28 07:27:50 2020 +0100

    tdf#133950 scale hotspot to sync with scaled cursors
    
    keep aspect ratio as well
    
    Change-Id: Ia3c7f84e377ebb952be0a56e9e532fb260f83459
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104840
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx
index 912bc52d116b..3182d1551f36 100644
--- a/vcl/unx/gtk3/gtk3gtkdata.cxx
+++ b/vcl/unx/gtk3/gtk3gtkdata.cxx
@@ -131,10 +131,18 @@ GdkCursor* GtkSalDisplay::getFromSvg(OUString const & name, int nXHot, int nYHot
     assert(pPixBuf && "missing image?");
     if (!pPixBuf)
         return nullptr;
+
     guint nDefaultCursorSize = gdk_display_get_default_cursor_size( m_pGdkDisplay );
-    GdkPixbuf* pScaledPixBuf = gdk_pixbuf_scale_simple(pPixBuf, nDefaultCursorSize, nDefaultCursorSize, GDK_INTERP_HYPER);
+    int nPixWidth = gdk_pixbuf_get_width(pPixBuf);
+    int nPixHeight = gdk_pixbuf_get_height(pPixBuf);
+    double fScalefactor = static_cast<double>(nDefaultCursorSize) / std::max(nPixWidth, nPixHeight);
+    GdkPixbuf* pScaledPixBuf = gdk_pixbuf_scale_simple(pPixBuf,
+                                                       nPixWidth * fScalefactor,
+                                                       nPixHeight * fScalefactor,
+                                                       GDK_INTERP_HYPER);
     g_object_unref(pPixBuf);
-    GdkCursor* pCursor = gdk_cursor_new_from_pixbuf( m_pGdkDisplay, pScaledPixBuf, nXHot, nYHot);
+    GdkCursor* pCursor = gdk_cursor_new_from_pixbuf(m_pGdkDisplay, pScaledPixBuf,
+                                                    nXHot * fScalefactor, nYHot * fScalefactor);
     return pCursor;
 }
 


More information about the Libreoffice-commits mailing list