Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ const (
IBspellCheckWithRules
IBspellCheckWithDicts
IBautoCommitWithDelay
IBautoCommitWithMouseMovement
_IBemojiDisabled //deprecated
_IBautoCommitWithMouseMovement //deprecated
_IBemojiDisabled //deprecated
IBpreeditElimination
_IBinputModeLookupTableEnabled //deprecated
IBautoCapitalizeMacro
_IBimQuickSwitchEnabled //deprecated
_IBrestoreKeyStrokesEnabled //deprecated
IBmouseCapturing
_IBmouseCapturing //deprecated
IBworkaroundForFBMessenger
IBworkaroundForWPS
IBstdFlags = IBspellCheckEnabled | IBspellCheckWithRules | IBautoNonVnRestore | IBddFreeStyle |
IBmouseCapturing | IBautoCapitalizeMacro | IBnoUnderline | IBworkaroundForWPS
IBautoCapitalizeMacro | IBnoUnderline | IBworkaroundForWPS
IBUsStdFlags = 0
)
18 changes: 1 addition & 17 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ func (e *IBusBambooEngine) FocusIn() *dbus.Error {
if e.config.IBflags&config.IBspellCheckWithDicts != 0 && len(dictionary) == 0 {
dictionary, _ = loadDictionary(DictVietnameseCm)
}
if inStringList(disabledMouseCapturingList, e.getWmClass()) {
stopMouseCapturing()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm missing something, what exactly is the problem with mouse capturing? Could you send me a link to the relevant discussion? tks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On most modern desktop environments, they start replacing from X11 to Wayland. And you know, the mouse capturing in the code used xlib to capture mouse events and commit the text, this is pretty a bad idea as not only it doesn't work on Wayland but also causes some trouble like #487, I assume XWayland on GNOME Wayland is trying some way to get the permission to control the mouse by popping up that remote interaction dialog.

} else if e.config.IBflags&config.IBmouseCapturing != 0 {
startMouseCapturing()
}
fmt.Printf("WM_CLASS=(%s)\n", e.getWmClass())
return nil
}
Expand All @@ -141,7 +136,7 @@ func (e *IBusBambooEngine) FocusOut() *dbus.Error {
func (e *IBusBambooEngine) Reset() *dbus.Error {
fmt.Print("Reset.\n")
if e.checkInputMode(config.PreeditIM) {
e.commitPreeditAndReset(e.getPreeditString())
Copy link
Contributor

@luongthanhlam luongthanhlam Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when mouse capture is not active, and you're typing text in one location and then clicking elsewhere will commit any remaining buffered input at the new cursor position. That's annoying in x11.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd because my gnome wayland would automatically commit the text when i click my cursor elsewhere, even if the line e.commitPreeditAndReset(e.getPreeditString()) was removed. With that normal code before my PR, ibus-bamboo spams 2 duplicate words: one in the old location and one in the new location that mouse just clicked.

Did you mean this line is X11 only?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's designed to work on x11 only. What do you think if we disable this entirely on wayland, but still active for X11 users?

Copy link
Author

@hien-ngo29 hien-ngo29 Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well i'm not sure. I tried switching to an X11 desktop (GNOME 46 and Cinnamon) and the issue was the same as on Wayland. It duplicated two same words on two different cursor locations instead of "moved" the word from location A to location B like you said. Are you sure you are able reproduce the that x11 issue while mouse capture option is disabled?

I doubt that you're using an older ibus version so that problem persists (mine is 1.5.33 and 1.5.29-rc2). Not too sure.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been a week and you haven't had any response to this. What do you think about integrating both features and let users choose whether one they want in the configuration window? It might be that your linux setup was too outdated, we could integrate that feature for users who like to keep their machine stable and outdated. But i would say, i wouldn't like that, it's a dirty workaround. What do you think?

We can hold up this and discuss more if you want. But is it fine to merge the super-space fix on Wayland right now?

e.preeditor.Reset()
}
return nil
}
Expand Down Expand Up @@ -333,17 +328,6 @@ func (e *IBusBambooEngine) PropertyActivate(propName string, propState uint32) *
e.config.IBflags &= ^config.IBspellCheckWithDicts
}
}
if propName == PropKeyMouseCapturing {
if propState == ibus.PROP_STATE_CHECKED {
e.config.IBflags |= config.IBmouseCapturing
startMouseCapturing()
startMouseRecording()
} else {
e.config.IBflags &= ^config.IBmouseCapturing
stopMouseCapturing()
stopMouseRecording()
}
}
if propName == PropKeyMacroEnabled {
if propState == ibus.PROP_STATE_CHECKED {
e.config.IBflags |= config.IBmacroEnabled
Expand Down
5 changes: 0 additions & 5 deletions engine_preedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ func (e *IBusBambooEngine) expandMacro(str string) string {
}

func (e *IBusBambooEngine) updatePreedit(processedStr string) {
defer func() {
if e.config.IBflags&config.IBmouseCapturing != 0 {
mouseCaptureUnlock()
}
}()
var encodedStr = e.encodeText(processedStr)
var preeditLen = uint32(len([]rune(encodedStr)))
if preeditLen == 0 {
Expand Down
35 changes: 1 addition & 34 deletions engine_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"os"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
"unicode"
Expand Down Expand Up @@ -86,39 +85,6 @@ func (e *IBusBambooEngine) init() {
}
}
keyPressHandler = e.keyPressForwardHandler

if e.config.IBflags&config.IBmouseCapturing != 0 {
startMouseCapturing()
startMouseRecording()
}
var mouseMutex sync.Mutex
onMouseMove = func() {
mouseMutex.Lock()
defer mouseMutex.Unlock()
if e.checkInputMode(config.PreeditIM) {
if e.getRawKeyLen() == 0 {
return
}
e.commitPreeditAndReset(e.getPreeditString())
}
}
onMouseClick = func() {
mouseMutex.Lock()
defer mouseMutex.Unlock()
if e.isEmojiLTOpened {
e.refreshEmojiCandidate()
} else {
e.resetFakeBackspace()
e.resetBuffer()
e.keyPressDelay = KeypressDelayMs
if e.capabilities&IBusCapSurroundingText != 0 {
//e.ForwardKeyEvent(IBUS_Shift_R, XK_Shift_R-8, 0)
x11SendShiftR()
e.isSurroundingTextReady = true
e.keyPressDelay = KeypressDelayMs * 10
}
}
}
}

func initConfigFiles(engineName string) {
Expand Down Expand Up @@ -418,6 +384,7 @@ func (e *IBusBambooEngine) updateInputModeLT() {
func isValidState(state uint32) bool {
if state&IBusControlMask != 0 ||
state&IBusMod1Mask != 0 ||
state&IBusMod4Mask != 0 ||
state&IBusIgnoredMask != 0 ||
state&IBusSuperMask != 0 ||
state&IBusHyperMask != 0 ||
Expand Down
3 changes: 2 additions & 1 deletion ibus_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
IBusLockMask = 1 << 1
IBusControlMask = 1 << 2
IBusMod1Mask = 1 << 3
IBusMod4Mask = 1 << 6

/* The next few modifiers are used by XKB so we skip to the end.
* Bits 15 - 23 are currently unused. Bit 29 is used internally.
Expand All @@ -41,7 +42,7 @@ const (
IBusReleaseMask = 1 << 30

IBusModifierMask = 0x5f001fff
IBusDefaultModMask = IBusControlMask | IBusShiftMask | IBusMod1Mask | IBusSuperMask | IBusHyperMask | IBusMetaMask
IBusDefaultModMask = IBusControlMask | IBusShiftMask | IBusMod1Mask | IBusMod4Mask | IBusSuperMask | IBusHyperMask | IBusMetaMask | 0xffeb
)

const (
Expand Down
17 changes: 0 additions & 17 deletions prop.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const (
PropKeySpellCheckByDicts = "spell_check_by_dicts"
PropKeyPreeditInvisibility = "preedit_invisibility"
PropKeyVnCharsetConvert = "charset_convert_page"
PropKeyMouseCapturing = "mouse_capturing"
PropKeyMacroEnabled = "macro_enabled"
PropKeyMacroTable = "open_macro_table"
PropKeyEmojiEnabled = "emoji_enabled"
Expand Down Expand Up @@ -369,10 +368,6 @@ func GetOptionsPropListByConfig(c *config.Config) *ibus.PropList {
toneFreeMarkingChecked := ibus.PROP_STATE_UNCHECKED
preeditInvisibilityChecked := ibus.PROP_STATE_UNCHECKED
x11FakeBackspaceChecked := ibus.PROP_STATE_UNCHECKED
mouseCapturingChecked := ibus.PROP_STATE_UNCHECKED
if c.IBflags&config.IBmouseCapturing != 0 {
mouseCapturingChecked = ibus.PROP_STATE_CHECKED
}

if c.Flags&bamboo.EstdToneStyle != 0 {
toneStdChecked = ibus.PROP_STATE_CHECKED
Expand Down Expand Up @@ -424,18 +419,6 @@ func GetOptionsPropListByConfig(c *config.Config) *ibus.PropList {
Symbol: dbus.MakeVariant(ibus.NewText("P")),
SubProps: dbus.MakeVariant(*ibus.NewPropList()),
},
&ibus.Property{
Name: "IBusProperty",
Key: PropKeyMouseCapturing,
Type: ibus.PROP_TYPE_TOGGLE,
Label: dbus.MakeVariant(ibus.NewText("Bắt sự kiện chuột")),
Tooltip: dbus.MakeVariant(ibus.NewText("Mouse capturing")),
Sensitive: true,
Visible: true,
State: mouseCapturingChecked,
Symbol: dbus.MakeVariant(ibus.NewText("F")),
SubProps: dbus.MakeVariant(*ibus.NewPropList()),
},
&ibus.Property{
Name: "IBusProperty",
Key: PropKeyPreeditElimination,
Expand Down
6 changes: 0 additions & 6 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,12 @@ var enabledAuxiliaryTextList = []string{
"wpsoffice:wpsoffice",
}

var disabledMouseCapturingList = []string{
"DesktopEditors", //onlyoffice
"DesktopEditors:DesktopEditors", //onlyoffice
}

var DefaultBrowserList = []string{
"Navigator:Firefox",
"google-chrome:Google-chrome",
"chromium-browser:Chromium-browser",
}


func getEngineSubFile(fileName string) string {
if _, err := os.Stat(fileName); err == nil {
// return source code data/macro.tpl.txt path
Expand Down
61 changes: 0 additions & 61 deletions x11.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ extern void x11Paste(int);
extern void clipboard_init();
extern void clipboard_exit();
extern void x11ClipboardReset();
extern void mouse_capture_init();
extern void mouse_capture_exit();
extern void mouse_capture_unlock();
extern void mouse_capture_start_or_unlock();
extern void mouse_recording_init();
extern void mouse_recording_exit();
extern void x11SendBackspace(int n, int timeout);
extern void x11SendShiftR();
extern void x11SendShiftLeft(int n, int r, int timeout);
Expand All @@ -58,19 +52,6 @@ func init() {
C.setXIgnoreErrorHandler()
}

//export mouse_move_handler
func mouse_move_handler() {
onMouseMove()
}

//export mouse_click_handler
func mouse_click_handler() {
onMouseClick()
}

var onMouseMove func()
var onMouseClick func()

func x11StartWindowInspector() {
C.x11StartWindowInspector()
}
Expand All @@ -79,48 +60,6 @@ func x11StopWindowInspector() {
C.x11StopWindowInspector()
}

func startMouseRecording() {
C.mouse_recording_init()
}

func stopMouseRecording() {
C.mouse_recording_exit()
}

func startMouseCapturing() {
mcapMutex.Lock()
defer mcapMutex.Unlock()
if !mcapRunning {
C.mouse_capture_init()
mcapRunning = true
}
}

func stopMouseCapturing() {
mcapMutex.RLock()
defer mcapMutex.RUnlock()
if mcapRunning {
C.mouse_capture_exit()
}
}

func mouseCaptureStartOrUnlock() {
mcapMutex.Lock()
defer mcapMutex.Unlock()
if !mcapRunning {
C.mouse_capture_start_or_unlock()
mcapRunning = true
}
}

func mouseCaptureUnlock() {
mcapMutex.RLock()
defer mcapMutex.RUnlock()
if mcapRunning {
C.mouse_capture_unlock()
}
}

func x11Copy(str string) {
cs := C.CString(str)
defer C.free(unsafe.Pointer(cs))
Expand Down
Loading