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

Side by Side 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: remove the VisibilityNotify event handler Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
6 6
7 #include <X11/extensions/shape.h> 7 #include <X11/extensions/shape.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/Xregion.h> 10 #include <X11/Xregion.h>
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 // minimized. 1252 // minimized.
1253 bool is_minimized = IsMinimized(); 1253 bool is_minimized = IsMinimized();
1254 if (is_minimized != was_minimized) { 1254 if (is_minimized != was_minimized) {
1255 if (is_minimized) { 1255 if (is_minimized) {
1256 compositor()->SetVisible(false); 1256 compositor()->SetVisible(false);
1257 content_window_->Hide(); 1257 content_window_->Hide();
1258 } else { 1258 } else {
1259 content_window_->Show(); 1259 content_window_->Show();
1260 compositor()->SetVisible(true); 1260 compositor()->SetVisible(true);
1261 } 1261 }
1262 } 1262 }
sadrul 2015/03/03 00:41:46 If this block of code does the right thing (i.e. c
joone 2015/03/03 03:30:22 Please see my previous comment.
1263 1263
1264 if (restored_bounds_in_pixels_.IsEmpty()) { 1264 if (restored_bounds_in_pixels_.IsEmpty()) {
1265 DCHECK(!IsFullscreen()); 1265 DCHECK(!IsFullscreen());
1266 if (IsMaximized()) { 1266 if (IsMaximized()) {
1267 // The request that we become maximized originated from a different 1267 // The request that we become maximized originated from a different
1268 // process. |bounds_in_pixels_| already contains our maximized bounds. Do 1268 // process. |bounds_in_pixels_| already contains our maximized bounds. Do
1269 // a best effort attempt to get restored bounds by setting it to our 1269 // a best effort attempt to get restored bounds by setting it to our
1270 // previously set bounds (and if we get this wrong, we aren't any worse 1270 // previously set bounds (and if we get this wrong, we aren't any worse
1271 // off since we'd otherwise be returning our maximized bounds). 1271 // off since we'd otherwise be returning our maximized bounds).
1272 restored_bounds_in_pixels_ = previous_bounds_in_pixels_; 1272 restored_bounds_in_pixels_ = previous_bounds_in_pixels_;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 &unused); 1745 &unused);
1746 } 1746 }
1747 gfx::Rect bounds_in_pixels(translated_x_in_pixels, translated_y_in_pixels, 1747 gfx::Rect bounds_in_pixels(translated_x_in_pixels, translated_y_in_pixels,
1748 xev->xconfigure.width, xev->xconfigure.height); 1748 xev->xconfigure.width, xev->xconfigure.height);
1749 bool size_changed = bounds_in_pixels_.size() != bounds_in_pixels.size(); 1749 bool size_changed = bounds_in_pixels_.size() != bounds_in_pixels.size();
1750 bool origin_changed = 1750 bool origin_changed =
1751 bounds_in_pixels_.origin() != bounds_in_pixels.origin(); 1751 bounds_in_pixels_.origin() != bounds_in_pixels.origin();
1752 previous_bounds_in_pixels_ = bounds_in_pixels_; 1752 previous_bounds_in_pixels_ = bounds_in_pixels_;
1753 bounds_in_pixels_ = bounds_in_pixels; 1753 bounds_in_pixels_ = bounds_in_pixels;
1754 1754
1755 if (origin_changed) 1755 if (origin_changed) {
1756 OnHostMoved(bounds_in_pixels_.origin()); 1756 OnHostMoved(bounds_in_pixels_.origin());
1757 // Allows to trigger visibilityChange events while swithcing between
1758 // workspaces.
1759 ::Screen* screen = DefaultScreenOfDisplay(xdisplay_);
1760 int screen_width = WidthOfScreen(screen);
1761 int screen_height = HeightOfScreen(screen);
1762
1763 if (translated_x_in_pixels < 0 || translated_x_in_pixels > screen_width
1764 || translated_y_in_pixels < 0 ||
1765 translated_y_in_pixels > screen_height)
1766 content_window_->SetPageVisibility(false);
1767 else
1768 content_window_->SetPageVisibility(true);
1769 }
1757 1770
1758 if (size_changed) { 1771 if (size_changed) {
1759 delayed_resize_task_.Reset(base::Bind( 1772 delayed_resize_task_.Reset(base::Bind(
1760 &DesktopWindowTreeHostX11::DelayedResize, 1773 &DesktopWindowTreeHostX11::DelayedResize,
1761 close_widget_factory_.GetWeakPtr(), bounds_in_pixels.size())); 1774 close_widget_factory_.GetWeakPtr(), bounds_in_pixels.size()));
1762 base::MessageLoop::current()->PostTask( 1775 base::MessageLoop::current()->PostTask(
1763 FROM_HERE, delayed_resize_task_.callback()); 1776 FROM_HERE, delayed_resize_task_.callback());
1764 } 1777 }
1765 break; 1778 break;
1766 } 1779 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 if (linux_ui) { 1999 if (linux_ui) {
1987 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 2000 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
1988 if (native_theme) 2001 if (native_theme)
1989 return native_theme; 2002 return native_theme;
1990 } 2003 }
1991 2004
1992 return ui::NativeTheme::instance(); 2005 return ui::NativeTheme::instance();
1993 } 2006 }
1994 2007
1995 } // namespace views 2008 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698