Compare commits

...

3 Commits

Author SHA1 Message Date
Robinson 91777224a1
version 1.4 2023-11-22 11:53:33 +01:00
Robinson 1110afa379
Added DPI awareness methods 2023-11-22 10:12:03 +01:00
Robinson 390e65d845
Fixed condition signal 2023-11-22 10:03:13 +01:00
7 changed files with 59 additions and 7 deletions

View File

@ -35,7 +35,7 @@ object Extras {
// set for the project
const val description = "Native JNA extensions for Linux, MacOS, and Windows, Java 1.8+"
const val group = "com.dorkbox"
const val version = "1.3"
const val version = "1.4"
// set as project.ext
const val name = "JNA"

View File

@ -37,7 +37,7 @@ class JNA {
*/
public static
String getVersion() {
return "1.3";
return "1.4";
}
static {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2021 dorkbox, llc
* Copyright 2023 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,14 @@ import dorkbox.os.OS;
*/
public
class ShCore {
public static final int DPI_AWARENESS_INVALID = -1;
public static final int DPI_AWARENESS_UNAWARE = 0;
public static final int DPI_AWARENESS_SYSTEM_AWARE = 1;
public static final int DPI_AWARENESS_PER_MONITOR_AWARE = 2;
private static Function GetDpiForMonitor = null;
private static Function SetProcessDpiAwareness = null;
static {
if (OS.Windows.INSTANCE.isWindows8_1_plus()) {
@ -47,6 +54,7 @@ class ShCore {
// Abusing static fields this way is not proper, but it gets the job done nicely.
// GetDpiForMonitor is NOT always available! (Windows 8.1+)
GetDpiForMonitor = library.getFunction("GetDpiForMonitor");
SetProcessDpiAwareness = library.getFunction("SetProcessDpiAwareness");
}
}
@ -82,4 +90,18 @@ class ShCore {
return null;
}
}
/**
* https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness
*/
public static int SetProcessDpiAwareness(int value) {
if (SetProcessDpiAwareness != null) {
// HRESULT SetProcessDpiAwareness(
// [in] PROCESS_DPI_AWARENESS value
// );
return (int) SetProcessDpiAwareness.invoke(Integer.class, new Object[]{value});
} else {
return -1;
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 dorkbox, llc
* Copyright 2023 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,6 +44,10 @@ interface User32 {
int WM_LBUTTONUP = 0x202;
int WM_RBUTTONUP = 0x205;
Pointer DPI_AWARENESS_CONTEXT_UNAWARE = new Pointer(-1);
Pointer DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = new Pointer(-2);
Pointer DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = new Pointer(-3);
/**
* This is overridden by the 64-bit version to be SetWindowLongPtr instead.
*/
@ -170,4 +174,14 @@ interface User32 {
* https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfrompoint
*/
HMONITOR MonitorFromPoint(POINT.ByValue pt, int dwFlags);
/**
* https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforsystem
*/
int GetDpiForSystem();
/**
* https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setthreaddpiawarenesscontext
*/
Pointer SetThreadDpiAwarenessContext(Pointer dpiContext);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2017 dorkbox, llc
* Copyright 2023 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -122,4 +122,12 @@ class User32_32 implements User32 {
@Override
public native
HMONITOR MonitorFromPoint(POINT.ByValue pt, int dwFlags);
@Override
public native
Pointer SetThreadDpiAwarenessContext(Pointer dpiContext);
@Override
public native
int GetDpiForSystem();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2017 dorkbox, llc
* Copyright 2023 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -127,4 +127,12 @@ class User32_64 implements User32 {
@Override
public native
HMONITOR MonitorFromPoint(POINT.ByValue pt, int dwFlags);
@Override
public native
Pointer SetThreadDpiAwarenessContext(Pointer dpiContext);
@Override
public native
int GetDpiForSystem();
}

View File

@ -195,7 +195,7 @@ class WindowsEventDispatch implements Runnable {
lock.lock();
try {
condition.notifyAll();
condition.signalAll();;
} finally {
lock.unlock();
}