brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.53k stars 2.27k forks source link

[ads] Consider using `X11Window::IsActive` for browser `IsForeground()` check #34473

Open aseren opened 9 months ago

aseren commented 9 months ago

Need to investigate X11Window::IsActive() usage for Brave Ads IsForeground() check.
The current solution uses _NET_ACTIVE_WINDOW window property https://github.com/brave/brave-core/blob/master/components/brave_ads/browser/background_helper_linux.cc, but it is not working for the WMII window manager. See comment for X11Window::Activate():

void X11Window::Activate() {
  if (!IsVisible() || !activatable_)
    return;

  BeforeActivationStateChanged();

  ignore_keyboard_input_ = false;

  // wmii says that it supports _NET_ACTIVE_WINDOW but does not.
  // https://code.google.com/p/wmii/issues/detail?id=266
  static bool wm_supports_active_window =
      GuessWindowManager() != WM_WMII &&
      WmSupportsHint(x11::GetAtom("_NET_ACTIVE_WINDOW"));
tmancey commented 1 month ago

Ubuntu 22 defaults to Wayland.