mirror of https://github.com/liamg/aminal.git
Recalculate monitor based DPI scale if Window moved; Set DPI awareness of UI on Windows. (#206)
This commit is contained in:
parent
77348c2188
commit
7caa46e443
11
gui/gui.go
11
gui/gui.go
|
@ -340,6 +340,8 @@ func (gui *GUI) Render() error {
|
|||
gui.terminal.SetDirty()
|
||||
}
|
||||
})
|
||||
gui.window.SetPosCallback(gui.windowPosChangeCallback)
|
||||
glfw.SetMonitorCallback(gui.monitorChangeCallback)
|
||||
|
||||
gui.generateDefaultCell(false)
|
||||
|
||||
|
@ -735,3 +737,12 @@ func (gui *GUI) Screenshot(path string) {
|
|||
defer file.Close()
|
||||
png.Encode(file, img)
|
||||
}
|
||||
|
||||
func (gui *GUI) windowPosChangeCallback(w *glfw.Window, xpos int, ypos int) {
|
||||
gui.SetDPIScale()
|
||||
}
|
||||
|
||||
func (gui *GUI) monitorChangeCallback(monitor *glfw.Monitor, event glfw.MonitorEvent) {
|
||||
gui.SetDPIScale()
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,11 @@ package platform
|
|||
// PVOID lpPreviousValue,
|
||||
// PSIZE_T lpReturnSize
|
||||
// );
|
||||
// typedef BOOL (* SetProcessDpiAwarenessContextType)(handle_t);
|
||||
//
|
||||
// InitializeProcThreadAttributeListProcType pfnInitializeProcThreadAttributeList = NULL;
|
||||
// UpdateProcThreadAttributeProcType pfnUpdateProcThreadAttribute = NULL;
|
||||
// SetProcessDpiAwarenessContextType pfnSetProcessDpiAwarenessContext = NULL;
|
||||
//
|
||||
// #define ProcThreadAttributePseudoConsole 22
|
||||
//
|
||||
|
@ -43,6 +45,10 @@ package platform
|
|||
// LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList;
|
||||
// } STARTUPINFOEXW, *LPSTARTUPINFOEXW;
|
||||
//
|
||||
// #ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
|
||||
// #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((handle_t)-4)
|
||||
// #endif
|
||||
//
|
||||
// HMODULE hLibKernel32_Proc = NULL;
|
||||
//
|
||||
// DWORD initProcKernFuncs()
|
||||
|
@ -68,6 +74,22 @@ package platform
|
|||
// return 0;
|
||||
// }
|
||||
//
|
||||
// DWORD enableHiDpiSupport() {
|
||||
// HMODULE hLibUser32_Proc = LoadLibrary( "User32.dll" );
|
||||
// if( hLibUser32_Proc == NULL )
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// pfnSetProcessDpiAwarenessContext = (SetProcessDpiAwarenessContextType) GetProcAddress(hLibUser32_Proc, "SetProcessDpiAwarenessContext" );
|
||||
// if( pfnInitializeProcThreadAttributeList == NULL )
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
// (*pfnSetProcessDpiAwarenessContext)( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 );
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// DWORD createGuestProcHelper( uintptr_t hpc, LPCWSTR imagePath, uintptr_t * hProcess, DWORD * dwProcessID )
|
||||
// {
|
||||
// STARTUPINFOEXW si;
|
||||
|
@ -152,6 +174,9 @@ var procsInitSucceeded = false
|
|||
|
||||
func init() {
|
||||
ret := int(C.initProcKernFuncs())
|
||||
if ret == 0 {
|
||||
ret = int(C.enableHiDpiSupport())
|
||||
}
|
||||
procsInitSucceeded = (ret == 0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue