Skip to content

Commit

Permalink
Standardize Screen::GetCursorScreenPoint() on Env::last_mouse_location
Browse files Browse the repository at this point in the history
For mus. Also, views::ScreenMus never gets a null delegate, so remove
code that allowed for null.

Env::last_mouse_location isn't always right for aura-mus, I filed 679402 to fix that.

BUG=660994 659155
TEST=none
R=erg@chromium.org

Review-Url: https://codereview.chromium.org/2626453002
Cr-Commit-Position: refs/heads/master@{#442304}
  • Loading branch information
sky authored and Commit bot committed Jan 9, 2017
1 parent 25bc7c5 commit 48e288a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 19 deletions.
5 changes: 5 additions & 0 deletions ash/mus/screen_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ash/mus/screen_mus.h"

#include "ui/aura/env.h"
#include "ui/aura/mus/window_tree_host_mus.h"
#include "ui/aura/window.h"

Expand All @@ -23,4 +24,8 @@ display::Display ScreenMus::GetDisplayNearestWindow(
return iter == display_list().displays().end() ? GetPrimaryDisplay() : *iter;
}

gfx::Point ScreenMus::GetCursorScreenPoint() {
return aura::Env::GetInstance()->last_mouse_location();
}

} // namespace ash
1 change: 1 addition & 0 deletions ash/mus/screen_mus.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ScreenMus : public display::ScreenBase {
private:
// display::ScreenBase:
display::Display GetDisplayNearestWindow(aura::Window* window) const override;
gfx::Point GetCursorScreenPoint() override;

DISALLOW_COPY_AND_ASSIGN(ScreenMus);
};
Expand Down
4 changes: 0 additions & 4 deletions ui/views/mus/mus_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ aura::PropertyConverter* MusClient::GetPropertyConverter() {
return property_converter_.get();
}

gfx::Point MusClient::GetCursorScreenPoint() {
return window_tree_client_->GetCursorScreenPoint();
}

aura::Window* MusClient::GetWindowAtScreenPoint(const gfx::Point& point) {
for (aura::Window* root : window_tree_client_->GetRoots()) {
aura::WindowTreeHost* window_tree_host = root->GetHost();
Expand Down
1 change: 0 additions & 1 deletion ui/views/mus/mus_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class VIEWS_MUS_EXPORT MusClient

// ScreenMusDelegate:
void OnWindowManagerFrameValuesChanged() override;
gfx::Point GetCursorScreenPoint() override;
aura::Window* GetWindowAtScreenPoint(const gfx::Point& point) override;

// ui:OSExchangeDataProviderFactory::Factory:
Expand Down
14 changes: 4 additions & 10 deletions ui/views/mus/screen_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "services/service_manager/public/cpp/connection.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/views/mus/screen_mus_delegate.h"
#include "ui/views/mus/window_manager_frame_values.h"
Expand Down Expand Up @@ -38,6 +39,7 @@ using Type = display::DisplayList::Type;

ScreenMus::ScreenMus(ScreenMusDelegate* delegate)
: delegate_(delegate), display_manager_observer_binding_(this) {
DCHECK(delegate);
display::Screen::SetScreenInstance(this);
}

Expand Down Expand Up @@ -71,14 +73,7 @@ void ScreenMus::Init(service_manager::Connector* connector) {
}

gfx::Point ScreenMus::GetCursorScreenPoint() {
if (!delegate_) {
// TODO(erg): If we need the cursor point in the window manager, we'll need
// to make |delegate_| required. It only recently changed to be optional.
NOTIMPLEMENTED();
return gfx::Point();
}

return delegate_->GetCursorScreenPoint();
return aura::Env::GetInstance()->last_mouse_location();
}

bool ScreenMus::IsWindowUnderCursor(gfx::NativeWindow window) {
Expand Down Expand Up @@ -131,8 +126,7 @@ void ScreenMus::OnDisplaysChanged(
ws_displays[i]
->frame_decoration_values.To<WindowManagerFrameValues>();
WindowManagerFrameValues::SetInstance(frame_values);
if (delegate_)
delegate_->OnWindowManagerFrameValuesChanged();
delegate_->OnWindowManagerFrameValuesChanged();
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions ui/views/mus/screen_mus.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class VIEWS_MUS_EXPORT ScreenMus
: public display::ScreenBase,
public NON_EXPORTED_BASE(ui::mojom::DisplayManagerObserver) {
public:
// |delegate| can be nullptr.
explicit ScreenMus(ScreenMusDelegate* delegate);
~ScreenMus() override;

Expand All @@ -44,7 +43,7 @@ class VIEWS_MUS_EXPORT ScreenMus
void OnDisplayRemoved(int64_t display_id) override;
void OnPrimaryDisplayChanged(int64_t primary_display_id) override;

ScreenMusDelegate* delegate_; // Can be nullptr.
ScreenMusDelegate* delegate_;
ui::mojom::DisplayManagerPtr display_manager_;
mojo::Binding<ui::mojom::DisplayManagerObserver>
display_manager_observer_binding_;
Expand Down
2 changes: 0 additions & 2 deletions ui/views/mus/screen_mus_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class VIEWS_MUS_EXPORT ScreenMusDelegate {
public:
virtual void OnWindowManagerFrameValuesChanged() = 0;

virtual gfx::Point GetCursorScreenPoint() = 0;

virtual aura::Window* GetWindowAtScreenPoint(const gfx::Point& point) = 0;

protected:
Expand Down

0 comments on commit 48e288a

Please sign in to comment.