Skip to content

Commit

Permalink
fix: honor cursor blink rate (#20046)
Browse files Browse the repository at this point in the history
* fix: honor cursor blink rate on macOS

* fix: honor cursor blink rate on Linux

* fix: honor cursor blink rate on Windows

* refactor: clean up os_win cursor blink logic

* remove unneeded include
  • Loading branch information
trop[bot] authored and zcbenz committed Sep 3, 2019
1 parent 8b6fa78 commit 8379487
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@

#if !defined(OS_MACOSX)
#include "ui/aura/window.h"
#else
#include "ui/base/cocoa/defaults_utils.h"
#endif

#if defined(OS_LINUX)
#include "ui/views/linux_ui/linux_ui.h"
#endif

#if defined(OS_LINUX) || defined(OS_WIN)
Expand Down Expand Up @@ -419,6 +425,25 @@ void WebContents::InitWithSessionAndOptions(
prefs->subpixel_rendering = params->subpixel_rendering;
#endif

// Honor the system's cursor blink rate settings
#if defined(OS_MACOSX)
base::TimeDelta interval;
if (ui::TextInsertionCaretBlinkPeriod(&interval))
prefs->caret_blink_interval = interval;
#elif defined(OS_LINUX)
views::LinuxUI* linux_ui = views::LinuxUI::instance();
if (linux_ui)
prefs->caret_blink_interval = linux_ui->GetCursorBlinkInterval();
#elif defined(OS_WIN)
const auto system_msec = ::GetCaretBlinkTime();
if (system_msec != 0) {
prefs->caret_blink_interval =
(system_msec == INFINITE)
? base::TimeDelta()
: base::TimeDelta::FromMilliseconds(system_msec);
}
#endif

// Save the preferences in C++.
new WebContentsPreferences(web_contents(), options);

Expand Down

0 comments on commit 8379487

Please sign in to comment.