Browse Source

Merge pull request #636 from AtomicGameEngine/JME-ATOMIC-WEBVIEW-FIXES

WebView Updates
JoshEngebretson 10 years ago
parent
commit
b700b9654b

+ 31 - 0
Licenses/LICENSE_THIRDPARTY.md

@@ -1109,3 +1109,34 @@ The externally maintained libraries used by Node.js are:
      * Hudson ([email protected]).
      *
      */
+     
+#### Chromium Embedded Framework
+    // Copyright (c) 2008-2014 Marshall A. Greenblatt. Portions Copyright (c)
+    // 2006-2009 Google Inc. All rights reserved.
+    //
+    // Redistribution and use in source and binary forms, with or without
+    // modification, are permitted provided that the following conditions are
+    // met:
+    //
+    //    * Redistributions of source code must retain the above copyright
+    // notice, this list of conditions and the following disclaimer.
+    //    * Redistributions in binary form must reproduce the above
+    // copyright notice, this list of conditions and the following disclaimer
+    // in the documentation and/or other materials provided with the
+    // distribution.
+    //    * Neither the name of Google Inc. nor the name Chromium Embedded
+    // Framework nor the names of its contributors may be used to endorse
+    // or promote products derived from this software without specific prior
+    // written permission.
+    //
+    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 47 - 5
Source/AtomicWebView/WebClient.cpp

@@ -31,7 +31,12 @@ namespace Atomic
 void* GetNSWindowContentView(void* window);
 #endif
 
-class WebClientPrivate : public CefClient, public CefLifeSpanHandler, public CefLoadHandler, public CefDisplayHandler, public CefRequestHandler
+class WebClientPrivate : public CefClient,
+        public CefLifeSpanHandler,
+        public CefLoadHandler,
+        public CefDisplayHandler,
+        public CefRequestHandler,
+        public CefKeyboardHandler
 {
     friend class WebClient;
 
@@ -84,6 +89,23 @@ public:
         return this;
     }
 
+    CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE
+    {
+        return this;
+    }
+
+
+    // CefKeyboardHandler
+
+    virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
+                               const CefKeyEvent& event,
+                               CefEventHandle os_event,
+                               bool* is_keyboard_shortcut) OVERRIDE
+    {
+        return false;
+    }
+
+
 
     // CefRequestHandler methods
     bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
@@ -480,7 +502,30 @@ void WebClient::SendKeyEvent(const StringHash eventType, VariantMap& eventData)
 
     host->SendKeyEvent(keyEvent);
 
+#ifdef ATOMIC_PLATFORM_WINDOWS
+
+    // RETURN KEY: We need to send both keydown and char for return key
+    // this allows it to be used both to confirm entry on popups,
+    // while also being used for text input
+    if (keyEvent.windows_key_code == 13)
+    {
+        keyEvent.type = KEYEVENT_CHAR;
+        host->SendKeyEvent(keyEvent);
+    }
+
+#endif
+
 #ifdef ATOMIC_PLATFORM_OSX
+
+    // RETURN KEY: We need to send both keydown and char for return key
+    // this allows it to be used both to confirm entry on popups,
+    // while also being used for text input
+    if (keyEvent.native_key_code == 36)
+    {
+        keyEvent.type = KEYEVENT_CHAR;
+        host->SendKeyEvent(keyEvent);
+    }
+
     // Send an empty key event on OSX, which seems to fix
     // keyboard problems on OSX with cefclient
     // ./cefclient --off-screen-rendering-enabled
@@ -490,10 +535,7 @@ void WebClient::SendKeyEvent(const StringHash eventType, VariantMap& eventData)
 
     memset((void*)&keyEvent, 0, sizeof(keyEvent));
 
-    if (eventType == "KeyDown")
-        keyEvent.type = KEYEVENT_KEYDOWN;
-    else
-        keyEvent.type = KEYEVENT_KEYUP;
+    keyEvent.type = KEYEVENT_KEYDOWN;
     keyEvent.modifiers = 0;
     keyEvent.native_key_code = 0;
     host->SendKeyEvent(keyEvent);

+ 4 - 3
Source/AtomicWebView/WebKeyboardMac.cpp

@@ -54,6 +54,8 @@ bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& event
     if (eventType == "KeyUp")
         return false;
 
+    memset((void*)&keyEvent, 0, sizeof(keyEvent));
+
     WebKeyEvent wk(eventType, eventData);
 
     if (wk.scanCode == SDL_SCANCODE_RETURN)
@@ -62,7 +64,7 @@ bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& event
             return false;
 
         keyEvent.native_key_code = 36;
-        keyEvent.type = KEYEVENT_CHAR;
+        keyEvent.type = KEYEVENT_RAWKEYDOWN;
         return true;
     }
 
@@ -80,12 +82,11 @@ bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& event
     if (superdown)
         keyEvent.modifiers |= EVENTFLAG_COMMAND_DOWN;
 
-
     int darwinScanCode;
     if (SDLScanCodeToDarwinScanCode((SDL_Scancode) wk.scanCode, darwinScanCode))
     {
         keyEvent.native_key_code = darwinScanCode;
-        keyEvent.type = wk.keyDown ? KEYEVENT_KEYDOWN : KEYEVENT_KEYUP;
+        keyEvent.type = wk.keyDown ? KEYEVENT_RAWKEYDOWN : KEYEVENT_KEYUP;
         return true;
     }
 

+ 1 - 1
Source/AtomicWebView/WebKeyboardWindows.cpp

@@ -86,7 +86,7 @@ bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& event
 
         keyEvent.windows_key_code = VK_RETURN;
         keyEvent.native_key_code = (int) 0;
-        keyEvent.type = KEYEVENT_CHAR;
+        keyEvent.type = KEYEVENT_RAWKEYDOWN;
         return true;
     }