Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glfw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pirvi-public
glfw
Commits
25b7eba4
Commit
25b7eba4
authored
7 years ago
by
Camilla Löwy
Browse files
Options
Downloads
Patches
Plain Diff
Win32: Clean up dynamic loading and version checks
parent
176ab9a5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/win32_init.c
+7
-7
7 additions, 7 deletions
src/win32_init.c
src/win32_platform.h
+30
-6
30 additions, 6 deletions
src/win32_platform.h
src/win32_window.c
+7
-7
7 additions, 7 deletions
src/win32_window.c
with
44 additions
and
20 deletions
src/win32_init.c
+
7
−
7
View file @
25b7eba4
...
...
@@ -85,9 +85,9 @@ static GLFWbool loadLibraries(void)
return
GLFW_FALSE
;
}
_glfw
.
win32
.
user32
.
SetProcessDPIAware
=
(
PFN_SetProcessDPIAware
)
_glfw
.
win32
.
user32
.
SetProcessDPIAware
_
=
(
PFN_SetProcessDPIAware
)
GetProcAddress
(
_glfw
.
win32
.
user32
.
instance
,
"SetProcessDPIAware"
);
_glfw
.
win32
.
user32
.
ChangeWindowMessageFilterEx
=
(
PFN_ChangeWindowMessageFilterEx
)
_glfw
.
win32
.
user32
.
ChangeWindowMessageFilterEx
_
=
(
PFN_ChangeWindowMessageFilterEx
)
GetProcAddress
(
_glfw
.
win32
.
user32
.
instance
,
"ChangeWindowMessageFilterEx"
);
_glfw
.
win32
.
dinput8
.
instance
=
LoadLibraryA
(
"dinput8.dll"
);
...
...
@@ -136,7 +136,7 @@ static GLFWbool loadLibraries(void)
_glfw
.
win32
.
shcore
.
instance
=
LoadLibraryA
(
"shcore.dll"
);
if
(
_glfw
.
win32
.
shcore
.
instance
)
{
_glfw
.
win32
.
shcore
.
SetProcessDpiAwareness
=
(
PFN_SetProcessDpiAwareness
)
_glfw
.
win32
.
shcore
.
SetProcessDpiAwareness
_
=
(
PFN_SetProcessDpiAwareness
)
GetProcAddress
(
_glfw
.
win32
.
shcore
.
instance
,
"SetProcessDpiAwareness"
);
}
...
...
@@ -507,10 +507,10 @@ int _glfwPlatformInit(void)
createKeyTables
();
_glfwUpdateKeyNamesWin32
();
if
(
_glfw_SetProcessDpiAwareness
)
_glfw_
SetProcessDpiAwareness
(
PROCESS_PER_MONITOR_DPI_AWARE
);
else
if
(
_glfw_SetProcessDPIAware
)
_glfw_
SetProcessDPIAware
();
if
(
IsWindows8Point1OrGreater
()
)
SetProcessDpiAwareness
(
PROCESS_PER_MONITOR_DPI_AWARE
);
else
if
(
IsWindowsVistaOrGreater
()
)
SetProcessDPIAware
();
if
(
!
_glfwRegisterWindowClassWin32
())
return
GLFW_FALSE
;
...
...
This diff is collapsed.
Click to expand it.
src/win32_platform.h
+
30
−
6
View file @
25b7eba4
...
...
@@ -122,6 +122,30 @@ typedef enum PROCESS_DPI_AWARENESS
}
PROCESS_DPI_AWARENESS
;
#endif
/*DPI_ENUMS_DECLARED*/
// HACK: Define versionhelpers.h functions manually as MinGW lacks the header
FORCEINLINE
BOOL
IsWindowsVersionOrGreater
(
WORD
major
,
WORD
minor
,
WORD
sp
)
{
OSVERSIONINFOEXW
osvi
=
{
sizeof
(
osvi
),
major
,
minor
,
0
,
0
,
{
0
},
sp
};
DWORD
mask
=
VER_MAJORVERSION
|
VER_MINORVERSION
|
VER_SERVICEPACKMAJOR
;
ULONGLONG
cond
=
VerSetConditionMask
(
0
,
VER_MAJORVERSION
,
VER_GREATER_EQUAL
);
cond
=
VerSetConditionMask
(
cond
,
VER_MINORVERSION
,
VER_GREATER_EQUAL
);
cond
=
VerSetConditionMask
(
cond
,
VER_SERVICEPACKMAJOR
,
VER_GREATER_EQUAL
);
return
VerifyVersionInfoW
(
&
osvi
,
mask
,
cond
);
}
#define IsWindowsVistaOrGreater() \
IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), \
LOBYTE(_WIN32_WINNT_VISTA), 0)
#define IsWindows7OrGreater() \
IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), \
LOBYTE(_WIN32_WINNT_WIN7), 0)
#define IsWindows8OrGreater() \
IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), \
LOBYTE(_WIN32_WINNT_WIN8), 0)
#define IsWindows8Point1OrGreater() \
IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), \
LOBYTE(_WIN32_WINNT_WINBLUE), 0)
// HACK: Define macros that some xinput.h variants don't
#ifndef XINPUT_CAPS_WIRELESS
#define XINPUT_CAPS_WIRELESS 0x0002
...
...
@@ -173,8 +197,8 @@ typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*
// user32.dll function pointer typedefs
typedef
BOOL
(
WINAPI
*
PFN_SetProcessDPIAware
)(
void
);
typedef
BOOL
(
WINAPI
*
PFN_ChangeWindowMessageFilterEx
)(
HWND
,
UINT
,
DWORD
,
PCHANGEFILTERSTRUCT
);
#define
_glfw_
SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
#define
_glfw_
ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
_
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx
_
// dwmapi.dll function pointer typedefs
typedef
HRESULT
(
WINAPI
*
PFN_DwmIsCompositionEnabled
)(
BOOL
*
);
...
...
@@ -184,7 +208,7 @@ typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
// shcore.dll function pointer typedefs
typedef
HRESULT
(
WINAPI
*
PFN_SetProcessDpiAwareness
)(
PROCESS_DPI_AWARENESS
);
#define
_glfw_
SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness
#define SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness
_
typedef
VkFlags
VkWin32SurfaceCreateFlagsKHR
;
...
...
@@ -278,8 +302,8 @@ typedef struct _GLFWlibraryWin32
struct
{
HINSTANCE
instance
;
PFN_SetProcessDPIAware
SetProcessDPIAware
;
PFN_ChangeWindowMessageFilterEx
ChangeWindowMessageFilterEx
;
PFN_SetProcessDPIAware
SetProcessDPIAware
_
;
PFN_ChangeWindowMessageFilterEx
ChangeWindowMessageFilterEx
_
;
}
user32
;
struct
{
...
...
@@ -290,7 +314,7 @@ typedef struct _GLFWlibraryWin32
struct
{
HINSTANCE
instance
;
PFN_SetProcessDpiAwareness
SetProcessDpiAwareness
;
PFN_SetProcessDpiAwareness
SetProcessDpiAwareness
_
;
}
shcore
;
}
_GLFWlibraryWin32
;
...
...
This diff is collapsed.
Click to expand it.
src/win32_window.c
+
7
−
7
View file @
25b7eba4
...
...
@@ -1039,13 +1039,13 @@ static int createNativeWindow(_GLFWwindow* window,
SetPropW
(
window
->
win32
.
handle
,
L"GLFW"
,
window
);
if
(
_glfw_ChangeWindowMessageFil
ter
Ex
)
if
(
IsWindows7OrGrea
ter
()
)
{
_glfw_
ChangeWindowMessageFilterEx
(
window
->
win32
.
handle
,
ChangeWindowMessageFilterEx
(
window
->
win32
.
handle
,
WM_DROPFILES
,
MSGFLT_ALLOW
,
NULL
);
_glfw_
ChangeWindowMessageFilterEx
(
window
->
win32
.
handle
,
ChangeWindowMessageFilterEx
(
window
->
win32
.
handle
,
WM_COPYDATA
,
MSGFLT_ALLOW
,
NULL
);
_glfw_
ChangeWindowMessageFilterEx
(
window
->
win32
.
handle
,
ChangeWindowMessageFilterEx
(
window
->
win32
.
handle
,
WM_COPYGLOBALDATA
,
MSGFLT_ALLOW
,
NULL
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment