Implement initial native window 58/143658/2
authorYoungsoo Choi <kenshin.choi@samsung.com>
Fri, 18 Sep 2015 01:48:04 +0000 (10:48 +0900)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Mon, 21 Aug 2017 06:14:18 +0000 (15:14 +0900)
This implements initial native window.

Original CL: http://suprem.sec.samsung.net/gerrit/#/c/48867

This implements initial native webview.

Change-Id: I79283c5aff50b65c477f7f696507e42b01c947b6
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
atom/app/atom_main.cc
atom/browser/atom_browser_main_parts.cc
atom/browser/native_window.h
atom/browser/native_window_efl.cc
atom/browser/native_window_efl.h
atom/browser/ui/accelerator_util_efl.cc
efl/build/system.gyp
electron.gyp
vendor/brightray/browser/inspectable_web_contents_impl.cc
vendor/brightray/browser/inspectable_web_contents_view_efl.cc [new file with mode: 0644]
vendor/brightray/filenames.gypi

index 9c255db..c464de2 100644 (file)
 #include "atom/app/atom_library_main.h"
 #endif  // defined(OS_MACOSX)
 
+#if defined(USE_EFL)
+#include "efl/init.h"
+#endif
+
 #include "atom/app/node_main.h"
 #include "atom/common/atom_command_line.h"
 #include "base/at_exit.h"
@@ -124,6 +128,11 @@ int main(int argc, const char* argv[]) {
     return atom::NodeMain(argc, const_cast<char**>(argv));
   }
 
+#if defined(USE_EFL)
+  if (efl::Initialize(argc, argv))
+    return 1;
+#endif
+
   atom::AtomMainDelegate delegate;
   content::ContentMainParams params(&delegate);
   params.argc = argc;
index d3f8237..c5155be 100644 (file)
 #include "ui/events/devices/x11/touch_factory_x11.h"
 #endif
 
+#if defined(USE_EFL)
+#include "ui/display/screen_efl.h"
+#endif
+
+#include "atom/common/node_includes.h"
+
 namespace atom {
 
 namespace {
@@ -180,6 +186,10 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
   libgtkui::GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess());
 #endif
 
+#if defined(USE_EFL)
+  ui::InstallScreenInstance();
+#endif
+
 #if !defined(OS_MACOSX)
   // The corresponding call in macOS is in AtomApplicationDelegate.
   Browser::Get()->WillFinishLaunching();
index d3f18d8..654b68e 100644 (file)
@@ -270,9 +270,9 @@ class NativeWindow : public base::SupportsUserData,
   bool is_modal() const { return is_modal_; }
 
  protected:
-  NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
-               const mate::Dictionary& options,
-               NativeWindow* parent);
+  explicit NativeWindow(brightray::InspectableWebContents* web_contents,
+                        const mate::Dictionary& options,
+                        NativeWindow* parent);
 
   // Convert draggable regions in raw format to SkRegion format. Caller is
   // responsible for deleting the returned SkRegion instance.
index d92c00b..031d5b7 100755 (executable)
@@ -4,22 +4,63 @@
 
 #include "atom/browser/native_window_efl.h"
 
-#include "base/logging.h"
+#include <Elementary.h>
+
+#include "atom/common/options_switches.h"
+#include "base/command_line.h"
+#include "content/public/browser/web_contents.h"
+#include "efl/window_factory.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/image/image.h"
 
 namespace atom {
 
+namespace {
+
+const int kDefaultWindowWidthDip = 800;
+const int kDefaultWindowHeightDip = 600;
+
+}
+
 NativeWindowEfl::NativeWindowEfl(
-    brightray::InspectableWebContents* web_contents,
+    brightray::InspectableWebContents* inspectable_web_contents,
     const mate::Dictionary& options,
     NativeWindow* parent)
-    : NativeWindow(web_contents, options, parent) {
-}
+    : NativeWindow(inspectable_web_contents, options, parent) {
+//  options.Get(switches::kTitle, &title_);
+
+  // Create Host window via elf::WindowFactory
+  window_ = efl::WindowFactory::GetHostWindow(web_contents_);
+  DCHECK(window_);
+
+  gfx::Size size = gfx::Size(kDefaultWindowWidthDip, kDefaultWindowHeightDip);
 
-NativeWindowEfl::~NativeWindowEfl() {
+  evas_object_smart_callback_add(window_, "delete,request",
+      OnWindowDeleteRequest, this);
+
+  evas_object_resize(window_, size.width(), size.height());
+
+  // Add a new box to the parent.
+  Evas_Object* box = elm_box_add(window_);
+  evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+  evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  elm_win_resize_object_add(window_, box);
+  evas_object_show(box);
+
+  // Add view at the end of the pack list.
+  Evas_Object* view = static_cast<Evas_Object*>(web_contents_->GetNativeView());
+  evas_object_size_hint_align_set(view, EVAS_HINT_FILL, EVAS_HINT_FILL);
+  evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  elm_box_pack_end(box, view);
+
+  web_contents_->Focus();
 }
 
 void NativeWindowEfl::Close() {
-  NOTIMPLEMENTED();
+  if(window_)
+    evas_object_del(window_);
+  window_ = nullptr;
 }
 
 void NativeWindowEfl::CloseImmediately() {
@@ -36,7 +77,7 @@ bool NativeWindowEfl::IsFocused() {
 }
 
 void NativeWindowEfl::Show() {
-  NOTIMPLEMENTED();
+  evas_object_show(window_);
 }
 
 void NativeWindowEfl::ShowInactive() {
@@ -44,7 +85,7 @@ void NativeWindowEfl::ShowInactive() {
 }
 
 void NativeWindowEfl::Hide() {
-  NOTIMPLEMENTED();
+  evas_object_hide(window_);
 }
 
 bool NativeWindowEfl::IsVisible() {
@@ -58,16 +99,15 @@ bool NativeWindowEfl::IsEnabled() {
 }
 
 void NativeWindowEfl::Maximize() {
-  NOTIMPLEMENTED();
+  elm_win_maximized_set(window_, EINA_TRUE);
 }
 
 void NativeWindowEfl::Unmaximize() {
-  NOTIMPLEMENTED();
+  elm_win_maximized_set(window_, EINA_FALSE);
 }
 
 bool NativeWindowEfl::IsMaximized() {
-  NOTIMPLEMENTED();
-  return true;
+  return elm_win_maximized_get(window_);
 }
 
 void NativeWindowEfl::Minimize() {
@@ -79,26 +119,27 @@ void NativeWindowEfl::Restore() {
 }
 
 bool NativeWindowEfl::IsMinimized() {
-  NOTIMPLEMENTED();
-  return true;
+   return !elm_win_maximized_get(window_);
 }
 
 void NativeWindowEfl::SetFullScreen(bool fullscreen) {
-  NOTIMPLEMENTED();
+  elm_win_fullscreen_set(window_, fullscreen);
 }
 
 bool NativeWindowEfl::IsFullscreen() const {
-  NOTIMPLEMENTED();
-  return true;
+  return elm_win_fullscreen_get(window_);
 }
 
 void NativeWindowEfl::SetBounds(const gfx::Rect& bounds, bool animate) {
-  NOTIMPLEMENTED();
+  //evas_object_resize(window_, size.width(), size.height());
 }
 
+
 gfx::Rect NativeWindowEfl::GetBounds() {
-  NOTIMPLEMENTED();
   return gfx::Rect();
+//  int width, height;
+//  evas_object_geometry_get(window_, nullptr, nullptr, &width, &height);
+//  return gfx::Size(width, height);
 }
 
 void NativeWindowEfl::SetResizable(bool resizable) {
@@ -175,11 +216,12 @@ void NativeWindowEfl::Invalidate() {
 }
 
 void NativeWindowEfl::SetTitle(const std::string& title) {
-  NOTIMPLEMENTED();
+  title_ = title;
+  elm_win_title_set(window_, title.c_str());
 }
 
 std::string NativeWindowEfl::GetTitle() {
-  NOTIMPLEMENTED();
+  return title_;
 }
 void NativeWindowEfl::FlashFrame(bool flash) {
   NOTIMPLEMENTED();
@@ -224,8 +266,7 @@ void NativeWindowEfl::SetBrowserView(NativeBrowserView* browser_view) {
 }
 
 gfx::NativeWindow NativeWindowEfl::GetNativeWindow() {
-  NOTIMPLEMENTED();
-  return gfx::NativeWindow();
+  return window_;
 }
 
 gfx::AcceleratedWidget NativeWindowEfl::GetAcceleratedWidget() {
@@ -265,11 +306,20 @@ gfx::Rect NativeWindowEfl::WindowBoundsToContentBounds(const gfx::Rect& bounds)
 }
 
 // static
+void NativeWindowEfl::OnWindowDeleteRequest(void* data, Evas_Object*, void*) {
+  NativeWindowEfl* thiz = static_cast<NativeWindowEfl*>(data);
+  if(!elm_win_autodel_get(thiz->window_))
+    thiz->Close();
+  thiz->window_ = nullptr;
+  thiz->web_contents_->Close();
+}
+
+// static
 NativeWindow* NativeWindow::Create(
-    brightray::InspectableWebContents* inspectable_web_contents,
+    brightray::InspectableWebContents* web_contents,
     const mate::Dictionary& options,
     NativeWindow* parent) {
-  return new NativeWindowEfl(inspectable_web_contents, options, parent);
+  return new NativeWindowEfl(web_contents, options, parent);
 }
 
 }
index bd4eb26..ea2afd4 100755 (executable)
@@ -7,17 +7,24 @@
 
 #include "atom/browser/native_window.h"
 
+#include <Evas.h>
+
 #include <string>
 #include <vector>
 
+namespace content {
+
+class WebContents;
+
+} // namespace content
+
 namespace atom {
 
 class NativeWindowEfl : public NativeWindow {
  public:
-  NativeWindowEfl(brightray::InspectableWebContents* inspectable_web_contents,
-                  const mate::Dictionary& options,
-                  NativeWindow* parent);
-  virtual ~NativeWindowEfl() override;
+  explicit NativeWindowEfl(brightray::InspectableWebContents* inspectable_web_contents,
+                           const mate::Dictionary& options,
+                           NativeWindow* parent);
 
   void Close() override;
   void CloseImmediately() override;
@@ -85,6 +92,14 @@ class NativeWindowEfl : public NativeWindow {
   // Converts between content bounds and window bounds.
   virtual gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) override;
   virtual gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) override;
+  ~NativeWindowEfl() override {};
+
+  static void OnWindowDeleteRequest(void* data, Evas_Object*, void*);
+
+  Evas_Object* window_;
+  content::WebContents* web_contents_;
+
+  std::string title_;
 
   DISALLOW_COPY_AND_ASSIGN(NativeWindowEfl);
 };
index d7b7736..41fe4a1 100644 (file)
@@ -1,5 +1,5 @@
-// Copyright (c) 2013 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
+// Copyright 2017 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include "atom/browser/ui/accelerator_util.h"
index e1894c0..542bf0b 100644 (file)
       ],
     }, # elementary
     {
+      'target_name': 'evas',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(<(pkg-config) --cflags evas)',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(<(pkg-config) --libs-only-L --libs-only-other evas)',
+        ],
+        'libraries': [
+          '<!@(<(pkg-config) --libs-only-l evas)',
+        ],
+      },
+    }, # evas
+    {
       'target_name': 'icu',
       'type': 'none',
       'direct_dependent_settings': {
index 2b34eaa..9fc0032 100644 (file)
@@ -38,6 +38,7 @@
       ],
       'include_dirs': [
         '.',
+        '<(libchromiumcontent_src_dir)/tizen_src/chromium_impl',
       ],
       'conditions': [
         ['OS=="mac"', {
             '<(DEPTH)/efl/build/system.gyp:ecore-x',
             '<(DEPTH)/efl/build/system.gyp:elocation',
             '<(DEPTH)/efl/build/system.gyp:elementary',
+            '<(DEPTH)/efl/build/system.gyp:evas',
             '<(DEPTH)/efl/build/system.gyp:icu',
           ],
           'sources': [
index 95e5024..4c52097 100644 (file)
@@ -236,12 +236,7 @@ InspectableWebContentsImpl::InspectableWebContentsImpl(
     }
   }
 
-  // FIXME: The aura is disabled in chromium-efl.
-#if defined(USE_EFL)
-  NOTIMPLEMENTED();
-#else
   view_.reset(CreateInspectableContentsView(this));
-#endif
 }
 
 InspectableWebContentsImpl::~InspectableWebContentsImpl() {
diff --git a/vendor/brightray/browser/inspectable_web_contents_view_efl.cc b/vendor/brightray/browser/inspectable_web_contents_view_efl.cc
new file mode 100644 (file)
index 0000000..4021d3d
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2014 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "browser/inspectable_web_contents_impl.h"
+
+#include "browser/inspectable_web_contents_view.h"
+
+namespace brightray {
+
+InspectableWebContentsView* CreateInspectableContentsView(
+    InspectableWebContentsImpl* inspectable_web_contents) {
+  return nullptr;
+}
+
+} // namespace brightray
index b7d4401..980803f 100644 (file)
@@ -27,6 +27,7 @@
       'browser/inspectable_web_contents_impl.cc',
       'browser/inspectable_web_contents_impl.h',
       'browser/inspectable_web_contents_view.h',
+      'browser/inspectable_web_contents_view_efl.cc',
       'browser/inspectable_web_contents_view_mac.h',
       'browser/inspectable_web_contents_view_mac.mm',
       'browser/mac/bry_application.h',