Skip to content

Commit 4ffdca3

Browse files
authored
Merge pull request #599 from hien-ngo29/ibus-lotus-fix
Fix mouse capture bugs and super-space problem on Wayland (ibus-lotus)
2 parents 1bf05ab + 738a597 commit 4ffdca3

10 files changed

Lines changed: 8 additions & 536 deletions

File tree

config/flags.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ const (
4040
IBspellCheckWithRules
4141
IBspellCheckWithDicts
4242
IBautoCommitWithDelay
43-
IBautoCommitWithMouseMovement
44-
_IBemojiDisabled //deprecated
43+
_IBautoCommitWithMouseMovement //deprecated
44+
_IBemojiDisabled //deprecated
4545
IBpreeditElimination
4646
_IBinputModeLookupTableEnabled //deprecated
4747
IBautoCapitalizeMacro
4848
_IBimQuickSwitchEnabled //deprecated
4949
_IBrestoreKeyStrokesEnabled //deprecated
50-
IBmouseCapturing
50+
_IBmouseCapturing //deprecated
5151
IBworkaroundForFBMessenger
5252
IBworkaroundForWPS
5353
IBstdFlags = IBspellCheckEnabled | IBspellCheckWithRules | IBautoNonVnRestore | IBddFreeStyle |
54-
IBmouseCapturing | IBautoCapitalizeMacro | IBnoUnderline | IBworkaroundForWPS
54+
IBautoCapitalizeMacro | IBnoUnderline | IBworkaroundForWPS
5555
IBUsStdFlags = 0
5656
)

engine.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ func (e *IBusBambooEngine) FocusIn() *dbus.Error {
124124
if e.config.IBflags&config.IBspellCheckWithDicts != 0 && len(dictionary) == 0 {
125125
dictionary, _ = loadDictionary(DictVietnameseCm)
126126
}
127-
if inStringList(disabledMouseCapturingList, e.getWmClass()) {
128-
stopMouseCapturing()
129-
} else if e.config.IBflags&config.IBmouseCapturing != 0 {
130-
startMouseCapturing()
131-
}
132127
fmt.Printf("WM_CLASS=(%s)\n", e.getWmClass())
133128
return nil
134129
}
@@ -141,7 +136,7 @@ func (e *IBusBambooEngine) FocusOut() *dbus.Error {
141136
func (e *IBusBambooEngine) Reset() *dbus.Error {
142137
fmt.Print("Reset.\n")
143138
if e.checkInputMode(config.PreeditIM) {
144-
e.commitPreeditAndReset(e.getPreeditString())
139+
e.preeditor.Reset()
145140
}
146141
return nil
147142
}
@@ -333,17 +328,6 @@ func (e *IBusBambooEngine) PropertyActivate(propName string, propState uint32) *
333328
e.config.IBflags &= ^config.IBspellCheckWithDicts
334329
}
335330
}
336-
if propName == PropKeyMouseCapturing {
337-
if propState == ibus.PROP_STATE_CHECKED {
338-
e.config.IBflags |= config.IBmouseCapturing
339-
startMouseCapturing()
340-
startMouseRecording()
341-
} else {
342-
e.config.IBflags &= ^config.IBmouseCapturing
343-
stopMouseCapturing()
344-
stopMouseRecording()
345-
}
346-
}
347331
if propName == PropKeyMacroEnabled {
348332
if propState == ibus.PROP_STATE_CHECKED {
349333
e.config.IBflags |= config.IBmacroEnabled

engine_preedit.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ func (e *IBusBambooEngine) expandMacro(str string) string {
9191
}
9292

9393
func (e *IBusBambooEngine) updatePreedit(processedStr string) {
94-
defer func() {
95-
if e.config.IBflags&config.IBmouseCapturing != 0 {
96-
mouseCaptureUnlock()
97-
}
98-
}()
9994
var encodedStr = e.encodeText(processedStr)
10095
var preeditLen = uint32(len([]rune(encodedStr)))
10196
if preeditLen == 0 {

engine_utils.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"os"
2828
"strconv"
2929
"strings"
30-
"sync"
3130
"sync/atomic"
3231
"time"
3332
"unicode"
@@ -86,39 +85,6 @@ func (e *IBusBambooEngine) init() {
8685
}
8786
}
8887
keyPressHandler = e.keyPressForwardHandler
89-
90-
if e.config.IBflags&config.IBmouseCapturing != 0 {
91-
startMouseCapturing()
92-
startMouseRecording()
93-
}
94-
var mouseMutex sync.Mutex
95-
onMouseMove = func() {
96-
mouseMutex.Lock()
97-
defer mouseMutex.Unlock()
98-
if e.checkInputMode(config.PreeditIM) {
99-
if e.getRawKeyLen() == 0 {
100-
return
101-
}
102-
e.commitPreeditAndReset(e.getPreeditString())
103-
}
104-
}
105-
onMouseClick = func() {
106-
mouseMutex.Lock()
107-
defer mouseMutex.Unlock()
108-
if e.isEmojiLTOpened {
109-
e.refreshEmojiCandidate()
110-
} else {
111-
e.resetFakeBackspace()
112-
e.resetBuffer()
113-
e.keyPressDelay = KeypressDelayMs
114-
if e.capabilities&IBusCapSurroundingText != 0 {
115-
//e.ForwardKeyEvent(IBUS_Shift_R, XK_Shift_R-8, 0)
116-
x11SendShiftR()
117-
e.isSurroundingTextReady = true
118-
e.keyPressDelay = KeypressDelayMs * 10
119-
}
120-
}
121-
}
12288
}
12389

12490
func initConfigFiles(engineName string) {
@@ -418,6 +384,7 @@ func (e *IBusBambooEngine) updateInputModeLT() {
418384
func isValidState(state uint32) bool {
419385
if state&IBusControlMask != 0 ||
420386
state&IBusMod1Mask != 0 ||
387+
state&IBusMod4Mask != 0 ||
421388
state&IBusIgnoredMask != 0 ||
422389
state&IBusSuperMask != 0 ||
423390
state&IBusHyperMask != 0 ||

ibus_const.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
IBusLockMask = 1 << 1
2525
IBusControlMask = 1 << 2
2626
IBusMod1Mask = 1 << 3
27+
IBusMod4Mask = 1 << 6
2728

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

4344
IBusModifierMask = 0x5f001fff
44-
IBusDefaultModMask = IBusControlMask | IBusShiftMask | IBusMod1Mask | IBusSuperMask | IBusHyperMask | IBusMetaMask
45+
IBusDefaultModMask = IBusControlMask | IBusShiftMask | IBusMod1Mask | IBusMod4Mask | IBusSuperMask | IBusHyperMask | IBusMetaMask | 0xffeb
4546
)
4647

4748
const (

prop.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const (
3636
PropKeySpellCheckByDicts = "spell_check_by_dicts"
3737
PropKeyPreeditInvisibility = "preedit_invisibility"
3838
PropKeyVnCharsetConvert = "charset_convert_page"
39-
PropKeyMouseCapturing = "mouse_capturing"
4039
PropKeyMacroEnabled = "macro_enabled"
4140
PropKeyMacroTable = "open_macro_table"
4241
PropKeyEmojiEnabled = "emoji_enabled"
@@ -369,10 +368,6 @@ func GetOptionsPropListByConfig(c *config.Config) *ibus.PropList {
369368
toneFreeMarkingChecked := ibus.PROP_STATE_UNCHECKED
370369
preeditInvisibilityChecked := ibus.PROP_STATE_UNCHECKED
371370
x11FakeBackspaceChecked := ibus.PROP_STATE_UNCHECKED
372-
mouseCapturingChecked := ibus.PROP_STATE_UNCHECKED
373-
if c.IBflags&config.IBmouseCapturing != 0 {
374-
mouseCapturingChecked = ibus.PROP_STATE_CHECKED
375-
}
376371

377372
if c.Flags&bamboo.EstdToneStyle != 0 {
378373
toneStdChecked = ibus.PROP_STATE_CHECKED
@@ -424,18 +419,6 @@ func GetOptionsPropListByConfig(c *config.Config) *ibus.PropList {
424419
Symbol: dbus.MakeVariant(ibus.NewText("P")),
425420
SubProps: dbus.MakeVariant(*ibus.NewPropList()),
426421
},
427-
&ibus.Property{
428-
Name: "IBusProperty",
429-
Key: PropKeyMouseCapturing,
430-
Type: ibus.PROP_TYPE_TOGGLE,
431-
Label: dbus.MakeVariant(ibus.NewText("Bắt sự kiện chuột")),
432-
Tooltip: dbus.MakeVariant(ibus.NewText("Mouse capturing")),
433-
Sensitive: true,
434-
Visible: true,
435-
State: mouseCapturingChecked,
436-
Symbol: dbus.MakeVariant(ibus.NewText("F")),
437-
SubProps: dbus.MakeVariant(*ibus.NewPropList()),
438-
},
439422
&ibus.Property{
440423
Name: "IBusProperty",
441424
Key: PropKeyPreeditElimination,

utils.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,12 @@ var enabledAuxiliaryTextList = []string{
6464
"wpsoffice:wpsoffice",
6565
}
6666

67-
var disabledMouseCapturingList = []string{
68-
"DesktopEditors", //onlyoffice
69-
"DesktopEditors:DesktopEditors", //onlyoffice
70-
}
71-
7267
var DefaultBrowserList = []string{
7368
"Navigator:Firefox",
7469
"google-chrome:Google-chrome",
7570
"chromium-browser:Chromium-browser",
7671
}
7772

78-
7973
func getEngineSubFile(fileName string) string {
8074
if _, err := os.Stat(fileName); err == nil {
8175
// return source code data/macro.tpl.txt path

x11.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ extern void x11Paste(int);
2929
extern void clipboard_init();
3030
extern void clipboard_exit();
3131
extern void x11ClipboardReset();
32-
extern void mouse_capture_init();
33-
extern void mouse_capture_exit();
34-
extern void mouse_capture_unlock();
35-
extern void mouse_capture_start_or_unlock();
36-
extern void mouse_recording_init();
37-
extern void mouse_recording_exit();
3832
extern void x11SendBackspace(int n, int timeout);
3933
extern void x11SendShiftR();
4034
extern void x11SendShiftLeft(int n, int r, int timeout);
@@ -58,19 +52,6 @@ func init() {
5852
C.setXIgnoreErrorHandler()
5953
}
6054

61-
//export mouse_move_handler
62-
func mouse_move_handler() {
63-
onMouseMove()
64-
}
65-
66-
//export mouse_click_handler
67-
func mouse_click_handler() {
68-
onMouseClick()
69-
}
70-
71-
var onMouseMove func()
72-
var onMouseClick func()
73-
7455
func x11StartWindowInspector() {
7556
C.x11StartWindowInspector()
7657
}
@@ -79,48 +60,6 @@ func x11StopWindowInspector() {
7960
C.x11StopWindowInspector()
8061
}
8162

82-
func startMouseRecording() {
83-
C.mouse_recording_init()
84-
}
85-
86-
func stopMouseRecording() {
87-
C.mouse_recording_exit()
88-
}
89-
90-
func startMouseCapturing() {
91-
mcapMutex.Lock()
92-
defer mcapMutex.Unlock()
93-
if !mcapRunning {
94-
C.mouse_capture_init()
95-
mcapRunning = true
96-
}
97-
}
98-
99-
func stopMouseCapturing() {
100-
mcapMutex.RLock()
101-
defer mcapMutex.RUnlock()
102-
if mcapRunning {
103-
C.mouse_capture_exit()
104-
}
105-
}
106-
107-
func mouseCaptureStartOrUnlock() {
108-
mcapMutex.Lock()
109-
defer mcapMutex.Unlock()
110-
if !mcapRunning {
111-
C.mouse_capture_start_or_unlock()
112-
mcapRunning = true
113-
}
114-
}
115-
116-
func mouseCaptureUnlock() {
117-
mcapMutex.RLock()
118-
defer mcapMutex.RUnlock()
119-
if mcapRunning {
120-
C.mouse_capture_unlock()
121-
}
122-
}
123-
12463
func x11Copy(str string) {
12564
cs := C.CString(str)
12665
defer C.free(unsafe.Pointer(cs))

0 commit comments

Comments
 (0)