Skip to content

Add KeyEventResult enum and support passthrough (filter) mode#30

Open
buzztaiki wants to merge 2 commits intofcitx:masterfrom
buzztaiki:passthrough
Open

Add KeyEventResult enum and support passthrough (filter) mode#30
buzztaiki wants to merge 2 commits intofcitx:masterfrom
buzztaiki:passthrough

Conversation

@buzztaiki
Copy link

This PR adds support for a passthrough mode to the KeyEvent handler by extending its return value handling.

I also introduced the KeyEventResult enum to provide a way to choose between NotHandled, Handled, and Passthrough from Lua. This solves the issue where users need to bypass Fcitx5 for specific applications (like Emacs with DDSKK) in Wayland environments.

Example usage

local fcitx = require("fcitx")

local target_programs = {
   ["emacs"] = true
}

function handler(keysym, states, release)
   local program = fcitx.currentProgram()
   if target_programs[program] then
      return fcitx.KeyEventResult.Passthrough
   end
   return fcitx.KeyEventResult.NotHandled
end

fcitx.watchEvent(fcitx.EventType.KeyEvent, "handler")

@buzztaiki buzztaiki mentioned this pull request Feb 2, 2026
@wengxt
Copy link
Member

wengxt commented Feb 2, 2026

can you add a test?

@buzztaiki
Copy link
Author

sure, I try to add a test.

@buzztaiki
Copy link
Author

@wengxt I've added tests for KeyEvent result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants