This source file includes following definitions.
- GetDefaultPopupOrigin
#include "chrome/browser/ui/window_sizer/window_sizer.h"
#include <gtk/gtk.h>
#include "base/logging.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/host_desktop.h"
#include "ui/gfx/screen.h"
const int WindowSizer::kWindowTilePixels = 10;
gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size,
chrome::HostDesktopType type) {
gfx::Rect monitor_bounds = gfx::Screen::GetNativeScreen()->
GetPrimaryDisplay().work_area();
gfx::Point corner(monitor_bounds.x(), monitor_bounds.y());
if (Browser* browser = chrome::FindLastActiveWithHostDesktopType(type)) {
GtkWindow* window =
reinterpret_cast<GtkWindow*>(browser->window()->GetNativeWindow());
int x = 0, y = 0;
gtk_window_get_position(window, &x, &y);
gfx::Point limit(
std::min(x + kWindowTilePixels, monitor_bounds.right() - size.width()),
std::min(y + kWindowTilePixels,
monitor_bounds.bottom() - size.height()));
corner = gfx::Point(
std::max(corner.x(), limit.x()),
std::max(corner.y(), limit.y()));
}
return corner;
}