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"
|
|
|
|
|
2018-04-19 17:44:42 +02:00
|
|
|
#include "third_party/blink/public/platform/web_cursor_info.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.
|
|
|
|
|
|
|
|
using blink::WebCursorInfo;
|
|
|
|
|
|
|
|
LPCWSTR ToCursorID(WebCursorInfo::Type type) {
|
|
|
|
switch (type) {
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypePointer:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_ARROW;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeCross:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_CROSS;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeHand:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_HAND;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeIBeam:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_IBEAM;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeWait:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_WAIT;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeHelp:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_HELP;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEWE;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENS;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENESW;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENWSE;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeSouthResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENS;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeSouthEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENWSE;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeSouthWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENESW;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEWE;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthSouthResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENS;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeEastWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEWE;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthEastSouthWestResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENESW;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthWestSouthEastResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZENWSE;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeColumnResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_COLRESIZE);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeRowResize:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ROWRESIZE);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeMiddlePanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_MIDDLE);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeEastPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_EAST);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_NORTH);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthEastPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNorthWestPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeSouthPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_SOUTH);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeSouthEastPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeSouthWestPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeWestPanning:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_PAN_WEST);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeMove:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_SIZEALL;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeVerticalText:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_VERTICALTEXT);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeCell:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_CELL);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeContextMenu:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_ARROW;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeAlias:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ALIAS);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeProgress:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_APPSTARTING;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNoDrop:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_NO;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeCopy:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_COPYCUR);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNone:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_CURSOR_NONE);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeNotAllowed:
|
2015-11-17 19:20:13 +01:00
|
|
|
return IDC_NO;
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeZoomIn:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ZOOMIN);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeZoomOut:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_ZOOMOUT);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeGrab:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_HAND_GRAB);
|
2017-04-20 21:28:17 +02:00
|
|
|
case WebCursorInfo::kTypeGrabbing:
|
2015-11-17 19:20:13 +01:00
|
|
|
return MAKEINTRESOURCE(IDC_HAND_GRABBING);
|
2017-12-07 22:44:24 +01:00
|
|
|
case WebCursorInfo::kTypeCustom:
|
|
|
|
break;
|
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
|
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
|
|
|
|
bool is_guest_view_hack) {
|
2015-11-17 19:20:13 +01:00
|
|
|
DCHECK(!window_);
|
|
|
|
window_.reset(new CefCompositorHostWin());
|
|
|
|
compositor_widget_ = window_->hwnd();
|
|
|
|
}
|
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(
|
|
|
|
const gfx::Size& size) {
|
2016-08-17 17:29:38 +02:00
|
|
|
DCHECK(window_);
|
|
|
|
SetWindowPos(window_->hwnd(), NULL, 0, 0, size.width(), size.height(),
|
2016-09-09 19:21:16 +02:00
|
|
|
SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE);
|
2016-08-17 17:29:38 +02:00
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
|
|
|
|
window_.reset(NULL);
|
|
|
|
compositor_widget_ = gfx::kNullAcceleratedWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
|
|
|
|
blink::WebCursorInfo::Type type) {
|
|
|
|
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);
|
|
|
|
}
|