File: platform_window.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (209 lines) | stat: -rw-r--r-- 8,937 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_PLATFORM_WINDOW_PLATFORM_WINDOW_H_
#define UI_PLATFORM_WINDOW_PLATFORM_WINDOW_H_

#include <memory>
#include <string>
#include <vector>

#include "base/component_export.h"
#include "ui/base/class_property.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/platform_window/platform_window_delegate.h"

template <class T>
class scoped_refptr;

namespace gfx {
class ImageSkia;
class Point;
class Rect;
class SizeF;
class Transform;
}  // namespace gfx

namespace ui {
class PlatformCursor;

// Generic PlatformWindow interface.
class COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindow
    : public PropertyHandler {
 public:
  PlatformWindow();
  ~PlatformWindow() override;

  // PlatformWindow may be called with the |inactive| set to true in some cases.
  // That means that the Window Manager must not activate the window when it is
  // shown.  Most of PlatformWindow may ignore this value if not supported.
  virtual void Show(bool inactive = false) = 0;
  virtual void Hide() = 0;
  virtual void Close() = 0;

  virtual bool IsVisible() const = 0;

  // Informs the window it is going to be destroyed sometime soon. This is only
  // called for specific code paths, for example by Ash, so it shouldn't be
  // assumed this will get called before destruction.
  virtual void PrepareForShutdown() = 0;

  // Sets and gets the bounds of the platform-window. Note that the bounds is in
  // physical pixel coordinates. The implementation should use
  // `PlatformWindowDelegate::ConvertRectToPixels|DIP` if conversion is
  // necessary.
  virtual void SetBoundsInPixels(const gfx::Rect& bounds) = 0;
  virtual gfx::Rect GetBoundsInPixels() const = 0;

  // Sets and gets the bounds of the platform-window. Note that the bounds is in
  // device-independent-pixel (dip) coordinates. The implementation should use
  // `PlatformWindowDelegate::ConvertRectToPixels|DIP` if conversion is
  // necessary.
  virtual void SetBoundsInDIP(const gfx::Rect& bounds) = 0;
  virtual gfx::Rect GetBoundsInDIP() const = 0;

  virtual void SetTitle(const std::u16string& title) = 0;

  virtual void SetCapture() = 0;
  virtual void ReleaseCapture() = 0;
  virtual bool HasCapture() const = 0;

  // Sets and releases video capture state for the platform-window.
  virtual void SetVideoCapture();
  // NOTE: This may not be called if the platform-window is deleted while
  // video capture is still active.
  virtual void ReleaseVideoCapture();

  // Enters or exits fullscreen when `fullscreen` is true or false respectively.
  // This operation may have no effect if the window is already in the specified
  // state. `target_display_id` indicates the display where the window should be
  // shown fullscreen when entering into fullscreen; display::kInvalidDisplayId
  // indicates that no display was specified, so the current display may be
  // used.
  virtual void SetFullscreen(bool fullscreen, int64_t target_display_id) = 0;
  virtual void Maximize() = 0;
  virtual void Minimize() = 0;
  virtual void Restore() = 0;
  virtual void ShowWindowControlsMenu(const gfx::Point& point);
  virtual PlatformWindowState GetPlatformWindowState() const = 0;

  virtual void Activate() = 0;
  virtual void Deactivate() = 0;

  // Sets whether the window should have the standard title bar provided by the
  // underlying windowing system.  For the main browser window, this may be
  // changed by the user at any time via 'Show system title bar' option in the
  // tab strip menu.
  virtual void SetUseNativeFrame(bool use_native_frame) = 0;
  virtual bool ShouldUseNativeFrame() const = 0;

  // This method sets the current cursor to `cursor`. Note that the platform
  // window should keep a copy of `cursor` and also avoid replacing it until the
  // new value has been set if any kind of platform-specific resources are
  // managed by the platform cursor, e.g. HCURSOR on Windows, which are
  // destroyed once the last copy of the platform cursor goes out of scope.
  virtual void SetCursor(scoped_refptr<PlatformCursor> cursor) = 0;

  // Moves the cursor to |location|. Location is in platform window coordinates.
  virtual void MoveCursorTo(const gfx::Point& location) = 0;

  // Confines the cursor to |bounds| when it is in the platform window. |bounds|
  // is in platform window coordinates.
  virtual void ConfineCursorToBounds(const gfx::Rect& bounds) = 0;

  // Sets and gets the restored bounds of the platform-window.
  virtual void SetRestoredBoundsInDIP(const gfx::Rect& bounds) = 0;
  virtual gfx::Rect GetRestoredBoundsInDIP() const = 0;

  // Sets the Window icons. |window_icon| is a 16x16 icon suitable for use in
  // a title bar. |app_icon| is a larger size for use in the host environment
  // app switching UI.
  virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
                              const gfx::ImageSkia& app_icon) = 0;

  // Notifies that size constraints of the host have been changed and the
  // PlatformWindow must react on them accordingly.
  virtual void SizeConstraintsChanged() = 0;

  // Tells if the content of the platform window should be transparent. By
  // default returns false.
  virtual bool ShouldWindowContentsBeTransparent() const;

  // Sets and gets ZOrderLevel of the PlatformWindow. Such platforms that do not
  // support ordering, should not implement these methods as the default
  // implementation always returns ZOrderLevel::kNormal value.
  virtual void SetZOrderLevel(ZOrderLevel order);
  virtual ZOrderLevel GetZOrderLevel() const;

  // Asks the PlatformWindow to stack itself on top of |widget|.
  virtual void StackAbove(gfx::AcceleratedWidget widget);
  virtual void StackAtTop();

  // Flashes the frame of the window to draw attention to it. If |flash_frame|
  // is set, the PlatformWindow must draw attention to it. If |flash_frame| is
  // not set, flashing must be stopped.
  virtual void FlashFrame(bool flash_frame);

  using ShapeRects = std::vector<gfx::Rect>;
  // Sets shape of the PlatformWindow. ShapeRects corresponds to the
  // Widget::ShapeRects that is a vector of gfx::Rects that describe the shape.
  virtual void SetShape(std::unique_ptr<ShapeRects> native_shape,
                        const gfx::Transform& transform);

  // Sets the aspect ratio of the Platform Window, which will be
  // maintained during interactive resizing. This size disregards title bar and
  // borders. Once set, some platforms ensure the content will only size to
  // integer multiples of |aspect_ratio|.
  virtual void SetAspectRatio(const gfx::SizeF& aspect_ratio);

  // Returns true if the window was closed but is still showing because of
  // animations.
  virtual bool IsAnimatingClosed() const;

  // Sets opacity of the platform window.
  virtual void SetOpacity(float opacity);

  // Enables or disables platform provided animations of the PlatformWindow.
  // If |enabled| is set to false, animations are disabled.
  virtual void SetVisibilityChangedAnimationsEnabled(bool enabled);

  // Returns a unique ID for the window. The interpretation of the ID is
  // platform specific. Overriding this method is optional.
  virtual std::string GetWindowUniqueId() const;

  // Returns true if window shape should be updated in host,
  // otherwise false when platform window or specific frame views updates the
  // window shape.
  virtual bool ShouldUpdateWindowShape() const;

  // Returns true if the WM supports setting the frame extents for client side
  // decorations.  This typically requires a compositor and an extension for
  // specifying the decoration insets.
  virtual bool CanSetDecorationInsets() const;

  // Sets a hint for the compositor so it can avoid unnecessarily redrawing
  // occluded portions of windows.  If |region_px| is nullopt or empty, then any
  // existing region will be reset.
  virtual void SetOpaqueRegion(std::optional<std::vector<gfx::Rect>> region_px);

  // Sets the clickable region of a window.  This is useful for trimming down a
  // potentially large (24px) hit area for window resizing on the window shadow
  // to a more reasonable (10px) area.  If |region_px| is nullopt, then any
  // existing region will be reset.
  virtual void SetInputRegion(std::optional<std::vector<gfx::Rect>> region_px);

  // Whether the platform supports client-controlled window movement. Under
  // Wayland, for example, this returns false, unless the required protocol
  // extension is supported by the compositor.
  virtual bool IsClientControlledWindowMovementSupported() const;

  // Notifies the DE that the app is done loading, so that it can dismiss any
  // loading animations.
  virtual void NotifyStartupComplete(const std::string& startup_id);
};

}  // namespace ui

#endif  // UI_PLATFORM_WINDOW_PLATFORM_WINDOW_H_