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

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

Issue 14189002: linux_aura: Implement dropping in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add HTML type to prefetch list to fix crashes. Created 7 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_root_window_host_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_root_window_host_x11.h"
6 6
7 #include <X11/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 #include <X11/Xatom.h> 8 #include <X11/Xatom.h>
9 #include <X11/Xutil.h> 9 #include <X11/Xutil.h>
10 10
11 #include "base/message_pump_aurax11.h" 11 #include "base/message_pump_aurax11.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "ui/aura/client/screen_position_client.h" 14 #include "ui/aura/client/screen_position_client.h"
15 #include "ui/aura/client/user_action_client.h" 15 #include "ui/aura/client/user_action_client.h"
16 #include "ui/aura/focus_manager.h" 16 #include "ui/aura/focus_manager.h"
17 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
18 #include "ui/aura/window_property.h" 18 #include "ui/aura/window_property.h"
19 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
19 #include "ui/base/events/event_utils.h" 20 #include "ui/base/events/event_utils.h"
20 #include "ui/base/touch/touch_factory_x11.h" 21 #include "ui/base/touch/touch_factory_x11.h"
21 #include "ui/base/x/x11_util.h" 22 #include "ui/base/x/x11_util.h"
22 #include "ui/gfx/insets.h" 23 #include "ui/gfx/insets.h"
23 #include "ui/linux_ui/linux_ui.h" 24 #include "ui/linux_ui/linux_ui.h"
24 #include "ui/native_theme/native_theme.h" 25 #include "ui/native_theme/native_theme.h"
25 #include "ui/views/corewm/compound_event_filter.h" 26 #include "ui/views/corewm/compound_event_filter.h"
26 #include "ui/views/corewm/corewm_switches.h" 27 #include "ui/views/corewm/corewm_switches.h"
27 #include "ui/views/corewm/cursor_manager.h" 28 #include "ui/views/corewm/cursor_manager.h"
28 #include "ui/views/corewm/focus_controller.h" 29 #include "ui/views/corewm/focus_controller.h"
29 #include "ui/views/ime/input_method.h" 30 #include "ui/views/ime/input_method.h"
30 #include "ui/views/widget/desktop_aura/desktop_activation_client.h" 31 #include "ui/views/widget/desktop_aura/desktop_activation_client.h"
31 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" 32 #include "ui/views/widget/desktop_aura/desktop_capture_client.h"
32 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.h" 33 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.h"
33 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" 34 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h"
35 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h"
34 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" 36 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
35 #include "ui/views/widget/desktop_aura/desktop_layout_manager.h" 37 #include "ui/views/widget/desktop_aura/desktop_layout_manager.h"
36 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" 38 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
37 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 39 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
38 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" 40 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
39 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" 41 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
40 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h" 42 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h"
41 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h" 43 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h"
42 44
43 namespace views { 45 namespace views {
(...skipping 12 matching lines...) Expand all
56 // Standard Linux mouse buttons for going back and forward. 58 // Standard Linux mouse buttons for going back and forward.
57 const int kBackMouseButton = 8; 59 const int kBackMouseButton = 8;
58 const int kForwardMouseButton = 9; 60 const int kForwardMouseButton = 9;
59 61
60 // Constants that are part of EWMH. 62 // Constants that are part of EWMH.
61 const int k_NET_WM_STATE_ADD = 1; 63 const int k_NET_WM_STATE_ADD = 1;
62 const int k_NET_WM_STATE_REMOVE = 0; 64 const int k_NET_WM_STATE_REMOVE = 0;
63 65
64 const char* kAtomsToCache[] = { 66 const char* kAtomsToCache[] = {
65 "WM_DELETE_WINDOW", 67 "WM_DELETE_WINDOW",
68 "WM_PROTOCOLS",
66 "WM_S0", 69 "WM_S0",
67 "_NET_WM_PID", 70 "_NET_WM_PID",
68 "_NET_WM_PING", 71 "_NET_WM_PING",
69 "_NET_WM_STATE", 72 "_NET_WM_STATE",
70 "_NET_WM_STATE_FULLSCREEN", 73 "_NET_WM_STATE_FULLSCREEN",
71 "_NET_WM_STATE_HIDDEN", 74 "_NET_WM_STATE_HIDDEN",
72 "_NET_WM_STATE_MAXIMIZED_HORZ", 75 "_NET_WM_STATE_MAXIMIZED_HORZ",
73 "_NET_WM_STATE_MAXIMIZED_VERT", 76 "_NET_WM_STATE_MAXIMIZED_VERT",
77 "XdndActionAsk",
78 "XdndActionCopy"
79 "XdndActionLink",
80 "XdndActionList",
81 "XdndActionMove",
82 "XdndActionPrivate",
83 "XdndAware",
84 "XdndDrop",
85 "XdndEnter",
86 "XdndFinished",
87 "XdndLeave",
88 "XdndPosition",
89 "XdndProxy", // Proxy windows?
90 "XdndSelection",
91 "XdndStatus",
92 "XdndTypeList",
74 NULL 93 NULL
75 }; 94 };
76 95
77 } // namespace 96 } // namespace
78 97
79 //////////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////////
80 // DesktopRootWindowHostX11, public: 99 // DesktopRootWindowHostX11, public:
81 100
82 DesktopRootWindowHostX11::DesktopRootWindowHostX11( 101 DesktopRootWindowHostX11::DesktopRootWindowHostX11(
83 internal::NativeWidgetDelegate* native_widget_delegate, 102 internal::NativeWidgetDelegate* native_widget_delegate,
84 DesktopNativeWidgetAura* desktop_native_widget_aura, 103 DesktopNativeWidgetAura* desktop_native_widget_aura,
85 const gfx::Rect& initial_bounds) 104 const gfx::Rect& initial_bounds)
86 : close_widget_factory_(this), 105 : close_widget_factory_(this),
87 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), 106 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()),
88 xwindow_(0), 107 xwindow_(0),
89 x_root_window_(DefaultRootWindow(xdisplay_)), 108 x_root_window_(DefaultRootWindow(xdisplay_)),
90 atom_cache_(xdisplay_, kAtomsToCache), 109 atom_cache_(xdisplay_, kAtomsToCache),
91 window_mapped_(false), 110 window_mapped_(false),
92 focus_when_shown_(false), 111 focus_when_shown_(false),
93 current_cursor_(ui::kCursorNull), 112 current_cursor_(ui::kCursorNull),
94 native_widget_delegate_(native_widget_delegate), 113 native_widget_delegate_(native_widget_delegate),
95 desktop_native_widget_aura_(desktop_native_widget_aura) { 114 desktop_native_widget_aura_(desktop_native_widget_aura),
115 drop_handler_(NULL) {
96 } 116 }
97 117
98 DesktopRootWindowHostX11::~DesktopRootWindowHostX11() { 118 DesktopRootWindowHostX11::~DesktopRootWindowHostX11() {
99 root_window_->ClearProperty(kHostForRootWindow); 119 root_window_->ClearProperty(kHostForRootWindow);
100 if (corewm::UseFocusControllerOnDesktop()) { 120 if (corewm::UseFocusControllerOnDesktop()) {
101 aura::client::SetFocusClient(root_window_, NULL); 121 aura::client::SetFocusClient(root_window_, NULL);
102 aura::client::SetActivationClient(root_window_, NULL); 122 aura::client::SetActivationClient(root_window_, NULL);
103 } 123 }
104 } 124 }
105 125
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 new DesktopCursorLoaderUpdaterAuraX11))))); 275 new DesktopCursorLoaderUpdaterAuraX11)))));
256 aura::client::SetCursorClient(root_window_, 276 aura::client::SetCursorClient(root_window_,
257 cursor_client_.get()); 277 cursor_client_.get());
258 278
259 position_client_.reset(new DesktopScreenPositionClient); 279 position_client_.reset(new DesktopScreenPositionClient);
260 aura::client::SetScreenPositionClient(root_window_, 280 aura::client::SetScreenPositionClient(root_window_,
261 position_client_.get()); 281 position_client_.get());
262 282
263 desktop_native_widget_aura_->InstallInputMethodEventFilter(root_window_); 283 desktop_native_widget_aura_->InstallInputMethodEventFilter(root_window_);
264 284
285 drag_drop_client_.reset(new DesktopDragDropClientAuraX11(
286 this, root_window_, xdisplay_, xwindow_));
287 aura::client::SetDragDropClient(root_window_, drag_drop_client_.get());
288
265 // TODO(erg): Unify this code once the other consumer goes away. 289 // TODO(erg): Unify this code once the other consumer goes away.
266 x11_window_event_filter_.reset( 290 x11_window_event_filter_.reset(
267 new X11WindowEventFilter(root_window_, activation_client_.get())); 291 new X11WindowEventFilter(root_window_, activation_client_.get()));
268 x11_window_event_filter_->SetUseHostWindowBorders(false); 292 x11_window_event_filter_->SetUseHostWindowBorders(false);
269 desktop_native_widget_aura_->root_window_event_filter()->AddHandler( 293 desktop_native_widget_aura_->root_window_event_filter()->AddHandler(
270 x11_window_event_filter_.get()); 294 x11_window_event_filter_.get());
271 295
272 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); 296 x11_window_move_client_.reset(new X11DesktopWindowMoveClient);
273 aura::client::SetWindowMoveClient(root_window_, 297 aura::client::SetWindowMoveClient(root_window_,
274 x11_window_move_client_.get()); 298 x11_window_move_client_.get());
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } 902 }
879 903
880 void DesktopRootWindowHostX11::OnDeviceScaleFactorChanged( 904 void DesktopRootWindowHostX11::OnDeviceScaleFactorChanged(
881 float device_scale_factor) { 905 float device_scale_factor) {
882 } 906 }
883 907
884 void DesktopRootWindowHostX11::PrepareForShutdown() { 908 void DesktopRootWindowHostX11::PrepareForShutdown() {
885 } 909 }
886 910
887 //////////////////////////////////////////////////////////////////////////////// 911 ////////////////////////////////////////////////////////////////////////////////
912 // DesktopRootWindowHostX11, ui::DesktopSelectionProviderAuraX11 implementation:
913
914 void DesktopRootWindowHostX11::SetDropHandler(
915 ui::OSExchangeDataProviderAuraX11* handler) {
916 if (handler) {
917 DCHECK(!drop_handler_);
918 drop_handler_ = handler;
919 } else {
920 DCHECK(drop_handler_);
921 drop_handler_ = NULL;
922 }
923 }
924
925 ////////////////////////////////////////////////////////////////////////////////
888 // DesktopRootWindowHostX11, MessageLoop::Dispatcher implementation: 926 // DesktopRootWindowHostX11, MessageLoop::Dispatcher implementation:
889 927
890 bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) { 928 bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) {
891 XEvent* xev = event; 929 XEvent* xev = event;
892 930
893 // May want to factor CheckXEventForConsistency(xev); into a common location 931 // May want to factor CheckXEventForConsistency(xev); into a common location
894 // since it is called here. 932 // since it is called here.
895 switch (xev->type) { 933 switch (xev->type) {
896 case Expose: 934 case Expose:
897 // TODO(erg): Can we only redraw the affected areas? 935 // TODO(erg): Can we only redraw the affected areas?
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 break; 1077 break;
1040 } 1078 }
1041 case MapNotify: { 1079 case MapNotify: {
1042 // If there's no window manager running, we need to assign the X input 1080 // If there's no window manager running, we need to assign the X input
1043 // focus to our host window. 1081 // focus to our host window.
1044 if (!IsWindowManagerPresent() && focus_when_shown_) 1082 if (!IsWindowManagerPresent() && focus_when_shown_)
1045 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); 1083 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime);
1046 break; 1084 break;
1047 } 1085 }
1048 case ClientMessage: { 1086 case ClientMessage: {
1049 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); 1087 Atom message_type = xev->xclient.message_type;
1050 if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { 1088 if (message_type == atom_cache_.GetAtom("WM_PROTOCOLS")) {
1051 // We have received a close message from the window manager. 1089 Atom protocol = static_cast<Atom>(xev->xclient.data.l[0]);
1052 root_window_->OnRootWindowHostCloseRequested(); 1090 if (protocol == atom_cache_.GetAtom("WM_DELETE_WINDOW")) {
1053 } else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) { 1091 // We have received a close message from the window manager.
1054 XEvent reply_event = *xev; 1092 root_window_->OnRootWindowHostCloseRequested();
1055 reply_event.xclient.window = x_root_window_; 1093 } else if (protocol == atom_cache_.GetAtom("_NET_WM_PING")) {
1094 XEvent reply_event = *xev;
1095 reply_event.xclient.window = x_root_window_;
1056 1096
1057 XSendEvent(xdisplay_, 1097 XSendEvent(xdisplay_,
1058 reply_event.xclient.window, 1098 reply_event.xclient.window,
1059 False, 1099 False,
1060 SubstructureRedirectMask | SubstructureNotifyMask, 1100 SubstructureRedirectMask | SubstructureNotifyMask,
1061 &reply_event); 1101 &reply_event);
1102 }
1103 } else if (message_type == atom_cache_.GetAtom("XdndEnter")) {
1104 drag_drop_client_->OnXdndEnter(xev->xclient);
1105 } else if (message_type == atom_cache_.GetAtom("XdndLeave")) {
1106 drag_drop_client_->OnXdndLeave(xev->xclient);
1107 } else if (message_type == atom_cache_.GetAtom("XdndPosition")) {
1108 drag_drop_client_->OnXdndPosition(xev->xclient);
1109 } else if (message_type == atom_cache_.GetAtom("XdndStatus")) {
1110 drag_drop_client_->OnXdndStatus(xev->xclient);
1111 } else if (message_type == atom_cache_.GetAtom("XdndFinished")) {
1112 drag_drop_client_->OnXdndFinished(xev->xclient);
1113 } else if (message_type == atom_cache_.GetAtom("XdndDrop")) {
1114 drag_drop_client_->OnXdndDrop(xev->xclient);
1062 } 1115 }
1063 break; 1116 break;
1064 } 1117 }
1065 case MappingNotify: { 1118 case MappingNotify: {
1066 switch (xev->xmapping.request) { 1119 switch (xev->xmapping.request) {
1067 case MappingModifier: 1120 case MappingModifier:
1068 case MappingKeyboard: 1121 case MappingKeyboard:
1069 XRefreshKeyboardMapping(&xev->xmapping); 1122 XRefreshKeyboardMapping(&xev->xmapping);
1070 root_window_->OnKeyboardMappingChanged(); 1123 root_window_->OnKeyboardMappingChanged();
1071 break; 1124 break;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 // fullscreen state. Unsure what to do about that. 1175 // fullscreen state. Unsure what to do about that.
1123 Widget* widget = native_widget_delegate_->AsWidget(); 1176 Widget* widget = native_widget_delegate_->AsWidget();
1124 NonClientView* non_client_view = widget->non_client_view(); 1177 NonClientView* non_client_view = widget->non_client_view();
1125 // non_client_view may be NULL, especially during creation. 1178 // non_client_view may be NULL, especially during creation.
1126 if (non_client_view) { 1179 if (non_client_view) {
1127 non_client_view->client_view()->InvalidateLayout(); 1180 non_client_view->client_view()->InvalidateLayout();
1128 non_client_view->InvalidateLayout(); 1181 non_client_view->InvalidateLayout();
1129 } 1182 }
1130 widget->GetRootView()->Layout(); 1183 widget->GetRootView()->Layout();
1131 } 1184 }
1185 break;
1186 }
1187 case SelectionNotify: {
1188 if (drop_handler_)
1189 drop_handler_->OnSelectionNotify(xev->xselection);
1190 break;
1132 } 1191 }
1133 } 1192 }
1134 return true; 1193 return true;
1135 } 1194 }
1136 1195
1137 //////////////////////////////////////////////////////////////////////////////// 1196 ////////////////////////////////////////////////////////////////////////////////
1138 // DesktopRootWindowHost, public: 1197 // DesktopRootWindowHost, public:
1139 1198
1140 // static 1199 // static
1141 DesktopRootWindowHost* DesktopRootWindowHost::Create( 1200 DesktopRootWindowHost* DesktopRootWindowHost::Create(
1142 internal::NativeWidgetDelegate* native_widget_delegate, 1201 internal::NativeWidgetDelegate* native_widget_delegate,
1143 DesktopNativeWidgetAura* desktop_native_widget_aura, 1202 DesktopNativeWidgetAura* desktop_native_widget_aura,
1144 const gfx::Rect& initial_bounds) { 1203 const gfx::Rect& initial_bounds) {
1145 return new DesktopRootWindowHostX11(native_widget_delegate, 1204 return new DesktopRootWindowHostX11(native_widget_delegate,
1146 desktop_native_widget_aura, 1205 desktop_native_widget_aura,
1147 initial_bounds); 1206 initial_bounds);
1148 } 1207 }
1149 1208
1150 } // namespace views 1209 } // namespace views
OLDNEW
« ui/ui.gyp ('K') | « ui/views/widget/desktop_aura/desktop_root_window_host_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698