mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-04-21 04:25:13 +08:00
fix: mask area error
This commit is contained in:
parent
b16e31405f
commit
22b106bcbe
@ -13,7 +13,8 @@
|
|||||||
{
|
{
|
||||||
"title": "scrcpy-mask",
|
"title": "scrcpy-mask",
|
||||||
"transparent": true,
|
"transparent": true,
|
||||||
"decorations": false
|
"decorations": false,
|
||||||
|
"shadow": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"macOSPrivateApi": true,
|
"macOSPrivateApi": true,
|
||||||
|
@ -12,9 +12,9 @@ import {
|
|||||||
} from "../hotkey";
|
} from "../hotkey";
|
||||||
import { KeySteeringWheel } from "../keyMappingConfig";
|
import { KeySteeringWheel } from "../keyMappingConfig";
|
||||||
import ScreenStream from "./ScreenStream.vue";
|
import ScreenStream from "./ScreenStream.vue";
|
||||||
import { getCurrentWindow, LogicalSize } from "@tauri-apps/api/window";
|
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { secondaryClean, secondaryInit } from "../tools/init";
|
import { secondaryClean, secondaryInit } from "../tools/init";
|
||||||
|
import { cleanAfterimage } from "../tools/tools";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
@ -60,15 +60,6 @@ onUnmounted(() => {
|
|||||||
secondaryClean();
|
secondaryClean();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function cleanAfterimage() {
|
|
||||||
const appWindow = getCurrentWindow();
|
|
||||||
const scale = await appWindow.scaleFactor();
|
|
||||||
const oldSize = (await appWindow.innerSize()).toLogical(scale);
|
|
||||||
const newSize = new LogicalSize(oldSize.width, oldSize.height + 1);
|
|
||||||
await appWindow.setSize(newSize);
|
|
||||||
await appWindow.setSize(oldSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
function toStartServer() {
|
function toStartServer() {
|
||||||
router.replace({ name: "device" });
|
router.replace({ name: "device" });
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import { allLanguage } from "../i18n";
|
|||||||
import { locale } from "@tauri-apps/plugin-os";
|
import { locale } from "@tauri-apps/plugin-os";
|
||||||
import { NonReactiveStore } from "./noneReactiveStore";
|
import { NonReactiveStore } from "./noneReactiveStore";
|
||||||
import {
|
import {
|
||||||
|
currentMonitor,
|
||||||
getCurrentWindow,
|
getCurrentWindow,
|
||||||
LogicalPosition,
|
LogicalPosition,
|
||||||
LogicalSize,
|
LogicalSize,
|
||||||
@ -86,7 +87,7 @@ async function initAdbPath() {
|
|||||||
LocalStore.vueStore.adbPath = adbPath;
|
LocalStore.vueStore.adbPath = adbPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initMaskArea() {
|
export async function initMaskArea() {
|
||||||
const maskArea = (await LocalStore.get<{
|
const maskArea = (await LocalStore.get<{
|
||||||
posX: number;
|
posX: number;
|
||||||
posY: number;
|
posY: number;
|
||||||
@ -102,29 +103,41 @@ async function initMaskArea() {
|
|||||||
|
|
||||||
// min size
|
// min size
|
||||||
if (sizeW < 120) sizeW = 120;
|
if (sizeW < 120) sizeW = 120;
|
||||||
if (sizeH < 150) sizeH = 120;
|
if (sizeH < 120) sizeH = 120;
|
||||||
// max size
|
|
||||||
const monitor = await primaryMonitor();
|
let monitor = await currentMonitor();
|
||||||
const monitorSize = monitor?.size.toLogical(monitor.scaleFactor);
|
if (monitor === null) monitor = await primaryMonitor();
|
||||||
if (monitorSize !== undefined) {
|
|
||||||
|
if (monitor) {
|
||||||
|
const monitorSize = monitor.size.toLogical(monitor.scaleFactor);
|
||||||
|
const monitorPos = monitor.position.toLogical(monitor.scaleFactor);
|
||||||
|
|
||||||
|
// max size
|
||||||
if (sizeW > monitorSize.width - ml) sizeW = monitorSize.width - ml;
|
if (sizeW > monitorSize.width - ml) sizeW = monitorSize.width - ml;
|
||||||
if (sizeH > monitorSize.height - mt) sizeH = monitorSize.height - mt;
|
if (sizeH > monitorSize.height - mt) sizeH = monitorSize.height - mt;
|
||||||
|
|
||||||
|
const tlPos = { x: monitorPos.x, y: monitorPos.y };
|
||||||
|
const brPos = {
|
||||||
|
x: monitorPos.x + monitorSize.width,
|
||||||
|
y: monitorPos.y + monitorSize.height,
|
||||||
|
};
|
||||||
|
|
||||||
|
// min pos (bottom right corner)
|
||||||
|
// move to top left corner
|
||||||
|
if (posX + sizeW < tlPos.x) posX = tlPos.x + ml;
|
||||||
|
if (posY + sizeH < tlPos.y) posY = tlPos.y + mt;
|
||||||
|
|
||||||
|
if (brPos !== null) {
|
||||||
|
// max pos (top left corner)
|
||||||
|
// move to bottom right corner
|
||||||
|
if (posX > brPos.x) posX = brPos.x - sizeW;
|
||||||
|
if (posY > brPos.y) posY = brPos.y - sizeH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[sizeW, sizeH] = [sizeW, sizeH].map((v) => Math.round(v));
|
[sizeW, sizeH] = [sizeW, sizeH].map((v) => Math.round(v));
|
||||||
appWindow.setSize(new LogicalSize(sizeW + ml, sizeH + mt));
|
|
||||||
|
|
||||||
// min pos (right bottom corner)
|
|
||||||
// move to left top corner
|
|
||||||
if (posX + sizeW < 0) posX = ml;
|
|
||||||
if (posY + sizeH < 0) posY = mt;
|
|
||||||
if (monitorSize !== undefined) {
|
|
||||||
// max pos (left top corner)
|
|
||||||
// move to right bottom corner
|
|
||||||
if (posX > monitorSize.width) posX = monitorSize.width - sizeW;
|
|
||||||
if (posY > monitorSize.height) posY = monitorSize.height - sizeH;
|
|
||||||
}
|
|
||||||
|
|
||||||
[posX, posY] = [posX, posY].map((v) => Math.round(v));
|
[posX, posY] = [posX, posY].map((v) => Math.round(v));
|
||||||
|
appWindow.setSize(new LogicalSize(sizeW + ml, sizeH + mt));
|
||||||
appWindow.setPosition(new LogicalPosition(posX - 70, posY - 30));
|
appWindow.setPosition(new LogicalPosition(posX - 70, posY - 30));
|
||||||
|
|
||||||
NonReactiveStore.setLocal("maskArea", {
|
NonReactiveStore.setLocal("maskArea", {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { getCurrentWindow, LogicalSize } from "@tauri-apps/api/window";
|
||||||
|
|
||||||
export function compareVersion(v1: string, v2: string) {
|
export function compareVersion(v1: string, v2: string) {
|
||||||
const [x1, y1, z1] = v1.split(".");
|
const [x1, y1, z1] = v1.split(".");
|
||||||
const [x2, y2, z2] = v2.split(".");
|
const [x2, y2, z2] = v2.split(".");
|
||||||
@ -25,3 +27,14 @@ export function genClientId() {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function cleanAfterimage() {
|
||||||
|
const appWindow = getCurrentWindow();
|
||||||
|
const scale = await appWindow.scaleFactor();
|
||||||
|
const oldSize = (await appWindow.innerSize()).toLogical(scale);
|
||||||
|
const newSize = new LogicalSize(oldSize.width, oldSize.height + 1);
|
||||||
|
await appWindow.setSize(newSize);
|
||||||
|
setTimeout(() => {
|
||||||
|
appWindow.setSize(oldSize);
|
||||||
|
}, 150);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user