mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-16 20:20:51 +01:00
Add CefBrowserHost::SetMouseCursorChangeDisabled() method for disabling mouse cursor changes (issue #884).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1178 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
f70030adab
commit
0343aa5236
@ -313,6 +313,18 @@ typedef struct _cef_browser_host_t {
|
||||
void (CEF_CALLBACK *start_download)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* url);
|
||||
|
||||
///
|
||||
// Set whether mouse cursor change is disabled.
|
||||
///
|
||||
void (CEF_CALLBACK *set_mouse_cursor_change_disabled)(
|
||||
struct _cef_browser_host_t* self, int disabled);
|
||||
|
||||
///
|
||||
// Returns true (1) if mouse cursor change is disabled.
|
||||
///
|
||||
int (CEF_CALLBACK *is_mouse_cursor_change_disabled)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if window rendering is disabled.
|
||||
///
|
||||
|
@ -353,6 +353,18 @@ class CefBrowserHost : public virtual CefBase {
|
||||
/*--cef()--*/
|
||||
virtual void StartDownload(const CefString& url) =0;
|
||||
|
||||
///
|
||||
// Set whether mouse cursor change is disabled.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetMouseCursorChangeDisabled(bool disabled) =0;
|
||||
|
||||
///
|
||||
// Returns true if mouse cursor change is disabled.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsMouseCursorChangeDisabled() =0;
|
||||
|
||||
///
|
||||
// Returns true if window rendering is disabled.
|
||||
///
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "base/command_line.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/download_url_parameters.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
@ -607,6 +608,16 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
|
||||
manager->DownloadUrl(params.Pass());
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
mouse_cursor_change_disabled_ = disabled;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::IsMouseCursorChangeDisabled() {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
return mouse_cursor_change_disabled_;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::IsWindowRenderingDisabled() {
|
||||
return IsWindowRenderingDisabled(window_info_);
|
||||
}
|
||||
@ -1835,6 +1846,11 @@ void CefBrowserHostImpl::PluginCrashed(const base::FilePath& plugin_path,
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
|
||||
// Handle the cursor message here if mouse cursor change is disabled instead
|
||||
// of propegating the message to the normal handler.
|
||||
if (message.type() == ViewHostMsg_SetCursor::ID)
|
||||
return IsMouseCursorChangeDisabled();
|
||||
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(CefBrowserHostImpl, message)
|
||||
IPC_MESSAGE_HANDLER(CefHostMsg_FrameIdentified, OnFrameIdentified)
|
||||
@ -2010,6 +2026,7 @@ CefBrowserHostImpl::CefBrowserHostImpl(
|
||||
window_destroyed_(false),
|
||||
is_in_onsetfocus_(false),
|
||||
focus_on_editable_field_(false),
|
||||
mouse_cursor_change_disabled_(false),
|
||||
file_chooser_pending_(false) {
|
||||
DCHECK(!browser_info_->browser().get());
|
||||
browser_info_->set_browser(this);
|
||||
|
@ -125,6 +125,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const std::vector<CefString>& accept_types,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) OVERRIDE;
|
||||
virtual void StartDownload(const CefString& url) OVERRIDE;
|
||||
virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE;
|
||||
virtual bool IsMouseCursorChangeDisabled() OVERRIDE;
|
||||
virtual bool IsWindowRenderingDisabled() OVERRIDE;
|
||||
virtual void WasResized() OVERRIDE;
|
||||
virtual void Invalidate(const CefRect& dirtyRect,
|
||||
@ -510,6 +512,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// accessed on the UI thread.
|
||||
bool focus_on_editable_field_;
|
||||
|
||||
// True if mouse cursor change is disabled.
|
||||
bool mouse_cursor_change_disabled_;
|
||||
|
||||
// Used for managing notification subscriptions.
|
||||
scoped_ptr<content::NotificationRegistrar> registrar_;
|
||||
|
||||
|
@ -281,6 +281,34 @@ void CEF_CALLBACK browser_host_start_download(struct _cef_browser_host_t* self,
|
||||
CefString(url));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_host_set_mouse_cursor_change_disabled(
|
||||
struct _cef_browser_host_t* self, int disabled) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefBrowserHostCppToC::Get(self)->SetMouseCursorChangeDisabled(
|
||||
disabled?true:false);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK browser_host_is_mouse_cursor_change_disabled(
|
||||
struct _cef_browser_host_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefBrowserHostCppToC::Get(self)->IsMouseCursorChangeDisabled();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK browser_host_is_window_rendering_disabled(
|
||||
struct _cef_browser_host_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -469,6 +497,10 @@ CefBrowserHostCppToC::CefBrowserHostCppToC(CefBrowserHost* cls)
|
||||
struct_.struct_.set_zoom_level = browser_host_set_zoom_level;
|
||||
struct_.struct_.run_file_dialog = browser_host_run_file_dialog;
|
||||
struct_.struct_.start_download = browser_host_start_download;
|
||||
struct_.struct_.set_mouse_cursor_change_disabled =
|
||||
browser_host_set_mouse_cursor_change_disabled;
|
||||
struct_.struct_.is_mouse_cursor_change_disabled =
|
||||
browser_host_is_mouse_cursor_change_disabled;
|
||||
struct_.struct_.is_window_rendering_disabled =
|
||||
browser_host_is_window_rendering_disabled;
|
||||
struct_.struct_.was_resized = browser_host_was_resized;
|
||||
|
@ -232,6 +232,30 @@ void CefBrowserHostCToCpp::StartDownload(const CefString& url) {
|
||||
url.GetStruct());
|
||||
}
|
||||
|
||||
void CefBrowserHostCToCpp::SetMouseCursorChangeDisabled(bool disabled) {
|
||||
if (CEF_MEMBER_MISSING(struct_, set_mouse_cursor_change_disabled))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
struct_->set_mouse_cursor_change_disabled(struct_,
|
||||
disabled);
|
||||
}
|
||||
|
||||
bool CefBrowserHostCToCpp::IsMouseCursorChangeDisabled() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_mouse_cursor_change_disabled))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_mouse_cursor_change_disabled(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefBrowserHostCToCpp::IsWindowRenderingDisabled() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_window_rendering_disabled))
|
||||
return false;
|
||||
|
@ -52,6 +52,8 @@ class CefBrowserHostCToCpp
|
||||
const std::vector<CefString>& accept_types,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) OVERRIDE;
|
||||
virtual void StartDownload(const CefString& url) OVERRIDE;
|
||||
virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE;
|
||||
virtual bool IsMouseCursorChangeDisabled() OVERRIDE;
|
||||
virtual bool IsWindowRenderingDisabled() OVERRIDE;
|
||||
virtual void WasResized() OVERRIDE;
|
||||
virtual void Invalidate(const CefRect& dirtyRect,
|
||||
|
@ -110,6 +110,9 @@ ClientHandler::ClientHandler()
|
||||
m_bExternalDevTools =
|
||||
command_line->HasSwitch(cefclient::kExternalDevTools) ||
|
||||
AppIsOffScreenRenderingEnabled();
|
||||
|
||||
m_bMouseCursorChangeDisabled =
|
||||
command_line->HasSwitch(cefclient::kMouseCursorChangeDisabled);
|
||||
}
|
||||
|
||||
ClientHandler::~ClientHandler() {
|
||||
@ -304,6 +307,10 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Disable mouse cursor change if requested via the command-line flag.
|
||||
if (m_bMouseCursorChangeDisabled)
|
||||
browser->GetHost()->SetMouseCursorChangeDisabled(true);
|
||||
|
||||
AutoLock lock_scope(this);
|
||||
if (!m_Browser.get()) {
|
||||
// We need to keep the main child window, but not popup windows
|
||||
|
@ -325,6 +325,9 @@ class ClientHandler : public CefClient,
|
||||
// The startup URL.
|
||||
std::string m_StartupURL;
|
||||
|
||||
// True if mouse cursor change is disabled.
|
||||
bool m_bMouseCursorChangeDisabled;
|
||||
|
||||
// Number of currently existing browser windows. The application will exit
|
||||
// when the number of windows reaches 0.
|
||||
static int m_BrowserCount;
|
||||
|
@ -24,5 +24,6 @@ const char kUrl[] = "url";
|
||||
const char kExternalDevTools[] = "external-devtools";
|
||||
const char kOffScreenRenderingEnabled[] = "off-screen-rendering-enabled";
|
||||
const char kTransparentPaintingEnabled[] = "transparent-painting-enabled";
|
||||
const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled";
|
||||
|
||||
} // namespace cefclient
|
||||
|
@ -16,6 +16,7 @@ extern const char kUrl[];
|
||||
extern const char kExternalDevTools[];
|
||||
extern const char kOffScreenRenderingEnabled[];
|
||||
extern const char kTransparentPaintingEnabled[];
|
||||
extern const char kMouseCursorChangeDisabled[];
|
||||
|
||||
} // namespace cefclient
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user