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

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

Issue 1003863005: Fix tab drag and drop with hi-dpi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename functions for clarity Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/x11_topmost_window_finder.h" 5 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
6 6
7 #include <X11/Xutil.h> 7 #include <X11/Xutil.h>
8 8
9 #include "ui/aura/client/screen_position_client.h" 9 #include "ui/aura/client/screen_position_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/gfx/screen.h"
11 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 12 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
12 13
13 namespace views { 14 namespace views {
14 15
16 float GetDeviceScaleFactor() {
17 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
18 return display.device_scale_factor();
19 }
20
21 gfx::Point DIPToPixelPoint(const gfx::Point& dip_point) {
22 return ToFlooredPoint(gfx::ScalePoint(dip_point, GetDeviceScaleFactor()));
23 }
24
15 X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) { 25 X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) {
16 } 26 }
17 27
18 X11TopmostWindowFinder::~X11TopmostWindowFinder() { 28 X11TopmostWindowFinder::~X11TopmostWindowFinder() {
19 } 29 }
20 30
21 aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt( 31 aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt(
22 const gfx::Point& screen_loc, 32 const gfx::Point& screen_loc,
23 const std::set<aura::Window*>& ignore) { 33 const std::set<aura::Window*>& ignore) {
24 screen_loc_ = screen_loc; 34 screen_loc_ = DIPToPixelPoint(screen_loc);
sadrul 2015/03/19 23:46:58 Since FindWindowAt() takes screen_loc in physical-
stapelberg 2015/03/20 08:34:40 Done.
25 ignore_ = ignore; 35 ignore_ = ignore;
26 36
27 std::vector<aura::Window*> local_process_windows = 37 std::vector<aura::Window*> local_process_windows =
28 DesktopWindowTreeHostX11::GetAllOpenWindows(); 38 DesktopWindowTreeHostX11::GetAllOpenWindows();
29 bool found_local_process_window = false; 39 bool found_local_process_window = false;
30 for (size_t i = 0; i < local_process_windows.size(); ++i) { 40 for (size_t i = 0; i < local_process_windows.size(); ++i) {
31 if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) { 41 if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) {
32 found_local_process_window = true; 42 found_local_process_window = true;
33 break; 43 break;
34 } 44 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (!host->GetX11RootWindowOuterBounds().Contains(screen_loc_)) 93 if (!host->GetX11RootWindowOuterBounds().Contains(screen_loc_))
84 return false; 94 return false;
85 95
86 ::Region shape = host->GetWindowShape(); 96 ::Region shape = host->GetWindowShape();
87 if (!shape) 97 if (!shape)
88 return true; 98 return true;
89 99
90 aura::client::ScreenPositionClient* screen_position_client = 100 aura::client::ScreenPositionClient* screen_position_client =
91 aura::client::GetScreenPositionClient(window->GetRootWindow()); 101 aura::client::GetScreenPositionClient(window->GetRootWindow());
92 gfx::Point window_loc(screen_loc_); 102 gfx::Point window_loc(screen_loc_);
93 screen_position_client->ConvertPointFromScreen(window, &window_loc); 103 screen_position_client->ConvertPointFromScreen(window, &window_loc);
sadrul 2015/03/19 23:47:40 Oh, also, does this do the right thing? (I seem t
stapelberg 2015/03/20 08:34:40 I’m not sure — the code path never gets executed f
sadrul 2015/03/20 17:40:23 Ah, you need some chrome app that sets custom wind
stapelberg 2015/03/20 21:48:06 I see. I’d like to postpone this until later, and
94 return XPointInRegion(shape, window_loc.x(), window_loc.y()) == True; 104 return XPointInRegion(shape, window_loc.x(), window_loc.y()) == True;
95 } 105 }
96 106
97 } // namespace views 107 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698