[Wayland] zwp_text_input_v3::delete_surrounding_text() does not delete expected text
Categories
(Core :: Widget: Gtk, defect, P3)
Tracking
()
People
(Reporter: sebastian-keller, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0
Steps to reproduce:
Use a Wayland compositor that implements the zwp_text_input_v3 protocol and uses delete_surrounding_text() to delete text. For example this could be gnome-shell >= 43 using the OSK backspace key. (On non-touch systems the OSK can be enabled in the accessibility settings under "typing").
Open a website with a text input with the text "test" and make sure it is focused with the text cursor is all the way to the right. Then press the backspace key on the OSK a couple of times.
Actual results:
From running Firefox with WAYLAND_DEBUG=1:
When selecting the input Firefox sends:
set_surrounding_text("test", 4, 4)
This means the current text is "test" and the cursor is placed at the end with no selection. So far this correct.
When pressing backspace on the OSK, gnome-shell sends:
delete_surrounding_text(1, 0)
This means that 1 character before the cursor should be deleted.
After this Firefox sends:
set_surrounding_text("test", 4, 4)
In the browser it leaves the text as "test", but selects the last "t". It did not delete the character and the selection is not reflected in the message either.
Pressing backspace again gnome-shell sends:
delete_surrounding_text(1, 0)
After this Firefox sends:
set_surrounding_text("test", 3, 3)
This means that the text is still "test" with the cursor placed between "s" and "t" and there being no selection, but in the browser the text has been changed to "tet" (with nothing selected).
Expected results:
After the first delete_surrounding_text(1, 0), Firefox should have changed the text to "tes" and responded with a set_surrounding_text("tes", 3, 3) and at no point any text should have been selected.
Additional information:
Something that might be relevant to this is that gtk3 does not support specifying a anchor due to API constraints, so the anchor position will always be set to the the cursor position, meaning selections are not properly reflected in zwp_text_input_v3.
Also currently gnome-shell does not consider the currently selected text and always sends delete_surrounding_text(1, 0) when pressing backspace. This should not be relevant here though, because this should not cause any selections and even the selections visible in the browser due to the bug are not reflected in the protocol, because cursor == anchor. But it might be something you encounter when trying to debug this.
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 years ago
|
||
I think that may come from Gtk3 code. I don't think Firefox uses zwp_text_input_v3 directly.
Reporter | ||
Comment 3•2 years ago
|
||
It works in regular gtk3 programs, at least for deleting single characters. I think it is more related to the way Firefox uses the gtk3 API for selections and deletions in IMContextWrapper.cpp, perhaps in combination with some of the limitations of gtk3 I mentioned.
Comment 4•1 year ago
|
||
I enabled IMEHandler logging and here are my observations:
Typing a key (here 'h'real keyboard) results in:
[Parent 6096: Main Thread]: I/IMEHandler >>>>>>>>>>>>>>>>
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(aCaller=0x7f49f20f9f00, aEvent(0x7f49dc8bd340): { type=GDK_KEY_PRESS, keyval=h, unicode=0x68, state=, time=1271646, hardware_keycode=43, group=0 }, aKeyboardEventWasDispatched=false)
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), mMaybeInDeadKeySequence=false, mCompositionState=NotComposing, current context=7f49f1bad250, active context=7f49f1bad250, mIMContextID=Wayland, mIsIMInAsyncKeyHandlingMode=false
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 SetCursorPosition(aContext=0x7f49f1bad250), mCompositionTargetRange={ mOffset=4294967295, mLength=4294967295 }, mContentSelection={ HasRange()=false }
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnCommitCompositionNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250, active context=0x7f49f1bad250, commitString="h", mProcessingKeyEvent=0x7f49dc8bd340, IsComposingOn(aContext)=false
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnCommitCompositionNative(), we'll send normal key event
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=0, selLength=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=, aText.Length()=0, aCursorPos=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), succeeded, filterThisEvent=false (isFiltered=true, mFallbackToKeyEvent=true, probablyHandledAsynchronously=false, maybeHandledAsynchronously=false), mPostingKeyEvents.Length()=0, mCompositionState=NotComposing, mMaybeInDeadKeySequence=false, mKeyboardEventWasDispatched=false, mKeyboardEventWasConsumed=false
[Parent 6096: Main Thread]: I/IMEHandler <<<<<<<<<<<<<<<<
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=1, mString="" (Length()=0), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=false, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=true, isSelectionRangeChanged=true
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 ResetIME(), mCompositionState=NotComposing, mIMEFocusState=IMEFocusState::Focused
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=1, selLength=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=h, aText.Length()=1, aCursorPos=1
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCompositionString(aContext=0x7f49f1bad250), aCompositionString=""
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 ResetIME() called gtk_im_context_reset(), activeContext=0x7f49f1bad250, mCompositionState=NotComposing, compositionString=, mIMEFocusState=IMEFocusState::Focused
[Parent 6096: Main Thread]: I/IMEHandler >>>>>>>>>>>>>>>>
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(aCaller=0x7f49f20f9f00, aEvent(0x7f49df1b3660): { type=GDK_KEY_RELEASE, keyval=h, unicode=0x68, state=, time=1271722, hardware_keycode=43, group=0 }, aKeyboardEventWasDispatched=false)
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), mMaybeInDeadKeySequence=false, mCompositionState=NotComposing, current context=7f49f1bad250, active context=7f49f1bad250, mIMContextID=Wayland, mIsIMInAsyncKeyHandlingMode=false
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 SetCursorPosition(aContext=0x7f49f1bad250), mCompositionTargetRange={ mOffset=4294967295, mLength=4294967295 }, mContentSelection={ HasRange()=false }
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), succeeded, filterThisEvent=false (isFiltered=false, mFallbackToKeyEvent=false, probablyHandledAsynchronously=false, maybeHandledAsynchronously=false), mPostingKeyEvents.Length()=0, mCompositionState=NotComposing, mMaybeInDeadKeySequence=false, mKeyboardEventWasDispatched=false, mKeyboardEventWasConsumed=false
[Parent 6096: Main Thread]: I/IMEHandler <<<<<<<<<<<<<<<<
The Backspace key (still using the USB keyboard) results in:
[Parent 6096: Main Thread]: I/IMEHandler >>>>>>>>>>>>>>>>
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(aCaller=0x7f49f20f9f00, aEvent(0x7f49e0a47740): { type=GDK_KEY_PRESS, keyval=BackSpace, unicode=0x8, state=, time=1273728, hardware_keycode=22, group=0 }, aKeyboardEventWasDispatched=false)
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), mMaybeInDeadKeySequence=false, mCompositionState=NotComposing, current context=7f49f1bad250, active context=7f49f1bad250, mIMContextID=Wayland, mIsIMInAsyncKeyHandlingMode=false
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), succeeded, filterThisEvent=false (isFiltered=false, mFallbackToKeyEvent=false, probablyHandledAsynchronously=false, maybeHandledAsynchronously=false), mPostingKeyEvents.Length()=0, mCompositionState=NotComposing, mMaybeInDeadKeySequence=false, mKeyboardEventWasDispatched=false, mKeyboardEventWasConsumed=false
[Parent 6096: Main Thread]: I/IMEHandler <<<<<<<<<<<<<<<<
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=3, mString="" (Length()=0), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=false, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=true, isSelectionRangeChanged=true
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 ResetIME(), mCompositionState=NotComposing, mIMEFocusState=IMEFocusState::Focused
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=3, selLength=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=hel, aText.Length()=3, aCursorPos=3
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCompositionString(aContext=0x7f49f1bad250), aCompositionString=""
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 ResetIME() called gtk_im_context_reset(), activeContext=0x7f49f1bad250, mCompositionState=NotComposing, compositionString=, mIMEFocusState=IMEFocusState::Focused
[Parent 6096: Main Thread]: I/IMEHandler >>>>>>>>>>>>>>>>
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(aCaller=0x7f49f20f9f00, aEvent(0x7f49df07a600): { type=GDK_KEY_RELEASE, keyval=BackSpace, unicode=0x8, state=, time=1273784, hardware_keycode=22, group=0 }, aKeyboardEventWasDispatched=false)
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), mMaybeInDeadKeySequence=false, mCompositionState=NotComposing, current context=7f49f1bad250, active context=7f49f1bad250, mIMContextID=Wayland, mIsIMInAsyncKeyHandlingMode=false
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 SetCursorPosition(aContext=0x7f49f1bad250), mCompositionTargetRange={ mOffset=4294967295, mLength=4294967295 }, mContentSelection={ HasRange()=false }
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), succeeded, filterThisEvent=false (isFiltered=false, mFallbackToKeyEvent=false, probablyHandledAsynchronously=false, maybeHandledAsynchronously=false), mPostingKeyEvents.Length()=0, mCompositionState=NotComposing, mMaybeInDeadKeySequence=false, mKeyboardEventWasDispatched=false, mKeyboardEventWasConsumed=false
[Parent 6096: Main Thread]: I/IMEHandler <<<<<<<<<<<<<<<<
Now, the same 'h' key but with the Gnome OSK looks like it triggers a similar outcome:
[Parent 6096: Main Thread]: I/IMEHandler >>>>>>>>>>>>>>>>
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(aCaller=0x7f49f20f9f00, aEvent(0x7f49df079c00): { type=GDK_KEY_PRESS, keyval=h, unicode=0x68, state=, time=1336541, hardware_keycode=43, group=0 }, aKeyboardEventWasDispatched=false)
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), mMaybeInDeadKeySequence=false, mCompositionState=NotComposing, current context=7f49f1bad250, active context=7f49f1bad250, mIMContextID=Wayland, mIsIMInAsyncKeyHandlingMode=false
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 SetCursorPosition(aContext=0x7f49f1bad250), mCompositionTargetRange={ mOffset=4294967295, mLength=4294967295 }, mContentSelection={ HasRange()=false }
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnCommitCompositionNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250, active context=0x7f49f1bad250, commitString="h", mProcessingKeyEvent=0x7f49df079c00, IsComposingOn(aContext)=false
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnCommitCompositionNative(), we'll send normal key event
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=0, selLength=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=, aText.Length()=0, aCursorPos=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), succeeded, filterThisEvent=false (isFiltered=true, mFallbackToKeyEvent=true, probablyHandledAsynchronously=false, maybeHandledAsynchronously=false), mPostingKeyEvents.Length()=0, mCompositionState=NotComposing, mMaybeInDeadKeySequence=false, mKeyboardEventWasDispatched=false, mKeyboardEventWasConsumed=false
[Parent 6096: Main Thread]: I/IMEHandler <<<<<<<<<<<<<<<<
[Parent 6096: Main Thread]: I/IMEHandler >>>>>>>>>>>>>>>>
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(aCaller=0x7f49f20f9f00, aEvent(0x7f49df1b3ac0): { type=GDK_KEY_RELEASE, keyval=h, unicode=0x68, state=, time=1336541, hardware_keycode=43, group=0 }, aKeyboardEventWasDispatched=false)
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), mMaybeInDeadKeySequence=false, mCompositionState=NotComposing, current context=7f49f1bad250, active context=7f49f1bad250, mIMContextID=Wayland, mIsIMInAsyncKeyHandlingMode=false
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 OnKeyEvent(), succeeded, filterThisEvent=false (isFiltered=false, mFallbackToKeyEvent=false, probablyHandledAsynchronously=false, maybeHandledAsynchronously=false), mPostingKeyEvents.Length()=0, mCompositionState=NotComposing, mMaybeInDeadKeySequence=false, mKeyboardEventWasDispatched=false, mKeyboardEventWasConsumed=false
[Parent 6096: Main Thread]: I/IMEHandler <<<<<<<<<<<<<<<<
However backspace with the Gnome OSK is quite different. In this case, the field contains "hello", the cursor is after the last "o", so backspace should just delete that "o". What happens is that instead it "selects" that o and doesn't delete anything:
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnDeleteSurroundingNative(aContext=0x7f49f1bad250, aOffset=-1, aNChar=1), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 DeleteText(aContext=0x7f49f1bad250, aOffset=-1, aNChars=1), mCompositionState=NotComposing
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(aFollowingEvent=eContentCommandDelete), dispatch fake eKeyDown event
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(), fake keydown event is dispatched
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=5, selLength=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=hello, aText.Length()=5, aCursorPos=5
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=4, mString="o" (Length()=1), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=true, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=true, isSelectionRangeChanged=true
Now we have "hello" with "o" selected (inverted). Another backspace results in the "l" before that "o" being deleted, so we end up with the string "helo", no selection, and the cursor sitting between "l" and "o":
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnDeleteSurroundingNative(aContext=0x7f49f1bad250, aOffset=-1, aNChar=1), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 DeleteText(aContext=0x7f49f1bad250, aOffset=-1, aNChars=1), mCompositionState=NotComposing
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(aFollowingEvent=eContentCommandDelete), dispatch fake eKeyDown event
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(), fake keydown event is dispatched
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=4, selLength=1
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=hello, aText.Length()=5, aCursorPos=4
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=3, mString="l" (Length()=1), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=true, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=true, isSelectionRangeChanged=true
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=3, mString="" (Length()=0), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=false, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=false, isSelectionRangeChanged=true
Another backspace this time selects that "l", so we have "helo" with "l" selected:
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnDeleteSurroundingNative(aContext=0x7f49f1bad250, aOffset=-1, aNChar=1), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 DeleteText(aContext=0x7f49f1bad250, aOffset=-1, aNChars=1), mCompositionState=NotComposing
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(aFollowingEvent=eContentCommandDelete), dispatch fake eKeyDown event
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(), fake keydown event is dispatched
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=3, selLength=0
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=helo, aText.Length()=4, aCursorPos=3
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=2, mString="l" (Length()=1), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=true, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=true, isSelectionRangeChanged=true
Another backspace now deletes the "e", we now have "hlo" with the cursor sitting between "h" and "l":
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnDeleteSurroundingNative(aContext=0x7f49f1bad250, aOffset=-1, aNChar=1), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 DeleteText(aContext=0x7f49f1bad250, aOffset=-1, aNChars=1), mCompositionState=NotComposing
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(aFollowingEvent=eContentCommandDelete), dispatch fake eKeyDown event
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 MaybeDispatchKeyEventAsProcessedByIME(), fake keydown event is dispatched
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnRetrieveSurroundingNative(aContext=0x7f49f1bad250), current context=0x7f49f1bad250
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), mCompositionState=NotComposing
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), selOffset=2, selLength=1
[Parent 6096: Main Thread]: D/IMEHandler 0x7f49fd3171b0 GetCurrentParagraph(), succeeded, aText=helo, aText.Length()=4, aCursorPos=2
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=1, mString="e" (Length()=1), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=true, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=true, isSelectionRangeChanged=true
[Parent 6096: Main Thread]: I/IMEHandler 0x7f49fd3171b0 OnSelectionChange(aCaller=0x7f49f20f9f00, aIMENotification={ mSelectionChangeData={ mOffset=1, mString="" (Length()=0), GetWritingMode()=h-ltr, mReversed=false, mCausedByComposition=false, mCausedBySelectionEvent=false, mOccurredDuringComposition=false } }), mCompositionState=NotComposing, mIsDeletingSurrounding=false, mRetrieveSurroundingSignalReceived=false, isSelectionRangeChanged=true
Etc...
I am out of time today and will be travelling for the next couple of weeks, but I intend to try to get to the bottom of this. I will let you guys have a look in case you find something, otherwise at some point I will dive into the code of IMContextWrapper.cpp
and try to find out what's going on. Keep in mind that I know nothing about Firefox internal and general structure nor gtk3, so any advice/hints will safe a tremendous amount of time, esp considering how long it takes to rebuild Firefox :-)
Comment 5•1 year ago
|
||
Note: Those logs were obtained with Firefox 127.0 on Fedora 40. The reproduction is fairly easy, install f40, enable the OSK (Accessibility -> Screen Keyboard) and type in Firefox in a web page field (works fine in the URL bar at the top of the window)
Comment 6•1 year ago
|
||
I also noticed that if I select a bunch of test and press the OSK backspace, I still only get a OnDeleteSurrounding
callback with aOffset=-1
and aNChar=1`.
Reporter | ||
Comment 7•1 year ago
|
||
That's what I mentioned in "Additional Information". Though since filing this gnome-shell gained support for correctly deleting selections in 46, but that's not too relevant here, because Firefox is still not able to tell it what text is selected due to the limitation in the gtk3 API used (this only works in gtk4 which is able to distinguish cursor and anchor). This however should not affect the case of simply pressing backspace without a selection, which is what seems to be broken on the Firefox side.
Comment 8•1 year ago
|
||
Yes, I think it is. Is there any legitimate case for OnDeleteSurrounding
being called with anything other than aOffset=-1
and `aNChar=`` ? From what you say, I don't think so with gtk3... which makes it tempting to remove the entire fairly large implementation and just synthetize Backspace keystrokes... I will try playing around more this week
Reporter | ||
Comment 9•1 year ago
|
||
When holding down the backspace key in the gnome-shell OSK it starts deleting entire words after a while.
Updated•1 year ago
|
Comment 10•1 year ago
|
||
Is there any possibility of a temporary workaround? To disable OnDeleteSurrounding?
Comment 11•1 year ago
|
||
The code lives here if anyone wants to work on it:
https://searchfox.org/mozilla-central/rev/54a5c4f14f3eb514a29e0cebcb5a095144bcd450/widget/gtk/IMContextWrapper.cpp#441
Comment 12•1 year ago
|
||
Adding Gtk4 tracker (Bug 1701123) to keep list of bugs which may be potentially fixed by moving to Gtk4.
Comment 13•1 year ago
|
||
Looks like zwp_text_input_manager_v3 is available via. Wayland registry so we may use it directly as we're going to do for touchpad hold events.
[ 439583.755] {Default Queue} wl_registry#30.global(25, "zwp_text_input_manager_v3", 1)
[ 439583.766] {Default Queue} -> wl_registry#30.bind(25, "zwp_text_input_manager_v3", 1, new id [unknown]#42)
[ 439583.778] {Default Queue} -> zwp_text_input_manager_v3#42.get_text_input(new id zwp_text_input_v3#43, wl_seat#21)
Comment 14•11 months ago
|
||
It's a bug in Firefox IM code, not related to Wayland itself which works correcly - Bug 1863611.
Description
•