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/15 03:46:56
Nit: No curlies.
| |
| 339 show_state != ui::SHOW_STATE_NORMAL) { | 339 MapWindow(show_state); |
| 340 // Only forwarding to Show(). | |
| 341 NOTIMPLEMENTED(); | |
| 342 } | 340 } |
| 343 | 341 |
| 344 Show(); | 342 if (show_state == ui::SHOW_STATE_NORMAL || |
| 343 show_state == ui::SHOW_STATE_MAXIMIZED) { | |
| 344 Activate(); | |
| 345 } | |
| 346 | |
| 347 native_widget_delegate_->AsWidget()->SetInitialFocus(); | |
|
Matt Giuca
2014/01/15 03:46:56
I thought you did not want this if SHOW_STATE_INAC
mlamouri (slow - plz ping)
2014/01/15 04:03:04
Let's have this dealt with in the other cl.
Matt Giuca
2014/01/15 04:11:24
Why? Isn't it not going to work unless you DO NOT
mlamouri (slow - plz ping)
2014/01/15 04:16:37
SetInitialFocus() will not give the input focus to
Matt Giuca
2014/01/15 04:21:59
OK.
| |
| 345 } | 348 } |
| 346 | 349 |
| 347 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( | 350 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( |
| 348 const gfx::Rect& restored_bounds) { | 351 const gfx::Rect& restored_bounds) { |
| 349 restored_bounds_ = restored_bounds; | 352 restored_bounds_ = restored_bounds; |
| 350 Maximize(); | 353 Maximize(); |
| 351 Show(); | 354 Show(); |
| 352 } | 355 } |
| 353 | 356 |
| 354 bool DesktopWindowTreeHostX11::IsVisible() const { | 357 bool DesktopWindowTreeHostX11::IsVisible() const { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 | 721 |
| 719 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { | 722 aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { |
| 720 return root_window_; | 723 return root_window_; |
| 721 } | 724 } |
| 722 | 725 |
| 723 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { | 726 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { |
| 724 return xwindow_; | 727 return xwindow_; |
| 725 } | 728 } |
| 726 | 729 |
| 727 void DesktopWindowTreeHostX11::Show() { | 730 void DesktopWindowTreeHostX11::Show() { |
| 728 if (!window_mapped_) { | 731 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 } | 732 } |
| 748 | 733 |
| 749 void DesktopWindowTreeHostX11::Hide() { | 734 void DesktopWindowTreeHostX11::Hide() { |
| 750 if (window_mapped_) { | 735 if (window_mapped_) { |
| 751 XWithdrawWindow(xdisplay_, xwindow_, 0); | 736 XWithdrawWindow(xdisplay_, xwindow_, 0); |
| 752 window_mapped_ = false; | 737 window_mapped_ = false; |
| 753 } | 738 } |
| 754 } | 739 } |
| 755 | 740 |
| 756 void DesktopWindowTreeHostX11::ToggleFullScreen() { | 741 void DesktopWindowTreeHostX11::ToggleFullScreen() { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1187 for (int x = 0; x < width; ++x) | 1172 for (int x = 0; x < width; ++x) |
| 1188 data->push_back(bitmap.getColor(x, y)); | 1173 data->push_back(bitmap.getColor(x, y)); |
| 1189 } | 1174 } |
| 1190 | 1175 |
| 1191 std::list<XID>& DesktopWindowTreeHostX11::open_windows() { | 1176 std::list<XID>& DesktopWindowTreeHostX11::open_windows() { |
| 1192 if (!open_windows_) | 1177 if (!open_windows_) |
| 1193 open_windows_ = new std::list<XID>(); | 1178 open_windows_ = new std::list<XID>(); |
| 1194 return *open_windows_; | 1179 return *open_windows_; |
| 1195 } | 1180 } |
| 1196 | 1181 |
| 1182 void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) { | |
| 1183 if (show_state != ui::SHOW_STATE_DEFAULT && | |
| 1184 show_state != ui::SHOW_STATE_NORMAL && | |
| 1185 show_state != ui::SHOW_STATE_INACTIVE) { | |
| 1186 // It will behave like SHOW_STATE_NORMAL. | |
| 1187 NOTIMPLEMENTED(); | |
| 1188 } | |
| 1189 | |
| 1190 // Before we map the window, set size hints. Otherwise, some window managers | |
| 1191 // will ignore toplevel XMoveWindow commands. | |
| 1192 XSizeHints size_hints; | |
| 1193 size_hints.flags = PPosition; | |
| 1194 size_hints.x = bounds_.x(); | |
| 1195 size_hints.y = bounds_.y(); | |
| 1196 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | |
| 1197 | |
| 1198 XWMHints wm_hints; | |
| 1199 wm_hints.flags = InputHint | StateHint; | |
| 1200 // If SHOW_STATE_INACTIVE, tell the window manager that the window is not | |
| 1201 // focusable. This will make the window inactive upon creation. | |
| 1202 wm_hints.input = show_state != ui::SHOW_STATE_INACTIVE; | |
| 1203 wm_hints.initial_state = NormalState; | |
| 1204 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
| 1205 | |
| 1206 XMapWindow(xdisplay_, xwindow_); | |
| 1207 | |
| 1208 // We now block until our window is mapped. Some X11 APIs will crash and | |
| 1209 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | |
| 1210 // asynchronous. | |
| 1211 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); | |
| 1212 window_mapped_ = true; | |
| 1213 | |
| 1214 // The window has been created and mapped. It should now accept input. | |
| 1215 if (show_state == ui::SHOW_STATE_INACTIVE) { | |
| 1216 XWMHints wm_hints; | |
| 1217 wm_hints.flags = InputHint; | |
| 1218 wm_hints.input = true; | |
| 1219 // Tell the window manager that the window is now focusable. | |
| 1220 XSetWMHints(xdisplay_, xwindow_, &wm_hints); | |
| 1221 } | |
| 1222 } | |
| 1223 | |
| 1197 //////////////////////////////////////////////////////////////////////////////// | 1224 //////////////////////////////////////////////////////////////////////////////// |
| 1198 // DesktopWindowTreeHostX11, MessageLoop::Dispatcher implementation: | 1225 // DesktopWindowTreeHostX11, MessageLoop::Dispatcher implementation: |
| 1199 | 1226 |
| 1200 bool DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { | 1227 bool DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { |
| 1201 XEvent* xev = event; | 1228 XEvent* xev = event; |
| 1202 | 1229 |
| 1203 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", | 1230 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", |
| 1204 "event->type", event->type); | 1231 "event->type", event->type); |
| 1205 | 1232 |
| 1206 // May want to factor CheckXEventForConsistency(xev); into a common location | 1233 // May want to factor CheckXEventForConsistency(xev); into a common location |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1546 if (linux_ui) { | 1573 if (linux_ui) { |
| 1547 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1574 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 1548 if (native_theme) | 1575 if (native_theme) |
| 1549 return native_theme; | 1576 return native_theme; |
| 1550 } | 1577 } |
| 1551 | 1578 |
| 1552 return ui::NativeTheme::instance(); | 1579 return ui::NativeTheme::instance(); |
| 1553 } | 1580 } |
| 1554 | 1581 |
| 1555 } // namespace views | 1582 } // namespace views |
| OLD | NEW |