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/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/Xregion.h> | 8 #include <X11/Xregion.h> |
9 #include <X11/Xutil.h> | 9 #include <X11/Xutil.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // DesktopWindowTreeHostX11, public: | 158 // DesktopWindowTreeHostX11, public: |
159 | 159 |
160 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( | 160 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( |
161 internal::NativeWidgetDelegate* native_widget_delegate, | 161 internal::NativeWidgetDelegate* native_widget_delegate, |
162 DesktopNativeWidgetAura* desktop_native_widget_aura) | 162 DesktopNativeWidgetAura* desktop_native_widget_aura) |
163 : xdisplay_(gfx::GetXDisplay()), | 163 : xdisplay_(gfx::GetXDisplay()), |
164 xwindow_(0), | 164 xwindow_(0), |
165 x_root_window_(DefaultRootWindow(xdisplay_)), | 165 x_root_window_(DefaultRootWindow(xdisplay_)), |
166 atom_cache_(xdisplay_, kAtomsToCache), | 166 atom_cache_(xdisplay_, kAtomsToCache), |
167 window_mapped_(false), | 167 window_mapped_(false), |
| 168 wait_for_unmap_(false), |
168 is_fullscreen_(false), | 169 is_fullscreen_(false), |
169 is_always_on_top_(false), | 170 is_always_on_top_(false), |
170 use_native_frame_(false), | 171 use_native_frame_(false), |
171 should_maximize_after_map_(false), | 172 should_maximize_after_map_(false), |
172 use_argb_visual_(false), | 173 use_argb_visual_(false), |
173 drag_drop_client_(NULL), | 174 drag_drop_client_(NULL), |
174 native_widget_delegate_(native_widget_delegate), | 175 native_widget_delegate_(native_widget_delegate), |
175 desktop_native_widget_aura_(desktop_native_widget_aura), | 176 desktop_native_widget_aura_(desktop_native_widget_aura), |
176 content_window_(NULL), | 177 content_window_(NULL), |
177 window_parent_(NULL), | 178 window_parent_(NULL), |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 | 971 |
971 void DesktopWindowTreeHostX11::ShowImpl() { | 972 void DesktopWindowTreeHostX11::ShowImpl() { |
972 ShowWindowWithState(ui::SHOW_STATE_NORMAL); | 973 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
973 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); | 974 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
974 } | 975 } |
975 | 976 |
976 void DesktopWindowTreeHostX11::HideImpl() { | 977 void DesktopWindowTreeHostX11::HideImpl() { |
977 if (window_mapped_) { | 978 if (window_mapped_) { |
978 XWithdrawWindow(xdisplay_, xwindow_, 0); | 979 XWithdrawWindow(xdisplay_, xwindow_, 0); |
979 window_mapped_ = false; | 980 window_mapped_ = false; |
| 981 wait_for_unmap_ = true; |
980 } | 982 } |
981 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); | 983 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); |
982 } | 984 } |
983 | 985 |
984 gfx::Rect DesktopWindowTreeHostX11::GetBounds() const { | 986 gfx::Rect DesktopWindowTreeHostX11::GetBounds() const { |
985 return bounds_in_pixels_; | 987 return bounds_in_pixels_; |
986 } | 988 } |
987 | 989 |
988 void DesktopWindowTreeHostX11::SetBounds( | 990 void DesktopWindowTreeHostX11::SetBounds( |
989 const gfx::Rect& requested_bounds_in_pixel) { | 991 const gfx::Rect& requested_bounds_in_pixel) { |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 XChangeProperty(xdisplay_, | 1660 XChangeProperty(xdisplay_, |
1659 xwindow_, | 1661 xwindow_, |
1660 atom_cache_.GetAtom("_NET_WM_USER_TIME"), | 1662 atom_cache_.GetAtom("_NET_WM_USER_TIME"), |
1661 XA_CARDINAL, | 1663 XA_CARDINAL, |
1662 32, | 1664 32, |
1663 PropModeReplace, | 1665 PropModeReplace, |
1664 reinterpret_cast<const unsigned char *>(&wm_user_time_ms), | 1666 reinterpret_cast<const unsigned char *>(&wm_user_time_ms), |
1665 1); | 1667 1); |
1666 } | 1668 } |
1667 | 1669 |
| 1670 ui::X11EventSource* event_source = ui::X11EventSource::GetInstance(); |
| 1671 DCHECK(event_source); |
| 1672 |
| 1673 if (wait_for_unmap_) { |
| 1674 // Block until our window is unmapped. This avoids a race condition when |
| 1675 // remapping an unmapped window. |
| 1676 event_source->BlockUntilWindowUnmapped(xwindow_); |
| 1677 DCHECK(!wait_for_unmap_); |
| 1678 } |
| 1679 |
1668 XMapWindow(xdisplay_, xwindow_); | 1680 XMapWindow(xdisplay_, xwindow_); |
1669 | 1681 |
1670 // We now block until our window is mapped. Some X11 APIs will crash and | 1682 // We now block until our window is mapped. Some X11 APIs will crash and |
1671 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | 1683 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is |
1672 // asynchronous. | 1684 // asynchronous. |
1673 if (ui::X11EventSource::GetInstance()) | 1685 event_source->BlockUntilWindowMapped(xwindow_); |
1674 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_); | |
1675 } | 1686 } |
1676 | 1687 |
1677 void DesktopWindowTreeHostX11::SetWindowTransparency() { | 1688 void DesktopWindowTreeHostX11::SetWindowTransparency() { |
1678 compositor()->SetHostHasTransparentBackground(use_argb_visual_); | 1689 compositor()->SetHostHasTransparentBackground(use_argb_visual_); |
1679 window()->SetTransparent(use_argb_visual_); | 1690 window()->SetTransparent(use_argb_visual_); |
1680 content_window_->SetTransparent(use_argb_visual_); | 1691 content_window_->SetTransparent(use_argb_visual_); |
1681 } | 1692 } |
1682 | 1693 |
1683 void DesktopWindowTreeHostX11::Relayout() { | 1694 void DesktopWindowTreeHostX11::Relayout() { |
1684 Widget* widget = native_widget_delegate_->AsWidget(); | 1695 Widget* widget = native_widget_delegate_->AsWidget(); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 // Some WMs only respect maximize hints after the window has been mapped. | 1907 // Some WMs only respect maximize hints after the window has been mapped. |
1897 // Check whether we need to re-do a maximization. | 1908 // Check whether we need to re-do a maximization. |
1898 if (should_maximize_after_map_) { | 1909 if (should_maximize_after_map_) { |
1899 Maximize(); | 1910 Maximize(); |
1900 should_maximize_after_map_ = false; | 1911 should_maximize_after_map_ = false; |
1901 } | 1912 } |
1902 | 1913 |
1903 break; | 1914 break; |
1904 } | 1915 } |
1905 case UnmapNotify: { | 1916 case UnmapNotify: { |
| 1917 wait_for_unmap_ = false; |
1906 FOR_EACH_OBSERVER(DesktopWindowTreeHostObserverX11, | 1918 FOR_EACH_OBSERVER(DesktopWindowTreeHostObserverX11, |
1907 observer_list_, | 1919 observer_list_, |
1908 OnWindowUnmapped(xwindow_)); | 1920 OnWindowUnmapped(xwindow_)); |
1909 break; | 1921 break; |
1910 } | 1922 } |
1911 case ClientMessage: { | 1923 case ClientMessage: { |
1912 Atom message_type = xev->xclient.message_type; | 1924 Atom message_type = xev->xclient.message_type; |
1913 if (message_type == atom_cache_.GetAtom("WM_PROTOCOLS")) { | 1925 if (message_type == atom_cache_.GetAtom("WM_PROTOCOLS")) { |
1914 Atom protocol = static_cast<Atom>(xev->xclient.data.l[0]); | 1926 Atom protocol = static_cast<Atom>(xev->xclient.data.l[0]); |
1915 if (protocol == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { | 1927 if (protocol == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 if (linux_ui) { | 2065 if (linux_ui) { |
2054 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2066 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2055 if (native_theme) | 2067 if (native_theme) |
2056 return native_theme; | 2068 return native_theme; |
2057 } | 2069 } |
2058 | 2070 |
2059 return ui::NativeThemeAura::instance(); | 2071 return ui::NativeThemeAura::instance(); |
2060 } | 2072 } |
2061 | 2073 |
2062 } // namespace views | 2074 } // namespace views |
OLD | NEW |