Skip to content

Commit

Permalink
ae.sys.sendinput: Add getMousePos
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed May 11, 2024
1 parent 2355695 commit fcdd1f9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sys/sendinput.d
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 82,19 @@ version (linux)
enforce(spawnProcess(["xdotool", "mousemove", text(x), text(y)]).wait() == 0, "xdotool failed");
}

int[2] getMousePos()
{
// TODO static if (haveX11)
import ae.sys.cmd : query;
import std.algorithm.searching : skipOver;
auto s = query(["xdotool", "getmouselocation"]);
auto t = s.split();
enforce(t.length == 4);
enforce(t[0].skipOver("x:"));
enforce(t[1].skipOver("y:"));
return [t[0].to!int, t[1].to!int];
}

/// Type used for window IDs.
static if (haveX11)
alias Window = deimos.X11.X.Window;
Expand Down

0 comments on commit fcdd1f9

Please sign in to comment.