Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit cb735d9

Browse filesBrowse files
Merge pull request #6815 from livecodepanos/bugfix-19277
[19277] Ensure the effective rect is fetched correctly when screen is locked
2 parents b125ee9 + 0011c72 commit cb735d9
Copy full SHA for cb735d9

File tree

Expand file treeCollapse file tree

5 files changed

+80
-11
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+80
-11
lines changed

‎docs/notes/bugfix-19277.md

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure the effective rect is fetched correctly when screen is locked

‎engine/src/desktop-stack.cpp

Copy file name to clipboardExpand all lines: engine/src/desktop-stack.cpp
+17-3Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,23 @@ void MCStack::realize(void)
225225

226226
MCRectangle MCStack::view_platform_getwindowrect() const
227227
{
228-
MCRectangle t_rect;
229-
MCPlatformGetWindowFrameRect(window, t_rect);
230-
return t_rect;
228+
MCRectangle t_frame_rect;
229+
MCPlatformGetWindowFrameRect(window, t_frame_rect);
230+
if (MClockscreen != 0)
231+
{
232+
MCRectangle t_content_rect, t_diff_rect;
233+
MCscreen->platform_getwindowgeometry(window, t_content_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);
240+
return t_diff_rect;
241+
}
242+
243+
return t_frame_rect;
244+
231245
}
232246

233247
bool MCStack::view_platform_dirtyviewonresize() const

‎engine/src/lnxstack.cpp

Copy file name to clipboardExpand all lines: engine/src/lnxstack.cpp
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,23 @@ MCRectangle MCStack::view_device_getwindowrect(void) const
489489
{
490490
GdkRectangle t_frame;
491491
gdk_window_get_frame_extents(window, &t_frame);
492-
return MCRectangleMake(t_frame . x, t_frame . y, t_frame . width, t_frame . height);
492+
MCRectangle t_frame_rect;
493+
t_frame_rect = MCRectangleMake(t_frame . x, t_frame . y, t_frame . width, t_frame . height);
494+
495+
if (MClockscreen != 0)
496+
{
497+
MCRectangle t_content_rect, t_diff_rect;
498+
MCscreen->platform_getwindowgeometry(window, t_content_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);
505+
return t_diff_rect;
506+
}
507+
508+
return t_frame_rect;
493509
}
494510

495511
// IM-2014-01-29: [[ HiDPI ]] Placeholder method for Linux HiDPI support

‎engine/src/w32stack.cpp

Copy file name to clipboardExpand all lines: engine/src/w32stack.cpp
+20-7Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,13 +487,26 @@ MCRectangle MCStack::view_platform_getwindowrect() const
487487
RECT wrect;
488488
GetWindowRect((HWND)window->handle.window, &wrect);
489489

490-
MCRectangle t_rect;
491-
t_rect = MCRectangleFromWin32RECT(wrect);
492-
493-
// IM-2014-01-28: [[ HiDPI ]] Convert screen to logical coords
494-
t_rect = MCscreen->screentologicalrect(t_rect);
495-
496-
return t_rect;
490+
MCRectangle t_frame_rect;
491+
t_frame_rect = MCRectangleFromWin32RECT(wrect);
492+
493+
// IM-2014-01-28: [[ HiDPI ]] Convert screen to logical coords
494+
t_frame_rect = MCscreen->screentologicalrect(t_frame_rect);
495+
496+
if (MClockscreen != 0)
497+
{
498+
MCRectangle t_content_rect, t_diff_rect;
499+
MCscreen->platform_getwindowgeometry(window, t_content_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);
506+
return t_diff_rect;
507+
}
508+
509+
return t_frame_rect;
497510
}
498511

499512
// IM-2013-09-23: [[ FullscreenMode ]] Factor out device-specific window sizing

‎tests/lcs/core/engine/engine.livecodescript

Copy file name to clipboardExpand all lines: tests/lcs/core/engine/engine.livecodescript
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,31 @@ wait 2 ticks
501501
TestAssert "the ticks change with time", the ticks - tTime >= 2
502502
end TestTicks
503503

504+
on TestEffectiveRectIsUpdatedWhileScreenIsLocked
505+
local tRectBefore, tRectAfter, tEffectiveRectBefore, tEffectiveRectAfter
506+
507+
local tLeft,tTop
508+
put 100 into tLeft
509+
put 200 into tTop
510+
511+
create stack "TestStack"
512+
put the rect of stack "TestStack" into tRectBefore
513+
lock screen
514+
set the top of stack "TestStack" to the top of stack "TestStack" + tTop
515+
set the left of stack "TestStack" to the left of stack "TestStack" + tLeft
516+
put the effective rect of stack "TestStack" into tEffectiveRectBefore
517+
put the rect of stack "TestStack" into tRectAfter
518+
unlock screen
519+
put the effective rect of stack "TestStack" into tEffectiveRectAfter
520+
add tTop to item 2 of tRectBefore
521+
add tTop to item 4 of tRectBefore
522+
add tLeft to item 1 of tRectBefore
523+
add tLeft to item 3 of tRectBefore
524+
TestAssert "rect of stack is updated while screen is locked", tRectBefore is tRectAfter
525+
TestAssert "effective rect of stack is updated while screen is locked", tEffectiveRectBefore is tEffectiveRectAfter
526+
delete stack "TestStack"
527+
end TestEffectiveRectIsUpdatedWhileScreenIsLocked
528+
504529
on TestUngroupAndQuit
505530
-- Bug 21500: run a subprocess in which we ungroup a group and
506531
-- then quit, to test that it no longer crashes

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.