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

Unified Diff: ui/views/widget/native_widget_win.cc

Issue 16336027: Enable high dpi in win/views. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/aero_tooltip_manager.cc ('k') | ui/views/widget/tooltip_manager_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/native_widget_win.cc
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index 93c3d5463e9a5c43583c7915ae5c419b3bd8ed93..ba4a33f4d78bc1ff9e2d730a677487959725da47 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -23,6 +23,7 @@
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/base/theme_provider.h"
#include "ui/base/view_prop.h"
+#include "ui/base/win/dpi.h"
#include "ui/base/win/hwnd_util.h"
#include "ui/base/win/mouse_wheel_util.h"
#include "ui/base/win/shell.h"
@@ -30,7 +31,9 @@
#include "ui/gfx/canvas_paint.h"
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/path.h"
+#include "ui/gfx/point_conversions.h"
#include "ui/gfx/screen.h"
+#include "ui/gfx/size_conversions.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/native_control_win.h"
#include "ui/views/controls/textfield/textfield.h"
@@ -111,8 +114,11 @@ void NativeWidgetWin::Show(int show_state) {
// NativeWidgetWin, NativeWidget implementation:
void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) {
- SetInitParams(params);
- message_handler_->Init(params.parent, params.bounds);
+ gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(params.bounds);
+ Widget::InitParams params_in_pixel(params);
+ params_in_pixel.bounds = pixel_bounds;
+ SetInitParams(params_in_pixel);
+ message_handler_->Init(params.parent, pixel_bounds);
}
NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() {
@@ -211,13 +217,15 @@ internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() {
}
void NativeWidgetWin::CenterWindow(const gfx::Size& size) {
- message_handler_->CenterWindow(size);
+ gfx::Size size_in_pixels = ui::win::DIPToScreenSize(size);
+ message_handler_->CenterWindow(size_in_pixels);
}
void NativeWidgetWin::GetWindowPlacement(
gfx::Rect* bounds,
ui::WindowShowState* show_state) const {
message_handler_->GetWindowPlacement(bounds, show_state);
+ *bounds = ui::win::ScreenToDIPRect(*bounds);
}
void NativeWidgetWin::SetWindowTitle(const string16& title) {
@@ -234,19 +242,26 @@ void NativeWidgetWin::InitModalType(ui::ModalType modal_type) {
}
gfx::Rect NativeWidgetWin::GetWindowBoundsInScreen() const {
- return message_handler_->GetWindowBoundsInScreen();
+ gfx::Rect bounds_in_pixels = message_handler_->GetWindowBoundsInScreen();
+ return ui::win::ScreenToDIPRect(bounds_in_pixels);
}
gfx::Rect NativeWidgetWin::GetClientAreaBoundsInScreen() const {
- return message_handler_->GetClientAreaBoundsInScreen();
+ gfx::Rect bounds_in_pixels = message_handler_->GetClientAreaBoundsInScreen();
+ return ui::win::ScreenToDIPRect(bounds_in_pixels);
}
gfx::Rect NativeWidgetWin::GetRestoredBounds() const {
- return message_handler_->GetRestoredBounds();
+ gfx::Rect bounds_in_pixels = message_handler_->GetRestoredBounds();
+ return ui::win::ScreenToDIPRect(bounds_in_pixels);
}
void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) {
- message_handler_->SetBounds(bounds);
+ float scale = ui::win::GetDeviceScaleFactor();
+ gfx::Rect bounds_in_pixels(
+ gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)),
+ gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale)));
+ message_handler_->SetBounds(bounds_in_pixels);
}
void NativeWidgetWin::SetSize(const gfx::Size& size) {
@@ -287,7 +302,8 @@ void NativeWidgetWin::Hide() {
void NativeWidgetWin::ShowMaximizedWithBounds(
const gfx::Rect& restored_bounds) {
- message_handler_->ShowMaximizedWithBounds(restored_bounds);
+ gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(restored_bounds);
+ message_handler_->ShowMaximizedWithBounds(pixel_bounds);
}
void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) {
@@ -393,7 +409,8 @@ void NativeWidgetWin::RunShellDrag(View* view,
}
void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) {
- message_handler_->SchedulePaintInRect(rect);
+ gfx::Rect pixel_rect = ui::win::DIPToScreenRect(rect);
+ message_handler_->SchedulePaintInRect(pixel_rect);
}
void NativeWidgetWin::SetCursor(gfx::NativeCursor cursor) {
@@ -405,8 +422,9 @@ void NativeWidgetWin::ClearNativeFocus() {
}
gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const {
- return gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(
- GetNativeView()).work_area();
+ return ui::win::ScreenToDIPRect(
+ gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(
+ GetNativeView()).work_area());
}
void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) {
@@ -533,7 +551,8 @@ bool NativeWidgetWin::WillProcessWorkAreaChange() const {
}
int NativeWidgetWin::GetNonClientComponent(const gfx::Point& point) const {
- return delegate_->GetNonClientComponent(point);
+ gfx::Point point_in_dip = ui::win::ScreenToDIPPoint(point);
+ return delegate_->GetNonClientComponent(point_in_dip);
}
void NativeWidgetWin::GetWindowMask(const gfx::Size& size, gfx::Path* path) {
@@ -547,12 +566,13 @@ bool NativeWidgetWin::GetClientAreaInsets(gfx::Insets* insets) const {
void NativeWidgetWin::GetMinMaxSize(gfx::Size* min_size,
gfx::Size* max_size) const {
- *min_size = delegate_->GetMinimumSize();
- *max_size = delegate_->GetMaximumSize();
+ *min_size = ui::win::ScreenToDIPSize(delegate_->GetMinimumSize());
+ *max_size = ui::win::ScreenToDIPSize(delegate_->GetMaximumSize());
}
gfx::Size NativeWidgetWin::GetRootViewSize() const {
- return GetWidget()->GetRootView()->size();
+ gfx::Size pixel_size = GetWidget()->GetRootView()->size();
+ return ui::win::ScreenToDIPSize(pixel_size);
}
void NativeWidgetWin::ResetWindowControls() {
@@ -687,7 +707,8 @@ void NativeWidgetWin::HandleVisibilityChanged(bool visible) {
}
void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) {
- delegate_->OnNativeWidgetSizeChanged(new_size);
+ gfx::Size size_in_dip = ui::win::ScreenToDIPSize(new_size);
+ delegate_->OnNativeWidgetSizeChanged(size_in_dip);
}
void NativeWidgetWin::HandleFrameChanged() {
@@ -710,8 +731,11 @@ void NativeWidgetWin::HandleNativeBlur(HWND focused_window) {
}
bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) {
- delegate_->OnMouseEvent(const_cast<ui::MouseEvent*>(&event));
- return event.handled();
+ ui::MouseEvent dpi_event(event);
+ dpi_event.set_location(ui::win::ScreenToDIPPoint(event.location()));
+ dpi_event.set_root_location(ui::win::ScreenToDIPPoint(event.location()));
+ delegate_->OnMouseEvent(&dpi_event);
+ return dpi_event.handled();
}
bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) {
@@ -757,7 +781,8 @@ void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set,
}
bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) {
- return delegate_->OnNativeWidgetPaintAccelerated(gfx::Rect(invalid_rect));
+ gfx::Rect dpi_rect = ui::win::ScreenToDIPRect(invalid_rect);
+ return delegate_->OnNativeWidgetPaintAccelerated(dpi_rect);
}
void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) {
@@ -846,11 +871,11 @@ bool Widget::ConvertRect(const Widget* source,
if (source_hwnd == target_hwnd)
return true;
- RECT win_rect = rect->ToRECT();
+ RECT win_rect = ui::win::DIPToScreenRect(*rect).ToRECT();
if (::MapWindowPoints(source_hwnd, target_hwnd,
reinterpret_cast<LPPOINT>(&win_rect),
sizeof(RECT)/sizeof(POINT))) {
- *rect = gfx::Rect(win_rect);
+ *rect = ui::win::ScreenToDIPRect(gfx::Rect(win_rect));
return true;
}
return false;
« no previous file with comments | « ui/views/widget/aero_tooltip_manager.cc ('k') | ui/views/widget/tooltip_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698