Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 2467053002: Revert of Linux Aura: Make tab dragging great again (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
64 #include "ui/views/widget/desktop_aura/x11_pointer_grab.h" 63 #include "ui/views/widget/desktop_aura/x11_pointer_grab.h"
65 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h" 64 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h"
66 #include "ui/wm/core/compound_event_filter.h" 65 #include "ui/wm/core/compound_event_filter.h"
67 #include "ui/wm/core/window_util.h" 66 #include "ui/wm/core/window_util.h"
68 67
69 DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*); 68 DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*);
70 69
71 namespace views { 70 namespace views {
72 71
73 DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::g_current_capture = 72 DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::g_current_capture =
74 NULL; 73 NULL;
75 std::list<XID>* DesktopWindowTreeHostX11::open_windows_ = NULL; 74 std::list<XID>* DesktopWindowTreeHostX11::open_windows_ = NULL;
76 75
77 DEFINE_WINDOW_PROPERTY_KEY( 76 DEFINE_WINDOW_PROPERTY_KEY(
78 aura::Window*, kViewsWindowForRootWindow, NULL); 77 aura::Window*, kViewsWindowForRootWindow, NULL);
79 78
80 DEFINE_WINDOW_PROPERTY_KEY( 79 DEFINE_WINDOW_PROPERTY_KEY(
81 DesktopWindowTreeHostX11*, kHostForRootWindow, NULL); 80 DesktopWindowTreeHostX11*, kHostForRootWindow, NULL);
82 81
83 namespace { 82 namespace {
84 83
85 // Constants that are part of EWMH. 84 // Constants that are part of EWMH.
86 const int k_NET_WM_STATE_ADD = 1; 85 const int k_NET_WM_STATE_ADD = 1;
87 const int k_NET_WM_STATE_REMOVE = 0; 86 const int k_NET_WM_STATE_REMOVE = 0;
88 87
89 // Special value of the _NET_WM_DESKTOP property which indicates that the window 88 // Special value of the _NET_WM_DESKTOP property which indicates that the window
90 // should appear on all desktops. 89 // should appear on all desktops.
91 const int kAllDesktops = 0xFFFFFFFF; 90 const int kAllDesktops = 0xFFFFFFFF;
92 91
93 const char* kAtomsToCache[] = {"UTF8_STRING", 92 const char* kAtomsToCache[] = {
94 "WM_DELETE_WINDOW", 93 "UTF8_STRING",
95 "WM_PROTOCOLS", 94 "WM_DELETE_WINDOW",
96 "_NET_ACTIVE_WINDOW", 95 "WM_PROTOCOLS",
97 "_NET_FRAME_EXTENTS", 96 "_NET_ACTIVE_WINDOW",
98 "_NET_WM_CM_S0", 97 "_NET_FRAME_EXTENTS",
99 "_NET_WM_DESKTOP", 98 "_NET_WM_CM_S0",
100 "_NET_WM_ICON", 99 "_NET_WM_DESKTOP",
101 "_NET_WM_MOVERESIZE", 100 "_NET_WM_ICON",
102 "_NET_WM_NAME", 101 "_NET_WM_NAME",
103 "_NET_WM_PID", 102 "_NET_WM_PID",
104 "_NET_WM_PING", 103 "_NET_WM_PING",
105 "_NET_WM_STATE", 104 "_NET_WM_STATE",
106 "_NET_WM_STATE_ABOVE", 105 "_NET_WM_STATE_ABOVE",
107 "_NET_WM_STATE_FULLSCREEN", 106 "_NET_WM_STATE_FULLSCREEN",
108 "_NET_WM_STATE_HIDDEN", 107 "_NET_WM_STATE_HIDDEN",
109 "_NET_WM_STATE_MAXIMIZED_HORZ", 108 "_NET_WM_STATE_MAXIMIZED_HORZ",
110 "_NET_WM_STATE_MAXIMIZED_VERT", 109 "_NET_WM_STATE_MAXIMIZED_VERT",
111 "_NET_WM_STATE_SKIP_TASKBAR", 110 "_NET_WM_STATE_SKIP_TASKBAR",
112 "_NET_WM_STATE_STICKY", 111 "_NET_WM_STATE_STICKY",
113 "_NET_WM_USER_TIME", 112 "_NET_WM_USER_TIME",
114 "_NET_WM_WINDOW_OPACITY", 113 "_NET_WM_WINDOW_OPACITY",
115 "_NET_WM_WINDOW_TYPE", 114 "_NET_WM_WINDOW_TYPE",
116 "_NET_WM_WINDOW_TYPE_DND", 115 "_NET_WM_WINDOW_TYPE_DND",
117 "_NET_WM_WINDOW_TYPE_MENU", 116 "_NET_WM_WINDOW_TYPE_MENU",
118 "_NET_WM_WINDOW_TYPE_NORMAL", 117 "_NET_WM_WINDOW_TYPE_NORMAL",
119 "_NET_WM_WINDOW_TYPE_NOTIFICATION", 118 "_NET_WM_WINDOW_TYPE_NOTIFICATION",
120 "_NET_WM_WINDOW_TYPE_TOOLTIP", 119 "_NET_WM_WINDOW_TYPE_TOOLTIP",
121 "XdndActionAsk", 120 "XdndActionAsk",
122 "XdndActionCopy", 121 "XdndActionCopy",
123 "XdndActionLink", 122 "XdndActionLink",
124 "XdndActionList", 123 "XdndActionList",
125 "XdndActionMove", 124 "XdndActionMove",
126 "XdndActionPrivate", 125 "XdndActionPrivate",
127 "XdndAware", 126 "XdndAware",
128 "XdndDrop", 127 "XdndDrop",
129 "XdndEnter", 128 "XdndEnter",
130 "XdndFinished", 129 "XdndFinished",
131 "XdndLeave", 130 "XdndLeave",
132 "XdndPosition", 131 "XdndPosition",
133 "XdndProxy", // Proxy windows? 132 "XdndProxy", // Proxy windows?
134 "XdndSelection", 133 "XdndSelection",
135 "XdndStatus", 134 "XdndStatus",
136 "XdndTypeList", 135 "XdndTypeList",
137 NULL}; 136 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
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
200 } // namespace 179 } // namespace
201 180
202 //////////////////////////////////////////////////////////////////////////////// 181 ////////////////////////////////////////////////////////////////////////////////
203 // DesktopWindowTreeHostX11, public: 182 // DesktopWindowTreeHostX11, public:
204 183
205 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( 184 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
206 internal::NativeWidgetDelegate* native_widget_delegate, 185 internal::NativeWidgetDelegate* native_widget_delegate,
207 DesktopNativeWidgetAura* desktop_native_widget_aura) 186 DesktopNativeWidgetAura* desktop_native_widget_aura)
208 : xdisplay_(gfx::GetXDisplay()), 187 : xdisplay_(gfx::GetXDisplay()),
209 xwindow_(0), 188 xwindow_(0),
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // Ensure that the X11DesktopHandler exists so that it tracks create/destroy 464 // Ensure that the X11DesktopHandler exists so that it tracks create/destroy
486 // notify events. 465 // notify events.
487 X11DesktopHandler::get(); 466 X11DesktopHandler::get();
488 467
489 // TODO(erg): Unify this code once the other consumer goes away. 468 // TODO(erg): Unify this code once the other consumer goes away.
490 SwapNonClientEventHandler( 469 SwapNonClientEventHandler(
491 std::unique_ptr<ui::EventHandler>(new X11WindowEventFilter(this))); 470 std::unique_ptr<ui::EventHandler>(new X11WindowEventFilter(this)));
492 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && 471 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW &&
493 !params.remove_standard_frame); 472 !params.remove_standard_frame);
494 473
495 474 x11_window_move_client_.reset(new X11DesktopWindowMoveClient);
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);
501 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get()); 475 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get());
502 476
503 SetWindowTransparency(); 477 SetWindowTransparency();
504 478
505 native_widget_delegate_->OnNativeWidgetCreated(true); 479 native_widget_delegate_->OnNativeWidgetCreated(true);
506 } 480 }
507 481
508 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() { 482 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() {
509 return base::WrapUnique(new corewm::TooltipAura); 483 return base::WrapUnique(new corewm::TooltipAura);
510 } 484 }
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_DND"); 1352 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_DND");
1379 break; 1353 break;
1380 default: 1354 default:
1381 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); 1355 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL");
1382 break; 1356 break;
1383 } 1357 }
1384 // An in-activatable window should not interact with the system wm. 1358 // An in-activatable window should not interact with the system wm.
1385 if (!activatable_) 1359 if (!activatable_)
1386 swa.override_redirect = True; 1360 swa.override_redirect = True;
1387 1361
1388 is_managed_ = !swa.override_redirect;
1389 if (swa.override_redirect) 1362 if (swa.override_redirect)
1390 attribute_mask |= CWOverrideRedirect; 1363 attribute_mask |= CWOverrideRedirect;
1391 1364
1392 bool enable_transparent_visuals; 1365 bool enable_transparent_visuals;
1393 switch (params.opacity) { 1366 switch (params.opacity) {
1394 case Widget::InitParams::OPAQUE_WINDOW: 1367 case Widget::InitParams::OPAQUE_WINDOW:
1395 enable_transparent_visuals = false; 1368 enable_transparent_visuals = false;
1396 break; 1369 break;
1397 case Widget::InitParams::TRANSLUCENT_WINDOW: 1370 case Widget::InitParams::TRANSLUCENT_WINDOW:
1398 enable_transparent_visuals = true; 1371 enable_transparent_visuals = true;
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 if (linux_ui) { 2347 if (linux_ui) {
2375 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 2348 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
2376 if (native_theme) 2349 if (native_theme)
2377 return native_theme; 2350 return native_theme;
2378 } 2351 }
2379 2352
2380 return ui::NativeThemeAura::instance(); 2353 return ui::NativeThemeAura::instance();
2381 } 2354 }
2382 2355
2383 } // namespace views 2356 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698