Initial work for Aura on Linux.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 2 Jul 2014 14:14:52 +0000 (14:14 +0000)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 2 Jul 2014 14:49:45 +0000 (22:49 +0800)
atom.gyp
atom/browser/api/atom_api_menu.h
atom/browser/api/atom_api_menu_gtk.cc
atom/browser/native_window_aura.cc [new file with mode: 0644]
atom/browser/native_window_aura.h [new file with mode: 0644]
atom/browser/ui/file_dialog_gtk.cc
atom/browser/ui/message_box_gtk.cc
filename_rules.gypi
vendor/brightray

index bedaf41..2358f9f 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
       'atom/browser/mac/atom_application_delegate.mm',
       'atom/browser/native_window.cc',
       'atom/browser/native_window.h',
-      'atom/browser/native_window_gtk.cc',
-      'atom/browser/native_window_gtk.h',
+      'atom/browser/native_window_aura.cc',
+      'atom/browser/native_window_aura.h',
+#     'atom/browser/native_window_gtk.cc',
+#     'atom/browser/native_window_gtk.h',
       'atom/browser/native_window_mac.h',
       'atom/browser/native_window_mac.mm',
       'atom/browser/native_window_win.cc',
index 2bd63df..122c8bc 100644 (file)
@@ -87,7 +87,7 @@ class Menu : public mate::Wrappable,
   virtual void UpdateStates() = 0;
 #endif
 
-#if defined(OS_WIN) || defined(TOOLKIT_GTK)
+#if defined(OS_WIN) || defined(OS_LINUX)
   virtual void AttachToWindow(Window* window) = 0;
 #endif
 
index acaca4b..9d45d3f 100644 (file)
@@ -19,6 +19,7 @@ MenuGtk::MenuGtk() {
 }
 
 void MenuGtk::Popup(Window* window) {
+  /*
   uint32_t triggering_event_time;
   gfx::Point point;
 
@@ -35,10 +36,11 @@ void MenuGtk::Popup(Window* window) {
 
   menu_gtk_.reset(new ::MenuGtk(this, model_.get()));
   menu_gtk_->PopupAsContext(point, triggering_event_time);
+  */
 }
 
 void MenuGtk::AttachToWindow(Window* window) {
-  static_cast<NativeWindowGtk*>(window->window())->SetMenu(model_.get());
+  // static_cast<NativeWindowGtk*>(window->window())->SetMenu(model_.get());
 }
 
 // static
diff --git a/atom/browser/native_window_aura.cc b/atom/browser/native_window_aura.cc
new file mode 100644 (file)
index 0000000..ada089a
--- /dev/null
@@ -0,0 +1,202 @@
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/browser/native_window_aura.h"
+
+#include "content/public/browser/web_contents_view.h"
+#include "ui/aura/env.h"
+#include "ui/aura/layout_manager.h"
+#include "ui/aura/window.h"
+
+namespace atom {
+
+namespace {
+
+class FillLayout : public aura::LayoutManager {
+ public:
+  explicit FillLayout(aura::Window* root)
+      : root_(root) {
+  }
+
+  virtual ~FillLayout() {}
+
+ private:
+  // aura::LayoutManager:
+  virtual void OnWindowResized() OVERRIDE {
+  }
+
+  virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
+    child->SetBounds(root_->bounds());
+  }
+
+  virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {
+  }
+
+  virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {
+  }
+
+  virtual void OnChildWindowVisibilityChanged(aura::Window* child,
+                                              bool visible) OVERRIDE {
+  }
+
+  virtual void SetChildBounds(aura::Window* child,
+                              const gfx::Rect& requested_bounds) OVERRIDE {
+    SetChildBoundsDirect(child, requested_bounds);
+  }
+
+  aura::Window* root_;
+
+  DISALLOW_COPY_AND_ASSIGN(FillLayout);
+};
+
+}  // namespace
+
+NativeWindowAura::NativeWindowAura(content::WebContents* web_contents,
+                                   const mate::Dictionary& options)
+    : NativeWindow(web_contents, options) {
+  aura::Env::CreateInstance();
+
+  host_.reset(aura::WindowTreeHost::Create(gfx::Rect(gfx::Size(800, 600))));
+  host_->InitHost();
+  host_->window()->SetLayoutManager(new FillLayout(host_->window()));
+  host_->window()->AddChild(web_contents->GetView()->GetNativeView());
+}
+
+NativeWindowAura::~NativeWindowAura() {
+}
+
+void NativeWindowAura::Close() {
+}
+
+void NativeWindowAura::CloseImmediately() {
+}
+
+void NativeWindowAura::Move(const gfx::Rect& pos) {
+}
+
+void NativeWindowAura::Focus(bool focus) {
+}
+
+bool NativeWindowAura::IsFocused() {
+  return false;
+}
+
+void NativeWindowAura::Show() {
+  host_->Show();
+}
+
+void NativeWindowAura::Hide() {
+  host_->Hide();
+}
+
+bool NativeWindowAura::IsVisible() {
+  return false;
+}
+
+void NativeWindowAura::Maximize() {
+}
+
+void NativeWindowAura::Unmaximize() {
+}
+
+void NativeWindowAura::Minimize() {
+}
+
+void NativeWindowAura::Restore() {
+}
+
+void NativeWindowAura::SetFullscreen(bool fullscreen) {
+}
+
+bool NativeWindowAura::IsFullscreen() {
+  return false;
+}
+
+void NativeWindowAura::SetSize(const gfx::Size& size) {
+}
+
+gfx::Size NativeWindowAura::GetSize() {
+  return gfx::Size();
+}
+
+void NativeWindowAura::SetContentSize(const gfx::Size& size) {
+}
+
+gfx::Size NativeWindowAura::GetContentSize() {
+  return gfx::Size();
+}
+
+void NativeWindowAura::SetMinimumSize(const gfx::Size& size) {
+}
+
+gfx::Size NativeWindowAura::GetMinimumSize() {
+  return gfx::Size();
+}
+
+void NativeWindowAura::SetMaximumSize(const gfx::Size& size) {
+}
+
+gfx::Size NativeWindowAura::GetMaximumSize() {
+  return gfx::Size();
+}
+
+void NativeWindowAura::SetResizable(bool resizable) {
+}
+
+bool NativeWindowAura::IsResizable() {
+  return false;
+}
+
+void NativeWindowAura::SetAlwaysOnTop(bool top) {
+}
+
+bool NativeWindowAura::IsAlwaysOnTop() {
+  return false;
+}
+
+void NativeWindowAura::Center() {
+}
+
+void NativeWindowAura::SetPosition(const gfx::Point& position) {
+}
+
+gfx::Point NativeWindowAura::GetPosition() {
+  return gfx::Point(0, 0);
+}
+
+void NativeWindowAura::SetTitle(const std::string& title) {
+}
+
+std::string NativeWindowAura::GetTitle() {
+  return "";
+}
+
+void NativeWindowAura::FlashFrame(bool flash) {
+}
+
+void NativeWindowAura::SetSkipTaskbar(bool skip) {
+}
+
+void NativeWindowAura::SetKiosk(bool kiosk) {
+}
+
+bool NativeWindowAura::IsKiosk() {
+  return false;
+}
+
+gfx::NativeWindow NativeWindowAura::GetNativeWindow() {
+  return NULL;
+}
+
+void NativeWindowAura::UpdateDraggableRegions(
+    const std::vector<DraggableRegion>& regions) {
+}
+
+// static
+NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
+                                   const mate::Dictionary& options) {
+  return new NativeWindowAura(web_contents, options);
+}
+
+}  // namespace atom
diff --git a/atom/browser/native_window_aura.h b/atom/browser/native_window_aura.h
new file mode 100644 (file)
index 0000000..dffeb11
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_BROWSER_NATIVE_WINDOW_AURA_H_
+#define ATOM_BROWSER_NATIVE_WINDOW_AURA_H_
+
+#include "atom/browser/native_window.h"
+
+#include "ui/aura/window_tree_host.h"
+
+namespace atom {
+
+class NativeWindowAura : public NativeWindow {
+ public:
+  explicit NativeWindowAura(content::WebContents* web_contents,
+                            const mate::Dictionary& options);
+  virtual ~NativeWindowAura();
+
+  // NativeWindow:
+  virtual void Close() OVERRIDE;
+  virtual void CloseImmediately() OVERRIDE;
+  virtual void Move(const gfx::Rect& pos) OVERRIDE;
+  virtual void Focus(bool focus) OVERRIDE;
+  virtual bool IsFocused() OVERRIDE;
+  virtual void Show() OVERRIDE;
+  virtual void Hide() OVERRIDE;
+  virtual bool IsVisible() OVERRIDE;
+  virtual void Maximize() OVERRIDE;
+  virtual void Unmaximize() OVERRIDE;
+  virtual void Minimize() OVERRIDE;
+  virtual void Restore() OVERRIDE;
+  virtual void SetFullscreen(bool fullscreen) OVERRIDE;
+  virtual bool IsFullscreen() OVERRIDE;
+  virtual void SetSize(const gfx::Size& size) OVERRIDE;
+  virtual gfx::Size GetSize() OVERRIDE;
+  virtual void SetContentSize(const gfx::Size& size) OVERRIDE;
+  virtual gfx::Size GetContentSize() OVERRIDE;
+  virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
+  virtual gfx::Size GetMinimumSize() OVERRIDE;
+  virtual void SetMaximumSize(const gfx::Size& size) OVERRIDE;
+  virtual gfx::Size GetMaximumSize() OVERRIDE;
+  virtual void SetResizable(bool resizable) OVERRIDE;
+  virtual bool IsResizable() OVERRIDE;
+  virtual void SetAlwaysOnTop(bool top) OVERRIDE;
+  virtual bool IsAlwaysOnTop() OVERRIDE;
+  virtual void Center() OVERRIDE;
+  virtual void SetPosition(const gfx::Point& position) OVERRIDE;
+  virtual gfx::Point GetPosition() OVERRIDE;
+  virtual void SetTitle(const std::string& title) OVERRIDE;
+  virtual std::string GetTitle() OVERRIDE;
+  virtual void FlashFrame(bool flash) OVERRIDE;
+  virtual void SetSkipTaskbar(bool skip) OVERRIDE;
+  virtual void SetKiosk(bool kiosk) OVERRIDE;
+  virtual bool IsKiosk() OVERRIDE;
+  virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
+
+ private:
+  // NativeWindow:
+  virtual void UpdateDraggableRegions(
+      const std::vector<DraggableRegion>& regions) OVERRIDE;
+
+  scoped_ptr<aura::WindowTreeHost> host_;
+
+  DISALLOW_COPY_AND_ASSIGN(NativeWindowAura);
+};
+
+}  // namespace atom
+
+#endif  // ATOM_BROWSER_NATR_NATIVE_WINDOW_AURA_H_
index 618ec31..7973fff 100644 (file)
@@ -27,7 +27,8 @@ class FileChooserDialog {
     else if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
       confirm_text = GTK_STOCK_OPEN;
 
-    GtkWindow* window = parent_window ? parent_window->GetNativeWindow() : NULL;
+    // GtkWindow* window = parent_window ? parent_window->GetNativeWindow() : NULL;
+    GtkWindow* window = NULL;
     dialog_ = gtk_file_chooser_dialog_new(
         title.c_str(),
         window,
index 4915d09..3793dad 100644 (file)
@@ -24,7 +24,8 @@ class MessageBox {
              const std::string& detail)
       : cancel_id_(0),
         dialog_scope_(new NativeWindow::DialogScope(parent_window)) {
-    GtkWindow* window = parent_window ? parent_window->GetNativeWindow() : NULL;
+    // GtkWindow* window = parent_window ? parent_window->GetNativeWindow() : NULL;
+    GtkWindow* window = NULL;
     dialog_ = gtk_dialog_new_with_buttons(
         title.c_str(),
         window,
index 0300805..5872786 100644 (file)
@@ -62,8 +62,8 @@
         ['exclude', '(^|/)x/'],
       ],
     }],
-    ['OS!="win"', {
-      'sources/': [ ['exclude', '_views\\.(h|cc)$'] ]
+    ['OS!="linux"', {
+      'sources/': [ ['exclude', '_aura\\.(h|cc)$'] ]
     }],
   ]
 }
index 1e41ef6..a348865 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1e41ef63ebd7ecb1ffb3a6fec74b5a5264f20092
+Subproject commit a348865e723b73cd01d0b976f2d0b8d9b836176d