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

Side by Side Diff: chrome/browser/ui/window_sizer_gtk.cc

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/window_sizer.cc ('k') | chrome/test/base/browser_with_test_window_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "chrome/browser/ui/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_list.h" 11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/browser_window.h" 12 #include "chrome/browser/ui/browser_window.h"
13 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
14 14
15 // Used to pad the default new window size. On Windows, this is also used for 15 // Used to pad the default new window size. On Windows, this is also used for
16 // positioning new windows (each window is offset from the previous one). 16 // positioning new windows (each window is offset from the previous one).
17 // Since we don't position windows, it's only used for the default new window 17 // Since we don't position windows, it's only used for the default new window
18 // size. 18 // size.
19 const int WindowSizer::kWindowTilePixels = 10; 19 const int WindowSizer::kWindowTilePixels = 10;
20 20
21 // static 21 // static
22 gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { 22 gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) {
23 gfx::Rect monitor_bounds = gfx::Screen::GetPrimaryMonitorWorkArea(); 23 gfx::Rect monitor_bounds = gfx::Screen::GetPrimaryMonitor().work_area();
24 gfx::Point corner(monitor_bounds.x(), monitor_bounds.y()); 24 gfx::Point corner(monitor_bounds.x(), monitor_bounds.y());
25 if (Browser* browser = BrowserList::GetLastActive()) { 25 if (Browser* browser = BrowserList::GetLastActive()) {
26 GtkWindow* window = 26 GtkWindow* window =
27 reinterpret_cast<GtkWindow*>(browser->window()->GetNativeHandle()); 27 reinterpret_cast<GtkWindow*>(browser->window()->GetNativeHandle());
28 int x = 0, y = 0; 28 int x = 0, y = 0;
29 gtk_window_get_position(window, &x, &y); 29 gtk_window_get_position(window, &x, &y);
30 // Limit to not overflow the work area right and bottom edges. 30 // Limit to not overflow the work area right and bottom edges.
31 gfx::Point limit( 31 gfx::Point limit(
32 std::min(x + kWindowTilePixels, monitor_bounds.right() - size.width()), 32 std::min(x + kWindowTilePixels, monitor_bounds.right() - size.width()),
33 std::min(y + kWindowTilePixels, 33 std::min(y + kWindowTilePixels,
34 monitor_bounds.bottom() - size.height())); 34 monitor_bounds.bottom() - size.height()));
35 // Adjust corner to now overflow the work area left and top edges, so 35 // Adjust corner to now overflow the work area left and top edges, so
36 // that if a popup does not fit the title-bar is remains visible. 36 // that if a popup does not fit the title-bar is remains visible.
37 corner = gfx::Point( 37 corner = gfx::Point(
38 std::max(corner.x(), limit.x()), 38 std::max(corner.x(), limit.x()),
39 std::max(corner.y(), limit.y())); 39 std::max(corner.y(), limit.y()));
40 } 40 }
41 return corner; 41 return corner;
42 } 42 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer.cc ('k') | chrome/test/base/browser_with_test_window_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698