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

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

Issue 290573003: Make tooltips toplevel windows on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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_screen_position_client.h" 5 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
6 6
7 #include "ui/aura/window_tree_host.h" 7 #include "ui/aura/window_tree_host.h"
8 #include "ui/gfx/display.h" 8 #include "ui/gfx/display.h"
9 #include "ui/gfx/point_conversions.h" 9 #include "ui/gfx/point_conversions.h"
10 #include "ui/gfx/screen.h" 10 #include "ui/gfx/screen.h"
11 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 11 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
12 12
13 namespace views { 13 namespace views {
14 14
15 namespace { 15 namespace {
16 16
17 gfx::Point GetOrigin(const aura::Window* root_window) { 17 gfx::Point GetOrigin(const aura::Window* root_window) {
18 gfx::Point origin_in_pixels = 18 gfx::Point origin_in_pixels =
19 root_window->GetHost()->GetBounds().origin(); 19 root_window->GetHost()->GetBounds().origin();
20 aura::Window* window = const_cast<aura::Window*>(root_window); 20 aura::Window* window = const_cast<aura::Window*>(root_window);
21 float scale = gfx::Screen::GetScreenFor(window)-> 21 float scale = gfx::Screen::GetScreenFor(window)->
22 GetDisplayNearestWindow(window).device_scale_factor(); 22 GetDisplayNearestWindow(window).device_scale_factor();
23 return gfx::ToFlooredPoint( 23 return gfx::ToFlooredPoint(
24 gfx::ScalePoint(origin_in_pixels, 1 / scale)); 24 gfx::ScalePoint(origin_in_pixels, 1 / scale));
25 } 25 }
26 26
27 // Returns true if bounds passed to window are treated as though they are in 27 // Returns true if bounds passed to window are treated as though they are in
28 // screen coordinates. 28 // screen coordinates.
29 bool PositionWindowInScreenCoordinates(aura::Window* window) { 29 bool PositionWindowInScreenCoordinates(aura::Window* window) {
30 if (window->type() == ui::wm::WINDOW_TYPE_POPUP || 30 if (window->type() == ui::wm::WINDOW_TYPE_POPUP)
31 window->type() == ui::wm::WINDOW_TYPE_TOOLTIP)
32 return true; 31 return true;
33 32
34 Widget* widget = Widget::GetWidgetForNativeView(window); 33 Widget* widget = Widget::GetWidgetForNativeView(window);
35 return widget && widget->is_top_level(); 34 return widget && widget->is_top_level();
36 } 35 }
37 36
38 } // namespace 37 } // namespace
39 38
40 DesktopScreenPositionClient::DesktopScreenPositionClient( 39 DesktopScreenPositionClient::DesktopScreenPositionClient(
41 aura::Window* root_window) : root_window_(root_window) { 40 aura::Window* root_window) : root_window_(root_window) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 gfx::Point host_origin = GetOrigin(root); 92 gfx::Point host_origin = GetOrigin(root);
94 origin.Offset(-host_origin.x(), -host_origin.y()); 93 origin.Offset(-host_origin.x(), -host_origin.y());
95 window->SetBounds(gfx::Rect(origin, bounds.size())); 94 window->SetBounds(gfx::Rect(origin, bounds.size()));
96 return; 95 return;
97 } 96 }
98 97
99 window->SetBounds(bounds); 98 window->SetBounds(bounds);
100 } 99 }
101 100
102 } // namespace views 101 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698