-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复 macOS 多显示器下剪贴板窗口位置异常的问题 (#893)
- Loading branch information
Showing
3 changed files
with
72 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const Dock = () => { | ||
return <div>Dock</div>; | ||
return <div className="h-screen rounded-t-16 bg-1">Dock</div>; | ||
}; | ||
|
||
export default Dock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
availableMonitors, | ||
cursorPosition, | ||
primaryMonitor, | ||
} from "@tauri-apps/api/window"; | ||
|
||
export const getCursorMonitor = async () => { | ||
const primary = await primaryMonitor(); | ||
|
||
const monitors = await availableMonitors(); | ||
|
||
if (!primary || !monitors.length) return; | ||
|
||
const mousePosition = await cursorPosition(); | ||
const { x, y } = mousePosition.toLogical(primary.scaleFactor); | ||
|
||
const monitor = monitors.find((monitor) => { | ||
const { scaleFactor } = monitor; | ||
|
||
const position = monitor.position.toLogical(scaleFactor); | ||
const size = monitor.size.toLogical(scaleFactor); | ||
|
||
const inX = x >= position.x && x <= position.x + size.width; | ||
const inY = y >= position.y && y <= position.y + size.height; | ||
|
||
return inX && inY; | ||
}); | ||
|
||
if (!monitor) return; | ||
|
||
const { scaleFactor, size, position } = monitor; | ||
|
||
return { | ||
...monitor, | ||
cursorX: x, | ||
cursorY: y, | ||
size: size.toLogical(scaleFactor), | ||
position: position.toLogical(scaleFactor), | ||
}; | ||
}; |