OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_AURA_WINDOW_H_ | 5 #ifndef UI_AURA_WINDOW_H_ |
6 #define UI_AURA_WINDOW_H_ | 6 #define UI_AURA_WINDOW_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | |
12 #include <string> | 13 #include <string> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
18 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
19 #include "ui/aura/aura_export.h" | 20 #include "ui/aura/aura_export.h" |
20 #include "ui/aura/window_observer.h" | 21 #include "ui/aura/window_observer.h" |
21 #include "ui/compositor/layer_animator.h" | 22 #include "ui/compositor/layer_animator.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
43 class EventHandler; | 44 class EventHandler; |
44 class Layer; | 45 class Layer; |
45 class TextInputClient; | 46 class TextInputClient; |
46 class Texture; | 47 class Texture; |
47 } | 48 } |
48 | 49 |
49 namespace aura { | 50 namespace aura { |
50 | 51 |
51 class LayoutManager; | 52 class LayoutManager; |
52 class WindowDelegate; | 53 class WindowDelegate; |
54 class WindowPort; | |
53 class WindowObserver; | 55 class WindowObserver; |
54 class WindowTreeHost; | 56 class WindowTreeHost; |
55 | 57 |
56 // Defined in window_property.h (which we do not include) | 58 // Defined in window_property.h (which we do not include) |
57 template<typename T> | 59 template<typename T> |
58 struct WindowProperty; | 60 struct WindowProperty; |
59 | 61 |
60 namespace subtle { | 62 namespace subtle { |
61 class PropertyHelper; | 63 class PropertyHelper; |
62 } | 64 } |
(...skipping 15 matching lines...) Expand all Loading... | |
78 | 80 |
79 // Used when stacking windows. | 81 // Used when stacking windows. |
80 enum StackDirection { | 82 enum StackDirection { |
81 STACK_ABOVE, | 83 STACK_ABOVE, |
82 STACK_BELOW | 84 STACK_BELOW |
83 }; | 85 }; |
84 | 86 |
85 typedef std::vector<Window*> Windows; | 87 typedef std::vector<Window*> Windows; |
86 | 88 |
87 explicit Window(WindowDelegate* delegate); | 89 explicit Window(WindowDelegate* delegate); |
90 Window(WindowDelegate* delegate, std::unique_ptr<WindowPort> port); | |
88 ~Window() override; | 91 ~Window() override; |
89 | 92 |
90 // Initializes the window. This creates the window's layer. | 93 // Initializes the window. This creates the window's layer. |
91 void Init(ui::LayerType layer_type); | 94 void Init(ui::LayerType layer_type); |
92 | 95 |
93 void set_owned_by_parent(bool owned_by_parent) { | 96 void set_owned_by_parent(bool owned_by_parent) { |
94 owned_by_parent_ = owned_by_parent; | 97 owned_by_parent_ = owned_by_parent; |
95 } | 98 } |
96 bool owned_by_parent() const { return owned_by_parent_; } | 99 bool owned_by_parent() const { return owned_by_parent_; } |
97 | 100 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 // Returns the value of the given window |property|. Returns the | 309 // Returns the value of the given window |property|. Returns the |
307 // property-specific default value if the property was not previously set. | 310 // property-specific default value if the property was not previously set. |
308 template<typename T> | 311 template<typename T> |
309 T GetProperty(const WindowProperty<T>* property) const; | 312 T GetProperty(const WindowProperty<T>* property) const; |
310 | 313 |
311 // Sets the |property| to its default value. Useful for avoiding a cast when | 314 // Sets the |property| to its default value. Useful for avoiding a cast when |
312 // setting to NULL. | 315 // setting to NULL. |
313 template<typename T> | 316 template<typename T> |
314 void ClearProperty(const WindowProperty<T>* property); | 317 void ClearProperty(const WindowProperty<T>* property); |
315 | 318 |
319 // Returns the value of all properties with a non-default value. | |
320 std::set<const void*> GetAllPropertKeys() const; | |
321 | |
316 // NativeWidget::[GS]etNativeWindowProperty use strings as keys, and this is | 322 // NativeWidget::[GS]etNativeWindowProperty use strings as keys, and this is |
317 // difficult to change while retaining compatibility with other platforms. | 323 // difficult to change while retaining compatibility with other platforms. |
318 // TODO(benrg): Find a better solution. | 324 // TODO(benrg): Find a better solution. |
319 void SetNativeWindowProperty(const char* key, void* value); | 325 void SetNativeWindowProperty(const char* key, void* value); |
320 void* GetNativeWindowProperty(const char* key) const; | 326 void* GetNativeWindowProperty(const char* key) const; |
321 | 327 |
322 // Type of a function to delete a property that this window owns. | 328 // Type of a function to delete a property that this window owns. |
323 typedef void (*PropertyDeallocator)(int64_t value); | 329 typedef void (*PropertyDeallocator)(int64_t value); |
324 | 330 |
325 // Overridden from ui::LayerDelegate: | 331 // Overridden from ui::LayerDelegate: |
326 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 332 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
327 | 333 |
328 #if !defined(NDEBUG) | 334 #if !defined(NDEBUG) |
329 // These methods are useful when debugging. | 335 // These methods are useful when debugging. |
330 std::string GetDebugInfo() const; | 336 std::string GetDebugInfo() const; |
331 void PrintWindowHierarchy(int depth) const; | 337 void PrintWindowHierarchy(int depth) const; |
332 #endif | 338 #endif |
333 | 339 |
334 // Returns true if there was state needing to be cleaned up. | 340 // Returns true if there was state needing to be cleaned up. |
335 bool CleanupGestureState(); | 341 bool CleanupGestureState(); |
336 | 342 |
337 protected: | 343 protected: |
338 // Deletes (or removes if not owned by parent) all child windows. Intended for | 344 // Deletes (or removes if not owned by parent) all child windows. Intended for |
339 // use from the destructor. | 345 // use from the destructor. |
340 void RemoveOrDestroyChildren(); | 346 void RemoveOrDestroyChildren(); |
341 | 347 |
342 private: | 348 private: |
343 friend class test::WindowTestApi; | |
344 friend class LayoutManager; | 349 friend class LayoutManager; |
350 friend class WindowPort; | |
345 friend class WindowTargeter; | 351 friend class WindowTargeter; |
346 friend class subtle::PropertyHelper; | 352 friend class subtle::PropertyHelper; |
353 friend class test::WindowTestApi; | |
354 | |
347 // Called by the public {Set,Get,Clear}Property functions. | 355 // Called by the public {Set,Get,Clear}Property functions. |
348 int64_t SetPropertyInternal(const void* key, | 356 int64_t SetPropertyInternal(const void* key, |
349 const char* name, | 357 const char* name, |
350 PropertyDeallocator deallocator, | 358 PropertyDeallocator deallocator, |
351 int64_t value, | 359 int64_t value, |
352 int64_t default_value); | 360 int64_t default_value); |
353 int64_t GetPropertyInternal(const void* key, int64_t default_value) const; | 361 int64_t GetPropertyInternal(const void* key, int64_t default_value) const; |
354 | 362 |
355 // Returns true if the mouse pointer at relative-to-this-Window's-origin | 363 // Returns true if the mouse pointer at relative-to-this-Window's-origin |
356 // |local_point| can trigger an event for this Window. | 364 // |local_point| can trigger an event for this Window. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 bool CanAcceptEvent(const ui::Event& event) override; | 461 bool CanAcceptEvent(const ui::Event& event) override; |
454 EventTarget* GetParentTarget() override; | 462 EventTarget* GetParentTarget() override; |
455 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; | 463 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
456 ui::EventTargeter* GetEventTargeter() override; | 464 ui::EventTargeter* GetEventTargeter() override; |
457 void ConvertEventToTarget(ui::EventTarget* target, | 465 void ConvertEventToTarget(ui::EventTarget* target, |
458 ui::LocatedEvent* event) override; | 466 ui::LocatedEvent* event) override; |
459 | 467 |
460 // Updates the layer name based on the window's name and id. | 468 // Updates the layer name based on the window's name and id. |
461 void UpdateLayerName(); | 469 void UpdateLayerName(); |
462 | 470 |
471 // Window owns its corresponding WindowPort, but the ref is held as a raw | |
472 // pointer so that |port_| is still valid while being destroyed. This is | |
473 // important as deleting the WindowPort may result in trying to lookup the | |
474 // |port_| associated with the Window. | |
475 WindowPort* port_; | |
sadrul
2016/10/26 04:25:55
Should we still use a unique_ptr<> here, and std::
sky
2016/10/26 16:25:21
I still need the ability to get the port_ during d
| |
476 | |
463 // Bounds of this window relative to the parent. This is cached as the bounds | 477 // Bounds of this window relative to the parent. This is cached as the bounds |
464 // of the Layer and Window are not necessarily the same. In particular bounds | 478 // of the Layer and Window are not necessarily the same. In particular bounds |
465 // of the Layer are relative to the first ancestor with a Layer, where as this | 479 // of the Layer are relative to the first ancestor with a Layer, where as this |
466 // is relative to the parent Window. | 480 // is relative to the parent Window. |
467 gfx::Rect bounds_; | 481 gfx::Rect bounds_; |
468 | 482 |
469 WindowTreeHost* host_; | 483 WindowTreeHost* host_; |
470 | 484 |
471 ui::wm::WindowType type_; | 485 ui::wm::WindowType type_; |
472 | 486 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 }; | 532 }; |
519 | 533 |
520 std::map<const void*, Value> prop_map_; | 534 std::map<const void*, Value> prop_map_; |
521 | 535 |
522 DISALLOW_COPY_AND_ASSIGN(Window); | 536 DISALLOW_COPY_AND_ASSIGN(Window); |
523 }; | 537 }; |
524 | 538 |
525 } // namespace aura | 539 } // namespace aura |
526 | 540 |
527 #endif // UI_AURA_WINDOW_H_ | 541 #endif // UI_AURA_WINDOW_H_ |
OLD | NEW |