Skip to content

Commit 97ccfd4

Browse files
committed
[19277] Compute effective rect of stack correctly
1 parent b7cbc7e commit 97ccfd4

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

engine/src/desktop-stack.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,12 @@ MCRectangle MCStack::view_platform_getwindowrect() const
231231
{
232232
MCRectangle t_content_rect, t_diff_rect;
233233
MCscreen->platform_getwindowgeometry(window, t_content_rect);
234-
t_diff_rect = MCU_subtract_rect(t_content_rect, t_frame_rect);
234+
// the content rect of a window should always be contained (or equal) to the frame rect
235+
// so compute these 4 margins and then apply them to the rect of the stack
236+
t_diff_rect.x = rect.x + (t_content_rect.x - t_frame_rect.x);
237+
t_diff_rect.y = rect.y + (t_content_rect.y - t_frame_rect.y);
238+
t_diff_rect.width = rect.width + (t_frame_rect.width - t_content_rect.width);
239+
t_diff_rect.height = rect.height + (t_frame_rect.height - t_content_rect.height);
235240
return t_diff_rect;
236241
}
237242

engine/src/lnxstack.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,12 @@ MCRectangle MCStack::view_device_getwindowrect(void) const
496496
{
497497
MCRectangle t_content_rect, t_diff_rect;
498498
MCscreen->platform_getwindowgeometry(window, t_content_rect);
499-
t_diff_rect = MCU_subtract_rect(t_content_rect, t_frame_rect);
499+
// the content rect of a window should always be contained (or equal) to the frame rect
500+
// so compute these 4 margins and then apply them to the rect of the stack
501+
t_diff_rect.x = rect.x + (t_content_rect.x - t_frame_rect.x);
502+
t_diff_rect.y = rect.y + (t_content_rect.y - t_frame_rect.y);
503+
t_diff_rect.width = rect.width + (t_frame_rect.width - t_content_rect.width);
504+
t_diff_rect.height = rect.height + (t_frame_rect.height - t_content_rect.height);
500505
return t_diff_rect;
501506
}
502507

engine/src/w32stack.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,12 @@ MCRectangle MCStack::view_platform_getwindowrect() const
497497
{
498498
MCRectangle t_content_rect, t_diff_rect;
499499
MCscreen->platform_getwindowgeometry((HWND)window->handle.window, t_content_rect);
500-
t_diff_rect = MCU_subtract_rect(t_content_rect, t_frame_rect);
500+
// the content rect of a window should always be contained (or equal) to the frame rect
501+
// so compute these 4 margins and then apply them to the rect of the stack
502+
t_diff_rect.x = rect.x + (t_content_rect.x - t_frame_rect.x);
503+
t_diff_rect.y = rect.y + (t_content_rect.y - t_frame_rect.y);
504+
t_diff_rect.width = rect.width + (t_frame_rect.width - t_content_rect.width);
505+
t_diff_rect.height = rect.height + (t_frame_rect.height - t_content_rect.height);
501506
return t_diff_rect;
502507
}
503508

0 commit comments

Comments
 (0)