From 89c3d91e9245f305a75d96a043421908e341c642 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Tue, 10 Jul 2018 21:00:52 +0800 Subject: [PATCH] update linux active pid consistent with other platforms --- robotgo_unix.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/robotgo_unix.go b/robotgo_unix.go index 7bfcc04..7b92f07 100644 --- a/robotgo_unix.go +++ b/robotgo_unix.go @@ -43,7 +43,8 @@ func ActivePIDC(pid int32, args ...int) { } // ActivePID makes the window of the PID the active window -func ActivePID(pid int32) error { +// If args[0] > 0 on the unix platform via a xid to active +func ActivePID(pid int32, args ...int) error { if xu == nil { var err error xu, err = xgbutil.NewConn() @@ -52,6 +53,15 @@ func ActivePID(pid int32) error { } } + if len(args) > 0 { + err := ewmh.ActiveWindowReq(xu, xproto.Window(pid)) + if err != nil { + return err + } + + return nil + } + xid, err := getXidFromPid(xu, pid) if err != nil { return err