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 "chrome/browser/ui/window_sizer/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/browser/ui/host_desktop.h" | 13 #include "chrome/browser/ui/host_desktop.h" |
14 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
15 | 15 |
16 // Used to pad the default new window size. On Windows, this is also used for | 16 // Used to pad the default new window size. On Windows, this is also used for |
17 // positioning new windows (each window is offset from the previous one). | 17 // positioning new windows (each window is offset from the previous one). |
18 // Since we don't position windows, it's only used for the default new window | 18 // Since we don't position windows, it's only used for the default new window |
19 // size. | 19 // size. |
20 const int WindowSizer::kWindowTilePixels = 10; | 20 const int WindowSizer::kWindowTilePixels = 10; |
21 | 21 |
22 // static | 22 // static |
23 gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size, | 23 gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size, |
24 chrome::HostDesktopType type) { | 24 chrome::HostDesktopType type) { |
25 gfx::Rect monitor_bounds = gfx::Screen::GetPrimaryDisplay().work_area(); | 25 gfx::Rect monitor_bounds = gfx::Screen::GetNativeScreen()-> |
| 26 GetPrimaryDisplay().work_area(); |
26 gfx::Point corner(monitor_bounds.x(), monitor_bounds.y()); | 27 gfx::Point corner(monitor_bounds.x(), monitor_bounds.y()); |
27 | 28 |
28 if (Browser* browser = browser::FindLastActiveWithHostDesktopType(type)) { | 29 if (Browser* browser = browser::FindLastActiveWithHostDesktopType(type)) { |
29 GtkWindow* window = | 30 GtkWindow* window = |
30 reinterpret_cast<GtkWindow*>(browser->window()->GetNativeWindow()); | 31 reinterpret_cast<GtkWindow*>(browser->window()->GetNativeWindow()); |
31 int x = 0, y = 0; | 32 int x = 0, y = 0; |
32 gtk_window_get_position(window, &x, &y); | 33 gtk_window_get_position(window, &x, &y); |
33 // Limit to not overflow the work area right and bottom edges. | 34 // Limit to not overflow the work area right and bottom edges. |
34 gfx::Point limit( | 35 gfx::Point limit( |
35 std::min(x + kWindowTilePixels, monitor_bounds.right() - size.width()), | 36 std::min(x + kWindowTilePixels, monitor_bounds.right() - size.width()), |
36 std::min(y + kWindowTilePixels, | 37 std::min(y + kWindowTilePixels, |
37 monitor_bounds.bottom() - size.height())); | 38 monitor_bounds.bottom() - size.height())); |
38 // Adjust corner to now overflow the work area left and top edges, so | 39 // Adjust corner to now overflow the work area left and top edges, so |
39 // that if a popup does not fit the title-bar is remains visible. | 40 // that if a popup does not fit the title-bar is remains visible. |
40 corner = gfx::Point( | 41 corner = gfx::Point( |
41 std::max(corner.x(), limit.x()), | 42 std::max(corner.x(), limit.x()), |
42 std::max(corner.y(), limit.y())); | 43 std::max(corner.y(), limit.y())); |
43 } | 44 } |
44 return corner; | 45 return corner; |
45 } | 46 } |
OLD | NEW |