fix some bugs

Change-Id: I0ff730c9d0252aa10210581c9f93b690152bedc6
Signed-off-by: luwh0708 <1632083718@qq.com>
This commit is contained in:
luwh0708 2021-08-11 17:57:40 +08:00
parent d358d8aa4d
commit 5d84ae9611
4 changed files with 15 additions and 13 deletions

View File

@ -115,7 +115,6 @@ private:
sptr<WlSurface> wlSurface = nullptr;
sptr<Surface> csurface = nullptr;
sptr<Surface> psurface = nullptr;
sptr<WindowOption> testParam = nullptr;
sptr<InputListener> logListener = nullptr;
sptr<MultimodalListener> mmiListener = nullptr;

View File

@ -16,6 +16,8 @@
#ifndef FRAMEWORKS_WM_INCLUDE_WL_BUFFER_H
#define FRAMEWORKS_WM_INCLUDE_WL_BUFFER_H
#include <map>
#include <refbase.h>
#include <wayland-client-protocol.h>
@ -34,6 +36,10 @@ public:
protected:
struct wl_buffer *buffer = nullptr;
WlBufferReleaseFunc onRelease = nullptr;
private:
static void Release(void *, struct wl_buffer *buffer);
static inline std::map<struct wl_buffer *, WlBufferReleaseFunc> onReleaseFuncs;
};
} // namespace OHOS

View File

@ -157,7 +157,6 @@ WMError WindowImpl::Create(sptr<Window> &window,
return wret;
}
wi->testParam = WindowOption::Get();
wi->logListener = SingletonContainer::Get<LogListener>()->AddListener(wi.GetRefPtr());
wi->mmiListener = SingletonContainer::Get<MultimodalListenerManager>()->AddListener(wi.GetRefPtr());
wi->exportListener = SingletonContainer::Get<InputListenerManager>()->AddListener(wi.GetRefPtr());
@ -226,6 +225,7 @@ sptr<Promise<WMError>> WindowImpl::SetWindowType(WindowType type)
{
WMLOGFI("(%{public}d)type: %{public}d", attr.GetID(), type);
CHECK_DESTROY(new Promise<WMError>(WM_ERROR_DESTROYED_OBJECT));
static sptr<WindowOption> testParam = WindowOption::Get();
if (testParam->SetWindowType(type) != WM_OK) {
return new Promise<WMError>(WM_ERROR_INVALID_PARAM);
}
@ -240,6 +240,7 @@ sptr<Promise<WMError>> WindowImpl::SetWindowMode(WindowMode mode)
{
WMLOGFI("(%{public}d)mode: %{public}d", attr.GetID(), mode);
CHECK_DESTROY(new Promise<WMError>(WM_ERROR_DESTROYED_OBJECT));
static sptr<WindowOption> testParam = WindowOption::Get();
if (testParam->SetWindowMode(mode) != WM_OK) {
return new Promise<WMError>(WM_ERROR_INVALID_PARAM);
}
@ -251,6 +252,7 @@ sptr<Promise<WMError>> WindowImpl::Resize(uint32_t width, uint32_t height)
{
WMLOGFI("(%{public}d)%{public}u x %{public}u", attr.GetID(), width, height);
CHECK_DESTROY(new Promise<WMError>(WM_ERROR_DESTROYED_OBJECT));
static sptr<WindowOption> testParam = WindowOption::Get();
if (testParam->SetWidth(width) != WM_OK || testParam->SetHeight(height) != WM_OK) {
return new Promise<WMError>(WM_ERROR_INVALID_PARAM);
}

View File

@ -15,30 +15,25 @@
#include "wl_buffer.h"
#include <map>
#include "window_manager_hilog.h"
namespace OHOS {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "WMWlBuffer" };
std::map<struct wl_buffer *, WlBufferReleaseFunc> g_onReleaseFuncs;
} // namespace
namespace {
void Release(void *, struct wl_buffer *buffer)
void WlBuffer::Release(void *, struct wl_buffer *buffer)
{
if (g_onReleaseFuncs.find(buffer) != g_onReleaseFuncs.end()) {
g_onReleaseFuncs[buffer](buffer);
if (onReleaseFuncs.find(buffer) != onReleaseFuncs.end()) {
onReleaseFuncs[buffer](buffer);
}
}
} // namespace
WlBuffer::WlBuffer(struct wl_buffer *buffer)
{
this->buffer = buffer;
if (buffer != nullptr) {
const struct wl_buffer_listener listener = { Release };
const struct wl_buffer_listener listener = { WlBuffer::Release };
if (wl_buffer_add_listener(buffer, &listener, nullptr) == -1) {
WMLOGFW("wl_buffer_add_listener failed");
}
@ -49,7 +44,7 @@ WlBuffer::~WlBuffer()
{
if (buffer != nullptr) {
wl_buffer_destroy(buffer);
g_onReleaseFuncs.erase(buffer);
onReleaseFuncs.erase(buffer);
}
}
@ -61,6 +56,6 @@ struct wl_buffer *WlBuffer::GetRawPtr() const
void WlBuffer::OnRelease(WlBufferReleaseFunc func)
{
onRelease = func;
g_onReleaseFuncs[buffer] = onRelease;
onReleaseFuncs[buffer] = onRelease;
}
} // namespace OHOS