Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1243 // called by PropertyNofify event from DispatchEvent() when the browser is | 1243 // called by PropertyNofify event from DispatchEvent() when the browser is |
| 1244 // minimized or shown from minimized state. On Windows, this is realized by | 1244 // minimized or shown from minimized state. On Windows, this is realized by |
| 1245 // calling OnHostResized() with an empty size. In particular, | 1245 // calling OnHostResized() with an empty size. In particular, |
| 1246 // HWNDMessageHandler::GetClientAreaBounds() returns an empty size when the | 1246 // HWNDMessageHandler::GetClientAreaBounds() returns an empty size when the |
| 1247 // window is minimized. On Linux, returning empty size in GetBounds() or | 1247 // window is minimized. On Linux, returning empty size in GetBounds() or |
| 1248 // SetBounds() does not work. | 1248 // SetBounds() does not work. |
| 1249 // We also propagate the minimization to the compositor, to makes sure that we | 1249 // We also propagate the minimization to the compositor, to makes sure that we |
| 1250 // don't draw any 'blank' frames that could be noticed in applications such as | 1250 // don't draw any 'blank' frames that could be noticed in applications such as |
| 1251 // window manager previews, which show content even when a window is | 1251 // window manager previews, which show content even when a window is |
| 1252 // minimized. | 1252 // minimized. |
| 1253 bool is_minimized = IsMinimized(); | 1253 bool is_minimized = IsMinimized(); |
|
sadrul
2015/02/23 21:43:33
Can this be fixed/made cleverer to work correctly
joone
2015/02/23 23:26:18
The Page Visibility API only works for minimizing/
| |
| 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 } |
| 1263 | 1263 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1708 break; | 1708 break; |
| 1709 } | 1709 } |
| 1710 case ui::ET_UNKNOWN: | 1710 case ui::ET_UNKNOWN: |
| 1711 // No event is created for X11-release events for mouse-wheel buttons. | 1711 // No event is created for X11-release events for mouse-wheel buttons. |
| 1712 break; | 1712 break; |
| 1713 default: | 1713 default: |
| 1714 NOTREACHED() << event_type; | 1714 NOTREACHED() << event_type; |
| 1715 } | 1715 } |
| 1716 break; | 1716 break; |
| 1717 } | 1717 } |
| 1718 case VisibilityNotify: | |
| 1719 // Allows to trigger visibilityChange events when the browser window | |
| 1720 // is minimized or restored. | |
| 1721 if (xev->xvisibility.state == VisibilityFullyObscured) | |
| 1722 content_window_->SetPageVisibility(false); | |
| 1723 else | |
| 1724 content_window_->SetPageVisibility(true); | |
| 1725 break; | |
| 1718 case FocusOut: | 1726 case FocusOut: |
| 1719 if (xev->xfocus.mode != NotifyGrab) { | 1727 if (xev->xfocus.mode != NotifyGrab) { |
| 1720 ReleaseCapture(); | 1728 ReleaseCapture(); |
| 1721 OnHostLostWindowCapture(); | 1729 OnHostLostWindowCapture(); |
| 1722 X11DesktopHandler::get()->ProcessXEvent(xev); | 1730 X11DesktopHandler::get()->ProcessXEvent(xev); |
| 1723 } else { | 1731 } else { |
| 1724 dispatcher()->OnHostLostMouseGrab(); | 1732 dispatcher()->OnHostLostMouseGrab(); |
| 1725 } | 1733 } |
| 1726 break; | 1734 break; |
| 1727 case FocusIn: | 1735 case FocusIn: |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1740 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_, | 1748 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_, |
| 1741 0, 0, &translated_x, &translated_y, &unused); | 1749 0, 0, &translated_x, &translated_y, &unused); |
| 1742 } | 1750 } |
| 1743 gfx::Rect bounds(translated_x, translated_y, | 1751 gfx::Rect bounds(translated_x, translated_y, |
| 1744 xev->xconfigure.width, xev->xconfigure.height); | 1752 xev->xconfigure.width, xev->xconfigure.height); |
| 1745 bool size_changed = bounds_.size() != bounds.size(); | 1753 bool size_changed = bounds_.size() != bounds.size(); |
| 1746 bool origin_changed = bounds_.origin() != bounds.origin(); | 1754 bool origin_changed = bounds_.origin() != bounds.origin(); |
| 1747 previous_bounds_ = bounds_; | 1755 previous_bounds_ = bounds_; |
| 1748 bounds_ = bounds; | 1756 bounds_ = bounds; |
| 1749 | 1757 |
| 1750 if (origin_changed) | 1758 if (origin_changed) { |
| 1751 OnHostMoved(bounds_.origin()); | 1759 OnHostMoved(bounds_.origin()); |
| 1760 // Allows to trigger visibilityChange events while swithcing between | |
| 1761 // workspaces. | |
| 1762 ::Screen* screen = DefaultScreenOfDisplay(xdisplay_); | |
| 1763 int screen_width = WidthOfScreen(screen); | |
| 1764 int screen_height = HeightOfScreen(screen); | |
| 1765 | |
| 1766 if (translated_x < 0 || translated_x > screen_width || | |
| 1767 translated_y < 0 || translated_y > screen_height) | |
| 1768 content_window_->SetPageVisibility(false); | |
| 1769 else | |
| 1770 content_window_->SetPageVisibility(true); | |
| 1771 } | |
| 1752 | 1772 |
| 1753 if (size_changed) { | 1773 if (size_changed) { |
| 1754 delayed_resize_task_.Reset(base::Bind( | 1774 delayed_resize_task_.Reset(base::Bind( |
| 1755 &DesktopWindowTreeHostX11::DelayedResize, | 1775 &DesktopWindowTreeHostX11::DelayedResize, |
| 1756 close_widget_factory_.GetWeakPtr(), | 1776 close_widget_factory_.GetWeakPtr(), |
| 1757 bounds.size())); | 1777 bounds.size())); |
| 1758 base::MessageLoop::current()->PostTask( | 1778 base::MessageLoop::current()->PostTask( |
| 1759 FROM_HERE, delayed_resize_task_.callback()); | 1779 FROM_HERE, delayed_resize_task_.callback()); |
| 1760 } | 1780 } |
| 1761 break; | 1781 break; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1947 if (linux_ui) { | 1967 if (linux_ui) { |
| 1948 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1968 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
| 1949 if (native_theme) | 1969 if (native_theme) |
| 1950 return native_theme; | 1970 return native_theme; |
| 1951 } | 1971 } |
| 1952 | 1972 |
| 1953 return ui::NativeTheme::instance(); | 1973 return ui::NativeTheme::instance(); |
| 1954 } | 1974 } |
| 1955 | 1975 |
| 1956 } // namespace views | 1976 } // namespace views |
| OLD | NEW |