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

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

Issue 197283008: Fix panel dragging on Linux Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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>
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 swa.override_redirect = True; 937 swa.override_redirect = True;
938 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_DND"); 938 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_DND");
939 break; 939 break;
940 default: 940 default:
941 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); 941 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL");
942 break; 942 break;
943 } 943 }
944 if (swa.override_redirect) 944 if (swa.override_redirect)
945 attribute_mask |= CWOverrideRedirect; 945 attribute_mask |= CWOverrideRedirect;
946 946
947 x_bounds_ = params.bounds;
947 bounds_ = params.bounds; 948 bounds_ = params.bounds;
948 xwindow_ = XCreateWindow( 949 xwindow_ = XCreateWindow(
949 xdisplay_, x_root_window_, 950 xdisplay_, x_root_window_,
950 bounds_.x(), bounds_.y(), 951 bounds_.x(), bounds_.y(),
951 bounds_.width(), bounds_.height(), 952 bounds_.width(), bounds_.height(),
952 0, // border width 953 0, // border width
953 CopyFromParent, // depth 954 CopyFromParent, // depth
954 InputOutput, 955 InputOutput,
955 CopyFromParent, // visual 956 CopyFromParent, // visual
956 attribute_mask, 957 attribute_mask,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 } 1114 }
1114 1115
1115 void DesktopWindowTreeHostX11::OnCaptureReleased() { 1116 void DesktopWindowTreeHostX11::OnCaptureReleased() {
1116 x11_capture_.reset(); 1117 x11_capture_.reset();
1117 g_current_capture = NULL; 1118 g_current_capture = NULL;
1118 OnHostLostWindowCapture(); 1119 OnHostLostWindowCapture();
1119 native_widget_delegate_->OnMouseCaptureLost(); 1120 native_widget_delegate_->OnMouseCaptureLost();
1120 } 1121 }
1121 1122
1122 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { 1123 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) {
1124 // The event location is relative to |x_bounds_|. However, Aura uses |bounds_|
1125 // for all computations, including converting to screen coordinates. Offset
1126 // the event location so that converting the event location to screen
1127 // coordinates returns the correct value.
1128 gfx::Vector2d event_offset(x_bounds_.origin() - bounds_.origin());
1129 event->set_location(event->location() + event_offset);
1130 event->set_root_location(event->location() + event_offset);
1131
sadrul 2014/03/13 15:41:31 This doesn't look right. Can you update DesktopWin
pkotwicz 2014/03/13 19:47:48 I think I understand what you are asking. You are
1123 if (!g_current_capture || g_current_capture == this) { 1132 if (!g_current_capture || g_current_capture == this) {
1124 SendEventToProcessor(event); 1133 SendEventToProcessor(event);
1125 } else { 1134 } else {
1126 // Another DesktopWindowTreeHostX11 has installed itself as 1135 // Another DesktopWindowTreeHostX11 has installed itself as
1127 // capture. Translate the event's location and dispatch to the other. 1136 // capture. Translate the event's location and dispatch to the other.
1128 event->ConvertLocationToTarget(window(), g_current_capture->window()); 1137 event->ConvertLocationToTarget(window(), g_current_capture->window());
1129 g_current_capture->SendEventToProcessor(event); 1138 g_current_capture->SendEventToProcessor(event);
1130 } 1139 }
1131 } 1140 }
1132 1141
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 DCHECK_EQ(xwindow_, xev->xconfigure.window); 1334 DCHECK_EQ(xwindow_, xev->xconfigure.window);
1326 DCHECK_EQ(xwindow_, xev->xconfigure.event); 1335 DCHECK_EQ(xwindow_, xev->xconfigure.event);
1327 // It's possible that the X window may be resized by some other means than 1336 // It's possible that the X window may be resized by some other means than
1328 // from within aura (e.g. the X window manager can change the size). Make 1337 // from within aura (e.g. the X window manager can change the size). Make
1329 // sure the root window size is maintained properly. 1338 // sure the root window size is maintained properly.
1330 int translated_x = xev->xconfigure.x; 1339 int translated_x = xev->xconfigure.x;
1331 int translated_y = xev->xconfigure.y; 1340 int translated_y = xev->xconfigure.y;
1332 if (!xev->xconfigure.send_event && !xev->xconfigure.override_redirect) { 1341 if (!xev->xconfigure.send_event && !xev->xconfigure.override_redirect) {
1333 Window unused; 1342 Window unused;
1334 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_, 1343 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_,
1335 0, 0, &translated_x, &translated_y, &unused); 1344 0, 0, &translated_x, &translated_y, &unused);
pkotwicz 2014/03/13 03:49:45 The event coordinates matched exactly those that I
sadrul 2014/03/13 15:41:31 I don't understand what you are asking. This is ha
pkotwicz 2014/03/13 19:47:48 Sorry for not being clear. I understand why XTrans
1336 } 1345 }
1337 gfx::Rect bounds(translated_x, translated_y, 1346 gfx::Rect bounds(translated_x, translated_y,
1338 xev->xconfigure.width, xev->xconfigure.height); 1347 xev->xconfigure.width, xev->xconfigure.height);
1339 bool size_changed = bounds_.size() != bounds.size(); 1348 bool size_changed = bounds_.size() != bounds.size();
1340 bool origin_changed = bounds_.origin() != bounds.origin(); 1349 bool origin_changed = bounds_.origin() != bounds.origin();
1341 previous_bounds_ = bounds_; 1350 previous_bounds_ = bounds_;
1351 x_bounds_ = bounds;
1342 bounds_ = bounds; 1352 bounds_ = bounds;
1343 if (size_changed) 1353 if (size_changed)
1344 OnHostResized(bounds.size()); 1354 OnHostResized(bounds.size());
1345 if (origin_changed) 1355 if (origin_changed)
1346 OnHostMoved(bounds_.origin()); 1356 OnHostMoved(bounds_.origin());
1347 ResetWindowRegion(); 1357 ResetWindowRegion();
1348 break; 1358 break;
1349 } 1359 }
1350 case GenericEvent: { 1360 case GenericEvent: {
1351 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 1361 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 if (linux_ui) { 1574 if (linux_ui) {
1565 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); 1575 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme();
1566 if (native_theme) 1576 if (native_theme)
1567 return native_theme; 1577 return native_theme;
1568 } 1578 }
1569 1579
1570 return ui::NativeTheme::instance(); 1580 return ui::NativeTheme::instance();
1571 } 1581 }
1572 1582
1573 } // namespace views 1583 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698