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"
12 WindowTreeHostMac::WindowTreeHostMac(const gfx::Rect& bounds) {
15 initWithContentRect:NSRectFromCGRect(bounds.ToCGRect())
16 styleMask:NSBorderlessWindowMask
17 backing:NSBackingStoreBuffered
19 CreateCompositor(GetAcceleratedWidget());
22 WindowTreeHostMac::~WindowTreeHostMac() {
26 EventSource* WindowTreeHostMac::GetEventSource() {
31 gfx::AcceleratedWidget WindowTreeHostMac::GetAcceleratedWidget() {
32 return [window_ contentView];
34 void WindowTreeHostMac::Show() {
35 [window_ makeKeyAndOrderFront:nil];
38 void WindowTreeHostMac::Hide() {
39 [window_ orderOut:nil];
42 void WindowTreeHostMac::ToggleFullScreen() {
45 gfx::Rect WindowTreeHostMac::GetBounds() const {
46 return gfx::Rect(NSRectToCGRect([window_ frame]));
49 void WindowTreeHostMac::SetBounds(const gfx::Rect& bounds) {
50 [window_ setFrame:NSRectFromCGRect(bounds.ToCGRect()) display:YES animate:NO];
53 gfx::Insets WindowTreeHostMac::GetInsets() const {
58 void WindowTreeHostMac::SetInsets(const gfx::Insets& insets) {
62 gfx::Point WindowTreeHostMac::GetLocationOnNativeScreen() const {
64 return gfx::Point(0, 0);
67 void WindowTreeHostMac::SetCapture() {
71 void WindowTreeHostMac::ReleaseCapture() {
75 bool WindowTreeHostMac::ConfineCursorToRootWindow() {
79 void WindowTreeHostMac::UnConfineCursor() {
83 void WindowTreeHostMac::SetCursorNative(gfx::NativeCursor cursor_type) {
87 void WindowTreeHostMac::MoveCursorToNative(const gfx::Point& location) {
91 void WindowTreeHostMac::OnCursorVisibilityChangedNative(bool show) {
95 void WindowTreeHostMac::PostNativeEvent(const base::NativeEvent& event) {
99 void WindowTreeHostMac::OnDeviceScaleFactorChanged(float device_scale_factor) {
104 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
105 return new WindowTreeHostMac(bounds);
109 gfx::Size WindowTreeHost::GetNativeScreenSize() {
111 return gfx::Size(1024, 768);