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.
|
2014-12-23 23:31:39 +00:00
|
|
|
void Close() override;
|
|
|
|
void CloseImmediately() override;
|
|
|
|
void Move(const gfx::Rect& pos) override;
|
|
|
|
void Focus(bool focus) override;
|
|
|
|
bool IsFocused() override;
|
|
|
|
void Show() override;
|
|
|
|
void ShowInactive() override;
|
|
|
|
void Hide() override;
|
|
|
|
bool IsVisible() override;
|
|
|
|
void Maximize() override;
|
|
|
|
void Unmaximize() override;
|
|
|
|
bool IsMaximized() override;
|
|
|
|
void Minimize() override;
|
|
|
|
void Restore() override;
|
|
|
|
bool IsMinimized() override;
|
|
|
|
void SetFullScreen(bool fullscreen) override;
|
|
|
|
bool IsFullscreen() override;
|
|
|
|
void SetSize(const gfx::Size& size) override;
|
|
|
|
gfx::Size GetSize() override;
|
|
|
|
void SetContentSize(const gfx::Size& size) override;
|
|
|
|
gfx::Size GetContentSize() override;
|
|
|
|
void SetMinimumSize(const gfx::Size& size) override;
|
|
|
|
gfx::Size GetMinimumSize() override;
|
|
|
|
void SetMaximumSize(const gfx::Size& size) override;
|
|
|
|
gfx::Size GetMaximumSize() override;
|
|
|
|
void SetResizable(bool resizable) override;
|
|
|
|
bool IsResizable() override;
|
|
|
|
void SetAlwaysOnTop(bool top) override;
|
|
|
|
bool IsAlwaysOnTop() override;
|
|
|
|
void Center() override;
|
|
|
|
void SetPosition(const gfx::Point& position) override;
|
|
|
|
gfx::Point GetPosition() override;
|
|
|
|
void SetTitle(const std::string& title) override;
|
|
|
|
std::string GetTitle() override;
|
|
|
|
void FlashFrame(bool flash) override;
|
|
|
|
void SetSkipTaskbar(bool skip) override;
|
|
|
|
void SetKiosk(bool kiosk) override;
|
|
|
|
bool IsKiosk() override;
|
|
|
|
void SetRepresentedFilename(const std::string& filename) override;
|
|
|
|
std::string GetRepresentedFilename() override;
|
|
|
|
void SetDocumentEdited(bool edited) override;
|
|
|
|
bool IsDocumentEdited() override;
|
|
|
|
bool HasModalDialog() override;
|
|
|
|
gfx::NativeWindow GetNativeWindow() override;
|
|
|
|
void SetProgressBar(double progress) override;
|
|
|
|
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-04-12 07:04:46 +00:00
|
|
|
protected:
|
2014-12-23 23:31:39 +00:00
|
|
|
void UpdateDraggableRegions(
|
|
|
|
const std::vector<DraggableRegion>& regions) override;
|
2013-09-05 12:06:54 +00:00
|
|
|
|
2013-04-12 12:31:15 +00:00
|
|
|
// Implementations of content::WebContentsDelegate.
|
2014-12-23 23:31:39 +00:00
|
|
|
void HandleKeyboardEvent(
|
2013-04-12 12:31:15 +00:00
|
|
|
content::WebContents*,
|
2014-12-23 23:31:39 +00:00
|
|
|
const content::NativeWebKeyboardEvent&) override;
|
2013-04-12 12:31:15 +00:00
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
private:
|
|
|
|
void InstallView();
|
|
|
|
void UninstallView();
|
2014-12-23 23:50:42 +00:00
|
|
|
|
|
|
|
// Install the drag view, which will cover the whole window and decides
|
|
|
|
// whehter we can drag.
|
|
|
|
void InstallDraggableRegionView();
|
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 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_
|