summary refs log tree commit diff
path: root/.config/mpv/scripts/mouse_coords.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.config/mpv/scripts/mouse_coords.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/.config/mpv/scripts/mouse_coords.lua b/.config/mpv/scripts/mouse_coords.lua
index 3bc59b9..b2a2a65 100644
--- a/.config/mpv/scripts/mouse_coords.lua
+++ b/.config/mpv/scripts/mouse_coords.lua
@@ -1,4 +1,4 @@
-local msg = require('mp.msg')
+local msg = require("mp.msg")
 
 -- local x, y = 0, 0
 
@@ -20,10 +20,20 @@ local msg = require('mp.msg')
 -- end
 
 function print_pos()
-    x, y = mp.get_mouse_pos()
-    pos = "xy: " .. x .. "," .. y
-    mp.msg.warn(pos)
-    mp.osd_message(pos)
+	dw = mp.get_property_number("dwidth")
+	dh = mp.get_property_number("dheight")
+	ow, oh = mp.get_osd_size()
+
+	wr = math.floor(ow / dw)
+	hr = math.floor(oh / dh)
+
+	mx, my = mp.get_mouse_pos()
+	x = math.floor(mx / wr)
+	y = math.floor(my / hr)
+
+	pos = dw .. "x" .. dh .. " " .. x .. "," .. y
+	mp.msg.warn(pos)
+	mp.osd_message(pos)
 end
 
 mp.add_key_binding("0", mp.get_script_name(), print_pos)