[PATCH] include/winuser: Add CopyRect and PtInRect as inline versions of common RECT helpers
Michael Stefaniuc
mstefani at winehq.org
Wed Dec 26 11:26:57 CST 2018
On 12/26/18 12:21 PM, Gabriel Ivăncescu wrote:
> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
> ---
>
> There shouldn't be a reason they aren't there like the rest, since they're
> very simple functions.
Well, there is a reason why I didn't include CopyRect(); it makes no
sense. A straight assignment should be used instead, especially as most
of the time the arguments are known to not be NULL.
There aren't many CopyRect()s left in the code.
PtInRect() I probably didn't add because I didn't replace any open coded
variants of that.
bye
michael
>
> include/winuser.h | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/include/winuser.h b/include/winuser.h
> index 693965a..c9e90c2 100644
> --- a/include/winuser.h
> +++ b/include/winuser.h
> @@ -3549,7 +3549,6 @@ WINUSERAPI INT WINAPI CopyAcceleratorTableW(HACCEL,LPACCEL,INT);
> #define CopyCursor(cur) ((HCURSOR)CopyIcon((HICON)(cur)))
> WINUSERAPI HICON WINAPI CopyIcon(HICON);
> WINUSERAPI HANDLE WINAPI CopyImage(HANDLE,UINT,INT,INT,UINT);
> -WINUSERAPI BOOL WINAPI CopyRect(RECT*,const RECT*);
> WINUSERAPI INT WINAPI CountClipboardFormats(void);
> WINUSERAPI HACCEL WINAPI CreateAcceleratorTableA(LPACCEL,INT);
> WINUSERAPI HACCEL WINAPI CreateAcceleratorTableW(LPACCEL,INT);
> @@ -4049,7 +4048,6 @@ WINUSERAPI UINT WINAPI PrivateExtractIconExA(LPCSTR,int,HICON*,HICON*,UIN
> WINUSERAPI UINT WINAPI PrivateExtractIconExW(LPCWSTR,int,HICON*,HICON*,UINT);
> WINUSERAPI UINT WINAPI PrivateExtractIconsA(LPCSTR,int,int,int,HICON*,UINT*,UINT,UINT);
> WINUSERAPI UINT WINAPI PrivateExtractIconsW(LPCWSTR,int,int,int,HICON*,UINT*,UINT,UINT);
> -WINUSERAPI BOOL WINAPI PtInRect(const RECT*,POINT);
> WINUSERAPI HWND WINAPI RealChildWindowFromPoint(HWND,POINT);
> WINUSERAPI UINT WINAPI RealGetWindowClassA(HWND,LPSTR,UINT);
> WINUSERAPI UINT WINAPI RealGetWindowClassW(HWND,LPWSTR,UINT);
> @@ -4274,10 +4272,12 @@ WINUSERAPI INT WINAPI wvsprintfW(LPWSTR,LPCWSTR,__ms_va_list);
>
> #if !defined(__WINESRC__) || defined(WINE_NO_INLINE_RECT)
>
> +WINUSERAPI BOOL WINAPI CopyRect(RECT*,const RECT*);
> WINUSERAPI BOOL WINAPI EqualRect(const RECT*,const RECT*);
> WINUSERAPI BOOL WINAPI InflateRect(LPRECT,INT,INT);
> WINUSERAPI BOOL WINAPI IsRectEmpty(const RECT*);
> WINUSERAPI BOOL WINAPI OffsetRect(LPRECT,INT,INT);
> +WINUSERAPI BOOL WINAPI PtInRect(const RECT*,POINT);
> WINUSERAPI BOOL WINAPI SetRect(LPRECT,INT,INT,INT,INT);
> WINUSERAPI BOOL WINAPI SetRectEmpty(LPRECT);
>
> @@ -4285,6 +4285,13 @@ WINUSERAPI BOOL WINAPI SetRectEmpty(LPRECT);
>
> /* Inline versions of common RECT helpers */
>
> +static inline BOOL WINAPI CopyRect(RECT *dest, const RECT *src)
> +{
> + if (!dest || !src) return FALSE;
> + *dest = *src;
> + return TRUE;
> +}
> +
> static inline BOOL WINAPI EqualRect(const RECT *rect1, const RECT *rect2)
> {
> if (!rect1 || !rect2) return FALSE;
> @@ -4318,6 +4325,13 @@ static inline BOOL WINAPI OffsetRect(LPRECT rect, INT x, INT y)
> return TRUE;
> }
>
> +static inline BOOL WINAPI PtInRect(const RECT *rect, POINT pt)
> +{
> + if (!rect) return FALSE;
> + return ((pt.x >= rect->left) && (pt.x < rect->right) &&
> + (pt.y >= rect->top) && (pt.y < rect->bottom));
> +}
> +
> static inline BOOL WINAPI SetRect(LPRECT rect, INT left, INT top, INT right, INT bottom)
> {
> if (!rect) return FALSE;
>
More information about the wine-devel
mailing list