Skip to content

Repository files navigation

MousePortal

Mouse Cursor Management for Multi-Display macOS

Version License Platform

中文版本 | English

MousePortal is a macOS utility for managing mouse cursor movement and window placement across multiple displays. It provides three core features:

  1. Hotkey Jump - Global keyboard shortcuts to instantly teleport the cursor to specific displays
  2. Portals - Custom edge-to-edge teleportation zones that warp the cursor when crossing defined screen boundaries
  3. Window Layouts - Save, preview, and restore application window positions for each display arrangement

MousePortal preview

Features

Hotkey Jump

  • Configure custom global shortcuts for each display
  • Support for any key + modifier combinations
  • Support for mapping via display layout name or ID

Portal System

  • Define custom teleportation zones on display edges
  • Support for bidirectional portals (from one display edge to another)
  • Two trigger modes:
    • Automatic - Always active
    • Key-held - Requires holding a modifier key (default: Option)
  • Visual editor for easy creation and adjustment of portal zones

Window Layouts and Recovery

  • Save multiple named window layouts for each display arrangement
  • Capture an automatic Before Lock layout before sleep or screen lock
  • Preview saved windows directly on the display canvas
  • Apply, rename, delete, or promote an automatic layout to a manual layout
  • Control global window recovery independently from sleep/lock capture and automatic wake restoration
  • Search for applications and exclude them from future snapshots
  • Restore standard, non-minimized, non-full-screen windows; Split View, Stage Manager groups, and Spaces are not restored

Multi-language Support

Available in 20 languages: English, Simplified Chinese, Traditional Chinese, Japanese, Korean, German, French, Spanish, Portuguese (Brazil), Russian, Italian, Dutch, Polish, Turkish, Arabic, Hindi, Thai, Vietnamese, Indonesian, Malay.

Other Features

  • Launch at login
  • Menu bar quick access
  • Configuration profile management (for different setups)
  • Display layout visualization
  • System, Light, and Dark app themes

Screenshots

English · Dark English · Light
MousePortal Window Layout in English and Dark theme MousePortal Window Layout in English and Light theme
简体中文 · 深色 简体中文 · 浅色
MousePortal 窗口布局中文深色主题 MousePortal 窗口布局中文浅色主题

System Requirements

  • macOS 13.0 or later
  • Accessibility Permission required (System Settings > Privacy & Security > Accessibility)

Installation

Download from Releases

  1. Download the latest .zip file from Releases
  2. Extract and drag MousePortal.app to /Applications folder
  3. On first launch, grant Accessibility permission in System Settings

Build from Source

# Clone the repository
git clone https://github.com/ai-eks/MousePortal.git
cd MousePortal

# Build
swift build -c release

# Run
swift run

Usage Guide

First-Time Setup

  1. Launch MousePortal
  2. Open System Settings > Privacy & Security > Accessibility
  3. Add MousePortal and ensure the toggle is enabled
  4. Return to MousePortal main window

Configure Hotkeys

  1. Open MousePortal main window
  2. Select Hotkeys in the left sidebar
  3. Click the hotkey input field and press your desired shortcut
  4. Select the display layout for this hotkey
  5. Click Save

Create Portals

  1. Select Portal Editor in the left sidebar
  2. Click + New Portal
  3. Select source and target displays
  4. Choose an edge (top/bottom/left/right)
  5. Adjust the portal zone start and end positions
  6. Select trigger mode (automatic or key-held)
  7. Name and save your portal

Display Layouts

  1. Define your display arrangement in Display Layouts
  2. Assign a name to each layout (e.g., "Dual Display", "Triple Display")
  3. Specify relative positions of each display

Save and Restore Window Layouts

  1. Open Settings > Window Recovery and turn on Enable Window Recovery
  2. Optionally enable Remember windows before sleep or lock and automatic restoration after displays wake
  3. Use the ignored-app search to exclude applications that should not be captured
  4. Return to Display Layouts, enable Show Window Layout, then click Save Window Layout
  5. Manage layouts below the matching display arrangement: apply, rename, delete, or promote an automatic layout to manual

Architecture

Core Services

Service Description
PortalService Monitors mouse movement, detects when cursor crosses portal lines, warps cursor using CGWarpMouseCursorPosition
HotkeyService Listens for global keyboard shortcuts via CGEvent
PermissionService Handles macOS Accessibility permission
DisplayService Fetches display info via CGGetActiveDisplayList/CGDisplayBounds
WindowLayoutService Captures, previews, and restores application window layouts
LanguageService Handles dynamic language switching
LaunchAtLoginService Manages launch at login

Key Models

  • PortalPair - Two PortalLine objects defining a bidirectional warp zone
  • HotkeyConfig - Maps a key+modifiers combo to a display layout
  • ConfigProfile - Named configuration snapshots for different setups
  • WindowLayoutSnapshot - A manual or automatic snapshot of windows for one display topology

Development

Requirements

  • macOS 13+
  • Swift 5.9+
  • Xcode 15+

Development Commands

# Open in Xcode
open Package.swift

# Run tests
swift test

# Build release version
swift build -c release

Project Structure

MousePortal/
├── MousePortal/              # Main application
│   ├── Models/               # Data models
│   ├── Views/                # SwiftUI views
│   ├── Services/             # Core services
│   ├── Utils/                # Utilities
│   ├── Protocols/            # Protocol definitions
│   └── Resources/            # Resources and localization
├── MousePortalTests/         # Unit tests
│   ├── Models/
│   ├── Services/
│   ├── Utils/
│   └── Mocks/
└── docs/                     # Documentation

Contributing

MousePortal is a focused utility and is mainly maintained by the project owner.

Bug reports and small focused fixes are welcome. Larger feature ideas may be discussed in issues first.

Privacy

See PRIVACY.md for the privacy note.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

FAQ

Q: Why is Accessibility permission required?

A: MousePortal needs to listen for global keyboard events and monitor mouse position, which requires macOS Accessibility permission.

Q: Portals not working?

A: Please ensure:

  1. Accessibility permission is granted
  2. The portal is enabled
  3. If using key-held mode, make sure you're holding the modifier key

About

MousePortal is a macOS utility for managing mouse cursor movement between multiple displays.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages