| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/services/native_viewport/native_viewport.h" | 5 #include "mojo/services/native_viewport/native_viewport.h" |
| 6 | 6 |
| 7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
| 8 #include "ui/gfx/win/msg_util.h" | 8 #include "ui/gfx/win/msg_util.h" |
| 9 #include "ui/gfx/win/window_impl.h" | 9 #include "ui/gfx/win/window_impl.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace services { | 12 namespace services { |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 gfx::Rect GetWindowBoundsForClientBounds(DWORD style, DWORD ex_style, | 15 gfx::Rect GetWindowBoundsForClientBounds(DWORD style, DWORD ex_style, |
| 16 const gfx::Rect& bounds) { | 16 const gfx::Rect& bounds) { |
| 17 RECT wr; | 17 RECT wr; |
| 18 wr.left = bounds.x(); | 18 wr.left = bounds.x(); |
| 19 wr.top = bounds.y(); | 19 wr.top = bounds.y(); |
| 20 wr.right = bounds.x() + bounds.width(); | 20 wr.right = bounds.x() + bounds.width(); |
| 21 wr.bottom = bounds.y() + bounds.height(); | 21 wr.bottom = bounds.y() + bounds.height(); |
| 22 AdjustWindowRectEx(&wr, style, FALSE, ex_style); | 22 AdjustWindowRectEx(&wr, style, FALSE, ex_style); |
| 23 return gfx::Rect(wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top); | 23 |
| 24 // Make sure to keep the window onscreen, as AdjustWindowRectEx() may have |
| 25 // moved part of it offscreen. |
| 26 gfx::Rect window_bounds(wr.left, wr.top, |
| 27 wr.right - wr.left, wr.bottom - wr.top); |
| 28 window_bounds.set_x(std::max(0, window_bounds.x())); |
| 29 window_bounds.set_y(std::max(0, window_bounds.y())); |
| 30 return window_bounds; |
| 24 } | 31 } |
| 25 | 32 |
| 26 } | 33 } |
| 27 | 34 |
| 28 class NativeViewportWin : public gfx::WindowImpl, | 35 class NativeViewportWin : public gfx::WindowImpl, |
| 29 public NativeViewport { | 36 public NativeViewport { |
| 30 public: | 37 public: |
| 31 explicit NativeViewportWin(NativeViewportDelegate* delegate) | 38 explicit NativeViewportWin(NativeViewportDelegate* delegate) |
| 32 : delegate_(delegate) { | 39 : delegate_(delegate) { |
| 33 } | 40 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 155 |
| 149 // static | 156 // static |
| 150 scoped_ptr<NativeViewport> NativeViewport::Create( | 157 scoped_ptr<NativeViewport> NativeViewport::Create( |
| 151 shell::Context* context, | 158 shell::Context* context, |
| 152 NativeViewportDelegate* delegate) { | 159 NativeViewportDelegate* delegate) { |
| 153 return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass(); | 160 return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass(); |
| 154 } | 161 } |
| 155 | 162 |
| 156 } // namespace services | 163 } // namespace services |
| 157 } // namespace mojo | 164 } // namespace mojo |
| OLD | NEW |