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

Function Apply

libop/window/WindowLayout.cpp:280–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280long Apply(const std::vector<HWND> &windows, const std::vector<Rect> &rects, const Options &options) {
281 if (windows.empty() || windows.size() != rects.size()) {
282 return 0;
283 }
284
285 for (size_t i = 0; i < windows.size(); ++i) {
286 if (!::IsWindow(windows[i])) {
287 return 0;
288 }
289
290 const auto &rect = rects[i];
291 Metrics initial_metrics = {};
292 const bool has_initial_metrics = GetWindowMetrics(windows[i], initial_metrics);
293 if (!::SetWindowPos(windows[i], nullptr, rect.x, rect.y, rect.width, rect.height,
294 SWP_NOZORDER | SWP_NOACTIVATE)) {
295 return 0;
296 }
297
298 // 某些窗口会吞掉尺寸修改,这里做一次结果校验,避免误报成功。
299 ::Sleep(100);
300 if (options.anchor_mode == AnchorMode::Client) {
301 if (!MatchesTargetClientSize(windows[i], options)) {
302 return 0;
303 }
304 if (has_initial_metrics && !MatchesTargetClientRect(windows[i], rect, initial_metrics)) {
305 return 0;
306 }
307 } else if (!MatchesTargetSize(windows[i], rect)) {
308 return 0;
309 }
310 }
311
312 return 1;
313}
314
315long Layout(const std::vector<HWND> &windows, const Options &options) {
316 if (windows.empty()) {

Callers 1

LayoutFunction · 0.85

Calls 6

GetWindowMetricsFunction · 0.85
MatchesTargetClientSizeFunction · 0.85
MatchesTargetClientRectFunction · 0.85
MatchesTargetSizeFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected