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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 | 323 |
324 desktop_native_widget_aura_->OnHostClosed(); | 324 desktop_native_widget_aura_->OnHostClosed(); |
325 } | 325 } |
326 | 326 |
327 aura::RootWindowHost* DesktopRootWindowHostX11::AsRootWindowHost() { | 327 aura::RootWindowHost* DesktopRootWindowHostX11::AsRootWindowHost() { |
328 return this; | 328 return this; |
329 } | 329 } |
330 | 330 |
331 void DesktopRootWindowHostX11::ShowWindowWithState( | 331 void DesktopRootWindowHostX11::ShowWindowWithState( |
332 ui::WindowShowState show_state) { | 332 ui::WindowShowState show_state) { |
333 if (window_mapped_) | |
334 return; | |
335 | |
333 if (show_state != ui::SHOW_STATE_DEFAULT && | 336 if (show_state != ui::SHOW_STATE_DEFAULT && |
334 show_state != ui::SHOW_STATE_NORMAL) { | 337 show_state != ui::SHOW_STATE_NORMAL && |
335 // Only forwarding to Show(). | 338 show_state != ui::SHOW_STATE_INACTIVE) { |
339 // It will behave like SHOW_STATE_NORMAL. | |
336 NOTIMPLEMENTED(); | 340 NOTIMPLEMENTED(); |
337 } | 341 } |
338 | 342 |
339 Show(); | 343 // Before we map the window, set size hints. Otherwise, some window managers |
344 // will ignore toplevel XMoveWindow commands. | |
345 XSizeHints size_hints; | |
346 size_hints.flags = PPosition; | |
347 size_hints.x = bounds_.x(); | |
348 size_hints.y = bounds_.y(); | |
349 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | |
350 | |
351 XWMHints wm_hints; | |
352 wm_hints.flags = InputHint | StateHint; | |
353 wm_hints.input = show_state != ui::SHOW_STATE_INACTIVE; | |
354 wm_hints.initial_state = NormalState; | |
355 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
356 | |
357 XMapWindow(xdisplay_, xwindow_); | |
358 | |
359 // We now block until our window is mapped. Some X11 APIs will crash and | |
360 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
361 // asynchronous. | |
362 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
363 window_mapped_ = true; | |
364 | |
365 // The window has been created and mapped. Keeping the hint will simply | |
366 // confuse the WM at that point. | |
367 if (show_state == ui::SHOW_STATE_INACTIVE) { | |
368 XWMHints wm_hints; | |
369 wm_hints.flags = InputHint; | |
370 wm_hints.input = true; | |
371 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
372 } | |
373 | |
374 if (show_state != ui::SHOW_STATE_INACTIVE) | |
sadrul
2013/12/16 03:40:10
Is this change sufficient to not give focus to the
mlamouri (slow - plz ping)
2013/12/16 15:26:05
We still need to call XMapWindow, otherwise XRaise
| |
375 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
340 } | 376 } |
341 | 377 |
342 void DesktopRootWindowHostX11::ShowMaximizedWithBounds( | 378 void DesktopRootWindowHostX11::ShowMaximizedWithBounds( |
343 const gfx::Rect& restored_bounds) { | 379 const gfx::Rect& restored_bounds) { |
344 restored_bounds_ = restored_bounds; | 380 restored_bounds_ = restored_bounds; |
345 Maximize(); | 381 Maximize(); |
346 Show(); | 382 Show(); |
347 } | 383 } |
348 | 384 |
349 bool DesktopRootWindowHostX11::IsVisible() const { | 385 bool DesktopRootWindowHostX11::IsVisible() const { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 | 743 |
708 aura::RootWindow* DesktopRootWindowHostX11::GetRootWindow() { | 744 aura::RootWindow* DesktopRootWindowHostX11::GetRootWindow() { |
709 return root_window_; | 745 return root_window_; |
710 } | 746 } |
711 | 747 |
712 gfx::AcceleratedWidget DesktopRootWindowHostX11::GetAcceleratedWidget() { | 748 gfx::AcceleratedWidget DesktopRootWindowHostX11::GetAcceleratedWidget() { |
713 return xwindow_; | 749 return xwindow_; |
714 } | 750 } |
715 | 751 |
716 void DesktopRootWindowHostX11::Show() { | 752 void DesktopRootWindowHostX11::Show() { |
717 if (!window_mapped_) { | 753 ShowWindowWithState(ui::SHOW_STATE_INACTIVE); |
sadrul
2013/12/16 03:40:10
This is not right.
mlamouri (slow - plz ping)
2013/12/16 15:26:05
This is actually what Widget::Show() is expected t
| |
718 // Before we map the window, set size hints. Otherwise, some window managers | |
719 // will ignore toplevel XMoveWindow commands. | |
720 XSizeHints size_hints; | |
721 size_hints.flags = PPosition; | |
722 size_hints.x = bounds_.x(); | |
723 size_hints.y = bounds_.y(); | |
724 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | |
725 | |
726 XMapWindow(xdisplay_, xwindow_); | |
727 | |
728 // We now block until our window is mapped. Some X11 APIs will crash and | |
729 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
730 // asynchronous. | |
731 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
732 window_mapped_ = true; | |
733 } | |
734 | |
735 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
736 } | 754 } |
737 | 755 |
738 void DesktopRootWindowHostX11::Hide() { | 756 void DesktopRootWindowHostX11::Hide() { |
739 if (window_mapped_) { | 757 if (window_mapped_) { |
740 XWithdrawWindow(xdisplay_, xwindow_, 0); | 758 XWithdrawWindow(xdisplay_, xwindow_, 0); |
741 window_mapped_ = false; | 759 window_mapped_ = false; |
742 } | 760 } |
743 } | 761 } |
744 | 762 |
745 void DesktopRootWindowHostX11::ToggleFullScreen() { | 763 void DesktopRootWindowHostX11::ToggleFullScreen() { |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1535 if (linux_ui) { | 1553 if (linux_ui) { |
1536 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1554 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
1537 if (native_theme) | 1555 if (native_theme) |
1538 return native_theme; | 1556 return native_theme; |
1539 } | 1557 } |
1540 | 1558 |
1541 return ui::NativeTheme::instance(); | 1559 return ui::NativeTheme::instance(); |
1542 } | 1560 } |
1543 | 1561 |
1544 } // namespace views | 1562 } // namespace views |
OLD | NEW |