linux: Share code on frameless window with Windows.
This commit is contained in:
parent
9afc2daf75
commit
2a2fc4903d
4 changed files with 7 additions and 27 deletions
|
@ -395,7 +395,7 @@ views::NonClientFrameView* NativeWindowViews::CreateNonClientFrameView(
|
||||||
views::Widget* widget) {
|
views::Widget* widget) {
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
LinuxFrameView* frame_view = new LinuxFrameView;
|
LinuxFrameView* frame_view = new LinuxFrameView;
|
||||||
#else defined(OS_WIN)
|
#else
|
||||||
WinFrameView* frame_view = new WinFrameView;
|
WinFrameView* frame_view = new WinFrameView;
|
||||||
#endif
|
#endif
|
||||||
frame_view->Init(this, widget);
|
frame_view->Init(this, widget);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "atom/browser/native_window_views.h"
|
#include "atom/browser/native_window_views.h"
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
|
#include "ui/base/hit_test.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
#include "ui/views/widget/widget_delegate.h"
|
#include "ui/views/widget/widget_delegate.h"
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,7 @@ const gfx::FontList& GetTitleFontList() {
|
||||||
// LinuxFrameView, public:
|
// LinuxFrameView, public:
|
||||||
|
|
||||||
LinuxFrameView::LinuxFrameView()
|
LinuxFrameView::LinuxFrameView()
|
||||||
: window_(NULL),
|
: window_icon_(NULL),
|
||||||
frame_(NULL),
|
|
||||||
window_icon_(NULL),
|
|
||||||
minimize_button_(NULL),
|
minimize_button_(NULL),
|
||||||
maximize_button_(NULL),
|
maximize_button_(NULL),
|
||||||
restore_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:
|
// LinuxFrameView, NonClientFrameView implementation:
|
||||||
|
|
||||||
|
@ -141,23 +133,13 @@ gfx::Rect LinuxFrameView::GetWindowBoundsForClientBounds(
|
||||||
}
|
}
|
||||||
|
|
||||||
int LinuxFrameView::NonClientHitTest(const gfx::Point& point) {
|
int LinuxFrameView::NonClientHitTest(const gfx::Point& point) {
|
||||||
|
if (!window_->has_frame())
|
||||||
|
return FramelessView::NonClientHitTest(point);
|
||||||
|
|
||||||
// Sanity check.
|
// Sanity check.
|
||||||
if (!bounds().Contains(point))
|
if (!bounds().Contains(point))
|
||||||
return HTNOWHERE;
|
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);
|
int frame_component = frame_->client_view()->NonClientHitTest(point);
|
||||||
|
|
||||||
// See if we're in the sysmenu region. (We check the ClientView first to be
|
// See if we're in the sysmenu region. (We check the ClientView first to be
|
||||||
|
|
|
@ -21,7 +21,7 @@ class ImageButton;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class LinuxFrameView : public FramelessView
|
class LinuxFrameView : public FramelessView,
|
||||||
public views::ButtonListener {
|
public views::ButtonListener {
|
||||||
public:
|
public:
|
||||||
LinuxFrameView();
|
LinuxFrameView();
|
||||||
|
@ -51,9 +51,6 @@ class LinuxFrameView : public FramelessView
|
||||||
virtual void ButtonPressed(views::Button* sender,
|
virtual void ButtonPressed(views::Button* sender,
|
||||||
const ui::Event& event) OVERRIDE;
|
const ui::Event& event) OVERRIDE;
|
||||||
|
|
||||||
// Returns whether the |point| is on frameless window's resizing border.
|
|
||||||
int ResizingBorderHitTest(const gfx::Point& point);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Returns the thickness of the border that makes up the window frame edges.
|
// Returns the thickness of the border that makes up the window frame edges.
|
||||||
// This does not include any client edge.
|
// This does not include any client edge.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue