| 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 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_H_ |
| 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "mojo/public/cpp/bindings/array.h" | 14 #include "mojo/public/cpp/bindings/array.h" |
| 15 #include "services/shell/public/interfaces/interface_provider.mojom.h" | 15 #include "services/shell/public/interfaces/interface_provider.mojom.h" |
| 16 #include "services/ui/common/types.h" | 16 #include "services/ui/common/types.h" |
| 17 #include "services/ui/public/interfaces/mus_constants.mojom.h" | 17 #include "services/ui/public/interfaces/mus_constants.mojom.h" |
| 18 #include "services/ui/public/interfaces/window_tree.mojom.h" | 18 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 19 #include "ui/gfx/geometry/insets.h" | 19 #include "ui/gfx/geometry/insets.h" |
| 20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 class Size; | 23 class Size; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 | 27 |
| 28 class InputEventHandler; | 28 class InputEventHandler; |
| 29 class ServiceProviderImpl; | 29 class ServiceProviderImpl; |
| 30 class SurfaceIdHandler; |
| 30 class WindowObserver; | 31 class WindowObserver; |
| 31 class WindowSurface; | 32 class WindowSurface; |
| 32 class WindowSurfaceBinding; | 33 class WindowSurfaceBinding; |
| 33 class WindowDropTarget; | 34 class WindowDropTarget; |
| 34 class WindowTreeClient; | 35 class WindowTreeClient; |
| 35 class WindowTreeClientPrivate; | 36 class WindowTreeClientPrivate; |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 class OrderChangedNotifier; | 39 class OrderChangedNotifier; |
| 39 } | 40 } |
| 40 | 41 |
| 41 // Defined in window_property.h (which we do not include) | 42 // Defined in window_property.h (which we do not include) |
| 42 template <typename T> | 43 template <typename T> |
| 43 struct WindowProperty; | 44 struct WindowProperty; |
| 44 | 45 |
| 45 // Windows are owned by the WindowTreeClient. See WindowTreeClientDelegate for | 46 // Windows are owned by the WindowTreeClient. See WindowTreeClientDelegate for |
| 46 // details on ownership. | 47 // details on ownership. |
| 47 // | 48 // |
| 48 // TODO(beng): Right now, you'll have to implement a WindowObserver to track | 49 // TODO(beng): Right now, you'll have to implement a WindowObserver to track |
| 49 // destruction and NULL any pointers you have. | 50 // destruction and NULL any pointers you have. |
| 50 // Investigate some kind of smart pointer or weak pointer for these. | 51 // Investigate some kind of smart pointer or weak pointer for these. |
| 51 class Window { | 52 class Window { |
| 52 public: | 53 public: |
| 53 using Children = std::vector<Window*>; | 54 using Children = std::vector<Window*>; |
| 54 using EmbedCallback = base::Callback<void(bool)>; | 55 using EmbedCallback = base::Callback<void(bool)>; |
| 55 using PropertyDeallocator = void (*)(int64_t value); | 56 using PropertyDeallocator = void (*)(int64_t value); |
| 56 using SharedProperties = std::map<std::string, std::vector<uint8_t>>; | 57 using SharedProperties = std::map<std::string, std::vector<uint8_t>>; |
| 57 | 58 |
| 59 struct SurfaceInfo { |
| 60 cc::SurfaceId surface_id; |
| 61 cc::SurfaceSequence surface_sequence; |
| 62 gfx::Size frame_size; |
| 63 float device_scale_factor; |
| 64 }; |
| 65 |
| 58 // Destroys this window and all its children. Destruction is allowed for | 66 // Destroys this window and all its children. Destruction is allowed for |
| 59 // windows that were created by this connection, or the roots. For windows | 67 // windows that were created by this connection, or the roots. For windows |
| 60 // from other connections (except the roots), Destroy() does nothing. If the | 68 // from other connections (except the roots), Destroy() does nothing. If the |
| 61 // destruction is allowed observers are notified and the Window is | 69 // destruction is allowed observers are notified and the Window is |
| 62 // immediately deleted. | 70 // immediately deleted. |
| 63 void Destroy(); | 71 void Destroy(); |
| 64 | 72 |
| 65 // Returns true if this client created and owns this window. | 73 // Returns true if this client created and owns this window. |
| 66 bool WasCreatedByThisClient() const; | 74 bool WasCreatedByThisClient() const; |
| 67 | 75 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // | 163 // |
| 156 // These properties are only visible in the current process and are not | 164 // These properties are only visible in the current process and are not |
| 157 // shared with other mojo services. | 165 // shared with other mojo services. |
| 158 template <typename T> | 166 template <typename T> |
| 159 void ClearLocalProperty(const WindowProperty<T>* property); | 167 void ClearLocalProperty(const WindowProperty<T>* property); |
| 160 | 168 |
| 161 void set_input_event_handler(InputEventHandler* input_event_handler) { | 169 void set_input_event_handler(InputEventHandler* input_event_handler) { |
| 162 input_event_handler_ = input_event_handler; | 170 input_event_handler_ = input_event_handler; |
| 163 } | 171 } |
| 164 | 172 |
| 173 void set_surface_id_handler(SurfaceIdHandler* surface_id_handler) { |
| 174 surface_id_handler_ = surface_id_handler; |
| 175 } |
| 176 |
| 165 // Observation. | 177 // Observation. |
| 166 void AddObserver(WindowObserver* observer); | 178 void AddObserver(WindowObserver* observer); |
| 167 void RemoveObserver(WindowObserver* observer); | 179 void RemoveObserver(WindowObserver* observer); |
| 168 | 180 |
| 169 // Tree. | 181 // Tree. |
| 170 Window* parent() { return parent_; } | 182 Window* parent() { return parent_; } |
| 171 const Window* parent() const { return parent_; } | 183 const Window* parent() const { return parent_; } |
| 172 | 184 |
| 173 Window* GetRoot() { | 185 Window* GetRoot() { |
| 174 return const_cast<Window*>(const_cast<const Window*>(this)->GetRoot()); | 186 return const_cast<Window*>(const_cast<const Window*>(this)->GetRoot()); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 void LocalSetClientArea( | 314 void LocalSetClientArea( |
| 303 const gfx::Insets& new_client_area, | 315 const gfx::Insets& new_client_area, |
| 304 const std::vector<gfx::Rect>& additional_client_areas); | 316 const std::vector<gfx::Rect>& additional_client_areas); |
| 305 void LocalSetParentDrawn(bool drawn); | 317 void LocalSetParentDrawn(bool drawn); |
| 306 void LocalSetDisplay(int64_t display_id); | 318 void LocalSetDisplay(int64_t display_id); |
| 307 void LocalSetVisible(bool visible); | 319 void LocalSetVisible(bool visible); |
| 308 void LocalSetOpacity(float opacity); | 320 void LocalSetOpacity(float opacity); |
| 309 void LocalSetPredefinedCursor(mojom::Cursor cursor_id); | 321 void LocalSetPredefinedCursor(mojom::Cursor cursor_id); |
| 310 void LocalSetSharedProperty(const std::string& name, | 322 void LocalSetSharedProperty(const std::string& name, |
| 311 const std::vector<uint8_t>* data); | 323 const std::vector<uint8_t>* data); |
| 324 void LocalSetSurfaceId(std::unique_ptr<SurfaceInfo> surface_info); |
| 312 | 325 |
| 313 // Notifies this winodw that its stacking position has changed. | 326 // Notifies this winodw that its stacking position has changed. |
| 314 void NotifyWindowStackingChanged(); | 327 void NotifyWindowStackingChanged(); |
| 315 // Methods implementing visibility change notifications. See WindowObserver | 328 // Methods implementing visibility change notifications. See WindowObserver |
| 316 // for more details. | 329 // for more details. |
| 317 void NotifyWindowVisibilityChanged(Window* target, bool visible); | 330 void NotifyWindowVisibilityChanged(Window* target, bool visible); |
| 318 // Notifies this window's observers. Returns false if |this| was deleted | 331 // Notifies this window's observers. Returns false if |this| was deleted |
| 319 // during the call (by an observer), otherwise true. | 332 // during the call (by an observer), otherwise true. |
| 320 bool NotifyWindowVisibilityChangedAtReceiver(Window* target, bool visible); | 333 bool NotifyWindowVisibilityChangedAtReceiver(Window* target, bool visible); |
| 321 // Notifies this window and its child hierarchy. Returns false if |this| was | 334 // Notifies this window and its child hierarchy. Returns false if |this| was |
| (...skipping 27 matching lines...) Expand all Loading... |
| 349 Children children_; | 362 Children children_; |
| 350 | 363 |
| 351 Window* stacking_target_; | 364 Window* stacking_target_; |
| 352 Window* transient_parent_; | 365 Window* transient_parent_; |
| 353 Children transient_children_; | 366 Children transient_children_; |
| 354 | 367 |
| 355 bool is_modal_; | 368 bool is_modal_; |
| 356 | 369 |
| 357 base::ObserverList<WindowObserver> observers_; | 370 base::ObserverList<WindowObserver> observers_; |
| 358 InputEventHandler* input_event_handler_; | 371 InputEventHandler* input_event_handler_; |
| 372 SurfaceIdHandler* surface_id_handler_; |
| 359 | 373 |
| 360 gfx::Rect bounds_; | 374 gfx::Rect bounds_; |
| 361 gfx::Insets client_area_; | 375 gfx::Insets client_area_; |
| 362 std::vector<gfx::Rect> additional_client_areas_; | 376 std::vector<gfx::Rect> additional_client_areas_; |
| 363 std::unique_ptr<gfx::Rect> hit_test_mask_; | 377 std::unique_ptr<gfx::Rect> hit_test_mask_; |
| 364 | 378 |
| 365 bool visible_; | 379 bool visible_; |
| 366 float opacity_; | 380 float opacity_; |
| 367 int64_t display_id_; | 381 int64_t display_id_; |
| 368 | 382 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 386 // Key cannot be used for this purpose because it can be char* or | 400 // Key cannot be used for this purpose because it can be char* or |
| 387 // WindowProperty<>. | 401 // WindowProperty<>. |
| 388 struct Value { | 402 struct Value { |
| 389 const char* name; | 403 const char* name; |
| 390 int64_t value; | 404 int64_t value; |
| 391 PropertyDeallocator deallocator; | 405 PropertyDeallocator deallocator; |
| 392 }; | 406 }; |
| 393 | 407 |
| 394 std::map<const void*, Value> prop_map_; | 408 std::map<const void*, Value> prop_map_; |
| 395 | 409 |
| 410 std::unique_ptr<SurfaceInfo> surface_info_; |
| 411 |
| 396 DISALLOW_COPY_AND_ASSIGN(Window); | 412 DISALLOW_COPY_AND_ASSIGN(Window); |
| 397 }; | 413 }; |
| 398 | 414 |
| 399 } // namespace ui | 415 } // namespace ui |
| 400 | 416 |
| 401 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_H_ | 417 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_H_ |
| OLD | NEW |