Introduced the cursor-changed event with one parameter - the name of the cursor type

This commit is contained in:
Heilig Benedek 2016-01-30 06:33:55 +01:00
parent e22cb0ca9f
commit 0c9174bc7c
5 changed files with 194 additions and 0 deletions

View file

@ -56,9 +56,12 @@
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/base/l10n/l10n_util.h"
#include "mw/cursor/cursor_event_filter.h"
#include "atom/common/node_includes.h"
#include <iostream>
namespace {
struct PrintSettings {
@ -619,6 +622,8 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
OnRendererMessageSync)
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
handled = false)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@ -1039,6 +1044,10 @@ void WebContents::EndFrameSubscription() {
view->EndFrameSubscription();
}
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
Emit("cursor-changed", CursorChangeEvent::toString(cursor));
}
void WebContents::SetSize(const SetSizeParams& params) {
if (guest_delegate_)
guest_delegate_->SetSize(params);

View file

@ -14,6 +14,7 @@
#include "atom/browser/common_web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/favicon_url.h"
#include "content/common/cursors/webcursor.h"
#include "native_mate/handle.h"
#include "ui/gfx/image/image.h"
@ -255,6 +256,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
return ++request_id_;
}
void OnCursorChange(const content::WebCursor& cursor);
// Called when received a message from renderer.
void OnRendererMessage(const base::string16& channel,
const base::ListValue& args);

View file

@ -371,6 +371,8 @@
'atom/renderer/node_array_buffer_bridge.h',
'atom/utility/atom_content_utility_client.cc',
'atom/utility/atom_content_utility_client.h',
'mw/cursor/cursor_event_filter.cc',
'mw/cursor/cursor_event_filter.h',
'chromium_src/chrome/browser/browser_process.cc',
'chromium_src/chrome/browser/browser_process.h',
'chromium_src/chrome/browser/chrome_process_finder_win.cc',

View file

@ -0,0 +1,150 @@
#include "mw/cursor/cursor_event_filter.h"
#include "content/common/view_messages.h"
namespace atom {
std::string CursorChangeEvent::toString(
const content::WebCursor& cursor) {
content::WebCursor::CursorInfo* info = new content::WebCursor::CursorInfo();
cursor.GetCursorInfo(info);
switch(info->type){
case blink::WebCursorInfo::Type::TypePointer:
return "Pointer";
break;
case blink::WebCursorInfo::Type::TypeCross:
return "Cross";
break;
case blink::WebCursorInfo::Type::TypeHand:
return "Hand";
break;
case blink::WebCursorInfo::Type::TypeIBeam:
return "IBeam";
break;
case blink::WebCursorInfo::Type::TypeWait:
return "Wait";
break;
case blink::WebCursorInfo::Type::TypeHelp:
return "Help";
break;
case blink::WebCursorInfo::Type::TypeEastResize:
return "EastResize";
break;
case blink::WebCursorInfo::Type::TypeNorthResize:
return "NorthResize";
break;
case blink::WebCursorInfo::Type::TypeNorthEastResize:
return "NorthEastResize";
break;
case blink::WebCursorInfo::Type::TypeNorthWestResize:
return "NorthWestResize";
break;
case blink::WebCursorInfo::Type::TypeSouthResize:
return "SouthResize";
break;
case blink::WebCursorInfo::Type::TypeSouthEastResize:
return "SouthEastResize";
break;
case blink::WebCursorInfo::Type::TypeSouthWestResize:
return "SouthWestResize";
break;
case blink::WebCursorInfo::Type::TypeWestResize:
return "WestResize";
break;
case blink::WebCursorInfo::Type::TypeNorthSouthResize:
return "NorthSouthResize";
break;
case blink::WebCursorInfo::Type::TypeEastWestResize:
return "EastWestResize";
break;
case blink::WebCursorInfo::Type::TypeNorthEastSouthWestResize:
return "NorthEastSouthWestResize";
break;
case blink::WebCursorInfo::Type::TypeNorthWestSouthEastResize:
return "NorthWestSouthEastResize";
break;
case blink::WebCursorInfo::Type::TypeColumnResize:
return "ColumnResize";
break;
case blink::WebCursorInfo::Type::TypeRowResize:
return "RowResize";
break;
case blink::WebCursorInfo::Type::TypeMiddlePanning:
return "MiddlePanning";
break;
case blink::WebCursorInfo::Type::TypeEastPanning:
return "EastPanning";
break;
case blink::WebCursorInfo::Type::TypeNorthPanning:
return "NorthPanning";
break;
case blink::WebCursorInfo::Type::TypeNorthEastPanning:
return "NorthEastPanning";
break;
case blink::WebCursorInfo::Type::TypeNorthWestPanning:
return "NorthWestPanning";
break;
case blink::WebCursorInfo::Type::TypeSouthPanning:
return "SouthPanning";
break;
case blink::WebCursorInfo::Type::TypeSouthEastPanning:
return "SouthEastPanning";
break;
case blink::WebCursorInfo::Type::TypeSouthWestPanning:
return "SouthWestPanning";
break;
case blink::WebCursorInfo::Type::TypeWestPanning:
return "WestPanning";
break;
case blink::WebCursorInfo::Type::TypeMove:
return "Move";
break;
case blink::WebCursorInfo::Type::TypeVerticalText:
return "VerticalText";
break;
case blink::WebCursorInfo::Type::TypeCell:
return "Cell";
break;
case blink::WebCursorInfo::Type::TypeContextMenu:
return "ContextMenu";
break;
case blink::WebCursorInfo::Type::TypeAlias:
return "Alias";
break;
case blink::WebCursorInfo::Type::TypeProgress:
return "Progress";
break;
case blink::WebCursorInfo::Type::TypeNoDrop:
return "NoDrop";
break;
case blink::WebCursorInfo::Type::TypeCopy:
return "Copy";
break;
case blink::WebCursorInfo::Type::TypeNone:
return "None";
break;
case blink::WebCursorInfo::Type::TypeNotAllowed:
return "NotAllowed";
break;
case blink::WebCursorInfo::Type::TypeZoomIn:
return "ZoomIn";
break;
case blink::WebCursorInfo::Type::TypeZoomOut:
return "ZoomOut";
break;
case blink::WebCursorInfo::Type::TypeGrab:
return "Grab";
break;
case blink::WebCursorInfo::Type::TypeGrabbing:
return "Grabbing";
break;
case blink::WebCursorInfo::Type::TypeCustom:
return "Custom";
break;
default:
return "Pointer";
break;
}
}
}

View file

@ -0,0 +1,30 @@
#ifndef MW_CURSOR_EVENT_H_
#define MW_CURSOR_EVENT_H_
#include "content/common/cursors/webcursor.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_HANDLER_CODE(msg_class, member_func, code) \
IPC_MESSAGE_FORWARD_CODE(msg_class, this, \
_IpcMessageHandlerClass::member_func, code)
#define IPC_MESSAGE_FORWARD_CODE(msg_class, obj, member_func, code) \
case msg_class::ID: { \
TRACK_RUN_IN_THIS_SCOPED_REGION(member_func); \
if (!msg_class::Dispatch(&ipc_message__, obj, this, param__, \
&member_func)) \
ipc_message__.set_dispatch_error(); \
code; \
} \
break;
namespace atom {
class CursorChangeEvent {
public:
static std::string toString(const content::WebCursor& cursor);
};
}
#endif // MW_CURSOR_EVENT_H_