Commit 6072d663 authored by Lepton Wu's avatar Lepton Wu Committed by Commit Bot

display_manager: use display as internal in VM.

The virtual display when running Chrome OS inside VM was treated as
external display. This stop us to test touch view mode on emulator since
Chrome OS think it's in dock mode. Just treat the first display as internal
display when running Chrome inside VM.

BUG=b:62822485
TEST=manual - push Chrome to emulator and make sure touch view mode works
R=derat@chromium.org

Change-Id: I8e8007931b078c96c57e6958e182edf5f095c8cd
Reviewed-on: https://chromium-review.googlesource.com/775893
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517292}
parent f21b15cb
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/user_activity/user_activity_detector.h" #include "ui/base/user_activity/user_activity_detector.h"
...@@ -221,12 +220,11 @@ void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() { ...@@ -221,12 +220,11 @@ void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() {
void DisplayChangeObserver::UpdateInternalDisplay( void DisplayChangeObserver::UpdateInternalDisplay(
const DisplayConfigurator::DisplayStateList& display_states) { const DisplayConfigurator::DisplayStateList& display_states) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); bool force_first_display_internal = ForceFirstDisplayInternal();
bool use_first_display_as_internal =
command_line->HasSwitch(::switches::kUseFirstDisplayAsInternal);
for (auto* state : display_states) { for (auto* state : display_states) {
if (state->type() == DISPLAY_CONNECTION_TYPE_INTERNAL || if (state->type() == DISPLAY_CONNECTION_TYPE_INTERNAL ||
(use_first_display_as_internal && (force_first_display_internal &&
(!Display::HasInternalDisplay() || (!Display::HasInternalDisplay() ||
state->display_id() == Display::InternalDisplayId()))) { state->display_id() == Display::InternalDisplayId()))) {
if (Display::HasInternalDisplay()) if (Display::HasInternalDisplay())
......
...@@ -96,8 +96,7 @@ void SetInternalManagedDisplayModeList(ManagedDisplayInfo* info) { ...@@ -96,8 +96,7 @@ void SetInternalManagedDisplayModeList(ManagedDisplayInfo* info) {
void MaybeInitInternalDisplay(ManagedDisplayInfo* info) { void MaybeInitInternalDisplay(ManagedDisplayInfo* info) {
int64_t id = info->id(); int64_t id = info->id();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (ForceFirstDisplayInternal()) {
if (command_line->HasSwitch(::switches::kUseFirstDisplayAsInternal)) {
Display::SetInternalDisplayId(id); Display::SetInternalDisplayId(id);
SetInternalManagedDisplayModeList(info); SetInternalManagedDisplayModeList(info);
} }
......
...@@ -6,11 +6,17 @@ ...@@ -6,11 +6,17 @@
#include <algorithm> #include <algorithm>
#include "base/command_line.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "ui/display/display_switches.h"
#include "ui/display/manager/managed_display_info.h" #include "ui/display/manager/managed_display_info.h"
#include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/size_f.h" #include "ui/gfx/geometry/size_f.h"
#if defined(OS_CHROMEOS)
#include "chromeos/system/statistics_provider.h"
#endif
namespace display { namespace display {
namespace { namespace {
...@@ -152,6 +158,18 @@ bool HasDisplayModeForUIScale(const ManagedDisplayInfo& info, float ui_scale) { ...@@ -152,6 +158,18 @@ bool HasDisplayModeForUIScale(const ManagedDisplayInfo& info, float ui_scale) {
return std::find_if(modes.begin(), modes.end(), comparator) != modes.end(); return std::find_if(modes.begin(), modes.end(), comparator) != modes.end();
} }
bool ForceFirstDisplayInternal() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool ret = command_line->HasSwitch(::switches::kUseFirstDisplayAsInternal);
#if defined(OS_CHROMEOS)
// Touch view mode is only available to internal display. We force the
// display as internal for emulator to test touch view mode.
ret = ret ||
chromeos::system::StatisticsProvider::GetInstance()->IsRunningOnVm();
#endif
return ret;
}
bool ComputeBoundary(const Display& a_display, bool ComputeBoundary(const Display& a_display,
const Display& b_display, const Display& b_display,
gfx::Rect* a_edge_in_screen, gfx::Rect* a_edge_in_screen,
......
...@@ -48,6 +48,10 @@ CreateUnifiedManagedDisplayModeList( ...@@ -48,6 +48,10 @@ CreateUnifiedManagedDisplayModeList(
// Tests if the |info| has display mode that matches |ui_scale|. // Tests if the |info| has display mode that matches |ui_scale|.
bool HasDisplayModeForUIScale(const ManagedDisplayInfo& info, float ui_scale); bool HasDisplayModeForUIScale(const ManagedDisplayInfo& info, float ui_scale);
// Returns true if the first display should unconditionally be considered an
// internal display.
bool ForceFirstDisplayInternal();
// Computes the bounds that defines the bounds between two displays. // Computes the bounds that defines the bounds between two displays.
// Returns false if two displays do not intersect. // Returns false if two displays do not intersect.
DISPLAY_MANAGER_EXPORT bool ComputeBoundary( DISPLAY_MANAGER_EXPORT bool ComputeBoundary(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment