Skip to content

About

用半透明边框实时框出鼠标光标下的窗口(Qt/C++,Windows 与 Linux)。 A Qt widget that outlines the window under the mouse cursor with a translucent frame.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

English | 简体中文

WindowRect

C++17 Qt Windows Linux License: MIT

A small Qt widget that outlines the window currently under the mouse cursor with a translucent frame — the "select a window" step of a screenshot tool, isolated into a runnable demo.

Features

  • Live window highlight — a frameless, always-on-top, translucent widget (rgba(58,196,255,…) background with a 2 px border) that follows the window under the cursor.
  • Click-through on Windows — the overlay is set to WA_TransparentForMouseEvents, so the desktop keeps receiving input; a low-level mouse hook (WH_MOUSE_LL) is installed instead to keep tracking mouse events.
  • Windows geometry — WindowFromPoint() + GetWindowRect() are polled by a 200 ms QTimer and applied with setGeometry().
  • X11 geometry — on Linux the root window's children are enumerated with XQueryTree() / XGetWindowAttributes(), the visible window containing the cursor is picked (skipping the overlay itself) and applied with move() + setFixedSize().
  • Cross-platform build — one CMake project supporting Qt 5 and Qt 6 (Widgets only), verified with Qt 5.15.2 + MSVC 2022 on Windows 10 22H2.
  • Reusable logic — the highlight goes through a hook plus WindowFromPoint; the code notes its trade-offs, making it a reference to compare against custom window-filtering implementations.

Build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

Requires CMake 3.5+ and Qt 5/6 with the Widgets module. Run the produced WindowRect executable and move the mouse across windows; the frame snaps to each window.

Links

About

用半透明边框实时框出鼠标光标下的窗口(Qt/C++,Windows 与 Linux)。 A Qt widget that outlines the window under the mouse cursor with a translucent frame.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages