Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Unified Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 944763002: Make Page Visibility API work when the browser window is visible or not Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/window_observer.h ('k') | ui/wm/core/focus_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 784446e2dfced277d11e5800b29d1bcada28ee1b..1e8b01c58d52d8c4d3fe6238a8b526b2bb4b3ea5 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -1715,6 +1715,14 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
}
break;
}
+ case VisibilityNotify:
+ // Allows to trigger visibilityChange events when the browser window
+ // is minimized or restored.
+ if (xev->xvisibility.state == VisibilityFullyObscured)
+ content_window_->SetPageVisibility(false);
+ else
+ content_window_->SetPageVisibility(true);
+ break;
case FocusOut:
if (xev->xfocus.mode != NotifyGrab) {
ReleaseCapture();
@@ -1747,8 +1755,20 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
previous_bounds_ = bounds_;
bounds_ = bounds;
- if (origin_changed)
+ if (origin_changed) {
OnHostMoved(bounds_.origin());
+ // Allows to trigger visibilityChange events while swithcing between
+ // workspaces.
+ ::Screen* screen = DefaultScreenOfDisplay(xdisplay_);
+ int screen_width = WidthOfScreen(screen);
+ int screen_height = HeightOfScreen(screen);
+
+ if (translated_x < 0 || translated_x > screen_width ||
+ translated_y < 0 || translated_y > screen_height)
+ content_window_->SetPageVisibility(false);
+ else
+ content_window_->SetPageVisibility(true);
+ }
if (size_changed) {
delayed_resize_task_.Reset(base::Bind(
« no previous file with comments | « ui/aura/window_observer.h ('k') | ui/wm/core/focus_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698