diff --git a/wayland/input/pointer.cc b/wayland/input/pointer.cc index cfae28ac..908a4724 100644 --- a/wayland/input/pointer.cc +++ b/wayland/input/pointer.cc @@ -17,11 +17,14 @@ namespace ozonewayland { WaylandPointer::WaylandPointer() : cursor_(NULL), dispatcher_(NULL), - pointer_position_(0, 0) { + pointer_position_(0, 0), + input_pointer_(NULL) { } WaylandPointer::~WaylandPointer() { delete cursor_; + if (input_pointer_) + wl_pointer_destroy(input_pointer_); } void WaylandPointer::OnSeatCapabilities(wl_seat *seat, uint32_t caps) { @@ -39,10 +42,10 @@ void WaylandPointer::OnSeatCapabilities(wl_seat *seat, uint32_t caps) { dispatcher_ = ui::EventFactoryOzoneWayland::GetInstance()->EventConverter(); if ((caps & WL_SEAT_CAPABILITY_POINTER) && !cursor_->GetInputPointer()) { - wl_pointer* input_pointer = wl_seat_get_pointer(seat); - cursor_->SetInputPointer(input_pointer); - wl_pointer_set_user_data(input_pointer, this); - wl_pointer_add_listener(input_pointer, &kInputPointerListener, this); + input_pointer_ = wl_seat_get_pointer(seat); + cursor_->SetInputPointer(input_pointer_); + wl_pointer_set_user_data(input_pointer_, this); + wl_pointer_add_listener(input_pointer_, &kInputPointerListener, this); } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && cursor_->GetInputPointer()) { cursor_->SetInputPointer(NULL); diff --git a/wayland/input/pointer.h b/wayland/input/pointer.h index a7d31e5b..e8d5ec30 100644 --- a/wayland/input/pointer.h +++ b/wayland/input/pointer.h @@ -68,6 +68,7 @@ class WaylandPointer { // dispatch this with events such as wheel or button which don't have a // position associated on Wayland. gfx::Point pointer_position_; + struct wl_pointer *input_pointer_; DISALLOW_COPY_AND_ASSIGN(WaylandPointer); };