2015-11-17 19:20:13 +01:00
|
|
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/osr/render_widget_host_view_osr.h"
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "libcef/browser/browser_host_impl.h"
|
|
|
|
#include "libcef/browser/content_browser_client.h"
|
|
|
|
|
2016-07-14 03:35:07 +02:00
|
|
|
#include "ui/resources/grit/ui_unscaled_resources.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class CefCompositorHostWin : public gfx::WindowImpl {
|
|
|
|
public:
|
|
|
|
CefCompositorHostWin() {
|
|
|
|
// Create a hidden 1x1 borderless window.
|
|
|
|
set_window_style(WS_POPUP | WS_SYSMENU);
|
|
|
|
Init(NULL, gfx::Rect(0, 0, 1, 1));
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
~CefCompositorHostWin() override { DestroyWindow(hwnd()); }
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
private:
|
2018-05-14 13:24:05 +02:00
|
|
|
CR_BEGIN_MSG_MAP_EX(CefCompositorHostWin)
|
2015-11-17 19:20:13 +01:00
|
|
|
CR_MSG_WM_PAINT(OnPaint)
|
|
|
|
CR_END_MSG_MAP()
|
|
|
|
|
2018-05-14 13:24:05 +02:00
|
|
|
CR_MSG_MAP_CLASS_DECLARATIONS(CefCompositorHostWin)
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void OnPaint(HDC dc) { ValidateRect(hwnd(), NULL); }
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefCompositorHostWin);
|
|
|
|
};
|
|
|
|
|
|
|
|
// From content/common/cursors/webcursor_win.cc.
|
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
LPCWSTR ToCursorID(ui::mojom::CursorType type) {
|
2015-11-17 19:20:13 +01:00
|
|
|
switch (type) {
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kPointer:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_ARROW;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kCross:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_CROSS;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kHand:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_HAND;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kIBeam:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_IBEAM;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kWait:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_WAIT;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kHelp:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_HELP;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEWE;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENS;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENESW;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENWSE;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kSouthResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENS;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kSouthEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENWSE;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kSouthWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENESW;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEWE;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthSouthResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENS;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kEastWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEWE;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthEastSouthWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENESW;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthWestSouthEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENWSE;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kColumnResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_COLRESIZE);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kRowResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ROWRESIZE);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kMiddlePanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_MIDDLE);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kEastPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_EAST);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_NORTH);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthEastPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNorthWestPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kSouthPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_SOUTH);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kSouthEastPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kSouthWestPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kWestPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_WEST);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kMove:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEALL;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kVerticalText:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_VERTICALTEXT);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kCell:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_CELL);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kAlias:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ALIAS);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kProgress:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_APPSTARTING;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNoDrop:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_NO;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kCopy:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_COPYCUR);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNotAllowed:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_NO;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kZoomIn:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ZOOMIN);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kZoomOut:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ZOOMOUT);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kGrab:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_HAND_GRAB);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kGrabbing:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_HAND_GRABBING);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kNull:
|
2019-09-04 17:13:32 +02:00
|
|
|
return IDC_NO;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kMiddlePanningVertical:
|
2019-09-04 17:13:32 +02:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_MIDDLE_VERTICAL);
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kMiddlePanningHorizontal:
|
2019-09-04 17:13:32 +02:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_MIDDLE_HORIZONTAL);
|
|
|
|
// TODO(cef): Find better cursors for these things
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kDndNone:
|
2019-09-04 17:13:32 +02:00
|
|
|
return IDC_ARROW;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kDndMove:
|
2019-09-04 17:13:32 +02:00
|
|
|
return IDC_ARROW;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kDndCopy:
|
2019-09-04 17:13:32 +02:00
|
|
|
return IDC_ARROW;
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kDndLink:
|
2019-09-04 17:13:32 +02:00
|
|
|
return IDC_ARROW;
|
2020-06-09 19:48:00 +02:00
|
|
|
case ui::mojom::CursorType::kContextMenu:
|
2020-03-30 22:13:42 +02:00
|
|
|
case ui::mojom::CursorType::kCustom:
|
2020-06-09 19:48:00 +02:00
|
|
|
case ui::mojom::CursorType::kNone:
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
return IDC_ARROW;
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
NOTREACHED();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsSystemCursorID(LPCWSTR cursor_id) {
|
|
|
|
return cursor_id >= IDC_ARROW; // See WinUser.h
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
|
2020-03-30 22:13:42 +02:00
|
|
|
ui::mojom::CursorType type) {
|
2020-06-09 19:48:00 +02:00
|
|
|
// 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 (type == ui::mojom::CursorType::kNone) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
HMODULE module_handle = NULL;
|
|
|
|
const wchar_t* cursor_id = ToCursorID(type);
|
|
|
|
if (!IsSystemCursorID(cursor_id)) {
|
2017-05-17 11:29:28 +02:00
|
|
|
module_handle =
|
|
|
|
::GetModuleHandle(CefContentBrowserClient::Get()->GetResourceDllName());
|
2015-11-17 19:20:13 +01:00
|
|
|
if (!module_handle)
|
|
|
|
module_handle = ::GetModuleHandle(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return LoadCursor(module_handle, cursor_id);
|
|
|
|
}
|