Merge pull request #255 from go-vgo/dev

Use CGDisplayBounds and update info test code
This commit is contained in:
vz 2020-01-05 09:06:35 -04:00 committed by GitHub
commit 9c21c09ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 9 deletions

View File

@ -11,6 +11,7 @@ jobs:
# specify any bash command here prefixed with `run: `
- run: apt-get update
- run: apt-get -y install xvfb
#
# override:
# './...' is a relative pattern which means all subdirectories
# - run: go get -u github.com/go-vgo/robotgo

View File

@ -29,5 +29,6 @@ jobs:
- name: Build
run: go build -v .
# - name: Test
# run: go test -v .
- name: Test
run: go test -v robot_info_test.go
# run: go test -v .

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
package robotgo
package robotgo_test
import (
"fmt"
@ -16,22 +16,23 @@ import (
"runtime"
"testing"
"github.com/go-vgo/robotgo"
"github.com/vcaesar/tt"
)
func TestGetVer(t *testing.T) {
fmt.Println("go version: ", runtime.Version())
ver := GetVersion()
ver := robotgo.GetVersion()
tt.Expect(t, Version, ver)
tt.Expect(t, robotgo.Version, ver)
}
func TestGetScreenSize(t *testing.T) {
x, y := GetScreenSize()
x, y := robotgo.GetScreenSize()
log.Println("GetScreenSize: ", x, y)
}
func TestGetSysScale(t *testing.T) {
s := SysScale()
s := robotgo.SysScale()
log.Println("SysScale: ", s)
}

View File

@ -11,8 +11,10 @@
MMSizeInt32 getMainDisplaySize(void){
#if defined(IS_MACOSX)
CGDirectDisplayID displayID = CGMainDisplayID();
return MMSizeInt32Make((int32_t)CGDisplayPixelsWide(displayID),
(int32_t)CGDisplayPixelsHigh(displayID));
CGRect displayRect = CGDisplayBounds(displayID);
CGSize size = displayRect.size;
return MMSizeInt32Make((int32_t)size.width, (int32_t)size.height);
#elif defined(USE_X11)
Display *display = XGetMainDisplay();
const int screen = DefaultScreen(display);