From 17307a10537fbd1f04c683c2f93bf880173ce3b4 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 15 Mar 2017 17:12:04 +0100 Subject: [PATCH] tdf#105415 Use the system caret width on GTK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6b7fc9d06a49613cc6fe247b44c56f36935082fa Reviewed-on: https://gerrit.libreoffice.org/35282 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/unx/gtk/salnativewidgets-gtk.cxx | 6 ++++++ vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx index e8e8cdd81ef7..162b48535dcb 100644 --- a/vcl/unx/gtk/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx @@ -4108,6 +4108,12 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aStyleSet.SetTitleFont( aFont ); aStyleSet.SetFloatTitleFont( aFont ); + // Cursor width + gfloat caretAspectRatio = 0.04f; + gtk_widget_style_get( gWidgetData[m_nXScreen].gEditBoxWidget, "cursor-aspect-ratio", &caretAspectRatio, nullptr ); + // Assume 20px tall for the ratio computation, which should give reasonable results + aStyleSet.SetCursorSize( 20 * caretAspectRatio + 1 ); + // get cursor blink time gboolean blink = false; diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index 60f2295b5a94..83bd40d9b9d1 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -2564,6 +2564,12 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) // This baby is the default page/paper color aStyleSet.SetWindowColor( aBackFieldColor ); + // Cursor width + gfloat caretAspectRatio = 0.04f; + gtk_style_context_get_style( pCStyle, "cursor-aspect-ratio", &caretAspectRatio, nullptr ); + // Assume 20px tall for the ratio computation, which should give reasonable results + aStyleSet.SetCursorSize( 20 * caretAspectRatio + 1 ); + // Dark shadow color style_context_set_state(pCStyle, GTK_STATE_FLAG_INSENSITIVE); gtk_style_context_get_color(pCStyle, gtk_style_context_get_state(pCStyle), &color);