| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_OBSERVER_H_ | |
| 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_OBSERVER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "services/ui/public/cpp/window.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 | |
| 16 class Window; | |
| 17 | |
| 18 // A note on -ing and -ed suffixes: | |
| 19 // | |
| 20 // -ing methods are called before changes are applied to the local window model. | |
| 21 // -ed methods are called after changes are applied to the local window model. | |
| 22 // | |
| 23 // If the change originated from another connection to the window manager, it's | |
| 24 // possible that the change has already been applied to the service-side model | |
| 25 // prior to being called, so for example in the case of OnWindowDestroying(), | |
| 26 // it's possible the window has already been destroyed on the service side. | |
| 27 | |
| 28 class WindowObserver { | |
| 29 public: | |
| 30 struct TreeChangeParams { | |
| 31 TreeChangeParams(); | |
| 32 // The window whose parent changed or is changing. | |
| 33 Window* target; | |
| 34 Window* old_parent; | |
| 35 Window* new_parent; | |
| 36 | |
| 37 // TreeChangeParams is supplied as an argument to various WindowObserver | |
| 38 // functions. |receiver| is the window being observed by the receipient of | |
| 39 // this notification, which may equal any of the struct members above. | |
| 40 // TODO(sky): move this outside of TreeChangeParams. | |
| 41 Window* receiver; | |
| 42 }; | |
| 43 | |
| 44 virtual void OnTreeChanging(const TreeChangeParams& params) {} | |
| 45 virtual void OnTreeChanged(const TreeChangeParams& params) {} | |
| 46 | |
| 47 virtual void OnWindowReordering(Window* window, | |
| 48 Window* relative_window, | |
| 49 mojom::OrderDirection direction) {} | |
| 50 virtual void OnWindowReordered(Window* window, | |
| 51 Window* relative_window, | |
| 52 mojom::OrderDirection direction) {} | |
| 53 | |
| 54 virtual void OnWindowDestroying(Window* window) {} | |
| 55 virtual void OnWindowDestroyed(Window* window) {} | |
| 56 | |
| 57 virtual void OnWindowBoundsChanging(Window* window, | |
| 58 const gfx::Rect& old_bounds, | |
| 59 const gfx::Rect& new_bounds) {} | |
| 60 virtual void OnWindowBoundsChanged(Window* window, | |
| 61 const gfx::Rect& old_bounds, | |
| 62 const gfx::Rect& new_bounds) {} | |
| 63 virtual void OnWindowLostCapture(Window* window) {} | |
| 64 virtual void OnWindowClientAreaChanged( | |
| 65 Window* window, | |
| 66 const gfx::Insets& old_client_area, | |
| 67 const std::vector<gfx::Rect>& old_additional_client_areas) {} | |
| 68 | |
| 69 virtual void OnWindowFocusChanged(Window* gained_focus, Window* lost_focus) {} | |
| 70 | |
| 71 virtual void OnWindowPredefinedCursorChanged(Window* window, | |
| 72 mojom::Cursor cursor) {} | |
| 73 | |
| 74 // Changing the visibility of a window results in the following sequence of | |
| 75 // functions being called: | |
| 76 // . OnWindowVisibilityChanging(): called on observers added to the window | |
| 77 // whose visibility is changing. This is called before the visibility has | |
| 78 // changed internally. | |
| 79 // The following are called after the visibility changes: | |
| 80 // . OnChildWindowVisibilityChanged(): called on observers added to the | |
| 81 // parent of the window whose visibility changed. This function is generally | |
| 82 // intended for layout managers that need to do processing before | |
| 83 // OnWindowVisibilityChanged() is called on observers of the window. | |
| 84 // . OnWindowVisibilityChanged(): called on observers added to the window | |
| 85 // whose visibility changed, as well as observers added to all ancestors and | |
| 86 // all descendants of the window. | |
| 87 virtual void OnWindowVisibilityChanging(Window* window, bool visible) {} | |
| 88 virtual void OnChildWindowVisibilityChanged(Window* window, bool visible) {} | |
| 89 virtual void OnWindowVisibilityChanged(Window* window, bool visible) {} | |
| 90 | |
| 91 virtual void OnWindowOpacityChanged(Window* window, | |
| 92 float old_opacity, | |
| 93 float new_opacity) {} | |
| 94 | |
| 95 // Invoked when this Window's shared properties have changed. This can either | |
| 96 // be caused by SetSharedProperty() being called locally, or by us receiving | |
| 97 // a mojo message that this property has changed. If this property has been | |
| 98 // added, |old_data| is null. If this property was removed, |new_data| is | |
| 99 // null. | |
| 100 virtual void OnWindowSharedPropertyChanged( | |
| 101 Window* window, | |
| 102 const std::string& name, | |
| 103 const std::vector<uint8_t>* old_data, | |
| 104 const std::vector<uint8_t>* new_data) {} | |
| 105 | |
| 106 // Invoked when SetProperty() or ClearProperty() is called on the window. | |
| 107 // |key| is either a WindowProperty<T>* (SetProperty, ClearProperty). Either | |
| 108 // way, it can simply be compared for equality with the property | |
| 109 // constant. |old| is the old property value, which must be cast to the | |
| 110 // appropriate type before use. | |
| 111 virtual void OnWindowLocalPropertyChanged(Window* window, | |
| 112 const void* key, | |
| 113 intptr_t old) {} | |
| 114 | |
| 115 virtual void OnWindowEmbeddedAppDisconnected(Window* window) {} | |
| 116 | |
| 117 // Sent when the drawn state changes. This is only sent for the root nodes | |
| 118 // when embedded. | |
| 119 virtual void OnWindowDrawnChanging(Window* window) {} | |
| 120 virtual void OnWindowDrawnChanged(Window* window) {} | |
| 121 | |
| 122 virtual void OnTransientChildAdded(Window* window, Window* transient) {} | |
| 123 virtual void OnTransientChildRemoved(Window* window, Window* transient) {} | |
| 124 | |
| 125 // The WindowManager has requested the window to close. If the observer | |
| 126 // allows the close it should destroy the window as appropriate. | |
| 127 virtual void OnRequestClose(Window* window) {} | |
| 128 | |
| 129 protected: | |
| 130 virtual ~WindowObserver() {} | |
| 131 }; | |
| 132 | |
| 133 } // namespace ui | |
| 134 | |
| 135 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_OBSERVER_H_ | |
| OLD | NEW |