| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 332 |
| 333 desktop_native_widget_aura_->OnHostClosed(); | 333 desktop_native_widget_aura_->OnHostClosed(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() { | 336 aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() { |
| 337 return this; | 337 return this; |
| 338 } | 338 } |
| 339 | 339 |
| 340 void DesktopWindowTreeHostX11::ShowWindowWithState( | 340 void DesktopWindowTreeHostX11::ShowWindowWithState( |
| 341 ui::WindowShowState show_state) { | 341 ui::WindowShowState show_state) { |
| 342 if (show_state != ui::SHOW_STATE_DEFAULT && | 342 if (!window_mapped_) |
| 343 show_state != ui::SHOW_STATE_NORMAL) { | 343 MapWindow(show_state); |
| 344 // Only forwarding to Show(). | 344 |
| 345 NOTIMPLEMENTED(); | 345 if (show_state == ui::SHOW_STATE_NORMAL || |
| 346 show_state == ui::SHOW_STATE_MAXIMIZED) { |
| 347 Activate(); |
| 346 } | 348 } |
| 347 | 349 |
| 348 Show(); | 350 native_widget_delegate_->AsWidget()->SetInitialFocus(); |
| 349 } | 351 } |
| 350 | 352 |
| 351 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( | 353 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( |
| 352 const gfx::Rect& restored_bounds) { | 354 const gfx::Rect& restored_bounds) { |
| 353 restored_bounds_ = restored_bounds; | 355 restored_bounds_ = restored_bounds; |
| 354 Maximize(); | 356 Maximize(); |
| 355 Show(); | 357 Show(); |
| 356 } | 358 } |
| 357 | 359 |
| 358 bool DesktopWindowTreeHostX11::IsVisible() const { | 360 bool DesktopWindowTreeHostX11::IsVisible() const { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 724 |
| 723 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { | 725 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { |
| 724 return root_window_; | 726 return root_window_; |
| 725 } | 727 } |
| 726 | 728 |
| 727 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { | 729 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { |
| 728 return xwindow_; | 730 return xwindow_; |
| 729 } | 731 } |
| 730 | 732 |
| 731 void DesktopWindowTreeHostX11::Show() { | 733 void DesktopWindowTreeHostX11::Show() { |
| 732 if (!window_mapped_) { | 734 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
| 733 // Before we map the window, set size hints. Otherwise, some window managers | |
| 734 // will ignore toplevel XMoveWindow commands. | |
| 735 XSizeHints size_hints; | |
| 736 size_hints.flags = PPosition; | |
| 737 size_hints.x = bounds_.x(); | |
| 738 size_hints.y = bounds_.y(); | |
| 739 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | |
| 740 | |
| 741 XMapWindow(xdisplay_, xwindow_); | |
| 742 | |
| 743 // We now block until our window is mapped. Some X11 APIs will crash and | |
| 744 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
| 745 // asynchronous. | |
| 746 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
| 747 window_mapped_ = true; | |
| 748 } | |
| 749 | |
| 750 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
| 751 } | 735 } |
| 752 | 736 |
| 753 void DesktopWindowTreeHostX11::Hide() { | 737 void DesktopWindowTreeHostX11::Hide() { |
| 754 if (window_mapped_) { | 738 if (window_mapped_) { |
| 755 XWithdrawWindow(xdisplay_, xwindow_, 0); | 739 XWithdrawWindow(xdisplay_, xwindow_, 0); |
| 756 window_mapped_ = false; | 740 window_mapped_ = false; |
| 757 } | 741 } |
| 758 } | 742 } |
| 759 | 743 |
| 760 void DesktopWindowTreeHostX11::ToggleFullScreen() { | 744 void DesktopWindowTreeHostX11::ToggleFullScreen() { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 for (int x = 0; x < width; ++x) | 1175 for (int x = 0; x < width; ++x) |
| 1192 data->push_back(bitmap.getColor(x, y)); | 1176 data->push_back(bitmap.getColor(x, y)); |
| 1193 } | 1177 } |
| 1194 | 1178 |
| 1195 std::list<XID>& DesktopWindowTreeHostX11::open_windows() { | 1179 std::list<XID>& DesktopWindowTreeHostX11::open_windows() { |
| 1196 if (!open_windows_) | 1180 if (!open_windows_) |
| 1197 open_windows_ = new std::list<XID>(); | 1181 open_windows_ = new std::list<XID>(); |
| 1198 return *open_windows_; | 1182 return *open_windows_; |
| 1199 } | 1183 } |
| 1200 | 1184 |
| 1185 void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) { |
| 1186 if (show_state != ui::SHOW_STATE_DEFAULT && |
| 1187 show_state != ui::SHOW_STATE_NORMAL && |
| 1188 show_state != ui::SHOW_STATE_INACTIVE) { |
| 1189 // It will behave like SHOW_STATE_NORMAL. |
| 1190 NOTIMPLEMENTED(); |
| 1191 } |
| 1192 |
| 1193 // Before we map the window, set size hints. Otherwise, some window managers |
| 1194 // will ignore toplevel XMoveWindow commands. |
| 1195 XSizeHints size_hints; |
| 1196 size_hints.flags = PPosition; |
| 1197 size_hints.x = bounds_.x(); |
| 1198 size_hints.y = bounds_.y(); |
| 1199 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); |
| 1200 |
| 1201 XWMHints wm_hints; |
| 1202 wm_hints.flags = InputHint | StateHint; |
| 1203 // If SHOW_STATE_INACTIVE, tell the window manager that the window is not |
| 1204 // focusable. This will make the window inactive upon creation. |
| 1205 wm_hints.input = show_state != ui::SHOW_STATE_INACTIVE; |
| 1206 wm_hints.initial_state = NormalState; |
| 1207 XSetWMHints(xdisplay_, xwindow_, &wm_hints); |
| 1208 |
| 1209 XMapWindow(xdisplay_, xwindow_); |
| 1210 |
| 1211 // We now block until our window is mapped. Some X11 APIs will crash and |
| 1212 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is |
| 1213 // asynchronous. |
| 1214 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); |
| 1215 window_mapped_ = true; |
| 1216 |
| 1217 // The window has been created and mapped. It should now accept input. |
| 1218 if (show_state == ui::SHOW_STATE_INACTIVE) { |
| 1219 XWMHints wm_hints; |
| 1220 wm_hints.flags = InputHint; |
| 1221 wm_hints.input = true; |
| 1222 // Tell the window manager that the window is now focusable. |
| 1223 XSetWMHints(xdisplay_, xwindow_, &wm_hints); |
| 1224 } |
| 1225 } |
| 1226 |
| 1201 //////////////////////////////////////////////////////////////////////////////// | 1227 //////////////////////////////////////////////////////////////////////////////// |
| 1202 // DesktopWindowTreeHostX11, MessageLoop::Dispatcher implementation: | 1228 // DesktopWindowTreeHostX11, MessageLoop::Dispatcher implementation: |
| 1203 | 1229 |
| 1204 bool DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { | 1230 bool DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { |
| 1205 XEvent* xev = event; | 1231 XEvent* xev = event; |
| 1206 | 1232 |
| 1207 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", | 1233 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", |
| 1208 "event->type", event->type); | 1234 "event->type", event->type); |
| 1209 | 1235 |
| 1210 // May want to factor CheckXEventForConsistency(xev); into a common location | 1236 // May want to factor CheckXEventForConsistency(xev); into a common location |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 if (linux_ui) { | 1576 if (linux_ui) { |
| 1551 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1577 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 1552 if (native_theme) | 1578 if (native_theme) |
| 1553 return native_theme; | 1579 return native_theme; |
| 1554 } | 1580 } |
| 1555 | 1581 |
| 1556 return ui::NativeTheme::instance(); | 1582 return ui::NativeTheme::instance(); |
| 1557 } | 1583 } |
| 1558 | 1584 |
| 1559 } // namespace views | 1585 } // namespace views |
| OLD | NEW |