Skip to content

Commit 9d7d9be

Browse files
committed
have only the input handler manager free the handle
1 parent 667ec1b commit 9d7d9be

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/wayland/input_method/input_method.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <wayland-input-method-unstable-v2-client-protocol.h>
55

66
#include "keyboard_grab.hpp"
7+
#include "manager.hpp"
78

89
namespace qs::wayland::input_method::impl {
910

@@ -59,7 +60,7 @@ void InputMethodHandle::zwp_input_method_v2_done() {
5960
void InputMethodHandle::zwp_input_method_v2_unavailable() {
6061
if (!this->mAvailable) return;
6162
this->mAvailable = false;
62-
deleteLater();
63+
InputMethodManager::instance()->releaseInput();
6364
qDebug()
6465
<< "Compositor denied input method request, likely due to one already existing elsewhere";
6566
}

src/wayland/input_method/manager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ wl_seat* getSeat() {
2525
} // namespace
2626

2727
QPointer<InputMethodHandle> InputMethodManager::acquireInput() {
28-
if (inputMethod && inputMethod->isAvailable()) return inputMethod;
28+
if (this->inputMethod && this->inputMethod->isAvailable()) return this->inputMethod;
2929

30-
inputMethod = new InputMethodHandle(this, get_input_method(getSeat()));
30+
this->inputMethod = new InputMethodHandle(this, get_input_method(getSeat()));
3131

32-
return inputMethod;
32+
return this->inputMethod;
33+
}
34+
35+
void InputMethodManager::releaseInput() {
36+
this->inputMethod->deleteLater();
37+
this->inputMethod = nullptr;
3338
}
3439

3540
VirtualKeyboardManager::VirtualKeyboardManager(): QWaylandClientExtensionTemplate(1) {

src/wayland/input_method/manager.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ class InputMethodManager
2424
static InputMethodManager* instance();
2525

2626
QPointer<InputMethodHandle> acquireInput();
27+
void releaseInput();
2728

2829
private:
2930
InputMethodManager();
30-
QPointer<InputMethodHandle> inputMethod = nullptr;
31+
InputMethodHandle* inputMethod = nullptr;
3132
};
3233

3334
class VirtualKeyboardHandle;

src/wayland/input_method/qml.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ void InputMethod::getInput() {
8080

8181
void InputMethod::releaseInput() {
8282
if (!this->handle) return;
83-
this->handle->deleteLater();
84-
this->handle = nullptr;
83+
InputMethodManager::instance()->releaseInput();
8584
emit hasInputChanged();
8685
}
8786

0 commit comments

Comments
 (0)