mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
modify extension connection
Signed-off-by: dubj <dubingjian@huawei.com> Change-Id: I5a1021d33eceba782b5fd7a4dc5921e4dc202bec
This commit is contained in:
@@ -31,7 +31,6 @@ ohos_shared_library("libwindowextension") {
|
||||
|
||||
sources = [
|
||||
"src/window_extension_connection.cpp",
|
||||
"src/window_extension_connection_impl.cpp",
|
||||
"src/window_extension_server_proxy.cpp",
|
||||
"src/window_extension_server_stub.cpp",
|
||||
]
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class IWindowExtensionServer : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowExtensionServer");
|
||||
enum {
|
||||
TRANS_ID_ON_WINDOW_READY,
|
||||
|
||||
@@ -22,14 +22,15 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class WindowExtensionServerProxy : public IRemoteProxy<IWindowExtensionServer> {
|
||||
public:
|
||||
WindowExtensionServerProxy(const sptr<IRemoteObject> &impl)
|
||||
: IRemoteProxy<IWindowExtensionServer>(impl) {};
|
||||
~WindowExtensionServerProxy() {};
|
||||
void OnWindowReady(const std::shared_ptr<RSSurfaceNode>& surfaceNode) override;
|
||||
void OnBackPress() override;
|
||||
void OnKeyEvent(shared_ptr<IMM::KeyEvent>& keyEvent) override;
|
||||
void OnPointerEvent(shared_ptr<IMM::PointerEvent>& pointerEvent) override;
|
||||
}
|
||||
void OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
|
||||
void OnPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // WINDOW_EXTESNION_SERVER_PROXY
|
||||
@@ -15,11 +15,14 @@
|
||||
|
||||
#include "window_extension_connection.h"
|
||||
|
||||
#include "ability_connect_callback_stub.h"
|
||||
#include "ability_manager_client.h"
|
||||
#include "element_name.h"
|
||||
#include <iremote_object.h>
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common.h"
|
||||
#include "window_extension_client_proxy.h"
|
||||
#include "window_extension_server_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@@ -27,14 +30,20 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowExtensionConnection"};
|
||||
}
|
||||
|
||||
class WindowExtensionClientRecipient
|
||||
: public IRemoteObject::DeathRecipient {
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote);
|
||||
};
|
||||
|
||||
|
||||
class WindowExtensionConnection::Impl
|
||||
: public AAFwk::AbilityConnectionStub, public RefBase {
|
||||
: public AAFwk::AbilityConnectionStub {
|
||||
public:
|
||||
Impl() = default;
|
||||
~Impl() = default;
|
||||
void WindowExtensionConnection::Impl::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
void OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode) override;
|
||||
void WindowExtensionConnection::Impl::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
|
||||
void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
|
||||
|
||||
void ConnectExtension(const AppExecFwk::ElementName &element, Rect rect,
|
||||
uint32_t uid, sptr<IWindowExtensionCallback>& callback);
|
||||
@@ -42,10 +51,15 @@ public:
|
||||
void Hide();
|
||||
void Resize(Rect rect);
|
||||
void RequestFocus();
|
||||
private:
|
||||
sptr<WindowExtensionServerStub> stub_;
|
||||
sptr<IWindowExtensionCallback> componentCallback_;
|
||||
sptr<WindowExtensionClientProxy> proxy_;
|
||||
sptr<WindowExtensionClientRecipient> deathRecipient_;
|
||||
};
|
||||
|
||||
WindowExtensionConnection::WindowExtensionConnection()
|
||||
:: pImpl_(new Impl())
|
||||
: pImpl_(new Impl())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -54,6 +68,7 @@ void WindowExtensionConnection::Impl::ConnectExtension(const AppExecFwk::Element
|
||||
{
|
||||
AAFwk::Want want;
|
||||
want.SetElement(element);
|
||||
// TODO
|
||||
// want.SetParam(RECT_FORM_KEY_POS_X, rect.posX_);
|
||||
// want.SetParam(RECT_FORM_KEY_POS_Y, rect.posY_);
|
||||
// want.SetParam(RECT_FORM_KEY_WIDTH, rect.width_);
|
||||
@@ -90,7 +105,7 @@ void WindowExtensionConnection::Impl::RequestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
void WindowExtensionConnection::Impp::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
void WindowExtensionConnection::Impl::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
if (!remoteObject) {
|
||||
@@ -125,22 +140,22 @@ void WindowExtensionConnection::Impl::OnAbilityDisconnectDone(const AppExecFwk::
|
||||
void WindowExtensionConnection::ConnectExtension(const AppExecFwk::ElementName &element, Rect rect,
|
||||
uint32_t uid, sptr<IWindowExtensionCallback>& callback)
|
||||
{
|
||||
impl_->ConnectExtension(element, rect, uid, callback);
|
||||
pImpl_->ConnectExtension(element, rect, uid, callback);
|
||||
}
|
||||
|
||||
void WindowExtensionConnection::Show()
|
||||
{
|
||||
impl_->Show();
|
||||
pImpl_->Show();
|
||||
}
|
||||
|
||||
void WindowExtensionConnection::Hide()
|
||||
{
|
||||
impl_->Hide();
|
||||
pImpl_->Hide();
|
||||
}
|
||||
|
||||
void WindowExtensionConnection::RequestFocus()
|
||||
{
|
||||
impl_->RequestFocus();
|
||||
pImpl_->RequestFocus();
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -28,14 +28,14 @@ void WindowExtensionServerProxy::OnWindowReady(const std::shared_ptr<RSSurfaceNo
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel replay;
|
||||
MessageParcel option;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("write token failed");
|
||||
retrun;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!surfaceNode.Marshalling(data)) {
|
||||
if (!surfaceNode->Marshalling(data)) {
|
||||
WLOGFE("write surfaceNode failed");
|
||||
return;
|
||||
}
|
||||
@@ -44,10 +44,10 @@ void WindowExtensionServerProxy::OnWindowReady(const std::shared_ptr<RSSurfaceNo
|
||||
}
|
||||
}
|
||||
|
||||
void WindowExtensionClientProxy::OnBackPress()
|
||||
void WindowExtensionServerProxy::OnBackPress()
|
||||
{
|
||||
MessageParcel data;
|
||||
MeeeageParcel replay;
|
||||
MessageParcel replay;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
@@ -59,10 +59,10 @@ void WindowExtensionClientProxy::OnBackPress()
|
||||
}
|
||||
}
|
||||
|
||||
void WindowExtensionClientProxy::OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
void WindowExtensionServerProxy::OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
MessageParcel message;
|
||||
MeeeageParcel message;
|
||||
MessageParcel data;
|
||||
MessageParcel replay;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
@@ -70,10 +70,10 @@ void WindowExtensionClientProxy::OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyE
|
||||
return;
|
||||
}
|
||||
|
||||
if (!keyEvent.Marshalling(data)) {
|
||||
WLOGFE("write key event failed");
|
||||
return;
|
||||
}
|
||||
// if (!keyEvent->Marshalling(data)) {
|
||||
// WLOGFE("write key event failed");
|
||||
// return;
|
||||
// }
|
||||
if (Remote()->SendRequest(TRANS_ID_ON_KEY_EVENT, data, replay, option) != ERR_NONE) {
|
||||
WLOGFE("send request failed");
|
||||
}
|
||||
@@ -81,8 +81,8 @@ void WindowExtensionClientProxy::OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyE
|
||||
|
||||
void WindowExtensionServerProxy::OnPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
MessageParcel message;
|
||||
MeeeageParcel message;
|
||||
MessageParcel data;
|
||||
MessageParcel replay;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
@@ -90,10 +90,10 @@ void WindowExtensionServerProxy::OnPointerEvent(std::shared_ptr<MMI::PointerEven
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pointerEvent.Marshalling(data)) {
|
||||
WLOGFE("write key event failed");
|
||||
return;
|
||||
}
|
||||
// if (!pointerEvent->Marshalling(data)) {
|
||||
// WLOGFE("write key event failed");
|
||||
// return;
|
||||
// }
|
||||
if (Remote()->SendRequest(TRANS_ID_ON_POINTER_EVENT, data, replay, option) != ERR_NONE) {
|
||||
WLOGFE("send request failed");
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ int WindowExtensionServerStub::OnRemoteRequest(uint32_t code, MessageParcel &dat
|
||||
break;
|
||||
}
|
||||
}
|
||||
retrun 0;
|
||||
return 0;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -29,6 +29,13 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
const static std::string RECT_FORM_KEY_POS_X = "ext_pos_x";
|
||||
const static std::string RECT_FORM_KEY_POS_Y = "ext_pos_y";
|
||||
const static std::string RECT_FORM_KEY_HEIGHT = "ext_pos_heigh";
|
||||
const static std::string RECT_FORM_KEY_WIDTH = "ext_pos_width";
|
||||
}
|
||||
|
||||
class RSSurfaceNode;
|
||||
class IWindowExtensionCallback : virtual public RefBase {
|
||||
public:
|
||||
@@ -41,13 +48,13 @@ public:
|
||||
|
||||
class WindowExtensionConnection : public RefBase {
|
||||
public:
|
||||
WindowExtensionConnection() = default;
|
||||
WindowExtensionConnection();
|
||||
~WindowExtensionConnection() = default;
|
||||
virtual void ConnectExtension(const AppExecFwk::ElementName &element, Rect rect,
|
||||
uint32_t uid, sptr<IWindowExtensionCallback>& callback) = 0;
|
||||
virtual void Show() = 0;
|
||||
virtual void Hide() = 0;
|
||||
virtual void RequestFocus() = 0;
|
||||
void ConnectExtension(const AppExecFwk::ElementName &element, Rect rect,
|
||||
uint32_t uid, sptr<IWindowExtensionCallback>& callback);
|
||||
void Show();
|
||||
void Hide();
|
||||
void RequestFocus();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
||||
Reference in New Issue
Block a user