2014-10-31 21:17:05 +03:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 13:49:37 +04:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-04-12 11:04:46 +04: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-19 02:40:35 +03:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-11 08:47:22 +04:00
|
|
|
#include "base/mac/scoped_nsobject.h"
|
2014-03-16 04:30:26 +04:00
|
|
|
#include "atom/browser/native_window.h"
|
2013-04-12 11:04:46 +04:00
|
|
|
|
2015-03-25 13:51:29 +03:00
|
|
|
@class AtomNSWindow;
|
|
|
|
@class AtomNSWindowDelegate;
|
2014-12-12 01:25:51 +03:00
|
|
|
@class FullSizeContentView;
|
2013-09-05 19:52:29 +04:00
|
|
|
|
2013-04-12 11:04:46 +04:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
class NativeWindowMac : public NativeWindow {
|
|
|
|
public:
|
2015-06-25 04:47:57 +03:00
|
|
|
NativeWindowMac(brightray::InspectableWebContents* inspectable_web_contents,
|
|
|
|
const mate::Dictionary& options);
|
|
|
|
~NativeWindowMac() override;
|
2013-04-12 11:04:46 +04:00
|
|
|
|
2015-06-25 06:07:23 +03:00
|
|
|
// NativeWindow:
|
2014-12-24 02:31:39 +03:00
|
|
|
void Close() override;
|
|
|
|
void CloseImmediately() 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;
|
2015-04-21 16:35:36 +03:00
|
|
|
bool IsFullscreen() const override;
|
2016-01-15 19:31:31 +03:00
|
|
|
void SetBounds(const gfx::Rect& bounds, bool animate = false) override;
|
2015-05-01 17:40:46 +03:00
|
|
|
gfx::Rect GetBounds() override;
|
2015-10-05 11:19:01 +03:00
|
|
|
void SetContentSizeConstraints(
|
|
|
|
const extensions::SizeConstraints& size_constraints) override;
|
2014-12-24 02:31:39 +03:00
|
|
|
void SetResizable(bool resizable) override;
|
|
|
|
bool IsResizable() override;
|
|
|
|
void SetAlwaysOnTop(bool top) override;
|
|
|
|
bool IsAlwaysOnTop() override;
|
|
|
|
void Center() 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;
|
2015-10-23 06:35:33 +03:00
|
|
|
void SetBackgroundColor(const std::string& color_name) override;
|
2014-12-24 02:31:39 +03:00
|
|
|
void SetRepresentedFilename(const std::string& filename) override;
|
|
|
|
std::string GetRepresentedFilename() override;
|
|
|
|
void SetDocumentEdited(bool edited) override;
|
|
|
|
bool IsDocumentEdited() override;
|
2015-12-06 05:14:54 +03:00
|
|
|
void SetIgnoreMouseEvents(bool ignore) override;
|
2014-12-24 02:31:39 +03:00
|
|
|
bool HasModalDialog() override;
|
|
|
|
gfx::NativeWindow GetNativeWindow() override;
|
2016-01-07 23:38:35 +03:00
|
|
|
gfx::AcceleratedWidget GetAcceleratedWidget() override;
|
2014-12-24 02:31:39 +03:00
|
|
|
void SetProgressBar(double progress) override;
|
2015-02-07 22:56:03 +03:00
|
|
|
void SetOverlayIcon(const gfx::Image& overlay,
|
2015-02-11 04:14:26 +03:00
|
|
|
const std::string& description) override;
|
2014-12-24 02:31:39 +03:00
|
|
|
void ShowDefinitionForSelection() override;
|
2013-04-12 11:04:46 +04:00
|
|
|
|
2015-03-26 09:18:37 +03:00
|
|
|
void SetVisibleOnAllWorkspaces(bool visible) override;
|
|
|
|
bool IsVisibleOnAllWorkspaces() override;
|
|
|
|
|
2015-10-21 02:33:43 +03:00
|
|
|
// Refresh the DraggableRegion views.
|
|
|
|
void UpdateDraggableRegionViews() {
|
|
|
|
UpdateDraggableRegionViews(draggable_regions_);
|
|
|
|
}
|
2013-09-05 19:52:29 +04:00
|
|
|
|
2015-12-23 07:38:11 +03:00
|
|
|
bool should_hide_native_toolbar_in_fullscreen() const {
|
2015-12-21 21:55:23 +03:00
|
|
|
return should_hide_native_toolbar_in_fullscreen_;
|
|
|
|
}
|
|
|
|
|
2013-04-12 11:04:46 +04:00
|
|
|
protected:
|
2015-06-25 06:07:23 +03:00
|
|
|
// NativeWindow:
|
2014-12-24 02:31:39 +03:00
|
|
|
void HandleKeyboardEvent(
|
2013-04-12 16:31:15 +04:00
|
|
|
content::WebContents*,
|
2014-12-24 02:31:39 +03:00
|
|
|
const content::NativeWebKeyboardEvent&) override;
|
2013-04-12 16:31:15 +04:00
|
|
|
|
2015-10-21 02:33:43 +03:00
|
|
|
// Return a vector of non-draggable regions that fill a window of size
|
|
|
|
// |width| by |height|, but leave gaps where the window should be draggable.
|
|
|
|
std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
|
|
|
const std::vector<DraggableRegion>& regions, int width, int height);
|
|
|
|
|
2013-04-12 11:04:46 +04:00
|
|
|
private:
|
2015-10-05 11:19:01 +03:00
|
|
|
// NativeWindow:
|
|
|
|
gfx::Size ContentSizeToWindowSize(const gfx::Size& size) override;
|
|
|
|
gfx::Size WindowSizeToContentSize(const gfx::Size& size) override;
|
2015-10-21 02:33:43 +03:00
|
|
|
void UpdateDraggableRegions(
|
|
|
|
const std::vector<DraggableRegion>& regions) override;
|
2015-10-05 11:19:01 +03:00
|
|
|
|
2013-04-12 11:04:46 +04:00
|
|
|
void InstallView();
|
|
|
|
void UninstallView();
|
2014-12-24 02:50:42 +03:00
|
|
|
|
|
|
|
// Install the drag view, which will cover the whole window and decides
|
|
|
|
// whehter we can drag.
|
2015-10-21 02:33:43 +03:00
|
|
|
void UpdateDraggableRegionViews(const std::vector<DraggableRegion>& regions);
|
2013-04-12 11:04:46 +04:00
|
|
|
|
2015-03-25 13:51:29 +03:00
|
|
|
base::scoped_nsobject<AtomNSWindow> window_;
|
|
|
|
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
|
2013-04-12 11:04:46 +04:00
|
|
|
|
2014-12-12 01:25:51 +03:00
|
|
|
// The view that will fill the whole frameless window.
|
|
|
|
base::scoped_nsobject<FullSizeContentView> content_view_;
|
|
|
|
|
2015-10-21 02:33:43 +03:00
|
|
|
std::vector<DraggableRegion> draggable_regions_;
|
|
|
|
|
2013-04-12 11:04:46 +04:00
|
|
|
bool is_kiosk_;
|
|
|
|
|
|
|
|
NSInteger attention_request_id_; // identifier from requestUserAttention
|
|
|
|
|
2014-06-09 09:04:59 +04:00
|
|
|
// The presentation options before entering kiosk mode.
|
|
|
|
NSApplicationPresentationOptions kiosk_options_;
|
|
|
|
|
2015-12-21 21:55:23 +03:00
|
|
|
bool should_hide_native_toolbar_in_fullscreen_;
|
|
|
|
|
2013-04-12 11:04:46 +04:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_NATIVE_WINDOW_MAC_H_
|