| 
5 | 5 | #include <qlogging.h>  | 
6 | 6 | #include <qobject.h>  | 
7 | 7 | #include <qpointer.h>  | 
 | 8 | +#include <qstring.h>  | 
8 | 9 | #include <qtmetamacros.h>  | 
9 | 10 | #include <qwayland-input-method-unstable-v2.h>  | 
10 | 11 | #include <wayland-input-method-unstable-v2-client-protocol.h>  | 
@@ -53,32 +54,69 @@ void InputMethodHandle::releaseKeyboard() {  | 
53 | 54 | bool InputMethodHandle::isActive() const { return this->mState.activated; }  | 
54 | 55 | bool InputMethodHandle::isAvailable() const { return this->mAvailable; }  | 
55 | 56 | 
 
  | 
 | 57 | +const QString& InputMethodHandle::surroundingText() const {  | 
 | 58 | +	return this->mState.surroundingText.text;  | 
 | 59 | +}  | 
 | 60 | +uint32_t InputMethodHandle::surroundingTextCursor() const {  | 
 | 61 | +	return this->mState.surroundingText.cursor;  | 
 | 62 | +}  | 
 | 63 | +uint32_t InputMethodHandle::surroundingTextAnchor() const {  | 
 | 64 | +	return this->mState.surroundingText.anchor;  | 
 | 65 | +}  | 
 | 66 | + | 
 | 67 | +ContentHint InputMethodHandle::contentHint() const {  | 
 | 68 | +	return this->mState.contentHint;  | 
 | 69 | +}  | 
 | 70 | +ContentPurpose InputMethodHandle::contentPurpose() const {  | 
 | 71 | +	return this->mState.contentPurpose;  | 
 | 72 | +}  | 
 | 73 | + | 
56 | 74 | void InputMethodHandle::zwp_input_method_v2_activate() { this->mNewState.activated = true; }  | 
57 | 75 | 
 
  | 
58 | 76 | void InputMethodHandle::zwp_input_method_v2_deactivate() { this->mNewState.activated = false; }  | 
59 | 77 | 
 
  | 
 | 78 | +void InputMethodHandle::zwp_input_method_v2_surrounding_text(  | 
 | 79 | +    const QString& text,  | 
 | 80 | +    uint32_t cursor,  | 
 | 81 | +    uint32_t anchor  | 
 | 82 | +) {  | 
 | 83 | +	this->mNewState.surroundingText.text = text;  | 
 | 84 | +	this->mNewState.surroundingText.cursor = cursor;  | 
 | 85 | +	this->mNewState.surroundingText.anchor = anchor;  | 
 | 86 | +}  | 
 | 87 | + | 
 | 88 | +void InputMethodHandle::zwp_input_method_v2_text_change_cause(uint32_t cause) {  | 
 | 89 | +	this->mNewState.surroundingText.textChangeCause = static_cast<TextChangeCause>(cause);  | 
 | 90 | +}  | 
60 | 91 | 
 
  | 
61 | 92 | void InputMethodHandle::zwp_input_method_v2_content_type(uint32_t hint, uint32_t purpose) {  | 
62 | 93 | 	this->mNewState.contentHint = static_cast<ContentHint>(hint);  | 
63 | 94 | 	this->mNewState.contentPurpose = static_cast<ContentPurpose>(purpose);  | 
64 | 95 | };  | 
65 | 96 | 
 
  | 
66 | 97 | void InputMethodHandle::zwp_input_method_v2_done() {  | 
67 |  | -	if (this->mState.activated != this->mNewState.activated){  | 
 | 98 | +	auto oldState= mState;  | 
 | 99 | +	this->mState = this->mNewState;  | 
 | 100 | + | 
 | 101 | + | 
 | 102 | +	if (this->mState.activated != oldState.activated) {  | 
68 | 103 | 		if (this->mNewState.activated) emit activated();  | 
69 | 104 | 		else emit deactivated();  | 
70 | 105 | 	}  | 
71 | 106 | 
 
  | 
72 |  | -	if (this->mState.contentHint != this->mNewState.contentHint){  | 
73 |  | -		emit contentHintChanged(this->mNewState.contentHint);  | 
 | 107 | +	if (this->mState.surroundingText != oldState.surroundingText) {  | 
 | 108 | +		emit surroundingTextChanged(  | 
 | 109 | +		    this->mNewState.surroundingText.textChangeCause  | 
 | 110 | +		);  | 
74 | 111 | 	}  | 
75 | 112 | 
 
  | 
76 |  | - | 
77 |  | -	if (this->mState.contentPurpose != this->mNewState.contentPurpose){  | 
78 |  | -		emit contentPurposeChanged(this->mNewState.contentPurpose);  | 
 | 113 | +	if (this->mState.contentHint != oldState.contentHint) {  | 
 | 114 | +		emit contentHintChanged();  | 
79 | 115 | 	}  | 
80 | 116 | 
 
  | 
81 |  | -	this->mState = this->mNewState;  | 
 | 117 | +	if (this->mState.contentPurpose != oldState.contentPurpose) {  | 
 | 118 | +		emit contentPurposeChanged();  | 
 | 119 | +	}  | 
82 | 120 | }  | 
83 | 121 | 
 
  | 
84 | 122 | void InputMethodHandle::zwp_input_method_v2_unavailable() {  | 
 | 
0 commit comments