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

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

Issue 922293002: linux/x11: Fix event dispatch in menus in High DPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 10 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
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 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 // While we unset the urgency hint when we gain focus, we also must remove it 1425 // While we unset the urgency hint when we gain focus, we also must remove it
1426 // on mouse clicks because we can call FlashFrame() on an active window. 1426 // on mouse clicks because we can call FlashFrame() on an active window.
1427 if (event->IsAnyButton() || event->IsMouseWheelEvent()) 1427 if (event->IsAnyButton() || event->IsMouseWheelEvent())
1428 FlashFrame(false); 1428 FlashFrame(false);
1429 1429
1430 if (!g_current_capture || g_current_capture == this) { 1430 if (!g_current_capture || g_current_capture == this) {
1431 SendEventToProcessor(event); 1431 SendEventToProcessor(event);
1432 } else { 1432 } else {
1433 // Another DesktopWindowTreeHostX11 has installed itself as 1433 // Another DesktopWindowTreeHostX11 has installed itself as
1434 // capture. Translate the event's location and dispatch to the other. 1434 // capture. Translate the event's location and dispatch to the other.
1435 event->ConvertLocationToTarget(window(), g_current_capture->window()); 1435 ConvertEventToDifferentHost(event, g_current_capture);
1436 g_current_capture->SendEventToProcessor(event); 1436 g_current_capture->SendEventToProcessor(event);
1437 } 1437 }
1438 } 1438 }
1439 1439
1440 void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) { 1440 void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) {
1441 if (g_current_capture && g_current_capture != this && 1441 if (g_current_capture && g_current_capture != this &&
1442 event->type() == ui::ET_TOUCH_PRESSED) { 1442 event->type() == ui::ET_TOUCH_PRESSED) {
1443 event->ConvertLocationToTarget(window(), g_current_capture->window()); 1443 ConvertEventToDifferentHost(event, g_current_capture);
1444 g_current_capture->SendEventToProcessor(event); 1444 g_current_capture->SendEventToProcessor(event);
1445 } else { 1445 } else {
1446 SendEventToProcessor(event); 1446 SendEventToProcessor(event);
1447 } 1447 }
1448 } 1448 }
1449 1449
1450 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost(
1451 ui::LocatedEvent* located_event,
1452 DesktopWindowTreeHostX11* host) {
1453 DCHECK_NE(this, host);
1454 const gfx::Display display_src =
1455 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window());
1456 const gfx::Display display_dest =
1457 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window());
1458 DCHECK_EQ(display_src.device_scale_factor(),
1459 display_dest.device_scale_factor());
1460 gfx::Vector2d offset = GetLocationOnNativeScreen() -
1461 host->GetLocationOnNativeScreen();
1462 gfx::Point location_in_pixel_in_host = located_event->location() + offset;
1463 located_event->set_location(location_in_pixel_in_host);
1464 }
1465
1450 void DesktopWindowTreeHostX11::ResetWindowRegion() { 1466 void DesktopWindowTreeHostX11::ResetWindowRegion() {
1451 // If a custom window shape was supplied then apply it. 1467 // If a custom window shape was supplied then apply it.
1452 if (custom_window_shape_) { 1468 if (custom_window_shape_) {
1453 XShapeCombineRegion( 1469 XShapeCombineRegion(
1454 xdisplay_, xwindow_, ShapeBounding, 0, 0, window_shape_, false); 1470 xdisplay_, xwindow_, ShapeBounding, 0, 0, window_shape_, false);
1455 return; 1471 return;
1456 } 1472 }
1457 1473
1458 if (window_shape_) 1474 if (window_shape_)
1459 XDestroyRegion(window_shape_); 1475 XDestroyRegion(window_shape_);
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 if (linux_ui) { 1947 if (linux_ui) {
1932 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 1948 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
1933 if (native_theme) 1949 if (native_theme)
1934 return native_theme; 1950 return native_theme;
1935 } 1951 }
1936 1952
1937 return ui::NativeTheme::instance(); 1953 return ui::NativeTheme::instance();
1938 } 1954 }
1939 1955
1940 } // namespace views 1956 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698