switches::kPageVisibility,
};
+// Convert draggable regions in raw format to SkRegion format. Caller is
+// responsible for deleting the returned SkRegion instance.
+SkRegion* DraggableRegionsToSkRegion(
+ const std::vector<DraggableRegion>& regions) {
+ SkRegion* sk_region = new SkRegion;
+ for (std::vector<DraggableRegion>::const_iterator iter = regions.begin();
+ iter != regions.end();
+ ++iter) {
+ const DraggableRegion& region = *iter;
+ sk_region->op(
+ region.bounds.x(),
+ region.bounds.y(),
+ region.bounds.right(),
+ region.bounds.bottom(),
+ region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
+ }
+ return sk_region;
+}
+
} // namespace
NativeWindow::NativeWindow(
return handled;
}
+void NativeWindow::UpdateDraggableRegions(
+ const std::vector<DraggableRegion>& regions) {
+ // Draggable region is not supported for non-frameless window.
+ if (has_frame_)
+ return;
+
+ draggable_region_.reset(DraggableRegionsToSkRegion(regions));
+}
+
void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
if (!window_unresposive_closure_.IsCancelled())
return;
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
+class SkRegion;
+
namespace base {
class CommandLine;
}
}
bool has_frame() const { return has_frame_; }
+ SkRegion* draggable_region() const { return draggable_region_.get(); }
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;
NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
const mate::Dictionary& options);
- // Called when the window needs to update its draggable region.
- virtual void UpdateDraggableRegions(
- const std::vector<DraggableRegion>& regions) = 0;
-
// brightray::InspectableWebContentsViewDelegate:
void DevToolsFocused() override;
void DevToolsOpened() override;
ObserverList<NativeWindowObserver> observers_;
private:
+ // Called when the window needs to update its draggable region.
+ void UpdateDraggableRegions(
+ const std::vector<DraggableRegion>& regions);
+
// Schedule a notification unresponsive event.
void ScheduleUnresponsiveEvent(int ms);
// The page this window is viewing.
brightray::InspectableWebContents* inspectable_web_contents_;
+ // For custom drag, the whole window is non-draggable and the draggable region
+ // has to been explicitly provided.
+ scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
+
base::WeakPtrFactory<NativeWindow> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
#include <vector>
#include "base/mac/scoped_nsobject.h"
-#include "base/memory/scoped_ptr.h"
#include "atom/browser/native_window.h"
@class AtomNSWindow;
@class AtomNSWindowDelegate;
@class FullSizeContentView;
-class SkRegion;
namespace atom {
void ClipWebView();
protected:
- void UpdateDraggableRegions(
- const std::vector<DraggableRegion>& regions) override;
-
// NativeWindow:
void HandleKeyboardEvent(
content::WebContents*,
// The presentation options before entering kiosk mode.
NSApplicationPresentationOptions kiosk_options_;
- // For custom drag, the whole window is non-draggable and the draggable region
- // has to been explicitly provided.
- scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
-
// Mouse location since the last mouse event, in screen coordinates. This is
// used in custom drag to compute the window movement.
NSPoint last_mouse_offset_;
namespace atom {
-namespace {
-
-// Convert draggable regions in raw format to SkRegion format. Caller is
-// responsible for deleting the returned SkRegion instance.
-SkRegion* DraggableRegionsToSkRegion(
- const std::vector<DraggableRegion>& regions) {
- SkRegion* sk_region = new SkRegion;
- for (std::vector<DraggableRegion>::const_iterator iter = regions.begin();
- iter != regions.end();
- ++iter) {
- const DraggableRegion& region = *iter;
- sk_region->op(
- region.bounds.x(),
- region.bounds.y(),
- region.bounds.right(),
- region.bounds.bottom(),
- region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
- }
- return sk_region;
-}
-
-} // namespace
-
NativeWindowMac::NativeWindowMac(
brightray::InspectableWebContents* web_contents,
const mate::Dictionary& options)
}
bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const {
- if (!draggable_region_)
+ if (!draggable_region())
return false;
if (!web_contents())
return false;
// |draggable_region_| is stored in local platform-indepdent coordiate system
// while |point| is in local Cocoa coordinate system. Do the conversion
// to match these two.
- return draggable_region_->contains(point.x, webViewHeight - point.y);
+ return draggable_region()->contains(point.x, webViewHeight - point.y);
}
void NativeWindowMac::HandleMouseEvent(NSEvent* event) {
}
}
-void NativeWindowMac::UpdateDraggableRegions(
- const std::vector<DraggableRegion>& regions) {
- // Draggable region is not supported for non-frameless window.
- if (has_frame_)
- return;
-
- draggable_region_.reset(DraggableRegionsToSkRegion(regions));
-}
-
void NativeWindowMac::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
}
-void NativeWindowViews::UpdateDraggableRegions(
- const std::vector<DraggableRegion>& regions) {
- if (has_frame_)
- return;
-
- SkRegion* draggable_region = new SkRegion;
-
- // By default, the whole window is non-draggable. We need to explicitly
- // include those draggable regions.
- for (std::vector<DraggableRegion>::const_iterator iter = regions.begin();
- iter != regions.end(); ++iter) {
- const DraggableRegion& region = *iter;
- draggable_region->op(
- region.bounds.x(),
- region.bounds.y(),
- region.bounds.right(),
- region.bounds.bottom(),
- region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
- }
-
- draggable_region_.reset(draggable_region);
-}
-
void NativeWindowViews::OnWidgetActivationChanged(
views::Widget* widget, bool active) {
if (widget != window_.get())
gfx::NativeView child,
const gfx::Point& location) {
// App window should claim mouse events that fall within the draggable region.
- if (draggable_region_ &&
- draggable_region_->contains(location.x(), location.y()))
+ if (draggable_region() &&
+ draggable_region()->contains(location.x(), location.y()))
return false;
// And the events on border for dragging resizable frameless window.
gfx::AcceleratedWidget GetAcceleratedWidget();
- SkRegion* draggable_region() const { return draggable_region_.get(); }
views::Widget* widget() const { return window_.get(); }
private:
- // NativeWindow:
- void UpdateDraggableRegions(
- const std::vector<DraggableRegion>& regions) override;
-
// views::WidgetObserver:
void OnWidgetActivationChanged(
views::Widget* widget, bool active) override;
gfx::Size maximum_size_;
gfx::Size widget_size_;
- scoped_ptr<SkRegion> draggable_region_;
-
DISALLOW_COPY_AND_ASSIGN(NativeWindowViews);
};