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

Unified Diff: ui/views/widget/desktop_aura/desktop_screen_x11.cc

Issue 27156003: linux_aura: Enable HIDPI support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid code-duplication with display_change_observer_chromeos.cc Created 7 years, 2 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
« ui/base/x/x11_util.cc ('K') | « ui/base/x/x11_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_screen_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index 9358875895ac0bd2f1aadb30c27df4f1fd018773..44a89f5189dbe964fc5599cd0f42bd7b9fe22e70 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -14,6 +14,7 @@
#include "base/x11/edid_parser_x11.h"
#include "ui/aura/root_window.h"
#include "ui/aura/root_window_host.h"
+#include "ui/base/layout.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/display.h"
#include "ui/gfx/display_observer.h"
@@ -29,14 +30,36 @@ namespace {
// in |Dispatch()|.
const int64 kConfigureDelayMs = 500;
+float g_device_scale_factor = 1.0f;
Daniel Erat 2013/10/29 14:28:25 why does this need to be global? it looks like it
Mikhail 2013/10/29 14:50:55 Indeed! Thanks for noticing it!
+
+float GetDeviceScaleFactor(int screen_dim, int mm_screen_dim) {
Daniel Erat 2013/10/29 14:28:25 what does "dim" stand for here?
Mikhail 2013/10/29 14:50:55 dimention, probably I should put the whole word.
+ const int kCSSDefaultDIPCountPerInch = 96;
Daniel Erat 2013/10/29 14:28:25 where does this number come from?
Mikhail 2013/10/29 14:50:55 We always assume 96 CSS pixels in an inch
+ const float kInchInMm = 25.4f;
+
+ float screen_DPI = (screen_dim * kInchInMm) / mm_screen_dim;
Daniel Erat 2013/10/29 14:28:25 nit: screen_dpi
+ float scale = screen_DPI / kCSSDefaultDIPCountPerInch;
+
+ return ui::GetImageScale(ui::GetSupportedScaleFactor(scale));
+}
+
std::vector<gfx::Display> GetFallbackDisplayList() {
::XDisplay* display = gfx::GetXDisplay();
::Screen* screen = DefaultScreenOfDisplay(display);
int width = WidthOfScreen(screen);
int height = HeightOfScreen(screen);
+ int mm_width = WidthMMOfScreen(screen);
+ int mm_height = HeightMMOfScreen(screen);
+
+ gfx::Rect bounds_in_pixels(0, 0, width, height);
+ gfx::Display gfx_display(0, bounds_in_pixels);
+ if (!gfx::Display::HasForceDeviceScaleFactor() &&
+ !ui::IsXDisplaySizeBlackListed(mm_width, mm_height)) {
+ g_device_scale_factor = GetDeviceScaleFactor(width, mm_width);
+ DCHECK_LE(1.0f, g_device_scale_factor);
+ gfx_display.SetScaleAndBounds(g_device_scale_factor, bounds_in_pixels);
+ }
- return std::vector<gfx::Display>(
- 1, gfx::Display(0, gfx::Rect(0, 0, width, height)));
+ return std::vector<gfx::Display>(1, gfx_display);
}
} // namespace
@@ -128,7 +151,7 @@ void DesktopScreenX11::ProcessDisplayChange(
// DesktopScreenX11, gfx::Screen implementation:
bool DesktopScreenX11::IsDIPEnabled() {
- return false;
+ return true;
}
gfx::Point DesktopScreenX11::GetCursorScreenPoint() {
@@ -317,6 +340,19 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
gfx::Rect crtc_bounds(crtc->x, crtc->y, crtc->width, crtc->height);
gfx::Display display(display_id, crtc_bounds);
+
+ if (!gfx::Display::HasForceDeviceScaleFactor()) {
+ if (i == 0 && !ui::IsXDisplaySizeBlackListed(output_info->mm_width,
+ output_info->mm_height)) {
+ // As per display scale factor is not supported right now,
+ // the primary display's scale factor is always used.
+ g_device_scale_factor = GetDeviceScaleFactor(crtc->width,
+ output_info->mm_width);
+ }
+ DCHECK_LE(1.0f, g_device_scale_factor);
+ display.SetScaleAndBounds(g_device_scale_factor, crtc_bounds);
+ }
+
if (has_work_area) {
gfx::Rect intersection = crtc_bounds;
intersection.Intersect(work_area);
« ui/base/x/x11_util.cc ('K') | « ui/base/x/x11_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698