ReadMe updated with Windows support; Detecting of currently used monitor.

This commit is contained in:
Max Risuhin 2019-01-06 22:43:39 +02:00
parent 44cf650bed
commit e658a13a7a
3 changed files with 58 additions and 6 deletions

View File

@ -24,7 +24,7 @@ Ensure you have your latest graphics card drivers installed before use.
- Scrollback buffer
- Clipboard access
- Clickable URLs
- Multi platform support (Windows coming soon...)
- Multi platform support (Windows, Linux, OSX)
- Sixel support
- Hints/overlays
- Built-in patched fonts for powerline
@ -41,11 +41,11 @@ brew install aminal
### Windows
A Windows version of Aminal is expected in the next 1-2 months.
Dev environment setup instructions are available [there](windows.md).
### Prebuilt Binaries
Prebuilt binaries are available for Linux and OSX on the [releases](https://github.com/liamg/aminal/releases) page.
Prebuilt binaries are available for Linux, OSX and Windows on the [releases](https://github.com/liamg/aminal/releases) page.
Download the binary and `sudo cp aminal-* /usr/local/bin/aminal && chmod +x /usr/local/bin/aminal`.

View File

@ -38,11 +38,59 @@ type GUI struct {
resizeLock *sync.Mutex
}
func Min(x, y int) int {
if x < y {
return x
}
return y
}
func Max(x, y int) int {
if x > y {
return x
}
return y
}
func (g *GUI) GetMonitor() *glfw.Monitor {
if g.window == nil {
panic("to determine current monitor the window must be set")
}
monitors := glfw.GetMonitors()
if len(monitors) == 1 {
return glfw.GetPrimaryMonitor()
}
x, y := g.window.GetPos()
w, h := g.window.GetSize()
var currentMonitor *glfw.Monitor
bestMatch := 0
for _, monitor := range monitors {
mode := monitor.GetVideoMode()
mx, my := monitor.GetPos()
overlap := Max(0, Min(x + w, mx + mode.Width) - Max(x, mx)) *
Max(0, Min(y + h, my + mode.Height) - Max(y, my))
if bestMatch < overlap {
bestMatch = overlap
currentMonitor = monitor
}
}
if currentMonitor == nil {
panic("was not able to resolve current monitor")
}
return currentMonitor
}
// RecalculateDpiScale calculates dpi scale in comparison with "standard" monitor's dpi values
func (g *GUI) RecalculateDpiScale() {
const standardDpi = 96
const mmPerInch = 25.4
m := glfw.GetPrimaryMonitor()
m := g.GetMonitor()
widthMM, _ := m.GetPhysicalSize()
if widthMM == 0 {
@ -153,6 +201,8 @@ func (gui *GUI) Render() error {
gui.logger.Debugf("Creating window...")
var err error
gui.window, err = gui.createWindow()
gui.RecalculateDpiScale()
gui.window.SetSize(gui.Width(), gui.Height())
if err != nil {
return fmt.Errorf("Failed to create window: %s", err)
}
@ -449,8 +499,6 @@ func (gui *GUI) createWindowWithOpenGLVersion(major int, minor int) (*glfw.Windo
glfw.WindowHint(glfw.ContextVersionMajor, major)
glfw.WindowHint(glfw.ContextVersionMinor, minor)
gui.RecalculateDpiScale()
window, err := glfw.CreateWindow(gui.Width(), gui.Height(), "Terminal", nil, nil)
if err != nil {
e := err.Error()

View File

@ -58,6 +58,10 @@ func (r *OpenGLRenderer) Clean() {
func (r *OpenGLRenderer) initRectangle(rect *rectangle, x float32, y float32, colourAttr uint32) {
if rect == nil {
panic("rect pointer is nil")
}
if rect.vao != 0 {
gl.DeleteVertexArrays(1, &rect.vao)
rect.vao = 0