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 if (show_state == ui::SHOW_STATE_INACTIVE) { | |
352 XWMHints wm_hints; | |
353 wm_hints.flags = InputHint; | |
354 wm_hints.input = false; | |
355 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
Elliot Glaysher
2013/12/10 20:21:55
While I'm not sure if the use of .input is correct
| |
356 } | |
357 | |
358 XMapWindow(xdisplay_, xwindow_); | |
359 | |
360 // We now block until our window is mapped. Some X11 APIs will crash and | |
361 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
362 // asynchronous. | |
363 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
364 window_mapped_ = true; | |
365 | |
366 // The window has been created and mapped. Keeping the hint will simply | |
367 // confuse the WM at that point. | |
368 if (show_state == ui::SHOW_STATE_INACTIVE) { | |
369 XWMHints wm_hints; | |
370 wm_hints.flags = InputHint; | |
371 wm_hints.input = true; | |
372 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
Elliot Glaysher
2013/12/10 20:21:55
I also suspect that we should be setting this all
mlamouri (slow - plz ping)
2013/12/11 14:58:48
I guess setting this on the previous call all the
| |
373 } | |
374 | |
375 if (show_state != ui::SHOW_STATE_INACTIVE) | |
376 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
340 } | 377 } |
341 | 378 |
342 void DesktopRootWindowHostX11::ShowMaximizedWithBounds( | 379 void DesktopRootWindowHostX11::ShowMaximizedWithBounds( |
343 const gfx::Rect& restored_bounds) { | 380 const gfx::Rect& restored_bounds) { |
344 restored_bounds_ = restored_bounds; | 381 restored_bounds_ = restored_bounds; |
345 Maximize(); | 382 Maximize(); |
346 Show(); | 383 Show(); |
347 } | 384 } |
348 | 385 |
349 bool DesktopRootWindowHostX11::IsVisible() const { | 386 bool DesktopRootWindowHostX11::IsVisible() const { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 | 744 |
708 aura::RootWindow* DesktopRootWindowHostX11::GetRootWindow() { | 745 aura::RootWindow* DesktopRootWindowHostX11::GetRootWindow() { |
709 return root_window_; | 746 return root_window_; |
710 } | 747 } |
711 | 748 |
712 gfx::AcceleratedWidget DesktopRootWindowHostX11::GetAcceleratedWidget() { | 749 gfx::AcceleratedWidget DesktopRootWindowHostX11::GetAcceleratedWidget() { |
713 return xwindow_; | 750 return xwindow_; |
714 } | 751 } |
715 | 752 |
716 void DesktopRootWindowHostX11::Show() { | 753 void DesktopRootWindowHostX11::Show() { |
717 if (!window_mapped_) { | 754 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
mlamouri (slow - plz ping)
2013/12/11 14:58:48
I realise that ::Show() is actually expecting to n
| |
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 } | 755 } |
737 | 756 |
738 void DesktopRootWindowHostX11::Hide() { | 757 void DesktopRootWindowHostX11::Hide() { |
739 if (window_mapped_) { | 758 if (window_mapped_) { |
740 XWithdrawWindow(xdisplay_, xwindow_, 0); | 759 XWithdrawWindow(xdisplay_, xwindow_, 0); |
741 window_mapped_ = false; | 760 window_mapped_ = false; |
742 } | 761 } |
743 } | 762 } |
744 | 763 |
745 void DesktopRootWindowHostX11::ToggleFullScreen() { | 764 void DesktopRootWindowHostX11::ToggleFullScreen() { |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1535 if (linux_ui) { | 1554 if (linux_ui) { |
1536 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1555 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
1537 if (native_theme) | 1556 if (native_theme) |
1538 return native_theme; | 1557 return native_theme; |
1539 } | 1558 } |
1540 | 1559 |
1541 return ui::NativeTheme::instance(); | 1560 return ui::NativeTheme::instance(); |
1542 } | 1561 } |
1543 | 1562 |
1544 } // namespace views | 1563 } // namespace views |
OLD | NEW |