blob: d418150dcdd7ea0aac467545058e08b39f4685ff [file] [log] [blame]
[email protected]81585f32011-07-29 19:32:061// Copyright (c) 2011 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.
4
5#include "aura/desktop_host_win.h"
6
7#include "aura/desktop.h"
8#include "base/message_loop.h"
9
10namespace aura {
11
12// static
13DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) {
14 return new DesktopHostWin(bounds);
15}
16
17DesktopHostWin::DesktopHostWin(const gfx::Rect& bounds) : desktop_(NULL) {
18 Init(NULL, bounds);
19}
20
21DesktopHostWin::~DesktopHostWin() {
22 DestroyWindow(hwnd());
23}
24
[email protected]711d8a82011-08-22 16:01:1925bool DesktopHostWin::Dispatch(const MSG& msg) {
26 // TODO(ben):
27 return true;
28}
29
[email protected]81585f32011-07-29 19:32:0630void DesktopHostWin::SetDesktop(Desktop* desktop) {
31 desktop_ = desktop;
32}
33
34gfx::AcceleratedWidget DesktopHostWin::GetAcceleratedWidget() {
35 return hwnd();
36}
37
38void DesktopHostWin::Show() {
39 ShowWindow(hwnd(), SW_SHOWNORMAL);
40}
41
42gfx::Size DesktopHostWin::GetSize() {
43 RECT r;
44 GetClientRect(hwnd(), &r);
45 return gfx::Rect(r).size();
46}
47
48void DesktopHostWin::OnClose() {
49 // TODO: this obviously shouldn't be here.
50 MessageLoopForUI::current()->Quit();
51}
52
53void DesktopHostWin::OnPaint(HDC dc) {
54 if (desktop_)
55 desktop_->Draw();
56 ValidateRect(hwnd(), NULL);
57}
58
59} // namespace aura