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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 return window_shape_; | 196 return window_shape_; |
197 } | 197 } |
198 | 198 |
199 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( | 199 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( |
200 bool active) { | 200 bool active) { |
201 if (active) { | 201 if (active) { |
202 FlashFrame(false); | 202 FlashFrame(false); |
203 OnHostActivated(); | 203 OnHostActivated(); |
204 open_windows().remove(xwindow_); | 204 open_windows().remove(xwindow_); |
205 open_windows().insert(open_windows().begin(), xwindow_); | 205 open_windows().insert(open_windows().begin(), xwindow_); |
| 206 } else { |
| 207 ReleaseCapture(); |
206 } | 208 } |
207 | 209 |
208 desktop_native_widget_aura_->HandleActivationChanged(active); | 210 desktop_native_widget_aura_->HandleActivationChanged(active); |
209 | 211 |
210 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); | 212 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); |
211 } | 213 } |
212 | 214 |
213 void DesktopWindowTreeHostX11::AddObserver( | 215 void DesktopWindowTreeHostX11::AddObserver( |
214 views::DesktopWindowTreeHostObserverX11* observer) { | 216 views::DesktopWindowTreeHostObserverX11* observer) { |
215 observer_list_.AddObserver(observer); | 217 observer_list_.AddObserver(observer); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 FROM_HERE, | 306 FROM_HERE, |
305 base::Bind(&DesktopWindowTreeHostX11::CloseNow, | 307 base::Bind(&DesktopWindowTreeHostX11::CloseNow, |
306 close_widget_factory_.GetWeakPtr())); | 308 close_widget_factory_.GetWeakPtr())); |
307 } | 309 } |
308 } | 310 } |
309 | 311 |
310 void DesktopWindowTreeHostX11::CloseNow() { | 312 void DesktopWindowTreeHostX11::CloseNow() { |
311 if (xwindow_ == None) | 313 if (xwindow_ == None) |
312 return; | 314 return; |
313 | 315 |
314 x11_capture_.reset(); | 316 ReleaseCapture(); |
315 native_widget_delegate_->OnNativeWidgetDestroying(); | 317 native_widget_delegate_->OnNativeWidgetDestroying(); |
316 | 318 |
317 // If we have children, close them. Use a copy for iteration because they'll | 319 // If we have children, close them. Use a copy for iteration because they'll |
318 // remove themselves. | 320 // remove themselves. |
319 std::set<DesktopWindowTreeHostX11*> window_children_copy = window_children_; | 321 std::set<DesktopWindowTreeHostX11*> window_children_copy = window_children_; |
320 for (std::set<DesktopWindowTreeHostX11*>::iterator it = | 322 for (std::set<DesktopWindowTreeHostX11*>::iterator it = |
321 window_children_copy.begin(); it != window_children_copy.end(); | 323 window_children_copy.begin(); it != window_children_copy.end(); |
322 ++it) { | 324 ++it) { |
323 (*it)->CloseNow(); | 325 (*it)->CloseNow(); |
324 } | 326 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 if (!window_mapped_) | 503 if (!window_mapped_) |
502 return; | 504 return; |
503 | 505 |
504 X11DesktopHandler::get()->ActivateWindow(xwindow_); | 506 X11DesktopHandler::get()->ActivateWindow(xwindow_); |
505 } | 507 } |
506 | 508 |
507 void DesktopWindowTreeHostX11::Deactivate() { | 509 void DesktopWindowTreeHostX11::Deactivate() { |
508 if (!IsActive()) | 510 if (!IsActive()) |
509 return; | 511 return; |
510 | 512 |
511 x11_capture_.reset(); | 513 ReleaseCapture(); |
512 X11DesktopHandler::get()->DeactivateWindow(xwindow_); | 514 X11DesktopHandler::get()->DeactivateWindow(xwindow_); |
513 } | 515 } |
514 | 516 |
515 bool DesktopWindowTreeHostX11::IsActive() const { | 517 bool DesktopWindowTreeHostX11::IsActive() const { |
516 return X11DesktopHandler::get()->IsActiveWindow(xwindow_); | 518 return X11DesktopHandler::get()->IsActiveWindow(xwindow_); |
517 } | 519 } |
518 | 520 |
519 void DesktopWindowTreeHostX11::Maximize() { | 521 void DesktopWindowTreeHostX11::Maximize() { |
520 // When we are in the process of requesting to maximize a window, we can | 522 // When we are in the process of requesting to maximize a window, we can |
521 // accurately keep track of our restored bounds instead of relying on the | 523 // accurately keep track of our restored bounds instead of relying on the |
522 // heuristics that are in the PropertyNotify and ConfigureNotify handlers. | 524 // heuristics that are in the PropertyNotify and ConfigureNotify handlers. |
523 restored_bounds_ = bounds_; | 525 restored_bounds_ = bounds_; |
524 | 526 |
525 SetWMSpecState(true, | 527 SetWMSpecState(true, |
526 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), | 528 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), |
527 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); | 529 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); |
528 if (IsMinimized()) | 530 if (IsMinimized()) |
529 ShowWindowWithState(ui::SHOW_STATE_NORMAL); | 531 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
530 } | 532 } |
531 | 533 |
532 void DesktopWindowTreeHostX11::Minimize() { | 534 void DesktopWindowTreeHostX11::Minimize() { |
533 x11_capture_.reset(); | 535 ReleaseCapture(); |
534 XIconifyWindow(xdisplay_, xwindow_, 0); | 536 XIconifyWindow(xdisplay_, xwindow_, 0); |
535 } | 537 } |
536 | 538 |
537 void DesktopWindowTreeHostX11::Restore() { | 539 void DesktopWindowTreeHostX11::Restore() { |
538 SetWMSpecState(false, | 540 SetWMSpecState(false, |
539 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), | 541 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), |
540 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); | 542 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); |
541 if (IsMinimized()) | 543 if (IsMinimized()) |
542 ShowWindowWithState(ui::SHOW_STATE_NORMAL); | 544 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
543 } | 545 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 } | 814 } |
813 | 815 |
814 XSetWMNormalHints(xdisplay_, xwindow_, &hints); | 816 XSetWMNormalHints(xdisplay_, xwindow_, &hints); |
815 } | 817 } |
816 | 818 |
817 void DesktopWindowTreeHostX11::OnNativeWidgetFocus() { | 819 void DesktopWindowTreeHostX11::OnNativeWidgetFocus() { |
818 native_widget_delegate_->AsWidget()->GetInputMethod()->OnFocus(); | 820 native_widget_delegate_->AsWidget()->GetInputMethod()->OnFocus(); |
819 } | 821 } |
820 | 822 |
821 void DesktopWindowTreeHostX11::OnNativeWidgetBlur() { | 823 void DesktopWindowTreeHostX11::OnNativeWidgetBlur() { |
822 if (xwindow_) { | 824 if (xwindow_) |
823 x11_capture_.reset(); | |
824 native_widget_delegate_->AsWidget()->GetInputMethod()->OnBlur(); | 825 native_widget_delegate_->AsWidget()->GetInputMethod()->OnBlur(); |
825 } | |
826 } | 826 } |
827 | 827 |
828 bool DesktopWindowTreeHostX11::IsAnimatingClosed() const { | 828 bool DesktopWindowTreeHostX11::IsAnimatingClosed() const { |
829 return false; | 829 return false; |
830 } | 830 } |
831 | 831 |
832 //////////////////////////////////////////////////////////////////////////////// | 832 //////////////////////////////////////////////////////////////////////////////// |
833 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: | 833 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: |
834 | 834 |
835 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() { | 835 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() { |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 if (linux_ui) { | 1803 if (linux_ui) { |
1804 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1804 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
1805 if (native_theme) | 1805 if (native_theme) |
1806 return native_theme; | 1806 return native_theme; |
1807 } | 1807 } |
1808 | 1808 |
1809 return ui::NativeTheme::instance(); | 1809 return ui::NativeTheme::instance(); |
1810 } | 1810 } |
1811 | 1811 |
1812 } // namespace views | 1812 } // namespace views |
OLD | NEW |