Skip to content

Commit efda35b

Browse files
committed
Update win32_clipboard.h
1 parent 3b647c8 commit efda35b

1 file changed

Lines changed: 40 additions & 36 deletions

File tree

src/external/win32_clipboard.h

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,38 @@ unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long
1616
// NOTE: These search for architecture is taken from "Windows.h", and it's necessary if we really don't wanna import windows.h
1717
// and still make it compile on msvc, because import indirectly importing "winnt.h" (e.g. <minwindef.h>) can cause problems is these are not defined.
1818
#if !defined(_X86_) && !defined(_68K_) && !defined(_MPPC_) && !defined(_IA64_) && !defined(_AMD64_) && !defined(_ARM_) && !defined(_ARM64_) && !defined(_ARM64EC_) && defined(_M_IX86)
19-
#define _X86_
20-
#if !defined(_CHPE_X86_ARM64_) && defined(_M_HYBRID)
21-
#define _CHPE_X86_ARM64_
22-
#endif
19+
#define _X86_
20+
#if !defined(_CHPE_X86_ARM64_) && defined(_M_HYBRID)
21+
#define _CHPE_X86_ARM64_
22+
#endif
2323
#endif
2424

2525
#if !defined(_AMD64_) && !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && !defined(_ARM_) && !defined(_ARM64_) && (defined(_M_AMD64) || defined(_M_ARM64EC))
26-
#define _AMD64_
26+
#define _AMD64_
2727
#endif
2828

2929
#if !defined(_ARM_) && !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && !defined(_ARM64_) && !defined(_ARM64EC_) && defined(_M_ARM)
30-
#define _ARM_
30+
#define _ARM_
3131
#endif
3232

3333
#if !defined(_ARM64_) && !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && !defined(_ARM_) && !defined(_ARM64EC_) && defined(_M_ARM64)
34-
#define _ARM64_
34+
#define _ARM64_
3535
#endif
3636

3737
#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_ARM_) && !defined(_ARM64_) && !defined(_ARM64EC_) && defined(_M_ARM64EC)
38-
#define _ARM64EC_
38+
#define _ARM64EC_
3939
#endif
4040

4141
#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && !defined(_ARM_) && !defined(_ARM64_) && !defined(_ARM64EC_) && defined(_M_M68K)
42-
#define _68K_
42+
#define _68K_
4343
#endif
4444

4545
#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && !defined(_ARM_) && !defined(_ARM64_) && !defined(_ARM64EC_) && defined(_M_MPPC)
46-
#define _MPPC_
46+
#define _MPPC_
4747
#endif
4848

4949
#if !defined(_IA64_) && !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_M_IX86) && !defined(_AMD64_) && !defined(_ARM_) && !defined(_ARM64_) && !defined(_ARM64EC_) && defined(_M_IA64)
50-
#define _IA64_
50+
#define _IA64_
5151
#endif
5252

5353

@@ -59,35 +59,35 @@ unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long
5959
// #include <minwinbase.h>
6060

6161
#ifndef WINAPI
62-
#if defined(_ARM_)
63-
#define WINAPI
64-
#else
65-
#define WINAPI __stdcall
66-
#endif
62+
#if defined(_ARM_)
63+
#define WINAPI
64+
#else
65+
#define WINAPI __stdcall
66+
#endif
6767
#endif
6868

6969
#ifndef WINAPI
70-
#if defined(_ARM_)
71-
#define WINAPI
72-
#else
73-
#define WINAPI __stdcall
74-
#endif
70+
#if defined(_ARM_)
71+
#define WINAPI
72+
#else
73+
#define WINAPI __stdcall
74+
#endif
7575
#endif
7676

7777
#ifndef WINBASEAPI
78-
#ifndef _KERNEL32_
79-
#define WINBASEAPI DECLSPEC_IMPORT
80-
#else
81-
#define WINBASEAPI
82-
#endif
78+
#ifndef _KERNEL32_
79+
#define WINBASEAPI DECLSPEC_IMPORT
80+
#else
81+
#define WINBASEAPI
82+
#endif
8383
#endif
8484

8585
#ifndef WINUSERAPI
86-
#ifndef _USER32_
87-
#define WINUSERAPI __declspec (dllimport)
88-
#else
89-
#define WINUSERAPI
90-
#endif
86+
#ifndef _USER32_
87+
#define WINUSERAPI __declspec (dllimport)
88+
#else
89+
#define WINUSERAPI
90+
#endif
9191
#endif
9292

9393
typedef int WINBOOL;
@@ -115,7 +115,7 @@ WINUSERAPI HWND WINAPI GetOpenClipboardWindow(VOID);
115115
#endif
116116

117117
#ifndef HGLOBAL
118-
#define HGLOBAL void*
118+
#define HGLOBAL void*
119119
#endif
120120

121121
#if !defined(_WINBASE_) || !defined(WINBASE_ALREADY_INCLUDED)
@@ -124,7 +124,6 @@ WINBASEAPI LPVOID WINAPI GlobalLock (HGLOBAL hMem);
124124
WINBASEAPI WINBOOL WINAPI GlobalUnlock (HGLOBAL hMem);
125125
#endif
126126

127-
128127
#if !defined(_WINGDI_) || !defined(WINGDI_ALREADY_INCLUDED)
129128
#ifndef BITMAPINFOHEADER_ALREADY_DEFINED
130129
#define BITMAPINFOHEADER_ALREADY_DEFINED
@@ -183,7 +182,6 @@ typedef struct tagRGBQUAD {
183182
// Bitmap not compressed and that the color table consists of four DWORD color masks,
184183
// that specify the red, green, blue, and alpha components of each pixel
185184
#define BI_ALPHABITFIELDS 0x0006
186-
187185
#endif
188186

189187
// REF: https://learn.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats
@@ -204,11 +202,14 @@ typedef struct tagRGBQUAD {
204202
// #define OCR_HAND 32649 // Link select
205203
// #define OCR_APPSTARTING 32650 //
206204

205+
//----------------------------------------------------------------------------------
206+
// Module Internal Functions Declaration
207+
//----------------------------------------------------------------------------------
207208
static BOOL OpenClipboardRetrying(HWND handle); // Open clipboard with a number of retries
208-
static int GetPixelDataOffset(BITMAPINFOHEADER bih);
209+
static int GetPixelDataOffset(BITMAPINFOHEADER bih); // Get pixel data offset from DIB image
209210

210211
//----------------------------------------------------------------------------------
211-
// Module Internal Functions Declaration
212+
// Module Functions Definition
212213
//----------------------------------------------------------------------------------
213214
unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long long int *dataSize)
214215
{
@@ -274,6 +275,9 @@ unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long
274275
return bmpData;
275276
}
276277

278+
//----------------------------------------------------------------------------------
279+
// Module Internal Functions Definition
280+
//----------------------------------------------------------------------------------
277281
// Open clipboard with several tries
278282
// NOTE: If parameter is NULL, the open clipboard is associated with the current task
279283
static BOOL OpenClipboardRetrying(HWND hWnd)

0 commit comments

Comments
 (0)