@@ -41,11 +41,11 @@ mpl_xdisplay_is_valid(void)
41
41
// than dlopen().
42
42
if (getenv (" DISPLAY" )
43
43
&& (libX11 = dlopen (" libX11.so.6" , RTLD_LAZY))) {
44
- typedef struct Display * (*XOpenDisplay_t)(char const *);
45
- typedef int (*XCloseDisplay_t)(struct Display *);
46
44
struct Display * display = nullptr ;
47
- XOpenDisplay_t XOpenDisplay = (XOpenDisplay_t)dlsym (libX11, " XOpenDisplay" );
48
- XCloseDisplay_t XCloseDisplay = (XCloseDisplay_t)dlsym (libX11, " XCloseDisplay" );
45
+ auto XOpenDisplay = (struct Display * (*)(char const *))
46
+ dlsym (libX11, " XOpenDisplay" );
47
+ auto XCloseDisplay = (int (*)(struct Display *))
48
+ dlsym (libX11, " XCloseDisplay" );
49
49
if (XOpenDisplay && XCloseDisplay
50
50
&& (display = XOpenDisplay (nullptr ))) {
51
51
XCloseDisplay (display);
@@ -73,13 +73,11 @@ mpl_display_is_valid(void)
73
73
void * libwayland_client;
74
74
if (getenv (" WAYLAND_DISPLAY" )
75
75
&& (libwayland_client = dlopen (" libwayland-client.so.0" , RTLD_LAZY))) {
76
- typedef struct wl_display * (*wl_display_connect_t )(char const *);
77
- typedef void (*wl_display_disconnect_t )(struct wl_display *);
78
76
struct wl_display * display = nullptr ;
79
- wl_display_connect_t wl_display_connect =
80
- ( wl_display_connect_t ) dlsym (libwayland_client, " wl_display_connect" );
81
- wl_display_disconnect_t wl_display_disconnect =
82
- ( wl_display_disconnect_t ) dlsym (libwayland_client, " wl_display_disconnect" );
77
+ auto wl_display_connect = ( struct wl_display * (*)( char const *))
78
+ dlsym (libwayland_client, " wl_display_connect" );
79
+ auto wl_display_disconnect = ( void (*)( struct wl_display *))
80
+ dlsym (libwayland_client, " wl_display_disconnect" );
83
81
if (wl_display_connect && wl_display_disconnect
84
82
&& (display = wl_display_connect (nullptr ))) {
85
83
wl_display_disconnect (display);
@@ -162,25 +160,19 @@ mpl_SetProcessDpiAwareness_max(void)
162
160
#ifdef _DPI_AWARENESS_CONTEXTS_
163
161
// These functions and options were added in later Windows 10 updates, so
164
162
// must be loaded dynamically.
165
- typedef BOOL (WINAPI *IsValidDpiAwarenessContext_t)(DPI_AWARENESS_CONTEXT);
166
- typedef BOOL (WINAPI *SetProcessDpiAwarenessContext_t)(DPI_AWARENESS_CONTEXT);
167
-
168
163
HMODULE user32 = LoadLibrary (" user32.dll" );
169
- IsValidDpiAwarenessContext_t IsValidDpiAwarenessContextPtr =
170
- (IsValidDpiAwarenessContext_t)GetProcAddress (
171
- user32, " IsValidDpiAwarenessContext" );
172
- SetProcessDpiAwarenessContext_t SetProcessDpiAwarenessContextPtr =
173
- (SetProcessDpiAwarenessContext_t)GetProcAddress (
174
- user32, " SetProcessDpiAwarenessContext" );
164
+ auto IsValidDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT))
165
+ GetProcAddress (user32, " IsValidDpiAwarenessContext" );
166
+ auto SetProcessDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT))
167
+ GetProcAddress (user32, " SetProcessDpiAwarenessContext" );
175
168
DPI_AWARENESS_CONTEXT ctxs[3 ] = {
176
169
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, // Win10 Creators Update
177
170
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, // Win10
178
171
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE}; // Win10
179
- if (IsValidDpiAwarenessContextPtr != NULL
180
- && SetProcessDpiAwarenessContextPtr != NULL ) {
172
+ if (IsValidDpiAwarenessContext && SetProcessDpiAwarenessContext) {
181
173
for (size_t i = 0 ; i < sizeof (ctxs) / sizeof (DPI_AWARENESS_CONTEXT); ++i) {
182
- if (IsValidDpiAwarenessContextPtr (ctxs[i])) {
183
- SetProcessDpiAwarenessContextPtr (ctxs[i]);
174
+ if (IsValidDpiAwarenessContext (ctxs[i])) {
175
+ SetProcessDpiAwarenessContext (ctxs[i]);
184
176
break ;
185
177
}
186
178
}
0 commit comments