2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-04-12 07:04:46 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_NATIVE_WINDOW_MAC_H_
|
|
|
|
#define ATOM_BROWSER_NATIVE_WINDOW_MAC_H_
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2014-12-18 23:40:35 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-11 04:47:22 +00:00
|
|
|
#include "base/mac/scoped_nsobject.h"
|
2013-04-12 07:04:46 +00:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/native_window.h"
|
2013-04-12 07:04:46 +00:00
|
|
|
|
2014-12-11 22:25:51 +00:00
|
|
|
@class FullSizeContentView;
|
2013-09-05 15:52:29 +00:00
|
|
|
class SkRegion;
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
class NativeWindowMac : public NativeWindow {
|
|
|
|
public:
|
2013-04-20 05:42:39 +00:00
|
|
|
explicit NativeWindowMac(content::WebContents* web_contents,
|
2014-06-23 13:51:42 +00:00
|
|
|
const mate::Dictionary& options);
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual ~NativeWindowMac();
|
|
|
|
|
|
|
|
// NativeWindow implementation.
|
|
|
|
virtual void Close() OVERRIDE;
|
2013-05-01 08:12:00 +00:00
|
|
|
virtual void CloseImmediately() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void Move(const gfx::Rect& pos) OVERRIDE;
|
|
|
|
virtual void Focus(bool focus) OVERRIDE;
|
2013-05-16 14:56:52 +00:00
|
|
|
virtual bool IsFocused() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void Show() OVERRIDE;
|
2014-10-17 14:51:20 +00:00
|
|
|
virtual void ShowInactive() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void Hide() OVERRIDE;
|
2013-10-03 00:27:59 +00:00
|
|
|
virtual bool IsVisible() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void Maximize() OVERRIDE;
|
|
|
|
virtual void Unmaximize() OVERRIDE;
|
2014-05-14 21:58:49 +00:00
|
|
|
virtual bool IsMaximized() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void Minimize() OVERRIDE;
|
|
|
|
virtual void Restore() OVERRIDE;
|
2014-07-26 05:58:26 +00:00
|
|
|
virtual bool IsMinimized() OVERRIDE;
|
2014-11-25 06:34:14 +00:00
|
|
|
virtual void SetFullScreen(bool fullscreen) OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual bool IsFullscreen() OVERRIDE;
|
|
|
|
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
|
|
|
virtual gfx::Size GetSize() OVERRIDE;
|
2014-05-15 08:05:35 +00:00
|
|
|
virtual void SetContentSize(const gfx::Size& size) OVERRIDE;
|
2014-05-15 07:30:04 +00:00
|
|
|
virtual gfx::Size GetContentSize() OVERRIDE;
|
2013-04-17 14:49:49 +00:00
|
|
|
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
2013-04-18 07:38:04 +00:00
|
|
|
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
2013-04-17 14:49:49 +00:00
|
|
|
virtual void SetMaximumSize(const gfx::Size& size) OVERRIDE;
|
2013-04-18 07:38:04 +00:00
|
|
|
virtual gfx::Size GetMaximumSize() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void SetResizable(bool resizable) OVERRIDE;
|
2013-04-18 07:38:04 +00:00
|
|
|
virtual bool IsResizable() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
|
2013-04-18 07:38:04 +00:00
|
|
|
virtual bool IsAlwaysOnTop() OVERRIDE;
|
2013-05-10 12:34:05 +00:00
|
|
|
virtual void Center() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
|
|
|
|
virtual gfx::Point GetPosition() OVERRIDE;
|
|
|
|
virtual void SetTitle(const std::string& title) OVERRIDE;
|
2013-04-18 06:30:05 +00:00
|
|
|
virtual std::string GetTitle() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void FlashFrame(bool flash) OVERRIDE;
|
2014-06-16 02:29:51 +00:00
|
|
|
virtual void SetSkipTaskbar(bool skip) OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
virtual void SetKiosk(bool kiosk) OVERRIDE;
|
|
|
|
virtual bool IsKiosk() OVERRIDE;
|
2014-05-27 06:15:34 +00:00
|
|
|
virtual void SetRepresentedFilename(const std::string& filename) OVERRIDE;
|
2014-07-18 13:42:26 +00:00
|
|
|
virtual std::string GetRepresentedFilename() OVERRIDE;
|
2014-05-27 06:15:34 +00:00
|
|
|
virtual void SetDocumentEdited(bool edited) OVERRIDE;
|
2014-07-24 07:48:33 +00:00
|
|
|
virtual bool IsDocumentEdited() OVERRIDE;
|
2013-12-04 08:32:32 +00:00
|
|
|
virtual bool HasModalDialog() OVERRIDE;
|
2013-05-03 11:31:24 +00:00
|
|
|
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
|
2014-09-17 07:58:08 +00:00
|
|
|
virtual void SetProgressBar(double progress) OVERRIDE;
|
2014-12-18 23:40:35 +00:00
|
|
|
virtual void ShowDefinitionForSelection() OVERRIDE;
|
2013-04-12 07:04:46 +00:00
|
|
|
|
2013-09-06 03:54:52 +00:00
|
|
|
// Returns true if |point| in local Cocoa coordinate system falls within
|
|
|
|
// the draggable region.
|
|
|
|
bool IsWithinDraggableRegion(NSPoint point) const;
|
|
|
|
|
2013-09-05 15:52:29 +00:00
|
|
|
// Called to handle a mouse event.
|
|
|
|
void HandleMouseEvent(NSEvent* event);
|
|
|
|
|
2013-09-11 10:10:28 +00:00
|
|
|
// Clip web view to rounded corner.
|
|
|
|
void ClipWebView();
|
|
|
|
|
2013-09-05 15:52:29 +00:00
|
|
|
SkRegion* draggable_region() const { return draggable_region_.get(); }
|
2013-05-24 09:51:15 +00:00
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
protected:
|
2013-09-05 12:06:54 +00:00
|
|
|
virtual void UpdateDraggableRegions(
|
|
|
|
const std::vector<DraggableRegion>& regions) OVERRIDE;
|
|
|
|
|
2013-04-12 12:31:15 +00:00
|
|
|
// Implementations of content::WebContentsDelegate.
|
|
|
|
virtual void HandleKeyboardEvent(
|
|
|
|
content::WebContents*,
|
|
|
|
const content::NativeWebKeyboardEvent&) OVERRIDE;
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
private:
|
|
|
|
void InstallView();
|
|
|
|
void UninstallView();
|
2013-09-05 15:52:29 +00:00
|
|
|
void InstallDraggableRegionViews();
|
|
|
|
void UpdateDraggableRegionsForCustomDrag(
|
|
|
|
const std::vector<DraggableRegion>& regions);
|
2013-04-12 07:04:46 +00:00
|
|
|
|
2014-04-11 04:47:22 +00:00
|
|
|
base::scoped_nsobject<NSWindow> window_;
|
2013-04-12 07:04:46 +00:00
|
|
|
|
2014-12-11 22:25:51 +00:00
|
|
|
// The view that will fill the whole frameless window.
|
|
|
|
base::scoped_nsobject<FullSizeContentView> content_view_;
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
bool is_kiosk_;
|
|
|
|
|
|
|
|
NSInteger attention_request_id_; // identifier from requestUserAttention
|
|
|
|
|
2014-06-09 05:04:59 +00:00
|
|
|
// The presentation options before entering kiosk mode.
|
|
|
|
NSApplicationPresentationOptions kiosk_options_;
|
|
|
|
|
2013-09-05 15:52:29 +00:00
|
|
|
// For system drag, the whole window is draggable and the non-draggable areas
|
|
|
|
// have to been explicitly excluded.
|
|
|
|
std::vector<gfx::Rect> system_drag_exclude_areas_;
|
|
|
|
|
|
|
|
// 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.
|
2013-09-06 04:12:17 +00:00
|
|
|
NSPoint last_mouse_offset_;
|
2013-09-05 15:52:29 +00:00
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_NATIVE_WINDOW_MAC_H_
|