diff options
author | joel@chromium.org <joel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 02:18:46 +0000 |
---|---|---|
committer | joel@chromium.org <joel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 02:18:46 +0000 |
commit | 39cd64ed4d4cf04df49c1f64e40019e9675dbba7 (patch) | |
tree | 4258eab76322704e8e93a24942800dc54a466f7d /chrome/common | |
parent | 137af626220af4ea63c89ffd23116d468b9bcec6 (diff) | |
download | chromium_src-39cd64ed4d4cf04df49c1f64e40019e9675dbba7.zip chromium_src-39cd64ed4d4cf04df49c1f64e40019e9675dbba7.tar.gz chromium_src-39cd64ed4d4cf04df49c1f64e40019e9675dbba7.tar.bz2 |
linux: Use gtk-cursor-blink from GtkSettings to set the caret blink interval
BUG=20772
TEST=Open gnome-keyboard-properties. Un-set the "Cursor Blinking" checkbox. Open a new tab in chromium and the cursor should not blink. Do the same with the slider, and the rate of blinking should vary.
Review URL: http://codereview.chromium.org/398003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/gtk_util.cc | 17 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 4 | ||||
-rw-r--r-- | chrome/common/renderer_preferences.h | 8 |
3 files changed, 28 insertions, 1 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index d989750..907f9b9 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -467,11 +467,19 @@ GtkWidget* IndentWidget(GtkWidget* content) { void UpdateGtkFontSettings(RendererPreferences* prefs) { DCHECK(prefs); + // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is + // the default value for gtk-cursor-blink-time. + static const gint kGtkDefaultCursorBlinkTime = 1200; + + gint cursor_blink_time = kGtkDefaultCursorBlinkTime; + gboolean cursor_blink = TRUE; gint antialias = 0; gint hinting = 0; gchar* hint_style = NULL; gchar* rgba_style = NULL; g_object_get(gtk_settings_get_default(), + "gtk-cursor-blink-time", &cursor_blink_time, + "gtk-cursor-blink", &cursor_blink, "gtk-xft-antialias", &antialias, "gtk-xft-hinting", &hinting, "gtk-xft-hintstyle", &hint_style, @@ -484,6 +492,15 @@ void UpdateGtkFontSettings(RendererPreferences* prefs) { prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; + if (cursor_blink) { + // Dividing by 2*1000ms follows the WebKit GTK port and makes the blink + // frequency appear similar to the omnibox. Without this the blink is too + // slow. + prefs->caret_blink_interval = cursor_blink_time / 2000.; + } else { + prefs->caret_blink_interval = 0; + } + // g_object_get() doesn't tell us whether the properties were present or not, // but if they aren't (because gnome-settings-daemon isn't running), we'll get // NULL values for the strings. diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index b50b0d1..ed99e66 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -1627,6 +1627,7 @@ struct ParamTraits<RendererPreferences> { WriteParam(m, p.inactive_selection_bg_color); WriteParam(m, p.inactive_selection_fg_color); WriteParam(m, p.browser_handles_top_level_requests); + WriteParam(m, p.caret_blink_interval); } static bool Read(const Message* m, void** iter, param_type* p) { if (!ReadParam(m, iter, &p->can_accept_load_drops)) @@ -1673,6 +1674,9 @@ struct ParamTraits<RendererPreferences> { if (!ReadParam(m, iter, &p->browser_handles_top_level_requests)) return false; + if (!ReadParam(m, iter, &p->caret_blink_interval)) + return false; + return true; } static void Log(const param_type& p, std::wstring* l) { diff --git a/chrome/common/renderer_preferences.h b/chrome/common/renderer_preferences.h index 30b267f..7a55b17 100644 --- a/chrome/common/renderer_preferences.h +++ b/chrome/common/renderer_preferences.h @@ -66,6 +66,11 @@ struct RendererPreferences { // Browser wants a look at all top level requests bool browser_handles_top_level_requests; + // Cursor blink rate in seconds. + // Currently only changed from default on Linux. Uses |gtk-cursor-blink| + // from GtkSettings. + double caret_blink_interval; + RendererPreferences() : can_accept_load_drops(true), should_antialias_text(true), @@ -80,7 +85,8 @@ struct RendererPreferences { active_selection_fg_color(0), inactive_selection_bg_color(0), inactive_selection_fg_color(0), - browser_handles_top_level_requests(false) { + browser_handles_top_level_requests(false), + caret_blink_interval(0) { } }; |