MCPcopy Create free account
hub / github.com/WallBreaker2/op / BuildLayoutSeeds

Function BuildLayoutSeeds

libop/window/WindowLayout.cpp:159–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159std::vector<LayoutSeed> BuildLayoutSeeds(const std::vector<HWND> &windows, const Options &options) {
160 std::vector<LayoutSeed> seeds;
161 seeds.reserve(windows.size());
162
163 for (HWND hwnd : windows) {
164 LayoutSeed seed = {};
165 Metrics metrics = {};
166 Insets insets = {};
167 const bool has_metrics = GetWindowMetrics(hwnd, metrics);
168 if (has_metrics) {
169 GetInsets(metrics, insets);
170 }
171
172 // 保持原大小时,优先读取窗口当前尺寸。
173 if (options.size_mode == SizeMode::Keep) {
174 if (!GetWindowSize(hwnd, seed.rect.width, seed.rect.height)) {
175 seed.rect.width = options.window_width;
176 seed.rect.height = options.window_height;
177 }
178
179 if (options.anchor_mode == AnchorMode::Client && has_metrics) {
180 seed.anchor_width = metrics.client_rect.width;
181 seed.anchor_height = metrics.client_rect.height;
182 seed.anchor_offset_x = insets.left;
183 seed.anchor_offset_y = insets.top;
184 } else {
185 seed.anchor_width = seed.rect.width;
186 seed.anchor_height = seed.rect.height;
187 }
188 } else {
189 if (!BuildUniformWindowRect(hwnd, options, seed.rect)) {
190 seed.rect.width = options.window_width;
191 seed.rect.height = options.window_height;
192 }
193
194 if (options.anchor_mode == AnchorMode::Client && has_metrics) {
195 seed.anchor_width = options.window_width;
196 seed.anchor_height = options.window_height;
197 seed.anchor_offset_x = insets.left;
198 seed.anchor_offset_y = insets.top;
199 } else {
200 seed.anchor_width = seed.rect.width;
201 seed.anchor_height = seed.rect.height;
202 }
203 }
204
205 seeds.push_back(seed);
206 }
207
208 return seeds;
209}
210
211} // namespace
212

Callers 1

CalculateFunction · 0.85

Calls 5

GetWindowMetricsFunction · 0.85
GetInsetsFunction · 0.85
GetWindowSizeFunction · 0.85
BuildUniformWindowRectFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected