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