Skip to content

Commit

Permalink
Add place holder to move gfx::Display/Screen to ui/display
Browse files Browse the repository at this point in the history
I tried to move them and update includes, but it was just too many files to change at once. I'll move the class after all other files are migrated.

I covered ui/chromeos as a first target

BUG=597761

Review URL: https://codereview.chromium.org/1913613002

Cr-Commit-Position: refs/heads/master@{#389557}
  • Loading branch information
mitoshima authored and Commit bot committed Apr 25, 2016
1 parent 821ac29 commit ef5fb89
Show file tree
Hide file tree
Showing 20 changed files with 211 additions and 146 deletions.
1 change: 1 addition & 0 deletions ui/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ component("ui_chromeos") {
"//ui/base/ime",
"//ui/chromeos/resources",
"//ui/chromeos/strings",
"//ui/display",
"//ui/events",
"//ui/events:gesture_detection",
"//ui/gfx",
Expand Down
1 change: 1 addition & 0 deletions ui/chromeos/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include_rules = [
"+third_party/cros_system_api",
"+ui/aura",
"+ui/base",
"+ui/display",
"+ui/events",
"+ui/gfx",
"+ui/gl",
Expand Down
7 changes: 4 additions & 3 deletions ui/chromeos/ime/candidate_window_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "base/strings/utf_string_conversions.h"
#include "ui/chromeos/ime/candidate_view.h"
#include "ui/chromeos/ime/candidate_window_constants.h"
#include "ui/display/screen.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/screen.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
Expand Down Expand Up @@ -55,8 +55,9 @@ class CandidateWindowBorder : public views::BubbleBorder {
// It cannot use the normal logic of arrow offset for horizontal offscreen,
// because the arrow must be in the content's edge. But CandidateWindow has
// to be visible even when |anchor_rect| is out of the screen.
gfx::Rect work_area =
gfx::Screen::GetScreen()->GetDisplayNearestWindow(parent_).work_area();
gfx::Rect work_area = display::Screen::GetScreen()
->GetDisplayNearestWindow(parent_)
.work_area();
if (bounds.right() > work_area.right())
bounds.set_x(work_area.right() - bounds.width());
if (bounds.x() < work_area.x())
Expand Down
6 changes: 3 additions & 3 deletions ui/chromeos/ime/mode_indicator_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "base/logging.h"
#include "base/macros.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/label.h"
Expand Down Expand Up @@ -35,7 +35,7 @@ class ModeIndicatorFrameView : public views::BubbleFrameView {
private:
// views::BubbleFrameView overrides:
gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect) const override {
return gfx::Screen::GetScreen()
return display::Screen::GetScreen()
->GetDisplayNearestPoint(rect.CenterPoint())
.bounds();
}
Expand Down
1 change: 1 addition & 0 deletions ui/chromeos/ui_chromeos.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'../aura/aura.gyp:aura',
'../base/ime/ui_base_ime.gyp:ui_base_ime',
'../base/ui_base.gyp:ui_base',
'../display/display.gyp:display',
'../events/events.gyp:events',
'../events/events.gyp:gesture_detection',
'../gfx/gfx.gyp:gfx',
Expand Down
3 changes: 3 additions & 0 deletions ui/display/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ component("display") {
"chromeos/x11/native_display_delegate_x11.h",
"chromeos/x11/native_display_event_dispatcher_x11.cc",
"chromeos/x11/native_display_event_dispatcher_x11.h",
"display.h",
"display_export.h",
"display_observer.h",
"display_switches.cc",
"display_switches.h",
"manager/display_layout.cc",
"manager/display_layout.h",
"manager/display_layout_builder.cc",
"manager/display_layout_builder.h",
"screen.h",
"win/display_info.cc",
"win/display_info.h",
"win/dpi.cc",
Expand Down
4 changes: 2 additions & 2 deletions ui/display/chromeos/display_configurator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include "ui/display/chromeos/display_snapshot_virtual.h"
#include "ui/display/chromeos/display_util.h"
#include "ui/display/chromeos/update_display_configuration_task.h"
#include "ui/display/display.h"
#include "ui/display/display_switches.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/display/types/native_display_delegate.h"
#include "ui/display/util/display_util.h"
#include "ui/gfx/display.h"

namespace ui {

Expand Down Expand Up @@ -1120,7 +1120,7 @@ void DisplayConfigurator::NotifyPowerStateObservers() {
int64_t DisplayConfigurator::AddVirtualDisplay(gfx::Size display_size) {
if (last_virtual_display_id_ == 0xff) {
LOG(WARNING) << "Exceeded virtual display id limit";
return gfx::Display::kInvalidDisplayID;
return display::Display::kInvalidDisplayID;
}

DisplaySnapshotVirtual* virtual_snapshot =
Expand Down
3 changes: 3 additions & 0 deletions ui/display/display.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@
'chromeos/x11/native_display_delegate_x11.h',
'chromeos/x11/native_display_event_dispatcher_x11.cc',
'chromeos/x11/native_display_event_dispatcher_x11.h',
'display.h',
'display_export.h',
'display_observer.h',
'display_switches.cc',
'display_switches.h',
'manager/display_layout.cc',
'manager/display_layout.h',
'manager/display_layout_builder.cc',
'manager/display_layout_builder.h',
'screen.h',
'win/display_info.cc',
'win/display_info.h',
'win/dpi.cc',
Expand Down
17 changes: 17 additions & 0 deletions ui/display/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_DISPLAY_DISPLAY_H_
#define UI_DISPLAY_DISPLAY_H_

#include "ui/gfx/display.h"

namespace display {

// TODO(oshima): move the gfx::Display to display::Display.
using Display = gfx::Display;

} // display

#endif // UI_DISPLAY_DISPLAY_H_
17 changes: 17 additions & 0 deletions ui/display/display_observer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_DISPLAY_DISPLAY_OBSERVER_H_
#define UI_DISPLAY_DISPLAY_OBSERVER_H_

#include "ui/gfx/display_observer.h"

namespace display {

// TODO(oshima): move the gfx::DisplayObserver to display::DisplayObserver.
using DisplayObserver = gfx::DisplayObserver;

} // display

#endif // UI_DISPLAY_DISPLAY_OBSERVER_H_
20 changes: 10 additions & 10 deletions ui/display/manager/display_layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "ui/gfx/display.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/insets.h"

namespace display {
Expand Down Expand Up @@ -49,14 +49,14 @@ gfx::Display* FindDisplayById(DisplayList* display_list, int64_t id) {
// DisplayPlacement

DisplayPlacement::DisplayPlacement()
: display_id(gfx::Display::kInvalidDisplayID),
parent_display_id(gfx::Display::kInvalidDisplayID),
: display_id(display::Display::kInvalidDisplayID),
parent_display_id(display::Display::kInvalidDisplayID),
position(DisplayPlacement::RIGHT),
offset(0) {}

DisplayPlacement::DisplayPlacement(Position pos, int offset)
: display_id(gfx::Display::kInvalidDisplayID),
parent_display_id(gfx::Display::kInvalidDisplayID),
: display_id(display::Display::kInvalidDisplayID),
parent_display_id(display::Display::kInvalidDisplayID),
position(pos),
offset(offset) {
DCHECK_LE(TOP, position);
Expand Down Expand Up @@ -97,9 +97,9 @@ DisplayPlacement& DisplayPlacement::Swap() {

std::string DisplayPlacement::ToString() const {
std::stringstream s;
if (display_id != gfx::Display::kInvalidDisplayID)
if (display_id != display::Display::kInvalidDisplayID)
s << "id=" << display_id << ", ";
if (parent_display_id != gfx::Display::kInvalidDisplayID)
if (parent_display_id != display::Display::kInvalidDisplayID)
s << "parent=" << parent_display_id << ", ";
s << PositionToString(position) << ", ";
s << offset;
Expand Down Expand Up @@ -155,7 +155,7 @@ bool DisplayPlacement::StringToPosition(const base::StringPiece& string,
DisplayLayout::DisplayLayout()
: mirrored(false),
default_unified(true),
primary_id(gfx::Display::kInvalidDisplayID) {}
primary_id(display::Display::kInvalidDisplayID) {}

DisplayLayout::~DisplayLayout() {}

Expand Down Expand Up @@ -202,11 +202,11 @@ bool DisplayLayout::Validate(const DisplayIdList& list,
LOG(ERROR) << "PlacementList must be sorted by display_id";
return false;
}
if (placement.display_id == gfx::Display::kInvalidDisplayID) {
if (placement.display_id == display::Display::kInvalidDisplayID) {
LOG(ERROR) << "display_id is not initialized";
return false;
}
if (placement.parent_display_id == gfx::Display::kInvalidDisplayID) {
if (placement.parent_display_id == display::Display::kInvalidDisplayID) {
LOG(ERROR) << "display_parent_id is not initialized";
return false;
}
Expand Down
1 change: 1 addition & 0 deletions ui/display/manager/display_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Display;
}

namespace display {
using Display = gfx::Display;

// An identifier used to manage display layout in DisplayManager /
// DisplayLayoutStore.
Expand Down
19 changes: 19 additions & 0 deletions ui/display/screen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_DISPLAY_SCREEN_H_
#define UI_DISPLAY_SCREEN_H_

#include "ui/gfx/screen.h"

namespace display {

// TODO(oshima): move the gfx::Screen to display::Screen.
using Display = gfx::Display;
using DisplayObserver = gfx::DisplayObserver;
using Screen = gfx::Screen;

} // display

#endif // UI_DISPLAY_SCREEN_H_
16 changes: 8 additions & 8 deletions ui/display/win/display_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@
#include "base/hash.h"
#include "base/strings/utf_string_conversions.h"

namespace display {
namespace {

gfx::Display::Rotation GetRotationForDevice(const wchar_t* device_name) {
Display::Rotation GetRotationForDevice(const wchar_t* device_name) {
DEVMODE mode;
::ZeroMemory(&mode, sizeof(mode));
mode.dmSize = sizeof(mode);
mode.dmDriverExtra = 0;
if (::EnumDisplaySettings(device_name, ENUM_CURRENT_SETTINGS, &mode)) {
switch (mode.dmDisplayOrientation) {
case DMDO_DEFAULT:
return gfx::Display::ROTATE_0;
return Display::ROTATE_0;
case DMDO_90:
return gfx::Display::ROTATE_90;
return Display::ROTATE_90;
case DMDO_180:
return gfx::Display::ROTATE_180;
return Display::ROTATE_180;
case DMDO_270:
return gfx::Display::ROTATE_270;
return Display::ROTATE_270;
default:
NOTREACHED();
}
}
return gfx::Display::ROTATE_0;
return Display::ROTATE_0;
}

} // namespace

namespace display {
namespace win {

DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info,
Expand All @@ -44,7 +44,7 @@ DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info,

DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info,
float device_scale_factor,
gfx::Display::Rotation rotation)
Display::Rotation rotation)
: id_(DeviceIdFromDeviceName(monitor_info.szDevice)),
rotation_(rotation),
screen_rect_(monitor_info.rcMonitor),
Expand Down
8 changes: 4 additions & 4 deletions ui/display/win/display_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <windows.h>
#include <stdint.h>

#include "ui/display/display.h"
#include "ui/display/display_export.h"
#include "ui/gfx/display.h"

namespace display {
namespace win {
Expand All @@ -20,19 +20,19 @@ class DISPLAY_EXPORT DisplayInfo final {
DisplayInfo(const MONITORINFOEX& monitor_info, float device_scale_factor);
DisplayInfo(const MONITORINFOEX& monitor_info,
float device_scale_factor,
gfx::Display::Rotation rotation);
display::Display::Rotation rotation);

static int64_t DeviceIdFromDeviceName(const wchar_t* device_name);

int64_t id() const { return id_; }
gfx::Display::Rotation rotation() const { return rotation_; }
display::Display::Rotation rotation() const { return rotation_; }
const gfx::Rect& screen_rect() const { return screen_rect_; }
const gfx::Rect& screen_work_rect() const { return screen_work_rect_; }
float device_scale_factor() const { return device_scale_factor_; }

private:
int64_t id_;
gfx::Display::Rotation rotation_;
display::Display::Rotation rotation_;
gfx::Rect screen_rect_;
gfx::Rect screen_work_rect_;
float device_scale_factor_;
Expand Down
Loading

0 comments on commit ef5fb89

Please sign in to comment.