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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 atom_cache_(xdisplay_, kAtomsToCache), | 125 atom_cache_(xdisplay_, kAtomsToCache), |
126 window_mapped_(false), | 126 window_mapped_(false), |
127 focus_when_shown_(false), | 127 focus_when_shown_(false), |
128 is_fullscreen_(false), | 128 is_fullscreen_(false), |
129 is_always_on_top_(false), | 129 is_always_on_top_(false), |
130 root_window_(NULL), | 130 root_window_(NULL), |
131 drag_drop_client_(NULL), | 131 drag_drop_client_(NULL), |
132 current_cursor_(ui::kCursorNull), | 132 current_cursor_(ui::kCursorNull), |
133 native_widget_delegate_(native_widget_delegate), | 133 native_widget_delegate_(native_widget_delegate), |
134 desktop_native_widget_aura_(desktop_native_widget_aura), | 134 desktop_native_widget_aura_(desktop_native_widget_aura), |
135 root_window_host_delegate_(NULL), | |
136 content_window_(NULL), | 135 content_window_(NULL), |
137 window_parent_(NULL) { | 136 window_parent_(NULL) { |
138 } | 137 } |
139 | 138 |
140 DesktopRootWindowHostX11::~DesktopRootWindowHostX11() { | 139 DesktopRootWindowHostX11::~DesktopRootWindowHostX11() { |
141 root_window_->window()->ClearProperty(kHostForRootWindow); | 140 root_window_->window()->ClearProperty(kHostForRootWindow); |
142 aura::client::SetWindowMoveClient(root_window_->window(), NULL); | 141 aura::client::SetWindowMoveClient(root_window_->window(), NULL); |
143 desktop_native_widget_aura_->OnDesktopRootWindowHostDestroyed(root_window_); | 142 desktop_native_widget_aura_->OnDesktopRootWindowHostDestroyed(root_window_); |
144 } | 143 } |
145 | 144 |
(...skipping 19 matching lines...) Expand all Loading... |
165 return windows; | 164 return windows; |
166 } | 165 } |
167 | 166 |
168 gfx::Rect DesktopRootWindowHostX11::GetX11RootWindowBounds() const { | 167 gfx::Rect DesktopRootWindowHostX11::GetX11RootWindowBounds() const { |
169 return bounds_; | 168 return bounds_; |
170 } | 169 } |
171 | 170 |
172 void DesktopRootWindowHostX11::HandleNativeWidgetActivationChanged( | 171 void DesktopRootWindowHostX11::HandleNativeWidgetActivationChanged( |
173 bool active) { | 172 bool active) { |
174 if (active) | 173 if (active) |
175 root_window_host_delegate_->OnHostActivated(); | 174 delegate_->OnHostActivated(); |
176 | 175 |
177 desktop_native_widget_aura_->HandleActivationChanged(active); | 176 desktop_native_widget_aura_->HandleActivationChanged(active); |
178 | 177 |
179 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); | 178 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); |
180 } | 179 } |
181 | 180 |
182 void DesktopRootWindowHostX11::AddObserver( | 181 void DesktopRootWindowHostX11::AddObserver( |
183 views::DesktopRootWindowHostObserverX11* observer) { | 182 views::DesktopRootWindowHostObserverX11* observer) { |
184 observer_list_.AddObserver(observer); | 183 observer_list_.AddObserver(observer); |
185 } | 184 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 220 } |
222 | 221 |
223 void DesktopRootWindowHostX11::OnRootWindowCreated( | 222 void DesktopRootWindowHostX11::OnRootWindowCreated( |
224 aura::RootWindow* root, | 223 aura::RootWindow* root, |
225 const Widget::InitParams& params) { | 224 const Widget::InitParams& params) { |
226 root_window_ = root; | 225 root_window_ = root; |
227 | 226 |
228 root_window_->window()->SetProperty(kViewsWindowForRootWindow, | 227 root_window_->window()->SetProperty(kViewsWindowForRootWindow, |
229 content_window_); | 228 content_window_); |
230 root_window_->window()->SetProperty(kHostForRootWindow, this); | 229 root_window_->window()->SetProperty(kHostForRootWindow, this); |
231 root_window_host_delegate_ = root_window_; | 230 delegate_ = root_window_; |
232 | 231 |
233 // If we're given a parent, we need to mark ourselves as transient to another | 232 // If we're given a parent, we need to mark ourselves as transient to another |
234 // window. Otherwise activation gets screwy. | 233 // window. Otherwise activation gets screwy. |
235 gfx::NativeView parent = params.parent; | 234 gfx::NativeView parent = params.parent; |
236 if (!params.child && params.parent) | 235 if (!params.child && params.parent) |
237 parent->AddTransientChild(content_window_); | 236 parent->AddTransientChild(content_window_); |
238 | 237 |
239 // Ensure that the X11DesktopHandler exists so that it dispatches activation | 238 // Ensure that the X11DesktopHandler exists so that it dispatches activation |
240 // messages to us. | 239 // messages to us. |
241 X11DesktopHandler::get(); | 240 X11DesktopHandler::get(); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 native_widget_delegate_->AsWidget()->GetInputMethod()->OnBlur(); | 675 native_widget_delegate_->AsWidget()->GetInputMethod()->OnBlur(); |
677 } | 676 } |
678 | 677 |
679 bool DesktopRootWindowHostX11::IsAnimatingClosed() const { | 678 bool DesktopRootWindowHostX11::IsAnimatingClosed() const { |
680 return false; | 679 return false; |
681 } | 680 } |
682 | 681 |
683 //////////////////////////////////////////////////////////////////////////////// | 682 //////////////////////////////////////////////////////////////////////////////// |
684 // DesktopRootWindowHostX11, aura::RootWindowHost implementation: | 683 // DesktopRootWindowHostX11, aura::RootWindowHost implementation: |
685 | 684 |
686 void DesktopRootWindowHostX11::SetDelegate( | |
687 aura::RootWindowHostDelegate* delegate) { | |
688 root_window_host_delegate_ = delegate; | |
689 } | |
690 | |
691 aura::RootWindow* DesktopRootWindowHostX11::GetRootWindow() { | 685 aura::RootWindow* DesktopRootWindowHostX11::GetRootWindow() { |
692 return root_window_; | 686 return root_window_; |
693 } | 687 } |
694 | 688 |
695 gfx::AcceleratedWidget DesktopRootWindowHostX11::GetAcceleratedWidget() { | 689 gfx::AcceleratedWidget DesktopRootWindowHostX11::GetAcceleratedWidget() { |
696 return xwindow_; | 690 return xwindow_; |
697 } | 691 } |
698 | 692 |
699 void DesktopRootWindowHostX11::Show() { | 693 void DesktopRootWindowHostX11::Show() { |
700 if (!window_mapped_) { | 694 if (!window_mapped_) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // Assume that the resize will go through as requested, which should be the | 752 // Assume that the resize will go through as requested, which should be the |
759 // case if we're running without a window manager. If there's a window | 753 // case if we're running without a window manager. If there's a window |
760 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a | 754 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a |
761 // (possibly synthetic) ConfigureNotify about the actual size and correct | 755 // (possibly synthetic) ConfigureNotify about the actual size and correct |
762 // |bounds_| later. | 756 // |bounds_| later. |
763 bounds_ = bounds; | 757 bounds_ = bounds; |
764 | 758 |
765 if (origin_changed) | 759 if (origin_changed) |
766 native_widget_delegate_->AsWidget()->OnNativeWidgetMove(); | 760 native_widget_delegate_->AsWidget()->OnNativeWidgetMove(); |
767 if (size_changed) | 761 if (size_changed) |
768 root_window_host_delegate_->OnHostResized(bounds.size()); | 762 delegate_->OnHostResized(bounds.size()); |
769 else | 763 else |
770 root_window_host_delegate_->OnHostPaint(gfx::Rect(bounds.size())); | 764 delegate_->OnHostPaint(gfx::Rect(bounds.size())); |
771 } | 765 } |
772 | 766 |
773 gfx::Insets DesktopRootWindowHostX11::GetInsets() const { | 767 gfx::Insets DesktopRootWindowHostX11::GetInsets() const { |
774 return gfx::Insets(); | 768 return gfx::Insets(); |
775 } | 769 } |
776 | 770 |
777 void DesktopRootWindowHostX11::SetInsets(const gfx::Insets& insets) { | 771 void DesktopRootWindowHostX11::SetInsets(const gfx::Insets& insets) { |
778 } | 772 } |
779 | 773 |
780 gfx::Point DesktopRootWindowHostX11::GetLocationOnNativeScreen() const { | 774 gfx::Point DesktopRootWindowHostX11::GetLocationOnNativeScreen() const { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 void DesktopRootWindowHostX11::OnCursorVisibilityChanged(bool show) { | 844 void DesktopRootWindowHostX11::OnCursorVisibilityChanged(bool show) { |
851 // TODO(erg): Conditional on us enabling touch on desktop linux builds, do | 845 // TODO(erg): Conditional on us enabling touch on desktop linux builds, do |
852 // the same tap-to-click disabling here that chromeos does. | 846 // the same tap-to-click disabling here that chromeos does. |
853 } | 847 } |
854 | 848 |
855 void DesktopRootWindowHostX11::MoveCursorTo(const gfx::Point& location) { | 849 void DesktopRootWindowHostX11::MoveCursorTo(const gfx::Point& location) { |
856 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, | 850 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, |
857 bounds_.x() + location.x(), bounds_.y() + location.y()); | 851 bounds_.x() + location.x(), bounds_.y() + location.y()); |
858 } | 852 } |
859 | 853 |
860 void DesktopRootWindowHostX11::SetFocusWhenShown(bool focus_when_shown) { | |
861 static const char* k_NET_WM_USER_TIME = "_NET_WM_USER_TIME"; | |
862 focus_when_shown_ = focus_when_shown; | |
863 if (IsWindowManagerPresent() && !focus_when_shown_) { | |
864 ui::SetIntProperty(xwindow_, | |
865 k_NET_WM_USER_TIME, | |
866 k_NET_WM_USER_TIME, | |
867 0); | |
868 } | |
869 } | |
870 | |
871 void DesktopRootWindowHostX11::PostNativeEvent( | 854 void DesktopRootWindowHostX11::PostNativeEvent( |
872 const base::NativeEvent& native_event) { | 855 const base::NativeEvent& native_event) { |
873 DCHECK(xwindow_); | 856 DCHECK(xwindow_); |
874 DCHECK(xdisplay_); | 857 DCHECK(xdisplay_); |
875 XEvent xevent = *native_event; | 858 XEvent xevent = *native_event; |
876 xevent.xany.display = xdisplay_; | 859 xevent.xany.display = xdisplay_; |
877 xevent.xany.window = xwindow_; | 860 xevent.xany.window = xwindow_; |
878 | 861 |
879 switch (xevent.type) { | 862 switch (xevent.type) { |
880 case EnterNotify: | 863 case EnterNotify: |
881 case LeaveNotify: | 864 case LeaveNotify: |
882 case MotionNotify: | 865 case MotionNotify: |
883 case KeyPress: | 866 case KeyPress: |
884 case KeyRelease: | 867 case KeyRelease: |
885 case ButtonPress: | 868 case ButtonPress: |
886 case ButtonRelease: { | 869 case ButtonRelease: { |
887 // The fields used below are in the same place for all of events | 870 // The fields used below are in the same place for all of events |
888 // above. Using xmotion from XEvent's unions to avoid repeating | 871 // above. Using xmotion from XEvent's unions to avoid repeating |
889 // the code. | 872 // the code. |
890 xevent.xmotion.root = x_root_window_; | 873 xevent.xmotion.root = x_root_window_; |
891 xevent.xmotion.time = CurrentTime; | 874 xevent.xmotion.time = CurrentTime; |
892 | 875 |
893 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); | 876 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); |
894 root_window_->ConvertPointToNativeScreen(&point); | 877 ConvertPointToNativeScreen(&point); |
895 xevent.xmotion.x_root = point.x(); | 878 xevent.xmotion.x_root = point.x(); |
896 xevent.xmotion.y_root = point.y(); | 879 xevent.xmotion.y_root = point.y(); |
897 } | 880 } |
898 default: | 881 default: |
899 break; | 882 break; |
900 } | 883 } |
901 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); | 884 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); |
902 } | 885 } |
903 | 886 |
904 void DesktopRootWindowHostX11::OnDeviceScaleFactorChanged( | 887 void DesktopRootWindowHostX11::OnDeviceScaleFactorChanged( |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 | 1010 |
1028 if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) { | 1011 if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) { |
1029 ui::SetWindowClassHint( | 1012 ui::SetWindowClassHint( |
1030 xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); | 1013 xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); |
1031 } | 1014 } |
1032 | 1015 |
1033 // If we have a parent, record the parent/child relationship. We use this | 1016 // If we have a parent, record the parent/child relationship. We use this |
1034 // data during destruction to make sure that when we try to close a parent | 1017 // data during destruction to make sure that when we try to close a parent |
1035 // window, we also destroy all child windows. | 1018 // window, we also destroy all child windows. |
1036 if (params.parent && params.parent->GetDispatcher()) { | 1019 if (params.parent && params.parent->GetDispatcher()) { |
1037 XID parent_xid = params.parent->GetDispatcher()->GetAcceleratedWidget(); | 1020 XID parent_xid = |
| 1021 params.parent->GetDispatcher()->host()->GetAcceleratedWidget(); |
1038 window_parent_ = GetHostForXID(parent_xid); | 1022 window_parent_ = GetHostForXID(parent_xid); |
1039 DCHECK(window_parent_); | 1023 DCHECK(window_parent_); |
1040 window_parent_->window_children_.insert(this); | 1024 window_parent_->window_children_.insert(this); |
1041 } | 1025 } |
1042 | 1026 |
1043 // If we have a delegate which is providing a default window icon, use that | 1027 // If we have a delegate which is providing a default window icon, use that |
1044 // icon. | 1028 // icon. |
1045 gfx::ImageSkia* window_icon = ViewsDelegate::views_delegate ? | 1029 gfx::ImageSkia* window_icon = ViewsDelegate::views_delegate ? |
1046 ViewsDelegate::views_delegate->GetDefaultWindowIcon() : NULL; | 1030 ViewsDelegate::views_delegate->GetDefaultWindowIcon() : NULL; |
1047 if (window_icon) { | 1031 if (window_icon) { |
(...skipping 29 matching lines...) Expand all Loading... |
1077 &xclient); | 1061 &xclient); |
1078 } | 1062 } |
1079 | 1063 |
1080 bool DesktopRootWindowHostX11::HasWMSpecProperty(const char* property) const { | 1064 bool DesktopRootWindowHostX11::HasWMSpecProperty(const char* property) const { |
1081 return window_properties_.find(atom_cache_.GetAtom(property)) != | 1065 return window_properties_.find(atom_cache_.GetAtom(property)) != |
1082 window_properties_.end(); | 1066 window_properties_.end(); |
1083 } | 1067 } |
1084 | 1068 |
1085 void DesktopRootWindowHostX11::OnCaptureReleased() { | 1069 void DesktopRootWindowHostX11::OnCaptureReleased() { |
1086 g_current_capture = NULL; | 1070 g_current_capture = NULL; |
1087 root_window_host_delegate_->OnHostLostWindowCapture(); | 1071 delegate_->OnHostLostWindowCapture(); |
1088 native_widget_delegate_->OnMouseCaptureLost(); | 1072 native_widget_delegate_->OnMouseCaptureLost(); |
1089 } | 1073 } |
1090 | 1074 |
1091 void DesktopRootWindowHostX11::DispatchMouseEvent(ui::MouseEvent* event) { | 1075 void DesktopRootWindowHostX11::DispatchMouseEvent(ui::MouseEvent* event) { |
1092 if (!g_current_capture || g_current_capture == this) { | 1076 if (!g_current_capture || g_current_capture == this) { |
1093 root_window_host_delegate_->OnHostMouseEvent(event); | 1077 delegate_->OnHostMouseEvent(event); |
1094 } else { | 1078 } else { |
1095 // Another DesktopRootWindowHostX11 has installed itself as | 1079 // Another DesktopRootWindowHostX11 has installed itself as |
1096 // capture. Translate the event's location and dispatch to the other. | 1080 // capture. Translate the event's location and dispatch to the other. |
1097 event->ConvertLocationToTarget(root_window_->window(), | 1081 event->ConvertLocationToTarget(root_window_->window(), |
1098 g_current_capture->root_window_->window()); | 1082 g_current_capture->root_window_->window()); |
1099 g_current_capture->root_window_host_delegate_->OnHostMouseEvent(event); | 1083 g_current_capture->delegate_->OnHostMouseEvent(event); |
1100 } | 1084 } |
1101 } | 1085 } |
1102 | 1086 |
1103 void DesktopRootWindowHostX11::ResetWindowRegion() { | 1087 void DesktopRootWindowHostX11::ResetWindowRegion() { |
1104 if (!IsMaximized()) { | 1088 if (!IsMaximized()) { |
1105 gfx::Path window_mask; | 1089 gfx::Path window_mask; |
1106 views::Widget* widget = native_widget_delegate_->AsWidget(); | 1090 views::Widget* widget = native_widget_delegate_->AsWidget(); |
1107 if (widget->non_client_view()) { | 1091 if (widget->non_client_view()) { |
1108 // Some frame views define a custom (non-rectangular) window mask. If | 1092 // Some frame views define a custom (non-rectangular) window mask. If |
1109 // so, use it to define the window shape. If not, fall through. | 1093 // so, use it to define the window shape. If not, fall through. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 case LeaveNotify: { | 1149 case LeaveNotify: { |
1166 if (!g_current_capture) | 1150 if (!g_current_capture) |
1167 X11DesktopHandler::get()->ProcessXEvent(xev); | 1151 X11DesktopHandler::get()->ProcessXEvent(xev); |
1168 ui::MouseEvent mouse_event(xev); | 1152 ui::MouseEvent mouse_event(xev); |
1169 DispatchMouseEvent(&mouse_event); | 1153 DispatchMouseEvent(&mouse_event); |
1170 break; | 1154 break; |
1171 } | 1155 } |
1172 case Expose: { | 1156 case Expose: { |
1173 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, | 1157 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, |
1174 xev->xexpose.width, xev->xexpose.height); | 1158 xev->xexpose.width, xev->xexpose.height); |
1175 root_window_host_delegate_->OnHostPaint(damage_rect); | 1159 delegate_->OnHostPaint(damage_rect); |
1176 break; | 1160 break; |
1177 } | 1161 } |
1178 case KeyPress: { | 1162 case KeyPress: { |
1179 ui::KeyEvent keydown_event(xev, false); | 1163 ui::KeyEvent keydown_event(xev, false); |
1180 root_window_host_delegate_->OnHostKeyEvent(&keydown_event); | 1164 delegate_->OnHostKeyEvent(&keydown_event); |
1181 break; | 1165 break; |
1182 } | 1166 } |
1183 case KeyRelease: { | 1167 case KeyRelease: { |
1184 ui::KeyEvent keyup_event(xev, false); | 1168 ui::KeyEvent keyup_event(xev, false); |
1185 root_window_host_delegate_->OnHostKeyEvent(&keyup_event); | 1169 delegate_->OnHostKeyEvent(&keyup_event); |
1186 break; | 1170 break; |
1187 } | 1171 } |
1188 case ButtonPress: { | 1172 case ButtonPress: { |
1189 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || | 1173 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || |
1190 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { | 1174 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { |
1191 aura::client::UserActionClient* gesture_client = | 1175 aura::client::UserActionClient* gesture_client = |
1192 aura::client::GetUserActionClient(root_window_->window()); | 1176 aura::client::GetUserActionClient(root_window_->window()); |
1193 if (gesture_client) { | 1177 if (gesture_client) { |
1194 gesture_client->OnUserAction( | 1178 gesture_client->OnUserAction( |
1195 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? | 1179 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? |
(...skipping 21 matching lines...) Expand all Loading... |
1217 // No event is created for X11-release events for mouse-wheel buttons. | 1201 // No event is created for X11-release events for mouse-wheel buttons. |
1218 break; | 1202 break; |
1219 default: | 1203 default: |
1220 NOTREACHED() << event_type; | 1204 NOTREACHED() << event_type; |
1221 } | 1205 } |
1222 break; | 1206 break; |
1223 } | 1207 } |
1224 case FocusOut: | 1208 case FocusOut: |
1225 if (xev->xfocus.mode != NotifyGrab) { | 1209 if (xev->xfocus.mode != NotifyGrab) { |
1226 ReleaseCapture(); | 1210 ReleaseCapture(); |
1227 root_window_host_delegate_->OnHostLostWindowCapture(); | 1211 delegate_->OnHostLostWindowCapture(); |
1228 } else { | 1212 } else { |
1229 root_window_host_delegate_->OnHostLostMouseGrab(); | 1213 delegate_->OnHostLostMouseGrab(); |
1230 } | 1214 } |
1231 break; | 1215 break; |
1232 case ConfigureNotify: { | 1216 case ConfigureNotify: { |
1233 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 1217 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
1234 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 1218 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
1235 // It's possible that the X window may be resized by some other means than | 1219 // It's possible that the X window may be resized by some other means than |
1236 // from within aura (e.g. the X window manager can change the size). Make | 1220 // from within aura (e.g. the X window manager can change the size). Make |
1237 // sure the root window size is maintained properly. | 1221 // sure the root window size is maintained properly. |
1238 int translated_x = xev->xconfigure.x; | 1222 int translated_x = xev->xconfigure.x; |
1239 int translated_y = xev->xconfigure.y; | 1223 int translated_y = xev->xconfigure.y; |
1240 if (!xev->xconfigure.send_event && !xev->xconfigure.override_redirect) { | 1224 if (!xev->xconfigure.send_event && !xev->xconfigure.override_redirect) { |
1241 Window unused; | 1225 Window unused; |
1242 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_, | 1226 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_, |
1243 0, 0, &translated_x, &translated_y, &unused); | 1227 0, 0, &translated_x, &translated_y, &unused); |
1244 } | 1228 } |
1245 gfx::Rect bounds(translated_x, translated_y, | 1229 gfx::Rect bounds(translated_x, translated_y, |
1246 xev->xconfigure.width, xev->xconfigure.height); | 1230 xev->xconfigure.width, xev->xconfigure.height); |
1247 bool size_changed = bounds_.size() != bounds.size(); | 1231 bool size_changed = bounds_.size() != bounds.size(); |
1248 bool origin_changed = bounds_.origin() != bounds.origin(); | 1232 bool origin_changed = bounds_.origin() != bounds.origin(); |
1249 previous_bounds_ = bounds_; | 1233 previous_bounds_ = bounds_; |
1250 bounds_ = bounds; | 1234 bounds_ = bounds; |
1251 if (size_changed) | 1235 if (size_changed) |
1252 root_window_host_delegate_->OnHostResized(bounds.size()); | 1236 delegate_->OnHostResized(bounds.size()); |
1253 if (origin_changed) | 1237 if (origin_changed) |
1254 root_window_host_delegate_->OnHostMoved(bounds_.origin()); | 1238 delegate_->OnHostMoved(bounds_.origin()); |
1255 ResetWindowRegion(); | 1239 ResetWindowRegion(); |
1256 break; | 1240 break; |
1257 } | 1241 } |
1258 case GenericEvent: { | 1242 case GenericEvent: { |
1259 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 1243 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
1260 if (!factory->ShouldProcessXI2Event(xev)) | 1244 if (!factory->ShouldProcessXI2Event(xev)) |
1261 break; | 1245 break; |
1262 | 1246 |
1263 ui::EventType type = ui::EventTypeFromNative(xev); | 1247 ui::EventType type = ui::EventTypeFromNative(xev); |
1264 XEvent last_event; | 1248 XEvent last_event; |
1265 int num_coalesced = 0; | 1249 int num_coalesced = 0; |
1266 | 1250 |
1267 switch (type) { | 1251 switch (type) { |
1268 // case ui::ET_TOUCH_MOVED: | 1252 // case ui::ET_TOUCH_MOVED: |
1269 // num_coalesced = CoalescePendingMotionEvents(xev, &last_event); | 1253 // num_coalesced = CoalescePendingMotionEvents(xev, &last_event); |
1270 // if (num_coalesced > 0) | 1254 // if (num_coalesced > 0) |
1271 // xev = &last_event; | 1255 // xev = &last_event; |
1272 // // fallthrough | 1256 // // fallthrough |
1273 // case ui::ET_TOUCH_PRESSED: | 1257 // case ui::ET_TOUCH_PRESSED: |
1274 // case ui::ET_TOUCH_RELEASED: { | 1258 // case ui::ET_TOUCH_RELEASED: { |
1275 // ui::TouchEvent touchev(xev); | 1259 // ui::TouchEvent touchev(xev); |
1276 // root_window_host_delegate_->OnHostTouchEvent(&touchev); | 1260 // delegate_->OnHostTouchEvent(&touchev); |
1277 // break; | 1261 // break; |
1278 // } | 1262 // } |
1279 case ui::ET_MOUSE_MOVED: | 1263 case ui::ET_MOUSE_MOVED: |
1280 case ui::ET_MOUSE_DRAGGED: | 1264 case ui::ET_MOUSE_DRAGGED: |
1281 case ui::ET_MOUSE_PRESSED: | 1265 case ui::ET_MOUSE_PRESSED: |
1282 case ui::ET_MOUSE_RELEASED: | 1266 case ui::ET_MOUSE_RELEASED: |
1283 case ui::ET_MOUSE_ENTERED: | 1267 case ui::ET_MOUSE_ENTERED: |
1284 case ui::ET_MOUSE_EXITED: { | 1268 case ui::ET_MOUSE_EXITED: { |
1285 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { | 1269 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { |
1286 // If this is a motion event, we want to coalesce all pending motion | 1270 // If this is a motion event, we want to coalesce all pending motion |
1287 // events that are at the top of the queue. | 1271 // events that are at the top of the queue. |
1288 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); | 1272 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); |
1289 if (num_coalesced > 0) | 1273 if (num_coalesced > 0) |
1290 xev = &last_event; | 1274 xev = &last_event; |
1291 } else if (type == ui::ET_MOUSE_PRESSED) { | 1275 } else if (type == ui::ET_MOUSE_PRESSED) { |
1292 XIDeviceEvent* xievent = | 1276 XIDeviceEvent* xievent = |
1293 static_cast<XIDeviceEvent*>(xev->xcookie.data); | 1277 static_cast<XIDeviceEvent*>(xev->xcookie.data); |
1294 int button = xievent->detail; | 1278 int button = xievent->detail; |
1295 if (button == kBackMouseButton || button == kForwardMouseButton) { | 1279 if (button == kBackMouseButton || button == kForwardMouseButton) { |
1296 aura::client::UserActionClient* gesture_client = | 1280 aura::client::UserActionClient* gesture_client = |
1297 aura::client::GetUserActionClient( | 1281 aura::client::GetUserActionClient( |
1298 root_window_host_delegate_->AsRootWindow()->window()); | 1282 delegate_->AsRootWindow()->window()); |
1299 if (gesture_client) { | 1283 if (gesture_client) { |
1300 bool reverse_direction = | 1284 bool reverse_direction = |
1301 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); | 1285 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); |
1302 gesture_client->OnUserAction( | 1286 gesture_client->OnUserAction( |
1303 (button == kBackMouseButton && !reverse_direction) || | 1287 (button == kBackMouseButton && !reverse_direction) || |
1304 (button == kForwardMouseButton && reverse_direction) ? | 1288 (button == kForwardMouseButton && reverse_direction) ? |
1305 aura::client::UserActionClient::BACK : | 1289 aura::client::UserActionClient::BACK : |
1306 aura::client::UserActionClient::FORWARD); | 1290 aura::client::UserActionClient::FORWARD); |
1307 } | 1291 } |
1308 break; | 1292 break; |
(...skipping 14 matching lines...) Expand all Loading... |
1323 } | 1307 } |
1324 case ui::ET_MOUSEWHEEL: { | 1308 case ui::ET_MOUSEWHEEL: { |
1325 ui::MouseWheelEvent mouseev(xev); | 1309 ui::MouseWheelEvent mouseev(xev); |
1326 DispatchMouseEvent(&mouseev); | 1310 DispatchMouseEvent(&mouseev); |
1327 break; | 1311 break; |
1328 } | 1312 } |
1329 case ui::ET_SCROLL_FLING_START: | 1313 case ui::ET_SCROLL_FLING_START: |
1330 case ui::ET_SCROLL_FLING_CANCEL: | 1314 case ui::ET_SCROLL_FLING_CANCEL: |
1331 case ui::ET_SCROLL: { | 1315 case ui::ET_SCROLL: { |
1332 ui::ScrollEvent scrollev(xev); | 1316 ui::ScrollEvent scrollev(xev); |
1333 root_window_host_delegate_->OnHostScrollEvent(&scrollev); | 1317 delegate_->OnHostScrollEvent(&scrollev); |
1334 break; | 1318 break; |
1335 } | 1319 } |
1336 case ui::ET_UNKNOWN: | 1320 case ui::ET_UNKNOWN: |
1337 break; | 1321 break; |
1338 default: | 1322 default: |
1339 NOTREACHED(); | 1323 NOTREACHED(); |
1340 } | 1324 } |
1341 | 1325 |
1342 // If we coalesced an event we need to free its cookie. | 1326 // If we coalesced an event we need to free its cookie. |
1343 if (num_coalesced > 0) | 1327 if (num_coalesced > 0) |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 if (linux_ui) { | 1487 if (linux_ui) { |
1504 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1488 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
1505 if (native_theme) | 1489 if (native_theme) |
1506 return native_theme; | 1490 return native_theme; |
1507 } | 1491 } |
1508 | 1492 |
1509 return ui::NativeTheme::instance(); | 1493 return ui::NativeTheme::instance(); |
1510 } | 1494 } |
1511 | 1495 |
1512 } // namespace views | 1496 } // namespace views |
OLD | NEW |