MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / AdjustWindowPosition

Method AdjustWindowPosition

TranslucentTB/uwp/basexamlpagehost.cpp:74–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74bool BaseXamlPageHost::AdjustWindowPosition(int &x, int &y, int width, int height, const RECT &workArea) noexcept
75{
76 RECT coords = { x, y, x + width, y + height };
77 if (win32::RectFitsInRect(workArea, coords))
78 {
79 // It fits, nothing to do.
80 return false;
81 }
82
83 const bool rightDoesntFits = coords.right > workArea.right;
84 const bool leftDoesntFits = coords.left < workArea.left;
85 const bool bottomDoesntFits = coords.bottom > workArea.bottom;
86 const bool topDoesntFits = coords.top < workArea.top;
87
88 if ((rightDoesntFits && leftDoesntFits) || (bottomDoesntFits && topDoesntFits))
89 {
90 // Doesn't fits in the monitor work area :(
91 return true;
92 }
93
94 // Offset the rect so that it is completely in the work area
95 int x_offset = 0;
96 if (rightDoesntFits)
97 {
98 x_offset = workArea.right - coords.right; // Negative offset
99 }
100 else if (leftDoesntFits)
101 {
102 x_offset = workArea.left - coords.left;
103 }
104
105 int y_offset = 0;
106 if (bottomDoesntFits)
107 {
108 y_offset = workArea.bottom - coords.bottom; // Negative offset
109 }
110 else if (topDoesntFits)
111 {
112 y_offset = workArea.top - coords.top;
113 }
114
115 win32::OffsetRect(coords, x_offset, y_offset);
116 x = coords.left;
117 y = coords.top;
118
119 return true;
120}
121
122LRESULT BaseXamlPageHost::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam)
123{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected