1 // Copyright 2019 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 UI_PLATFORM_WINDOW_PLATFORM_WINDOW_DELEGATE_H_
6 #define UI_PLATFORM_WINDOW_PLATFORM_WINDOW_DELEGATE_H_
7 
8 #include "base/component_export.h"
9 #include "base/optional.h"
10 #include "ui/gfx/native_widget_types.h"
11 
12 namespace gfx {
13 class Rect;
14 class Size;
15 }  // namespace gfx
16 
17 namespace ui {
18 
19 class Event;
20 
21 enum class PlatformWindowState {
22   kUnknown,
23   kMaximized,
24   kMinimized,
25   kNormal,
26   kFullScreen,
27 };
28 
COMPONENT_EXPORT(PLATFORM_WINDOW)29 class COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowDelegate {
30  public:
31   PlatformWindowDelegate();
32   virtual ~PlatformWindowDelegate();
33 
34   // Note that |new_bounds| is in physical screen coordinates.
35   virtual void OnBoundsChanged(const gfx::Rect& new_bounds) = 0;
36 
37   // Note that |damaged_region| is in the platform-window's coordinates, in
38   // physical pixels.
39   virtual void OnDamageRect(const gfx::Rect& damaged_region) = 0;
40 
41   virtual void DispatchEvent(Event* event) = 0;
42 
43   virtual void OnCloseRequest() = 0;
44   virtual void OnClosed() = 0;
45 
46   virtual void OnWindowStateChanged(PlatformWindowState new_state) = 0;
47 
48   virtual void OnLostCapture() = 0;
49 
50   virtual void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) = 0;
51 
52   // Notifies the delegate that the widget is about to be destroyed.
53   virtual void OnWillDestroyAcceleratedWidget() = 0;
54 
55   // Notifies the delegate that the widget cannot be used anymore until
56   // a new widget is made available through OnAcceleratedWidgetAvailable().
57   // Must not be called when the PlatformWindow is being destroyed.
58   virtual void OnAcceleratedWidgetDestroyed() = 0;
59 
60   virtual void OnActivationChanged(bool active) = 0;
61 
62   // Requests size constraints for the PlatformWindow.
63   virtual base::Optional<gfx::Size> GetMinimumSizeForWindow();
64   virtual base::Optional<gfx::Size> GetMaximumSizeForWindow();
65 
66   // Called when the location of mouse pointer entered the window.  This is
67   // different from ui::ET_MOUSE_ENTERED which may not be generated when mouse
68   // is captured either by implicitly or explicitly.
69   virtual void OnMouseEnter() = 0;
70 };
71 
72 }  // namespace ui
73 
74 #endif  // UI_PLATFORM_WINDOW_PLATFORM_WINDOW_DELEGATE_H_
75