]> khamidou — GitHub mirrors - electron.git/commitdiff
linux: Share code on frameless window with Windows.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 16 Jul 2014 08:00:08 +0000 (16:00 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 16 Jul 2014 08:00:08 +0000 (16:00 +0800)
atom/browser/native_window_views.cc
atom/browser/ui/views/frameless_view.cc
atom/browser/ui/views/linux_frame_view.cc
atom/browser/ui/views/linux_frame_view.h

index d5e8ad851420d5deab2d81cd0fc7268990a91fb8..b0e3784e123d976de4fb9b974c5d5413aa26b1f8 100644 (file)
@@ -395,7 +395,7 @@ views::NonClientFrameView* NativeWindowViews::CreateNonClientFrameView(
     views::Widget* widget) {
 #if defined(USE_X11)
   LinuxFrameView* frame_view =  new LinuxFrameView;
-#else defined(OS_WIN)
+#else
   WinFrameView* frame_view =  new WinFrameView;
 #endif
   frame_view->Init(this, widget);
index 7a98891dcaf9d5d3fb8382564db7da5b4520268e..a7c5f3c1765eb2ec6ccb975097ef26dd9f20bcd7 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "atom/browser/native_window_views.h"
 #include "ui/aura/window.h"
+#include "ui/base/hit_test.h"
 #include "ui/views/widget/widget.h"
 #include "ui/views/widget/widget_delegate.h"
 
index b8c9265f12238708682d4e328f55adb7efbf0422..c68a2e933246cd986b933313bd4632f2ff88d167 100644 (file)
@@ -76,9 +76,7 @@ const gfx::FontList& GetTitleFontList() {
 // LinuxFrameView, public:
 
 LinuxFrameView::LinuxFrameView()
-    : window_(NULL),
-      frame_(NULL),
-      window_icon_(NULL),
+    : window_icon_(NULL),
       minimize_button_(NULL),
       maximize_button_(NULL),
       restore_button_(NULL),
@@ -117,12 +115,6 @@ void LinuxFrameView::Init(NativeWindowViews* window, views::Widget* frame) {
   }
 }
 
-int LinuxFrameView::ResizingBorderHitTest(const gfx::Point& point) {
-  return GetHTComponentForFrame(point, FrameBorderThickness(),
-      FrameBorderThickness() + kClientEdgeThickness, kResizeAreaCornerSize,
-      kResizeAreaCornerSize, true);
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 // LinuxFrameView, NonClientFrameView implementation:
 
@@ -141,23 +133,13 @@ gfx::Rect LinuxFrameView::GetWindowBoundsForClientBounds(
 }
 
 int LinuxFrameView::NonClientHitTest(const gfx::Point& point) {
+  if (!window_->has_frame())
+    return FramelessView::NonClientHitTest(point);
+
   // Sanity check.
   if (!bounds().Contains(point))
     return HTNOWHERE;
 
-  // Check for possible draggable region in the client area for the frameless
-  // window.
-  SkRegion* draggable_region = window_->draggable_region();
-  if (draggable_region && draggable_region->contains(point.x(), point.y()))
-    return HTCAPTION;
-
-  // Support resizing frameless window by dragging the border.
-  if (!window_->has_frame() && frame_->widget_delegate()->CanResize()) {
-    int window_component = ResizingBorderHitTest(point);
-    if (window_component != HTNOWHERE)
-      return window_component;
-  }
-
   int frame_component = frame_->client_view()->NonClientHitTest(point);
 
   // See if we're in the sysmenu region.  (We check the ClientView first to be
index 85ea975e3c1d8f7f9fcc3ab8e2e888ada3d1e3bf..2f6793fe7a40d695550303a9faa4dcb52c20e27d 100644 (file)
@@ -21,7 +21,7 @@ class ImageButton;
 
 namespace atom {
 
-class LinuxFrameView : public FramelessView
+class LinuxFrameView : public FramelessView,
                        public views::ButtonListener {
  public:
   LinuxFrameView();
@@ -51,9 +51,6 @@ class LinuxFrameView : public FramelessView
   virtual void ButtonPressed(views::Button* sender,
                              const ui::Event& event) OVERRIDE;
 
-  // Returns whether the |point| is on frameless window's resizing border.
-  int ResizingBorderHitTest(const gfx::Point& point);
-
  private:
   // Returns the thickness of the border that makes up the window frame edges.
   // This does not include any client edge.