Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Make Focus() / Blur() reliable and let Blur() return focus to the previous app

Open
#69 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp

Research direction

Start by locating the platform implementations of Window::Focus(), Blur(), and IsFocused(), then inspect the Windows, Linux, and macOS focus behavior described in the issue. Done means focus changes succeed reliably across those platforms and Blur() returns focus to the previously active window or app.

Written by the indexing model from the issue text.

Description

bug

Window::Focus() and Blur() follow the platforms' simplest calls and fail in common cases:

  • Windows: Focus() is SetForegroundWindow + SetFocus, which the foreground lock refuses when the app isn't in the foreground (only the taskbar flashes). Consider the AttachThreadInput / AllowSetForegroundWindow approaches, and check IsFocused() after focus changes.
  • Linux: gtk_window_present() without a timestamp is subject to focus-stealing prevention; use gtk_window_present_with_time() with the last event time.
  • Blur() should hand focus back to the previously active window or app. On macOS it only does orderBack:, and on Windows SetFocus(nullptr), which leaves the app active. Typical use: a launcher/search bar that hides and pastes into the previous app. Related: libnativeapi/nativeapi#59 (app-level hide on macOS).

Background:

  • leanflutter/window_manager#364: focus() not always working, isFocused() always false (Windows)
  • leanflutter/window_manager#218: focus() doesn't focus the window on Ubuntu
  • leanflutter/window_manager#387: how to unfocus the window and bring back the previous one
  • leanflutter/window_manager#352: focus the previous window when hiding
Dominant language
C++
Stars
34
Forks
7
Avg merge
3d 1h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libnativeapi/nativeapi

All issues in libnativeapi/nativeapi

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.