Skip to content

Commit 4eb9166

Browse files
committed
Allowed for Aero Snap for GetMainWindowPosition/GetWorldWindowPosition
1 parent 2b8d15d commit 4eb9166

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

scripting/lua_methods.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,10 +3059,21 @@ static void luaWindowPositionHelper (lua_State *L, const RECT & r)
30593059
//----------------------------------------
30603060
static int L_GetMainWindowPosition (lua_State *L)
30613061
{
3062-
CWindowPlacement wp;
3063-
Frame.GetWindowPlacement(&wp);
3062+
bool useGetWindowRect = optboolean (L, 1, 0); // if true use GetWindowRect
3063+
3064+
if (useGetWindowRect)
3065+
{
3066+
CRect rect;
3067+
Frame.GetWindowRect (&rect);
3068+
luaWindowPositionHelper (L, rect);
3069+
}
3070+
else
3071+
{
3072+
CWindowPlacement wp;
3073+
Frame.GetWindowPlacement(&wp);
3074+
luaWindowPositionHelper (L, wp.rcNormalPosition);
3075+
}
30643076

3065-
luaWindowPositionHelper (L, wp.rcNormalPosition);
30663077
return 1; // number of result fields
30673078
} // end of L_GetMainWindowPosition
30683079

@@ -3109,9 +3120,9 @@ static int L_GetWorldWindowPosition (lua_State *L)
31093120
CMUSHclientDoc *pDoc = doc (L);
31103121
int which = my_optnumber (L, 1, 1); // Which
31113122
bool screen = optboolean (L, 2, 0); // client or screen
3123+
bool useGetWindowRect = optboolean (L, 3, 0); // if true use GetWindowRect
31123124
int count = 0;
31133125

3114-
CWindowPlacement wp;
31153126

31163127
for(POSITION pos=pDoc->GetFirstViewPosition();pos!=NULL;)
31173128
{
@@ -3126,13 +3137,22 @@ static int L_GetWorldWindowPosition (lua_State *L)
31263137
continue; // wrong one
31273138

31283139
// pmyView->GetParentFrame ()->GetClientRect (&wp.rcNormalPosition);
3129-
pmyView->GetParentFrame ()->GetWindowPlacement(&wp);
31303140

3131-
if (screen)
3141+
CRect rect;
3142+
if (useGetWindowRect)
31323143
{
3133-
pmyView->GetParentFrame ()->ClientToScreen (&wp.rcNormalPosition);
3144+
pmyView->GetParentFrame ()->GetWindowRect (&rect);
31343145
}
3135-
luaWindowPositionHelper (L, wp.rcNormalPosition);
3146+
else
3147+
{
3148+
CWindowPlacement wp;
3149+
pmyView->GetParentFrame ()->GetWindowPlacement(&wp);
3150+
rect = wp.rcNormalPosition;
3151+
}
3152+
3153+
if (screen)
3154+
pmyView->GetParentFrame ()->ClientToScreen (&rect);
3155+
luaWindowPositionHelper (L, rect);
31363156
return 1; // number of result fields
31373157

31383158
}

0 commit comments

Comments
 (0)