Commit 379274b0 authored by jchen10's avatar jchen10 Committed by Commit Bot

Remove hidden cursor from screen

Currently ui/resources/cursors/none.cur is used to hide the cursor,
which is a dark 1x1 bit bmp. This may cause DWM to do composition
with the underlay video at very frame. To solve it, the hidden
cursor should be further removed from the screen.

Bug: 1069698
Change-Id: I4122a7a2085dbde5a78053e69f29f988a1b20de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145234Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Cr-Commit-Position: refs/heads/master@{#759481}
parent cbd7326b
......@@ -109,10 +109,9 @@ const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) {
return MAKEINTRESOURCE(IDC_COPYCUR);
case mojom::CursorType::kAlias:
return MAKEINTRESOURCE(IDC_ALIAS);
case mojom::CursorType::kNone:
return MAKEINTRESOURCE(IDC_CURSOR_NONE);
case mojom::CursorType::kContextMenu:
case mojom::CursorType::kCustom:
case mojom::CursorType::kNone:
NOTIMPLEMENTED();
return IDC_ARROW;
default:
......@@ -151,19 +150,28 @@ void CursorLoaderWin::UnloadAll() {
}
void CursorLoaderWin::SetPlatformCursor(gfx::NativeCursor* cursor) {
if (cursor->type() != mojom::CursorType::kCustom) {
if (cursor->platform()) {
cursor->SetPlatformCursor(cursor->platform());
} else {
const wchar_t* cursor_id = GetCursorId(*cursor);
PlatformCursor platform_cursor = LoadCursor(NULL, cursor_id);
if (!platform_cursor && !g_cursor_resource_module_name.Get().empty()) {
platform_cursor = LoadCursor(
GetModuleHandle(g_cursor_resource_module_name.Get().c_str()),
cursor_id);
}
cursor->SetPlatformCursor(platform_cursor);
if (cursor->type() == mojom::CursorType::kCustom)
return;
// Using a dark 1x1 bit bmp kNone cursor may still cause DWM to do composition
// work unnecessarily. Better to totally remove it from the screen.
// crbug.com/1069698
if (cursor->type() == mojom::CursorType::kNone) {
cursor->SetPlatformCursor(nullptr);
return;
}
if (cursor->platform()) {
cursor->SetPlatformCursor(cursor->platform());
} else {
const wchar_t* cursor_id = GetCursorId(*cursor);
PlatformCursor platform_cursor = LoadCursor(nullptr, cursor_id);
if (!platform_cursor && !g_cursor_resource_module_name.Get().empty()) {
platform_cursor = LoadCursor(
GetModuleHandle(g_cursor_resource_module_name.Get().c_str()),
cursor_id);
}
cursor->SetPlatformCursor(platform_cursor);
}
}
......
......@@ -13,7 +13,6 @@
<include name="IDC_CELL" file="cursors/cell.cur" type="CURSOR" />
<include name="IDC_COLRESIZE" file="cursors/col_resize.cur" type="CURSOR" />
<include name="IDC_COPYCUR" file="cursors/copy.cur" type="CURSOR" />
<include name="IDC_CURSOR_NONE" file="cursors/none.cur" type="CURSOR" />
<include name="IDC_HAND_GRAB" file="cursors/hand_grab.cur" type="CURSOR" />
<include name="IDC_HAND_GRABBING" file="cursors/hand_grabbing.cur" type="CURSOR" />
<include name="IDC_PAN_EAST" file="cursors/pan_east.cur" type="CURSOR" />
......
......@@ -403,7 +403,6 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate,
use_system_default_icon_(false),
restored_enabled_(false),
current_cursor_(nullptr),
previous_cursor_(nullptr),
dpi_(0),
called_enable_non_client_dpi_scaling_(false),
active_mouse_tracking_flags_(0),
......@@ -864,15 +863,9 @@ bool HWNDMessageHandler::SetTitle(const base::string16& title) {
}
void HWNDMessageHandler::SetCursor(HCURSOR cursor) {
TRACE_EVENT2("ui,input", "HWNDMessageHandler::SetCursor", "cursor", cursor,
"previous_cursor", previous_cursor_);
if (cursor) {
previous_cursor_ = ::SetCursor(cursor);
current_cursor_ = cursor;
} else if (previous_cursor_) {
::SetCursor(previous_cursor_);
previous_cursor_ = nullptr;
}
TRACE_EVENT1("ui,input", "HWNDMessageHandler::SetCursor", "cursor", cursor);
::SetCursor(cursor);
current_cursor_ = cursor;
}
void HWNDMessageHandler::FrameTypeChanged() {
......
......@@ -625,10 +625,6 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
// The current cursor.
HCURSOR current_cursor_;
// The last cursor that was active before the current one was selected. Saved
// so that we can restore it.
HCURSOR previous_cursor_;
// The icon created from the bitmap image of the window icon.
base::win::ScopedHICON window_icon_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment