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_root_window_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 | 328 |
| 329 desktop_native_widget_aura_->OnHostClosed(); | 329 desktop_native_widget_aura_->OnHostClosed(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() { | 332 aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() { |
| 333 return this; | 333 return this; |
| 334 } | 334 } |
| 335 | 335 |
| 336 void DesktopWindowTreeHostX11::ShowWindowWithState( | 336 void DesktopWindowTreeHostX11::ShowWindowWithState( |
| 337 ui::WindowShowState show_state) { | 337 ui::WindowShowState show_state) { |
| 338 if (show_state != ui::SHOW_STATE_DEFAULT && | 338 if (!window_mapped_) { |
|
Matt Giuca
2014/01/14 05:43:28
Why did you revert this change? (Is it because you
| |
| 339 show_state != ui::SHOW_STATE_NORMAL) { | 339 if (show_state != ui::SHOW_STATE_DEFAULT && |
| 340 // Only forwarding to Show(). | 340 show_state != ui::SHOW_STATE_NORMAL && |
| 341 NOTIMPLEMENTED(); | 341 show_state != ui::SHOW_STATE_INACTIVE) { |
| 342 // It will behave like SHOW_STATE_NORMAL. | |
| 343 NOTIMPLEMENTED(); | |
| 344 } | |
| 345 | |
| 346 // Before we map the window, set size hints. Otherwise, some window managers | |
| 347 // will ignore toplevel XMoveWindow commands. | |
| 348 XSizeHints size_hints; | |
| 349 size_hints.flags = PPosition; | |
| 350 size_hints.x = bounds_.x(); | |
| 351 size_hints.y = bounds_.y(); | |
| 352 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | |
| 353 | |
| 354 XWMHints wm_hints; | |
| 355 wm_hints.flags = InputHint | StateHint; | |
| 356 wm_hints.input = show_state != ui::SHOW_STATE_INACTIVE; | |
| 357 wm_hints.initial_state = NormalState; | |
| 358 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
| 359 | |
| 360 XMapWindow(xdisplay_, xwindow_); | |
| 361 | |
| 362 // We now block until our window is mapped. Some X11 APIs will crash and | |
| 363 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
| 364 // asynchronous. | |
| 365 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
| 366 window_mapped_ = true; | |
| 367 | |
| 368 // The window has been created and mapped. It should now accept input. | |
| 369 if (show_state == ui::SHOW_STATE_INACTIVE) { | |
| 370 XWMHints wm_hints; | |
| 371 wm_hints.flags = InputHint; | |
| 372 wm_hints.input = true; | |
| 373 // Tell the window manager that the window is now focusable. | |
| 374 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
| 375 } | |
| 342 } | 376 } |
| 343 | 377 |
| 344 Show(); | 378 if (show_state == ui::SHOW_STATE_NORMAL || |
| 379 show_state == ui::SHOW_STATE_MAXIMIZED) { | |
| 380 Activate(); | |
| 381 } | |
| 382 | |
| 383 if (show_state != ui::SHOW_STATE_INACTIVE) | |
| 384 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
| 345 } | 385 } |
| 346 | 386 |
| 347 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( | 387 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( |
| 348 const gfx::Rect& restored_bounds) { | 388 const gfx::Rect& restored_bounds) { |
| 349 restored_bounds_ = restored_bounds; | 389 restored_bounds_ = restored_bounds; |
| 350 Maximize(); | 390 Maximize(); |
| 351 Show(); | 391 Show(); |
| 352 } | 392 } |
| 353 | 393 |
| 354 bool DesktopWindowTreeHostX11::IsVisible() const { | 394 bool DesktopWindowTreeHostX11::IsVisible() const { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 | 758 |
| 719 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { | 759 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { |
| 720 return root_window_; | 760 return root_window_; |
| 721 } | 761 } |
| 722 | 762 |
| 723 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { | 763 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { |
| 724 return xwindow_; | 764 return xwindow_; |
| 725 } | 765 } |
| 726 | 766 |
| 727 void DesktopWindowTreeHostX11::Show() { | 767 void DesktopWindowTreeHostX11::Show() { |
| 728 if (!window_mapped_) { | 768 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
| 729 // Before we map the window, set size hints. Otherwise, some window managers | |
| 730 // will ignore toplevel XMoveWindow commands. | |
| 731 XSizeHints size_hints; | |
| 732 size_hints.flags = PPosition; | |
| 733 size_hints.x = bounds_.x(); | |
| 734 size_hints.y = bounds_.y(); | |
| 735 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | |
| 736 | |
| 737 XMapWindow(xdisplay_, xwindow_); | |
| 738 | |
| 739 // We now block until our window is mapped. Some X11 APIs will crash and | |
| 740 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
| 741 // asynchronous. | |
| 742 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
| 743 window_mapped_ = true; | |
| 744 } | |
| 745 | |
| 746 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
| 747 } | 769 } |
| 748 | 770 |
| 749 void DesktopWindowTreeHostX11::Hide() { | 771 void DesktopWindowTreeHostX11::Hide() { |
| 750 if (window_mapped_) { | 772 if (window_mapped_) { |
| 751 XWithdrawWindow(xdisplay_, xwindow_, 0); | 773 XWithdrawWindow(xdisplay_, xwindow_, 0); |
| 752 window_mapped_ = false; | 774 window_mapped_ = false; |
| 753 } | 775 } |
| 754 } | 776 } |
| 755 | 777 |
| 756 void DesktopWindowTreeHostX11::ToggleFullScreen() { | 778 void DesktopWindowTreeHostX11::ToggleFullScreen() { |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1546 if (linux_ui) { | 1568 if (linux_ui) { |
| 1547 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1569 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 1548 if (native_theme) | 1570 if (native_theme) |
| 1549 return native_theme; | 1571 return native_theme; |
| 1550 } | 1572 } |
| 1551 | 1573 |
| 1552 return ui::NativeTheme::instance(); | 1574 return ui::NativeTheme::instance(); |
| 1553 } | 1575 } |
| 1554 | 1576 |
| 1555 } // namespace views | 1577 } // namespace views |
| OLD | NEW |