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 (window_mapped_) | |
339 return; | |
340 | |
338 if (show_state != ui::SHOW_STATE_DEFAULT && | 341 if (show_state != ui::SHOW_STATE_DEFAULT && |
339 show_state != ui::SHOW_STATE_NORMAL) { | 342 show_state != ui::SHOW_STATE_NORMAL && |
340 // Only forwarding to Show(). | 343 show_state != ui::SHOW_STATE_INACTIVE) { |
344 // It will behave like SHOW_STATE_NORMAL. | |
341 NOTIMPLEMENTED(); | 345 NOTIMPLEMENTED(); |
342 } | 346 } |
343 | 347 |
344 Show(); | 348 // Before we map the window, set size hints. Otherwise, some window managers |
349 // will ignore toplevel XMoveWindow commands. | |
Matt Giuca
2014/01/13 00:18:57
Optional nit (I realize you didn't write this): to
mlamouri (slow - plz ping)
2014/01/13 02:04:58
If I knew which WM would ignore the toplevel XMove
| |
350 XSizeHints size_hints; | |
351 size_hints.flags = PPosition; | |
352 size_hints.x = bounds_.x(); | |
353 size_hints.y = bounds_.y(); | |
354 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | |
355 | |
356 XWMHints wm_hints; | |
357 wm_hints.flags = InputHint | StateHint; | |
358 wm_hints.input = show_state != ui::SHOW_STATE_INACTIVE; | |
Matt Giuca
2014/01/13 00:18:57
// If SHOW_STATE_INACTIVE, tell the window manager
mlamouri (slow - plz ping)
2014/01/13 02:04:58
Done.
Matt Giuca
2014/01/14 05:43:27
I don't see any such comment?
| |
359 wm_hints.initial_state = NormalState; | |
360 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
361 | |
362 XMapWindow(xdisplay_, xwindow_); | |
363 | |
364 // We now block until our window is mapped. Some X11 APIs will crash and | |
365 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
Matt Giuca
2014/01/13 00:18:57
Optional nit (I realize you didn't write this): Ge
mlamouri (slow - plz ping)
2014/01/13 02:04:58
I removed "and burn". I guess those other API call
| |
366 // asynchronous. | |
367 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
368 window_mapped_ = true; | |
369 | |
370 // The window has been created and mapped. Keeping the hint will simply | |
371 // confuse the WM at that point. | |
Matt Giuca
2014/01/13 00:18:57
What does "confuse" mean? Which hint are you refer
mlamouri (slow - plz ping)
2014/01/13 02:04:58
Updated the comment. There is no need to set |init
| |
372 if (show_state == ui::SHOW_STATE_INACTIVE) { | |
373 XWMHints wm_hints; | |
374 wm_hints.flags = InputHint; | |
375 wm_hints.input = true; | |
Matt Giuca
2014/01/13 00:18:57
// Tell the window manager that the window is now
mlamouri (slow - plz ping)
2014/01/13 02:04:58
Done.
| |
376 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
377 } | |
378 | |
379 if (show_state != ui::SHOW_STATE_INACTIVE) | |
Matt Giuca
2014/01/13 00:18:57
How about "else"?
mlamouri (slow - plz ping)
2014/01/13 02:04:58
That has changed. It is being taken care of in cl
Matt Giuca
2014/01/14 05:43:27
As I wrote on that CL, is this one going first or
| |
380 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
345 } | 381 } |
346 | 382 |
347 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( | 383 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( |
348 const gfx::Rect& restored_bounds) { | 384 const gfx::Rect& restored_bounds) { |
349 restored_bounds_ = restored_bounds; | 385 restored_bounds_ = restored_bounds; |
350 Maximize(); | 386 Maximize(); |
351 Show(); | 387 Show(); |
352 } | 388 } |
353 | 389 |
354 bool DesktopWindowTreeHostX11::IsVisible() const { | 390 bool DesktopWindowTreeHostX11::IsVisible() const { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 | 754 |
719 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { | 755 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { |
720 return root_window_; | 756 return root_window_; |
721 } | 757 } |
722 | 758 |
723 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { | 759 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { |
724 return xwindow_; | 760 return xwindow_; |
725 } | 761 } |
726 | 762 |
727 void DesktopWindowTreeHostX11::Show() { | 763 void DesktopWindowTreeHostX11::Show() { |
728 if (!window_mapped_) { | 764 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 } | 765 } |
748 | 766 |
749 void DesktopWindowTreeHostX11::Hide() { | 767 void DesktopWindowTreeHostX11::Hide() { |
750 if (window_mapped_) { | 768 if (window_mapped_) { |
751 XWithdrawWindow(xdisplay_, xwindow_, 0); | 769 XWithdrawWindow(xdisplay_, xwindow_, 0); |
752 window_mapped_ = false; | 770 window_mapped_ = false; |
753 } | 771 } |
754 } | 772 } |
755 | 773 |
756 void DesktopWindowTreeHostX11::ToggleFullScreen() { | 774 void DesktopWindowTreeHostX11::ToggleFullScreen() { |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 if (linux_ui) { | 1564 if (linux_ui) { |
1547 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1565 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
1548 if (native_theme) | 1566 if (native_theme) |
1549 return native_theme; | 1567 return native_theme; |
1550 } | 1568 } |
1551 | 1569 |
1552 return ui::NativeTheme::instance(); | 1570 return ui::NativeTheme::instance(); |
1553 } | 1571 } |
1554 | 1572 |
1555 } // namespace views | 1573 } // namespace views |
OLD | NEW |