Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tui: schedule event instead of <FocusGained> pseudokey #7221

Merged
merged 13 commits into from Sep 6, 2017

Conversation

Projects
None yet
4 participants
@justinmk
Copy link
Member

justinmk commented Aug 28, 2017

  • eventloop: schedule event instead of <FocusGained> pseudokey: This commit works in some cases. But there's a subtle problem because of the different event-loop scheduling mechanisms. loop_schedule(&main_loop, ...) puts the event on fast_events which is processed at a different stage than a pseudokey on the input queue would be processed.
  • eventloop: FocusGained: schedule the schedule: this commit convinces the event subsystem to put the event on main_loop.events by scheduling a handler which then enqueues another handler directly.

fixes #6164
fixes #4840

@marvim marvim added the WIP label Aug 28, 2017

@justinmk justinmk changed the title [WIP] tui: schedule event instead of <FocusGained> pseudokey [RFC] tui: schedule event instead of <FocusGained> pseudokey Sep 1, 2017

@justinmk justinmk force-pushed the justinmk:ev-focusgained branch from a4fd616 to 0c01f0e Sep 1, 2017

@marvim marvim added RFC and removed WIP labels Sep 1, 2017

@justinmk justinmk force-pushed the justinmk:ev-focusgained branch 4 times, most recently from 170e811 to 3a78383 Sep 2, 2017

@justinmk justinmk changed the title [RFC] tui: schedule event instead of <FocusGained> pseudokey tui: schedule event instead of <FocusGained> pseudokey Sep 3, 2017

@justinmk

This comment has been minimized.

Copy link
Member Author

justinmk commented Sep 3, 2017

Currently some UIs (oni, neovim.app) call :doautocmd FocusGained to "notify" nvim of focus. Other UIs (nvim-qt, VimR) send the <FocusGained> pseudokey.

This PR removes <FocusGained>, so focus behavior in the latter UIs will break.

@justinmk justinmk force-pushed the justinmk:ev-focusgained branch 2 times, most recently from 7a93c97 to b9ad325 Sep 4, 2017

justinmk added some commits Aug 27, 2017

eventloop: FocusGained: schedule the schedule
main_loop.fast_events does not manifest as K_EVENT, because it is
processed at a different stage than main_loop.events. In order to queue
into main_loop.events, we need to go through the threadsafe
loop_schedule(), which queues into main_loop.thread_events and
eventually main_loop.fast_events. _Then_ it is safe to directly queue
into main_loop.events.

This makes it more likely that the event is treated as K_EVENT.
eventloop: do not redraw in cmdline K_EVENT handler
If :echo is done by an timer or event (such as FocusGained/FocusLost),
redrawcmdline() clobbers it.
eventloop: restore redraw in cmdline K_EVENT handler
Restores behavior from commit: 02e86ef04cc1
test: FocusGained: let UI settle before sending input
This significantly increases the likelihood that the :echo'd text will
be included in the next UI flush, instead of being lost.
eventloop: loop_schedule_deferred()
Generalize the "schedule schedule" technique.

@justinmk justinmk force-pushed the justinmk:ev-focusgained branch from b9ad325 to b9d6bda Sep 5, 2017

@justinmk justinmk merged commit 51808a2 into neovim:master Sep 6, 2017

3 of 4 checks passed

QuickBuild Build pr-7221 finished with status FAILED
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on master at 76.487%
Details

@justinmk justinmk deleted the justinmk:ev-focusgained branch Sep 6, 2017

@justinmk justinmk removed the RFC label Sep 6, 2017

@justinmk

This comment has been minimized.

Copy link
Member Author

justinmk commented Sep 6, 2017

@equalsraf @qvacua This will require a change in neovim-qt and VimR.

The VimR change is similar to what we do for the built-in UI (TUI): just call aucmd_schedule_focusgained().

Neovim-Qt change, for the time being, needs to call nvim_command('doautocmd Focus{Gained,Lost}').

@zackhsi

This comment has been minimized.

Copy link

zackhsi commented Sep 22, 2017

@justinmk what is the recommendation for terminal nvim users? The reload-on-focus I used to have is no longer there.

Am I supposed to put aucmd_schedule_focusgained in my config file?

@jamessan

This comment has been minimized.

Copy link
Member

jamessan commented Sep 22, 2017

This shouldn't have changed any visible behavior. I can confirm that nvim is still reacting to FocusLost/FocusGained in xterm.

au FocusLost * echom 'Bye'
au FocusGained * echom 'Hi'

Then change focus and you should see Bye/Hi in :messages.

@zackhsi

This comment has been minimized.

Copy link

zackhsi commented Sep 22, 2017

Hmm, you are right. When I switch tabs away from then back to, I see the messages.

But when I background and foreground nvim, I get nothing? Is there a separate trigger I should be looking for to detect backgrounding/foregrounding?

@jamessan

This comment has been minimized.

Copy link
Member

jamessan commented Sep 22, 2017

See #3648 and #2127.

@zackhsi

This comment has been minimized.

Copy link

zackhsi commented Sep 22, 2017

#3648 (comment) is a lifesaver, thanks :)

justinmk added a commit to justinmk/neovim that referenced this pull request Nov 8, 2017

NVIM v0.2.1
FEATURES:
0e873a3 Lua(Jit) built-in neovim#4411
5b32bce Windows: `:terminal` neovim#7007
7b0ceb3 UI/API: externalize cmdline neovim#7173
b67f58b UI/API: externalize wildmenu neovim#7454
b23aa1c UI: 'winhighlight' neovim#6597
17531ed UI: command-line coloring (`:help input()-highlight`) neovim#6364
244a1f9 API: execute lua directly from the remote api neovim#6704
45626de API: `get_keymap()` neovim#6236
db99982 API: `nvim_get_hl_by_name()`, `nvim_get_hl_by_id()` neovim#7082
dc68538 menu_get() function neovim#6322
9db42d4 :cquit : take an error code argument neovim#7336
9cc185d job-control: serverstart(): support ipv6 neovim#6680
1b7a9bf job-control: sockopen() neovim#6594
6efe84a clipboard: fallback to tmux clipboard neovim#6894
6016ac2 clipboard: customize clipboard with `g:clipboard` neovim#6030
3a86dd5 ruby: override ruby host via `g:ruby_host_prog` neovim#6841
16cce1a debug: $NVIM_LOG_FILE neovim#6827
0cba3da `:checkhealth` built-in, validates $VIMRUNTIME neovim#7399

FIXES:
105d680 TUI: more terminals, improve scroll/resize neovim#6816
cb912a3 :terminal : handle F1-F12, other keys neovim#7241
619838f inccommand: improve performance neovim#6949
04b3c32 inccommand: Fix matches for zero-width neovim#7487
60b1e8a inccommand: multiline, other fixes neovim#7315
f1f7f3b inccommand: Ignore leading modifiers in the command neovim#6967
1551f71 inccommand: fix 'gdefault' lockup neovim#7262
6338199 API: bufhl: support creating new groups neovim#7414
541dde3 API: allow K_EVENT during operator-pending
8c732f7 terminal: adjust for 'number' neovim#7440
5bec946 UI: preserve wildmenu during jobs/events neovim#7110
c349083 UI: disable 'lazyredraw' during ui_refresh. neovim#6259
51808a2 send FocusGained/FocusLost event instead of pseudokey neovim#7221
133f8bc shada: preserve unnamed register on restart neovim#4700
1b70a1d shada: avoid assertion on corrupt shada file neovim#6958
9f534f3 mksession: Restore tab-local working directory neovim#6859
de1084f fix buf_write() crash neovim#7140
7f76986 syntax: register 'Normal' highlight group neovim#6973
6e7a8c3 RPC: close channel if stream was closed neovim#7081
85f3084 clipboard: disallow recursion; show hint only once neovim#7203
8d1ccb6 clipboard: performance, avoid weird edge-cases neovim#7193
01487d4 'titleold' neovim#7358
01e53a5 Windows: better path-handling, separator (slash) hygiene neovim#7349
0f2873c Windows: multibyte startup arguments neovim#7060

CHANGES:
9ff0cc7 :terminal : start in normal-mode neovim#6808
032b088 lower priority of 'cursorcolumn', 'colorcolumn' neovim#7364
2a3bcd1 RPC: Don't delay notifications when request is pending neovim#6544
023f67c :terminal : Do not change 'number', 'relativenumber' neovim#6796
1ef2d76 socket.c: Disable Nagle's algorithm on TCP sockets neovim#6915
6720fe2 help: `K` tries Vim help instead of manpage neovim#3104
7068370 help, man.vim: change "outline" map to `gO` neovim#7405

@justinmk justinmk referenced this pull request Nov 8, 2017

Merged

NVIM v0.2.1 #7505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.