OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "ui/views/test/widget_test.h" | 5 #include "ui/views/test/widget_test.h" |
6 | 6 |
7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/aura/window_tree_host.h" | 8 #include "ui/aura/window_tree_host.h" |
9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
10 | 10 |
| 11 #if defined(USE_X11) |
| 12 #include <X11/Xutil.h> |
| 13 #include "ui/gfx/x/x11_types.h" |
| 14 #endif |
| 15 |
11 namespace views { | 16 namespace views { |
12 namespace test { | 17 namespace test { |
13 | 18 |
14 namespace { | 19 namespace { |
15 | 20 |
16 // Perform a pre-order traversal of |children| and all descendants, looking for | 21 // Perform a pre-order traversal of |children| and all descendants, looking for |
17 // |first| and |second|. If |first| is found before |second|, return true. | 22 // |first| and |second|. If |first| is found before |second|, return true. |
18 // When a layer is found, it is set to null. Returns once |second| is found, or | 23 // When a layer is found, it is set to null. Returns once |second| is found, or |
19 // when there are no children left. | 24 // when there are no children left. |
20 // Note that ui::Layer children are bottom-to-top stacking order. | 25 // Note that ui::Layer children are bottom-to-top stacking order. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 64 |
60 ui::Layer* root_layer = above->GetNativeWindow()->GetRootWindow()->layer(); | 65 ui::Layer* root_layer = above->GetNativeWindow()->GetRootWindow()->layer(); |
61 | 66 |
62 // Traversal is bottom-to-top, so |below| should be found first. | 67 // Traversal is bottom-to-top, so |below| should be found first. |
63 const ui::Layer* first = below->GetLayer(); | 68 const ui::Layer* first = below->GetLayer(); |
64 const ui::Layer* second = above->GetLayer(); | 69 const ui::Layer* second = above->GetLayer(); |
65 return FindLayersInOrder(root_layer->children(), &first, &second); | 70 return FindLayersInOrder(root_layer->children(), &first, &second); |
66 } | 71 } |
67 | 72 |
68 // static | 73 // static |
| 74 gfx::Size WidgetTest::GetNativeWidgetMinimumContentSize(Widget* widget) { |
| 75 // On Windows, HWNDMessageHandler receives a WM_GETMINMAXINFO message whenever |
| 76 // the window manager is interested in knowing the size constraints. On |
| 77 // ChromeOS, it's handled internally. Elsewhere, the size constraints need to |
| 78 // be pushed to the window server when they change. |
| 79 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 80 return widget->GetNativeWindow()->delegate()->GetMinimumSize(); |
| 81 #elif defined(USE_X11) |
| 82 XSizeHints hints; |
| 83 long supplied_return; |
| 84 XGetWMNormalHints( |
| 85 gfx::GetXDisplay(), |
| 86 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget(), &hints, |
| 87 &supplied_return); |
| 88 return gfx::Size(hints.min_width, hints.min_height); |
| 89 #else |
| 90 NOTREACHED(); |
| 91 #endif |
| 92 } |
| 93 |
| 94 // static |
69 ui::EventProcessor* WidgetTest::GetEventProcessor(Widget* widget) { | 95 ui::EventProcessor* WidgetTest::GetEventProcessor(Widget* widget) { |
70 return widget->GetNativeWindow()->GetHost()->event_processor(); | 96 return widget->GetNativeWindow()->GetHost()->event_processor(); |
71 } | 97 } |
72 | 98 |
73 } // namespace test | 99 } // namespace test |
74 } // namespace views | 100 } // namespace views |
OLD | NEW |