Changed StringArray options to regular js objects with boolean values for better readability from the js side
This commit is contained in:
parent
dbcd0a4235
commit
b2af370249
6 changed files with 139 additions and 80 deletions
|
@ -528,10 +528,10 @@ void Window::SendKeyboardEvent(v8::Isolate* isolate, const mate::Dictionary& dat
|
|||
int keycode = 0;
|
||||
int native = 0;
|
||||
std::string type_str = "";
|
||||
std::vector<std::string> modifier_array;
|
||||
mate::Dictionary modifier_list = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
data.Get(switches::kEventType, &type_str);
|
||||
data.Get(switches::kModifiers, &modifier_array);
|
||||
data.Get(switches::kModifiers, &modifier_list);
|
||||
data.Get(switches::kKeyCode, &keycode);
|
||||
data.Get(switches::kNativeKeyCode, &native);
|
||||
|
||||
|
@ -543,28 +543,22 @@ void Window::SendKeyboardEvent(v8::Isolate* isolate, const mate::Dictionary& dat
|
|||
type = blink::WebInputEvent::Type::Char;
|
||||
}
|
||||
|
||||
for(std::vector<std::string>::iterator mod = modifier_array.begin(); mod != modifier_array.end(); ++mod) {
|
||||
if(mod->compare(event_types::kModifierIsKeyPad) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::IsKeyPad;
|
||||
}else if(mod->compare(event_types::kModifierIsAutoRepeat) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::IsAutoRepeat;
|
||||
}else if(mod->compare(event_types::kModifierIsLeft) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::IsLeft;
|
||||
}else if(mod->compare(event_types::kModifierIsRight) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::IsRight;
|
||||
}else if(mod->compare(event_types::kModifierShiftKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::ShiftKey;
|
||||
}else if(mod->compare(event_types::kModifierControlKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::ControlKey;
|
||||
}else if(mod->compare(event_types::kModifierAltKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::AltKey;
|
||||
}else if(mod->compare(event_types::kModifierMetaKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::MetaKey;
|
||||
}else if(mod->compare(event_types::kModifierCapsLockOn) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::CapsLockOn;
|
||||
}else if(mod->compare(event_types::kModifierNumLockOn) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::NumLockOn;
|
||||
}
|
||||
std::map<std::string, bool> modifier_types;
|
||||
modifier_types[event_types::kModifierIsKeyPad] = false;
|
||||
modifier_types[event_types::kModifierIsAutoRepeat] = false;
|
||||
modifier_types[event_types::kModifierIsLeft] = false;
|
||||
modifier_types[event_types::kModifierIsRight] = false;
|
||||
modifier_types[event_types::kModifierShiftKey] = false;
|
||||
modifier_types[event_types::kModifierControlKey] = false;
|
||||
modifier_types[event_types::kModifierAltKey] = false;
|
||||
modifier_types[event_types::kModifierMetaKey] = false;
|
||||
modifier_types[event_types::kModifierCapsLockOn] = false;
|
||||
modifier_types[event_types::kModifierNumLockOn] = false;
|
||||
|
||||
for(std::map<std::string, bool>::iterator it = modifier_types.begin(); it != modifier_types.end(); ++it){
|
||||
modifier_list.Get(it->first,&(it->second));
|
||||
|
||||
if(it->second) modifiers = modifiers & event_types::modifierStrToWebModifier(it->first);
|
||||
}
|
||||
|
||||
window_->SendKeyboardEvent(type, modifiers, keycode, native);
|
||||
|
@ -574,7 +568,7 @@ void Window::SendMouseEvent(v8::Isolate* isolate, const mate::Dictionary& data){
|
|||
int x, y, movementX, movementY, clickCount;
|
||||
std::string type_str = "";
|
||||
std::string button_str = "";
|
||||
std::vector<std::string> modifier_array;
|
||||
mate::Dictionary modifier_list = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
blink::WebInputEvent::Type type = blink::WebInputEvent::Type::MouseMove;
|
||||
blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::ButtonNone;
|
||||
|
@ -582,7 +576,7 @@ void Window::SendMouseEvent(v8::Isolate* isolate, const mate::Dictionary& data){
|
|||
|
||||
data.Get(switches::kEventType, &type_str);
|
||||
data.Get(switches::kMouseEventButton, &button_str);
|
||||
data.Get(switches::kModifiers, &modifier_array);
|
||||
data.Get(switches::kModifiers, &modifier_list);
|
||||
|
||||
if(type_str.compare(event_types::kMouseDown) == 0){
|
||||
type = blink::WebInputEvent::Type::MouseDown;
|
||||
|
@ -600,37 +594,24 @@ void Window::SendMouseEvent(v8::Isolate* isolate, const mate::Dictionary& data){
|
|||
type = blink::WebInputEvent::Type::MouseWheel;
|
||||
}
|
||||
|
||||
if(button_str.compare(event_types::kMouseLeftButton) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::LeftButtonDown;
|
||||
button = blink::WebMouseEvent::Button::ButtonLeft;
|
||||
}else if(button_str.compare(event_types::kMouseRightButton) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::RightButtonDown;
|
||||
button = blink::WebMouseEvent::Button::ButtonRight;
|
||||
}else if(button_str.compare(event_types::kMouseMiddleButton) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::MiddleButtonDown;
|
||||
button = blink::WebMouseEvent::Button::ButtonMiddle;
|
||||
}
|
||||
std::map<std::string, bool> modifier_types;
|
||||
modifier_types[event_types::kMouseLeftButton] = false;
|
||||
modifier_types[event_types::kMouseRightButton] = false;
|
||||
modifier_types[event_types::kMouseMiddleButton] = false;
|
||||
modifier_types[event_types::kModifierLeftButtonDown] = false;
|
||||
modifier_types[event_types::kModifierMiddleButtonDown] = false;
|
||||
modifier_types[event_types::kModifierRightButtonDown] = false;
|
||||
modifier_types[event_types::kModifierShiftKey] = false;
|
||||
modifier_types[event_types::kModifierControlKey] = false;
|
||||
modifier_types[event_types::kModifierAltKey] = false;
|
||||
modifier_types[event_types::kModifierMetaKey] = false;
|
||||
modifier_types[event_types::kModifierCapsLockOn] = false;
|
||||
modifier_types[event_types::kModifierNumLockOn] = false;
|
||||
|
||||
for(std::vector<std::string>::iterator mod = modifier_array.begin(); mod != modifier_array.end(); ++mod) {
|
||||
if(mod->compare(event_types::kModifierLeftButtonDown) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::LeftButtonDown;
|
||||
}else if(mod->compare(event_types::kModifierMiddleButtonDown) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::MiddleButtonDown;
|
||||
}else if(mod->compare(event_types::kModifierRightButtonDown) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::RightButtonDown;
|
||||
}else if(mod->compare(event_types::kModifierShiftKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::ShiftKey;
|
||||
}else if(mod->compare(event_types::kModifierControlKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::ControlKey;
|
||||
}else if(mod->compare(event_types::kModifierAltKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::AltKey;
|
||||
}else if(mod->compare(event_types::kModifierMetaKey) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::MetaKey;
|
||||
}else if(mod->compare(event_types::kModifierCapsLockOn) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::CapsLockOn;
|
||||
}else if(mod->compare(event_types::kModifierNumLockOn) == 0){
|
||||
modifiers = modifiers & blink::WebInputEvent::Modifiers::NumLockOn;
|
||||
}
|
||||
for(std::map<std::string, bool>::iterator it = modifier_types.begin(); it != modifier_types.end(); ++it){
|
||||
modifier_list.Get(it->first,&(it->second));
|
||||
|
||||
if(it->second) modifiers = modifiers & event_types::modifierStrToWebModifier(it->first);
|
||||
}
|
||||
|
||||
if(type == blink::WebInputEvent::Type::MouseWheel){
|
||||
|
|
|
@ -332,6 +332,7 @@ class NativeWindow : public content::WebContentsObserver,
|
|||
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
|
||||
};
|
||||
|
||||
//This class provides a way to listen to frame renders and to use the rendered frames for offscreen rendering
|
||||
class RenderSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
||||
public:
|
||||
RenderSubscriber(gfx::Size size, base::Callback<void(bool, scoped_refptr<media::VideoFrame>)> callback) : size_(size), callback_(callback) {}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/event_types.h"
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -40,6 +41,78 @@ const char kModifierIsAutoRepeat[] = "auto-repeat";
|
|||
const char kModifierIsLeft[] = "left";
|
||||
const char kModifierIsRight[] = "right";
|
||||
|
||||
} // namespace switches
|
||||
int modifierStrToWebModifier(std::string modifier){
|
||||
if(modifier.compare(event_types::kModifierLeftButtonDown) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::LeftButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierMiddleButtonDown) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::MiddleButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierRightButtonDown) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::RightButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kMouseLeftButton) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::LeftButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kMouseRightButton) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::RightButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kMouseMiddleButton) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::MiddleButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsKeyPad) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsKeyPad;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsAutoRepeat) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsAutoRepeat;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsLeft) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsLeft;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsRight) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsRight;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierShiftKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::ShiftKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierControlKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::ControlKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierAltKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::AltKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierMetaKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::MetaKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierCapsLockOn) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::CapsLockOn;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierNumLockOn) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::NumLockOn;
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace event_types
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef ATOM_COMMON_EVENT_TYPES_H_
|
||||
#define ATOM_COMMON_EVENT_TYPES_H_
|
||||
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace event_types {
|
||||
|
@ -41,7 +43,9 @@ extern const char kModifierIsAutoRepeat[];
|
|||
extern const char kModifierIsLeft[];
|
||||
extern const char kModifierIsRight[];
|
||||
|
||||
} // namespace switches
|
||||
int modifierStrToWebModifier(std::string modifier);
|
||||
|
||||
} // namespace event_types
|
||||
|
||||
} // namespace atom
|
||||
|
||||
|
|
|
@ -759,16 +759,16 @@ Sends a mouse event to the BrowserWindow.
|
|||
* `middle` String - The middle button was pressed.
|
||||
* `click-count` Integer - The number of clicks associated with the mouse event.
|
||||
* `precise` Boolean - For the `wheel` event type, this option sets the `hasPreciseScrollingDeltas` option of the event.
|
||||
* `modifiers` Array of Strings - The modifier values associated with the event.
|
||||
* `left-button-down` String - The left mouse button was pressed.
|
||||
* `middle-button-down` String - The right mouse button was pressed.
|
||||
* `right-button-down` String - The middle mouse button was pressed.
|
||||
* `shift` String - The shift key was pressed.
|
||||
* `control` String - The control key was pressed.
|
||||
* `alt` String - The alt key was pressed.
|
||||
* `meta` String - The meta key was pressed.
|
||||
* `caps-lock` String - The caps-lock key was pressed.
|
||||
* `num-lock` String - The num-lock key was pressed.
|
||||
* `modifiers` Object - The modifier values associated with the event.
|
||||
* `left-button-down` Boolean - The left mouse button was pressed.
|
||||
* `middle-button-down` Boolean - The right mouse button was pressed.
|
||||
* `right-button-down` Boolean - The middle mouse button was pressed.
|
||||
* `shift` Boolean - The shift key was pressed.
|
||||
* `control` Boolean - The control key was pressed.
|
||||
* `alt` Boolean - The alt key was pressed.
|
||||
* `meta` Boolean - The meta key was pressed.
|
||||
* `caps-lock` Boolean - The caps-lock key was on.
|
||||
* `num-lock` Boolean - The num-lock key was on.
|
||||
|
||||
### BrowserWindow.sendKeyboardEvent(options)
|
||||
|
||||
|
@ -780,17 +780,17 @@ Sends a keyboard event to the BrowserWindow.
|
|||
* `char` String - Character event.
|
||||
* `code` Integer - The key code of the key that generated the event.
|
||||
* `native` Integer - The native key code of the key that generated the event.
|
||||
* `modifiers` Array of Strings - The modifier values associated with the event.
|
||||
* `keypad` String - Sets the `IsKeyPad` option of the event.
|
||||
* `auto-repeat` String - Sets the `IsAutoRepeat` option of the event.
|
||||
* `left` String - Sets the `IsLeft` option of the event.
|
||||
* `right` String - Sets the `IsRight` option of the event.
|
||||
* `shift` String - The shift key was pressed.
|
||||
* `control` String - The control key was pressed.
|
||||
* `alt` String - The alt key was pressed.
|
||||
* `meta` String - The meta key was pressed.
|
||||
* `caps-lock` String - The caps-lock key was pressed.
|
||||
* `num-lock` String - The num-lock key was pressed.
|
||||
* `modifiers` Object - The modifier values associated with the event.
|
||||
* `keypad` Boolean - Sets the `IsKeyPad` option of the event.
|
||||
* `auto-repeat` Boolean - Sets the `IsAutoRepeat` option of the event.
|
||||
* `left` Boolean - Sets the `IsLeft` option of the event.
|
||||
* `right` Boolean - Sets the `IsRight` option of the event.
|
||||
* `shift` Boolean - The shift key was pressed.
|
||||
* `control` Boolean - The control key was pressed.
|
||||
* `alt` Boolean - The alt key was pressed.
|
||||
* `meta` Boolean - The meta key was pressed.
|
||||
* `caps-lock` Boolean - The caps-lock key was on.
|
||||
* `num-lock` Boolean - The num-lock key was on.
|
||||
|
||||
## Class: WebContents
|
||||
|
||||
|
|
2
vendor/native_mate
vendored
2
vendor/native_mate
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 31b6395d9938558ea39a77ef2f432beaf2dcd4cb
|
||||
Subproject commit c71b1694e51fe62f646a0e92e39329d8ab569d5c
|
Loading…
Add table
Reference in a new issue