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

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

Issue 219743002: x11: Move X event handling out of the message-pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r261267 Created 6 years, 8 months 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 | Annotate | Revision Log
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>
11 #include <X11/Xutil.h> 11 #include <X11/Xutil.h>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
15 #include "base/message_loop/message_pump_x11.h" 15 #include "base/message_loop/message_pump_x11.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "third_party/skia/include/core/SkPath.h" 18 #include "third_party/skia/include/core/SkPath.h"
19 #include "ui/aura/client/cursor_client.h" 19 #include "ui/aura/client/cursor_client.h"
20 #include "ui/aura/client/focus_client.h" 20 #include "ui/aura/client/focus_client.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/aura/window_event_dispatcher.h" 22 #include "ui/aura/window_event_dispatcher.h"
23 #include "ui/aura/window_property.h" 23 #include "ui/aura/window_property.h"
24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" 24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
25 #include "ui/base/hit_test.h" 25 #include "ui/base/hit_test.h"
26 #include "ui/base/x/x11_util.h" 26 #include "ui/base/x/x11_util.h"
27 #include "ui/events/event_utils.h" 27 #include "ui/events/event_utils.h"
28 #include "ui/events/platform/platform_event_source.h"
29 #include "ui/events/platform/x11/x11_event_source.h"
28 #include "ui/events/x/device_data_manager.h" 30 #include "ui/events/x/device_data_manager.h"
29 #include "ui/events/x/device_list_cache_x.h" 31 #include "ui/events/x/device_list_cache_x.h"
30 #include "ui/events/x/touch_factory_x11.h" 32 #include "ui/events/x/touch_factory_x11.h"
31 #include "ui/gfx/image/image_skia.h" 33 #include "ui/gfx/image/image_skia.h"
32 #include "ui/gfx/image/image_skia_rep.h" 34 #include "ui/gfx/image/image_skia_rep.h"
33 #include "ui/gfx/insets.h" 35 #include "ui/gfx/insets.h"
34 #include "ui/gfx/path.h" 36 #include "ui/gfx/path.h"
35 #include "ui/gfx/path_x11.h" 37 #include "ui/gfx/path_x11.h"
36 #include "ui/native_theme/native_theme.h" 38 #include "ui/native_theme/native_theme.h"
37 #include "ui/views/corewm/tooltip_aura.h" 39 #include "ui/views/corewm/tooltip_aura.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 desktop_native_widget_aura_->root_window_event_filter()->RemoveHandler( 306 desktop_native_widget_aura_->root_window_event_filter()->RemoveHandler(
305 x11_window_event_filter_.get()); 307 x11_window_event_filter_.get());
306 308
307 // Destroy the compositor before destroying the |xwindow_| since shutdown 309 // Destroy the compositor before destroying the |xwindow_| since shutdown
308 // may try to swap, and the swap without a window causes an X error, which 310 // may try to swap, and the swap without a window causes an X error, which
309 // causes a crash with in-process renderer. 311 // causes a crash with in-process renderer.
310 DestroyCompositor(); 312 DestroyCompositor();
311 313
312 open_windows().remove(xwindow_); 314 open_windows().remove(xwindow_);
313 // Actually free our native resources. 315 // Actually free our native resources.
314 base::MessagePumpX11::Current()->RemoveDispatcherForWindow(xwindow_); 316 if (ui::PlatformEventSource::GetInstance())
317 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
315 XDestroyWindow(xdisplay_, xwindow_); 318 XDestroyWindow(xdisplay_, xwindow_);
316 xwindow_ = None; 319 xwindow_ = None;
317 320
318 desktop_native_widget_aura_->OnHostClosed(); 321 desktop_native_widget_aura_->OnHostClosed();
319 } 322 }
320 323
321 aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() { 324 aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() {
322 return this; 325 return this;
323 } 326 }
324 327
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 xwindow_ = XCreateWindow( 972 xwindow_ = XCreateWindow(
970 xdisplay_, x_root_window_, 973 xdisplay_, x_root_window_,
971 bounds_.x(), bounds_.y(), 974 bounds_.x(), bounds_.y(),
972 bounds_.width(), bounds_.height(), 975 bounds_.width(), bounds_.height(),
973 0, // border width 976 0, // border width
974 CopyFromParent, // depth 977 CopyFromParent, // depth
975 InputOutput, 978 InputOutput,
976 CopyFromParent, // visual 979 CopyFromParent, // visual
977 attribute_mask, 980 attribute_mask,
978 &swa); 981 &swa);
979 base::MessagePumpX11::Current()->AddDispatcherForWindow(this, xwindow_); 982 if (ui::PlatformEventSource::GetInstance())
983 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
980 open_windows().push_back(xwindow_); 984 open_windows().push_back(xwindow_);
981 985
982 // TODO(erg): Maybe need to set a ViewProp here like in RWHL::RWHL(). 986 // TODO(erg): Maybe need to set a ViewProp here like in RWHL::RWHL().
983 987
984 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | 988 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
985 KeyPressMask | KeyReleaseMask | 989 KeyPressMask | KeyReleaseMask |
986 EnterWindowMask | LeaveWindowMask | 990 EnterWindowMask | LeaveWindowMask |
987 ExposureMask | VisibilityChangeMask | 991 ExposureMask | VisibilityChangeMask |
988 StructureNotifyMask | PropertyChangeMask | 992 StructureNotifyMask | PropertyChangeMask |
989 PointerMotionMask; 993 PointerMotionMask;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 // https://crbug.com/355667 1299 // https://crbug.com/355667
1296 XDeleteProperty( 1300 XDeleteProperty(
1297 xdisplay_, xwindow_, atom_cache_.GetAtom("_NET_WM_USER_TIME")); 1301 xdisplay_, xwindow_, atom_cache_.GetAtom("_NET_WM_USER_TIME"));
1298 } 1302 }
1299 1303
1300 XMapWindow(xdisplay_, xwindow_); 1304 XMapWindow(xdisplay_, xwindow_);
1301 1305
1302 // We now block until our window is mapped. Some X11 APIs will crash and 1306 // We now block until our window is mapped. Some X11 APIs will crash and
1303 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is 1307 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is
1304 // asynchronous. 1308 // asynchronous.
1305 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); 1309 if (ui::X11EventSource::GetInstance())
1310 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_);
1306 window_mapped_ = true; 1311 window_mapped_ = true;
1307 } 1312 }
1308 1313
1309 //////////////////////////////////////////////////////////////////////////////// 1314 ////////////////////////////////////////////////////////////////////////////////
1310 // DesktopWindowTreeHostX11, MessagePumpDispatcher implementation: 1315 // DesktopWindowTreeHostX11, ui::PlatformEventDispatcher implementation:
1311 1316
1312 uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { 1317 bool DesktopWindowTreeHostX11::CanDispatchEvent(
1318 const ui::PlatformEvent& event) {
1319 return event->xany.window == xwindow_ ||
1320 (event->type == GenericEvent &&
1321 static_cast<XIDeviceEvent*>(event->xcookie.data)->event == xwindow_);
1322 }
1323
1324 uint32_t DesktopWindowTreeHostX11::DispatchEvent(
1325 const ui::PlatformEvent& event) {
1313 XEvent* xev = event; 1326 XEvent* xev = event;
1314 1327
1315 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", 1328 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch",
1316 "event->type", event->type); 1329 "event->type", event->type);
1317 1330
1318 // May want to factor CheckXEventForConsistency(xev); into a common location 1331 // May want to factor CheckXEventForConsistency(xev); into a common location
1319 // since it is called here. 1332 // since it is called here.
1320 switch (xev->type) { 1333 switch (xev->type) {
1321 case EnterNotify: 1334 case EnterNotify:
1322 case LeaveNotify: { 1335 case LeaveNotify: {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 // changed the window's maximization state. 1605 // changed the window's maximization state.
1593 ResetWindowRegion(); 1606 ResetWindowRegion();
1594 } 1607 }
1595 break; 1608 break;
1596 } 1609 }
1597 case SelectionNotify: { 1610 case SelectionNotify: {
1598 drag_drop_client_->OnSelectionNotify(xev->xselection); 1611 drag_drop_client_->OnSelectionNotify(xev->xselection);
1599 break; 1612 break;
1600 } 1613 }
1601 } 1614 }
1602 return POST_DISPATCH_NONE; 1615 return ui::POST_DISPATCH_STOP_PROPAGATION;
1603 } 1616 }
1604 1617
1605 //////////////////////////////////////////////////////////////////////////////// 1618 ////////////////////////////////////////////////////////////////////////////////
1606 // DesktopWindowTreeHost, public: 1619 // DesktopWindowTreeHost, public:
1607 1620
1608 // static 1621 // static
1609 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 1622 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
1610 internal::NativeWidgetDelegate* native_widget_delegate, 1623 internal::NativeWidgetDelegate* native_widget_delegate,
1611 DesktopNativeWidgetAura* desktop_native_widget_aura) { 1624 DesktopNativeWidgetAura* desktop_native_widget_aura) {
1612 return new DesktopWindowTreeHostX11(native_widget_delegate, 1625 return new DesktopWindowTreeHostX11(native_widget_delegate,
1613 desktop_native_widget_aura); 1626 desktop_native_widget_aura);
1614 } 1627 }
1615 1628
1616 // static 1629 // static
1617 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { 1630 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) {
1618 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); 1631 const views::LinuxUI* linux_ui = views::LinuxUI::instance();
1619 if (linux_ui) { 1632 if (linux_ui) {
1620 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); 1633 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme();
1621 if (native_theme) 1634 if (native_theme)
1622 return native_theme; 1635 return native_theme;
1623 } 1636 }
1624 1637
1625 return ui::NativeTheme::instance(); 1638 return ui::NativeTheme::instance();
1626 } 1639 }
1627 1640
1628 } // namespace views 1641 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h ('k') | ui/views/widget/desktop_aura/x11_desktop_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698