0

Win8 Aura :add suport for changing cursors

To change the cursor we need to send a message from
the browser to the viewer with the right HCURSOR. Since the
cursors are a GDI shared resource, we can call ::LoadCursor
in the browser and ::SetCursor in the viewer.

BUG=151718
TEST= moving pointer to a chrome window edge changes cursor to resize cursor
Review URL: https://codereview.chromium.org/11446078

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172265 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
cpu@chromium.org
2012-12-11 04:33:08 +00:00
parent 7aa96b1b38
commit 28b0e8f8e5
4 changed files with 39 additions and 3 deletions

@ -121,6 +121,10 @@ gfx::Point RemoteRootWindowHostWin::GetLocationOnNativeScreen() const {
}
void RemoteRootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) {
if (!host_)
return;
host_->Send(
new MetroViewerHostMsg_SetCursor(uint64(native_cursor.platform())));
}
void RemoteRootWindowHostWin::SetCapture() {

@ -14,7 +14,7 @@
IPC_ENUM_TRAITS(ui::EventType)
IPC_ENUM_TRAITS(ui::EventFlags)
// Messages sent from the viewer to the browser.
// Messages sent from the viewer to the browser:
// Inform the browser of the surface to target for compositing.
IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_SetTargetSurface,
@ -51,6 +51,7 @@ IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_Character,
// Informs the browser that the visibiliy of the viewer has changed.
IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_VisibilityChanged,
bool /* visible */);
IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_TouchDown,
int32, /* x-coordinate */
int32, /* y-coordinate */
@ -63,3 +64,9 @@ IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_TouchMoved,
int32, /* x-coordinate */
int32, /* y-coordinate */
uint64) /* timestamp */
// Messages sent from the browser to the viewer:
// Requests the viewer to change the pointer to a new cursor.
IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_SetCursor,
int64 /* cursor */);

@ -66,8 +66,16 @@ void MetroExit() {
class ChromeChannelListener : public IPC::Listener {
public:
ChromeChannelListener(MessageLoop* ui_loop, ChromeAppViewAsh* app_view)
: ui_proxy_(ui_loop->message_loop_proxy()),
app_view_(app_view) {
}
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
DVLOG(1) << "Received ipc message " << message.type();
IPC_BEGIN_MESSAGE_MAP(ChromeChannelListener, message)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursor, OnSetCursor)
IPC_MESSAGE_UNHANDLED(__debugbreak())
IPC_END_MESSAGE_MAP()
return true;
}
@ -75,6 +83,17 @@ class ChromeChannelListener : public IPC::Listener {
DVLOG(1) << "Channel error";
MetroExit();
}
private:
void OnSetCursor(int64 cursor) {
ui_proxy_->PostTask(FROM_HERE,
base::Bind(&ChromeAppViewAsh::OnSetCursor,
base::Unretained(app_view_),
reinterpret_cast<HCURSOR>(cursor)));
}
scoped_refptr<base::MessageLoopProxy> ui_proxy_;
ChromeAppViewAsh* app_view_;
};
bool WaitForChromeIPCConnection(const std::string& channel_name) {
@ -328,7 +347,7 @@ ChromeAppViewAsh::Run() {
// In Aura mode we create an IPC channel to the browser, then ask it to
// connect to us.
ChromeChannelListener ui_channel_listener;
ChromeChannelListener ui_channel_listener(&msg_loop, this);
IPC::ChannelProxy ui_channel(ipc_channel_name,
IPC::Channel::MODE_NAMED_CLIENT,
&ui_channel_listener,
@ -355,6 +374,10 @@ ChromeAppViewAsh::Uninitialize() {
return S_OK;
}
void ChromeAppViewAsh::OnSetCursor(HCURSOR cursor) {
::SetCursor(HCURSOR(cursor));
}
HRESULT ChromeAppViewAsh::OnActivate(
winapp::Core::ICoreApplicationView*,
winapp::Activation::IActivatedEventArgs* args) {

@ -32,6 +32,8 @@ class ChromeAppViewAsh
IFACEMETHOD(Run)();
IFACEMETHOD(Uninitialize)();
void OnSetCursor(HCURSOR cursor);
private:
HRESULT OnActivate(winapp::Core::ICoreApplicationView* view,
winapp::Activation::IActivatedEventArgs* args);