Bug 212581 - [GTK4] Monitor root window to update activity state
Summary: [GTK4] Monitor root window to update activity state
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks: GTK4
  Show dependency treegraph
 
Reported: 2020-05-31 07:32 PDT by Carlos Garcia Campos
Modified: 2020-06-01 05:38 PDT (History)
5 users (show)

See Also:


Attachments
Patch (10.90 KB, patch)
2020-05-31 07:34 PDT, Carlos Garcia Campos
aperez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2020-05-31 07:32:32 PDT
To update ActivityState::IsInWindow and ActivityState::WindowIsActive
Comment 1 Carlos Garcia Campos 2020-05-31 07:34:31 PDT
Created attachment 400703 [details]
Patch
Comment 2 EWS Watchlist 2020-05-31 07:35:22 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Adrian Perez 2020-06-01 02:22:49 PDT
Comment on attachment 400703 [details]
Patch

Patch looks good, there's just one small wrinkle (please read below)
and a nit, otherwise I would have approved it already :]

View in context: https://bugs.webkit.org/attachment.cgi?id=400703&action=review

> Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:1715
> +    if (isActive && !gtk_widget_get_visible(GTK_WIDGET(window)))

This will return early if the window is not visible, regardless of
its activity status. I think the code would be clearer if it checked
the window visibility first and returned early in that case. Something
like this:

  if (!gtk_widget_get_visible(GTK_WIDGET(window))
      return;

  const bool isActive = gtk_window_is_active(window);
  // ...

> Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:1735
> +    bool visible = !(state & GDK_SURFACE_STATE_MINIMIZED);

This should check also for GDK_SURFACE_STATE_WITHDRAWN,
which indicates that the surface is not being shown.
Comment 4 Adrian Perez 2020-06-01 02:45:36 PDT
Comment on attachment 400703 [details]
Patch

Carlos and me looked into GDK_SURFACE_STATE_WITHDRAWN and it's
basically equivalent to “the surface/window is not mapped”, which
is handled elsewhere by the widget implementation — we do not need
to add handling for it also in this patch.

Therefore, changed to r+
Comment 5 Carlos Garcia Campos 2020-06-01 05:36:45 PDT
(In reply to Adrian Perez from comment #3)
> Comment on attachment 400703 [details]
> Patch
> 
> Patch looks good, there's just one small wrinkle (please read below)
> and a nit, otherwise I would have approved it already :]
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=400703&action=review
> 
> > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:1715
> > +    if (isActive && !gtk_widget_get_visible(GTK_WIDGET(window)))
> 
> This will return early if the window is not visible, regardless of
> its activity status. I think the code would be clearer if it checked
> the window visibility first and returned early in that case. Something
> like this:
> 
>   if (!gtk_widget_get_visible(GTK_WIDGET(window))
>       return;
> 
>   const bool isActive = gtk_window_is_active(window);
>   // ...

This comes from GTK3 code, where this early return only happens in the focus-in, and includes this comment:

// Spurious focus in events can occur when the window is hidden.

I don't even know if that's the case with GTK4, so I think I'm going to assume a hidden toplevel can't get the focus.

> > Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:1735
> > +    bool visible = !(state & GDK_SURFACE_STATE_MINIMIZED);
> 
> This should check also for GDK_SURFACE_STATE_WITHDRAWN,
> which indicates that the surface is not being shown.
Comment 6 Carlos Garcia Campos 2020-06-01 05:38:23 PDT
Committed r262373: <https://trac.webkit.org/changeset/262373>