https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0bfa0cd0d27a31580abc2d0598fdd1f02c49ee71

commit 0bfa0cd0d27a31580abc2d0598fdd1f02c49ee71
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sun Nov 26 11:46:42 2023 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sun Nov 26 11:46:42 2023 +0900

    [NTGDI] Fix PatBlt with negative values (#6038)
    
    When I am implementing the IME soft keyboard (#6021 and #6036),
    I noticed an issue with PatBlt function.
    
    - Fix the rectangle coordinates when the value was
      negative in NtGdiPatBlt function.
    - Fix NC_DrawFrame function.
    - Fix UserDrawWindowFrame function.
    
    CORE-19334
---
 win32ss/gdi/ntgdi/bitblt.c      | 12 ++++++------
 win32ss/user/ntuser/nonclient.c | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/win32ss/gdi/ntgdi/bitblt.c b/win32ss/gdi/ntgdi/bitblt.c
index c86bbbc53ba..ab45fe82019 100644
--- a/win32ss/gdi/ntgdi/bitblt.c
+++ b/win32ss/gdi/ntgdi/bitblt.c
@@ -858,26 +858,26 @@ IntPatBlt(
         return TRUE;
     }
 
-    if (Width > 0)
+    if (Width >= 0)
     {
         DestRect.left = XLeft;
         DestRect.right = XLeft + Width;
     }
     else
     {
-        DestRect.left = XLeft + Width + 1;
-        DestRect.right = XLeft + 1;
+        DestRect.left = XLeft + Width;
+        DestRect.right = XLeft;
     }
 
-    if (Height > 0)
+    if (Height >= 0)
     {
         DestRect.top = YLeft;
         DestRect.bottom = YLeft + Height;
     }
     else
     {
-        DestRect.top = YLeft + Height + 1;
-        DestRect.bottom = YLeft + 1;
+        DestRect.top = YLeft + Height;
+        DestRect.bottom = YLeft;
     }
 
     IntLPtoDP(pdc, (LPPOINT)&DestRect, 2);
diff --git a/win32ss/user/ntuser/nonclient.c b/win32ss/user/ntuser/nonclient.c
index 69291c50adb..a3852066b69 100644
--- a/win32ss/user/ntuser/nonclient.c
+++ b/win32ss/user/ntuser/nonclient.c
@@ -47,8 +47,8 @@ UserDrawWindowFrame(HDC hdc,
    HBRUSH hbrush = NtGdiSelectBrush( hdc, gpsi->hbrGray );
    NtGdiPatBlt( hdc, rect->left, rect->top, rect->right - rect->left - width, 
height, PATINVERT );
    NtGdiPatBlt( hdc, rect->left, rect->top + height, width, rect->bottom - 
rect->top - height, PATINVERT );
-   NtGdiPatBlt( hdc, rect->left + width, rect->bottom - 1, rect->right - 
rect->left - width, -(LONG)height, PATINVERT );
-   NtGdiPatBlt( hdc, rect->right - 1, rect->top, -(LONG)width, rect->bottom - 
rect->top - height, PATINVERT );
+   NtGdiPatBlt( hdc, rect->left + width, rect->bottom, rect->right - 
rect->left - width, -(LONG)height, PATINVERT );
+   NtGdiPatBlt( hdc, rect->right, rect->top, -(LONG)width, rect->bottom - 
rect->top - height, PATINVERT );
    NtGdiSelectBrush( hdc, hbrush );
 }
 
@@ -891,8 +891,8 @@ NC_DrawFrame( HDC hDC, RECT *CurrentRect, BOOL Active, 
DWORD Style, DWORD ExStyl
       /* Draw frame */
       NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, CurrentRect->right 
- CurrentRect->left, Height, PATCOPY);
       NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, Width, 
CurrentRect->bottom - CurrentRect->top, PATCOPY);
-      NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->bottom - 1, 
CurrentRect->right - CurrentRect->left, -Height, PATCOPY);
-      NtGdiPatBlt(hDC, CurrentRect->right - 1, CurrentRect->top, -Width, 
CurrentRect->bottom - CurrentRect->top, PATCOPY);
+      NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->bottom, 
CurrentRect->right - CurrentRect->left, -Height, PATCOPY);
+      NtGdiPatBlt(hDC, CurrentRect->right, CurrentRect->top, -Width, 
CurrentRect->bottom - CurrentRect->top, PATCOPY);
 
       RECTL_vInflateRect(CurrentRect, -Width, -Height);
    }
@@ -912,8 +912,8 @@ NC_DrawFrame( HDC hDC, RECT *CurrentRect, BOOL Active, 
DWORD Style, DWORD ExStyl
       /* Draw frame */
       NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, CurrentRect->right 
- CurrentRect->left, Height, PATCOPY);
       NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, Width, 
CurrentRect->bottom - CurrentRect->top, PATCOPY);
-      NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->bottom - 1, 
CurrentRect->right - CurrentRect->left, -Height, PATCOPY);
-      NtGdiPatBlt(hDC, CurrentRect->right - 1, CurrentRect->top, -Width, 
CurrentRect->bottom - CurrentRect->top, PATCOPY);
+      NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->bottom, 
CurrentRect->right - CurrentRect->left, -Height, PATCOPY);
+      NtGdiPatBlt(hDC, CurrentRect->right, CurrentRect->top, -Width, 
CurrentRect->bottom - CurrentRect->top, PATCOPY);
 
       RECTL_vInflateRect(CurrentRect, -Width, -Height);
    }

Reply via email to