1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <Cocoa/Cocoa.h>
7 #include "ui/aura/window_tree_host_mac.h"
8 #include "ui/aura/window_tree_host.h"
9 #include "ui/aura/window_tree_host_delegate.h"
13 WindowTreeHostMac::WindowTreeHostMac(const gfx::Rect& bounds) {
16 initWithContentRect:NSRectFromCGRect(bounds.ToCGRect())
17 styleMask:NSBorderlessWindowMask
18 backing:NSBackingStoreBuffered
20 CreateCompositor(GetAcceleratedWidget());
23 WindowTreeHostMac::~WindowTreeHostMac() {
26 RootWindow* WindowTreeHostMac::GetRootWindow() {
27 return delegate_->AsRootWindow();
30 gfx::AcceleratedWidget WindowTreeHostMac::GetAcceleratedWidget() {
31 return [window_ contentView];
33 void WindowTreeHostMac::Show() {
34 [window_ makeKeyAndOrderFront:nil];
37 void WindowTreeHostMac::Hide() {
38 [window_ orderOut:nil];
41 void WindowTreeHostMac::ToggleFullScreen() {
44 gfx::Rect WindowTreeHostMac::GetBounds() const {
45 return gfx::Rect(NSRectToCGRect([window_ frame]));
48 void WindowTreeHostMac::SetBounds(const gfx::Rect& bounds) {
49 [window_ setFrame:NSRectFromCGRect(bounds.ToCGRect()) display:YES animate:NO];
52 gfx::Insets WindowTreeHostMac::GetInsets() const {
57 void WindowTreeHostMac::SetInsets(const gfx::Insets& insets) {
61 gfx::Point WindowTreeHostMac::GetLocationOnNativeScreen() const {
63 return gfx::Point(0, 0);
66 void WindowTreeHostMac::SetCapture() {
70 void WindowTreeHostMac::ReleaseCapture() {
74 bool WindowTreeHostMac::QueryMouseLocation(gfx::Point* location_return) {
79 bool WindowTreeHostMac::ConfineCursorToRootWindow() {
83 void WindowTreeHostMac::UnConfineCursor() {
87 void WindowTreeHostMac::SetCursorNative(gfx::NativeCursor cursor_type) {
91 void WindowTreeHostMac::MoveCursorToNative(const gfx::Point& location) {
95 void WindowTreeHostMac::OnCursorVisibilityChangedNative(bool show) {
99 void WindowTreeHostMac::PostNativeEvent(const base::NativeEvent& event) {
103 void WindowTreeHostMac::OnDeviceScaleFactorChanged(float device_scale_factor) {
107 void WindowTreeHostMac::PrepareForShutdown() {
112 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
113 return new WindowTreeHostMac(bounds);
117 gfx::Size WindowTreeHost::GetNativeScreenSize() {
119 return gfx::Size(1024, 768);