提交 fff45a41 编写于 作者: M Matt Gajownik 提交者: Matt Gajownik

UI: Scale Interact cursor position based on display DPI

上级 448599e7
......@@ -218,6 +218,14 @@ static int TranslateQtMouseEventModifiers(QMouseEvent *event)
bool OBSBasicInteraction::GetSourceRelativeXY(int mouseX, int mouseY, int &relX,
int &relY)
{
#ifdef SUPPORTS_FRACTIONAL_SCALING
float pixelRatio = devicePixelRatioF();
#else
float pixelRatio = devicePixelRatio();
#endif
int mouseXscaled = (int)roundf(mouseX * pixelRatio);
int mouseYscaled = (int)roundf(mouseY * pixelRatio);
QSize size = GetPixelSize(ui->preview);
uint32_t sourceCX = max(obs_source_get_width(source), 1u);
......@@ -230,11 +238,11 @@ bool OBSBasicInteraction::GetSourceRelativeXY(int mouseX, int mouseY, int &relX,
y, scale);
if (x > 0) {
relX = int(float(mouseX - x) / scale);
relY = int(float(mouseY / scale));
relX = int(float(mouseXscaled - x) / scale);
relY = int(float(mouseYscaled / scale));
} else {
relX = int(float(mouseX / scale));
relY = int(float(mouseY - y) / scale);
relX = int(float(mouseXscaled / scale));
relY = int(float(mouseYscaled - y) / scale);
}
// Confirm mouse is inside the source
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册