| 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_window_tree_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "ui/views/corewm/tooltip_aura.h" | 53 #include "ui/views/corewm/tooltip_aura.h" |
| 54 #include "ui/views/linux_ui/linux_ui.h" | 54 #include "ui/views/linux_ui/linux_ui.h" |
| 55 #include "ui/views/views_delegate.h" | 55 #include "ui/views/views_delegate.h" |
| 56 #include "ui/views/views_switches.h" | 56 #include "ui/views/views_switches.h" |
| 57 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" | 57 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" |
| 58 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 58 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
| 59 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 59 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 60 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" | 60 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" |
| 61 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 61 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
| 62 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h" | 62 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h" |
| 63 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client_managed.h" |
| 63 #include "ui/views/widget/desktop_aura/x11_pointer_grab.h" | 64 #include "ui/views/widget/desktop_aura/x11_pointer_grab.h" |
| 64 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h" | 65 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h" |
| 65 #include "ui/wm/core/compound_event_filter.h" | 66 #include "ui/wm/core/compound_event_filter.h" |
| 66 #include "ui/wm/core/window_util.h" | 67 #include "ui/wm/core/window_util.h" |
| 67 | 68 |
| 68 DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*); | 69 DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*); |
| 69 | 70 |
| 70 namespace views { | 71 namespace views { |
| 71 | 72 |
| 72 DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::g_current_capture = | 73 DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::g_current_capture = |
| 73 NULL; | 74 NULL; |
| 74 std::list<XID>* DesktopWindowTreeHostX11::open_windows_ = NULL; | 75 std::list<XID>* DesktopWindowTreeHostX11::open_windows_ = NULL; |
| 75 | 76 |
| 76 DEFINE_WINDOW_PROPERTY_KEY( | 77 DEFINE_WINDOW_PROPERTY_KEY( |
| 77 aura::Window*, kViewsWindowForRootWindow, NULL); | 78 aura::Window*, kViewsWindowForRootWindow, NULL); |
| 78 | 79 |
| 79 DEFINE_WINDOW_PROPERTY_KEY( | 80 DEFINE_WINDOW_PROPERTY_KEY( |
| 80 DesktopWindowTreeHostX11*, kHostForRootWindow, NULL); | 81 DesktopWindowTreeHostX11*, kHostForRootWindow, NULL); |
| 81 | 82 |
| 82 namespace { | 83 namespace { |
| 83 | 84 |
| 84 // Constants that are part of EWMH. | 85 // Constants that are part of EWMH. |
| 85 const int k_NET_WM_STATE_ADD = 1; | 86 const int k_NET_WM_STATE_ADD = 1; |
| 86 const int k_NET_WM_STATE_REMOVE = 0; | 87 const int k_NET_WM_STATE_REMOVE = 0; |
| 87 | 88 |
| 88 // Special value of the _NET_WM_DESKTOP property which indicates that the window | 89 // Special value of the _NET_WM_DESKTOP property which indicates that the window |
| 89 // should appear on all desktops. | 90 // should appear on all desktops. |
| 90 const int kAllDesktops = 0xFFFFFFFF; | 91 const int kAllDesktops = 0xFFFFFFFF; |
| 91 | 92 |
| 92 const char* kAtomsToCache[] = { | 93 const char* kAtomsToCache[] = {"UTF8_STRING", |
| 93 "UTF8_STRING", | 94 "WM_DELETE_WINDOW", |
| 94 "WM_DELETE_WINDOW", | 95 "WM_PROTOCOLS", |
| 95 "WM_PROTOCOLS", | 96 "_NET_ACTIVE_WINDOW", |
| 96 "_NET_ACTIVE_WINDOW", | 97 "_NET_FRAME_EXTENTS", |
| 97 "_NET_FRAME_EXTENTS", | 98 "_NET_WM_CM_S0", |
| 98 "_NET_WM_CM_S0", | 99 "_NET_WM_DESKTOP", |
| 99 "_NET_WM_DESKTOP", | 100 "_NET_WM_ICON", |
| 100 "_NET_WM_ICON", | 101 "_NET_WM_MOVERESIZE", |
| 101 "_NET_WM_NAME", | 102 "_NET_WM_NAME", |
| 102 "_NET_WM_PID", | 103 "_NET_WM_PID", |
| 103 "_NET_WM_PING", | 104 "_NET_WM_PING", |
| 104 "_NET_WM_STATE", | 105 "_NET_WM_STATE", |
| 105 "_NET_WM_STATE_ABOVE", | 106 "_NET_WM_STATE_ABOVE", |
| 106 "_NET_WM_STATE_FULLSCREEN", | 107 "_NET_WM_STATE_FULLSCREEN", |
| 107 "_NET_WM_STATE_HIDDEN", | 108 "_NET_WM_STATE_HIDDEN", |
| 108 "_NET_WM_STATE_MAXIMIZED_HORZ", | 109 "_NET_WM_STATE_MAXIMIZED_HORZ", |
| 109 "_NET_WM_STATE_MAXIMIZED_VERT", | 110 "_NET_WM_STATE_MAXIMIZED_VERT", |
| 110 "_NET_WM_STATE_SKIP_TASKBAR", | 111 "_NET_WM_STATE_SKIP_TASKBAR", |
| 111 "_NET_WM_STATE_STICKY", | 112 "_NET_WM_STATE_STICKY", |
| 112 "_NET_WM_USER_TIME", | 113 "_NET_WM_USER_TIME", |
| 113 "_NET_WM_WINDOW_OPACITY", | 114 "_NET_WM_WINDOW_OPACITY", |
| 114 "_NET_WM_WINDOW_TYPE", | 115 "_NET_WM_WINDOW_TYPE", |
| 115 "_NET_WM_WINDOW_TYPE_DND", | 116 "_NET_WM_WINDOW_TYPE_DND", |
| 116 "_NET_WM_WINDOW_TYPE_MENU", | 117 "_NET_WM_WINDOW_TYPE_MENU", |
| 117 "_NET_WM_WINDOW_TYPE_NORMAL", | 118 "_NET_WM_WINDOW_TYPE_NORMAL", |
| 118 "_NET_WM_WINDOW_TYPE_NOTIFICATION", | 119 "_NET_WM_WINDOW_TYPE_NOTIFICATION", |
| 119 "_NET_WM_WINDOW_TYPE_TOOLTIP", | 120 "_NET_WM_WINDOW_TYPE_TOOLTIP", |
| 120 "XdndActionAsk", | 121 "XdndActionAsk", |
| 121 "XdndActionCopy", | 122 "XdndActionCopy", |
| 122 "XdndActionLink", | 123 "XdndActionLink", |
| 123 "XdndActionList", | 124 "XdndActionList", |
| 124 "XdndActionMove", | 125 "XdndActionMove", |
| 125 "XdndActionPrivate", | 126 "XdndActionPrivate", |
| 126 "XdndAware", | 127 "XdndAware", |
| 127 "XdndDrop", | 128 "XdndDrop", |
| 128 "XdndEnter", | 129 "XdndEnter", |
| 129 "XdndFinished", | 130 "XdndFinished", |
| 130 "XdndLeave", | 131 "XdndLeave", |
| 131 "XdndPosition", | 132 "XdndPosition", |
| 132 "XdndProxy", // Proxy windows? | 133 "XdndProxy", // Proxy windows? |
| 133 "XdndSelection", | 134 "XdndSelection", |
| 134 "XdndStatus", | 135 "XdndStatus", |
| 135 "XdndTypeList", | 136 "XdndTypeList", |
| 136 NULL | 137 NULL}; |
| 137 }; | |
| 138 | 138 |
| 139 const char kX11WindowRolePopup[] = "popup"; | 139 const char kX11WindowRolePopup[] = "popup"; |
| 140 const char kX11WindowRoleBubble[] = "bubble"; | 140 const char kX11WindowRoleBubble[] = "bubble"; |
| 141 | 141 |
| 142 // Returns the whole path from |window| to the root. | 142 // Returns the whole path from |window| to the root. |
| 143 std::vector<::Window> GetParentsList(XDisplay* xdisplay, ::Window window) { | 143 std::vector<::Window> GetParentsList(XDisplay* xdisplay, ::Window window) { |
| 144 ::Window parent_win, root_win; | 144 ::Window parent_win, root_win; |
| 145 Window* child_windows; | 145 Window* child_windows; |
| 146 unsigned int num_child_windows; | 146 unsigned int num_child_windows; |
| 147 std::vector<::Window> result; | 147 std::vector<::Window> result; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 169 case XINotifyPassiveUngrab: | 169 case XINotifyPassiveUngrab: |
| 170 return NotifyUngrab; | 170 return NotifyUngrab; |
| 171 case XINotifyWhileGrabbed: | 171 case XINotifyWhileGrabbed: |
| 172 return NotifyWhileGrabbed; | 172 return NotifyWhileGrabbed; |
| 173 default: | 173 default: |
| 174 NOTREACHED(); | 174 NOTREACHED(); |
| 175 return NotifyNormal; | 175 return NotifyNormal; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool CanUseManagedWindowMove() { |
| 180 if (!ui::IsXInput2Available() || |
| 181 !ui::WmSupportsHint(ui::GetAtom("_NET_WM_MOVERESIZE"))) |
| 182 return false; |
| 183 switch(ui::GuessWindowManager()) { |
| 184 case ui::WM_COMPIZ: |
| 185 case ui::WM_METACITY: |
| 186 case ui::WM_MUFFIN: |
| 187 case ui::WM_MUTTER: |
| 188 return true; |
| 189 case ui::WM_XFWM4: |
| 190 // Xfwm does not release the pointer grab when the dragging window gets |
| 191 // destroyed (dragged into another window), and does not support |
| 192 // _NET_WM_MOVERESIZE_CANCEL. |
| 193 return false; |
| 194 default: |
| 195 // Whitelist only tested WMs. |
| 196 return false; |
| 197 } |
| 198 } |
| 199 |
| 179 } // namespace | 200 } // namespace |
| 180 | 201 |
| 181 //////////////////////////////////////////////////////////////////////////////// | 202 //////////////////////////////////////////////////////////////////////////////// |
| 182 // DesktopWindowTreeHostX11, public: | 203 // DesktopWindowTreeHostX11, public: |
| 183 | 204 |
| 184 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( | 205 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( |
| 185 internal::NativeWidgetDelegate* native_widget_delegate, | 206 internal::NativeWidgetDelegate* native_widget_delegate, |
| 186 DesktopNativeWidgetAura* desktop_native_widget_aura) | 207 DesktopNativeWidgetAura* desktop_native_widget_aura) |
| 187 : xdisplay_(gfx::GetXDisplay()), | 208 : xdisplay_(gfx::GetXDisplay()), |
| 188 xwindow_(0), | 209 xwindow_(0), |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // Ensure that the X11DesktopHandler exists so that it tracks create/destroy | 485 // Ensure that the X11DesktopHandler exists so that it tracks create/destroy |
| 465 // notify events. | 486 // notify events. |
| 466 X11DesktopHandler::get(); | 487 X11DesktopHandler::get(); |
| 467 | 488 |
| 468 // TODO(erg): Unify this code once the other consumer goes away. | 489 // TODO(erg): Unify this code once the other consumer goes away. |
| 469 SwapNonClientEventHandler( | 490 SwapNonClientEventHandler( |
| 470 std::unique_ptr<ui::EventHandler>(new X11WindowEventFilter(this))); | 491 std::unique_ptr<ui::EventHandler>(new X11WindowEventFilter(this))); |
| 471 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && | 492 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && |
| 472 !params.remove_standard_frame); | 493 !params.remove_standard_frame); |
| 473 | 494 |
| 474 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); | 495 |
| 496 static bool can_use_managed_move = CanUseManagedWindowMove(); |
| 497 if (can_use_managed_move && is_managed_) |
| 498 x11_window_move_client_.reset(new X11DesktopWindowMoveClientManaged); |
| 499 else |
| 500 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); |
| 475 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get()); | 501 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get()); |
| 476 | 502 |
| 477 SetWindowTransparency(); | 503 SetWindowTransparency(); |
| 478 | 504 |
| 479 native_widget_delegate_->OnNativeWidgetCreated(true); | 505 native_widget_delegate_->OnNativeWidgetCreated(true); |
| 480 } | 506 } |
| 481 | 507 |
| 482 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() { | 508 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() { |
| 483 return base::WrapUnique(new corewm::TooltipAura); | 509 return base::WrapUnique(new corewm::TooltipAura); |
| 484 } | 510 } |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_DND"); | 1378 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_DND"); |
| 1353 break; | 1379 break; |
| 1354 default: | 1380 default: |
| 1355 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); | 1381 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); |
| 1356 break; | 1382 break; |
| 1357 } | 1383 } |
| 1358 // An in-activatable window should not interact with the system wm. | 1384 // An in-activatable window should not interact with the system wm. |
| 1359 if (!activatable_) | 1385 if (!activatable_) |
| 1360 swa.override_redirect = True; | 1386 swa.override_redirect = True; |
| 1361 | 1387 |
| 1388 is_managed_ = !swa.override_redirect; |
| 1362 if (swa.override_redirect) | 1389 if (swa.override_redirect) |
| 1363 attribute_mask |= CWOverrideRedirect; | 1390 attribute_mask |= CWOverrideRedirect; |
| 1364 | 1391 |
| 1365 bool enable_transparent_visuals; | 1392 bool enable_transparent_visuals; |
| 1366 switch (params.opacity) { | 1393 switch (params.opacity) { |
| 1367 case Widget::InitParams::OPAQUE_WINDOW: | 1394 case Widget::InitParams::OPAQUE_WINDOW: |
| 1368 enable_transparent_visuals = false; | 1395 enable_transparent_visuals = false; |
| 1369 break; | 1396 break; |
| 1370 case Widget::InitParams::TRANSLUCENT_WINDOW: | 1397 case Widget::InitParams::TRANSLUCENT_WINDOW: |
| 1371 enable_transparent_visuals = true; | 1398 enable_transparent_visuals = true; |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2347 if (linux_ui) { | 2374 if (linux_ui) { |
| 2348 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2375 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
| 2349 if (native_theme) | 2376 if (native_theme) |
| 2350 return native_theme; | 2377 return native_theme; |
| 2351 } | 2378 } |
| 2352 | 2379 |
| 2353 return ui::NativeThemeAura::instance(); | 2380 return ui::NativeThemeAura::instance(); |
| 2354 } | 2381 } |
| 2355 | 2382 |
| 2356 } // namespace views | 2383 } // namespace views |
| OLD | NEW |