Fixed rare mupdf winid issue

This commit is contained in:
Karl Yngve Lervåg 2015-01-30 09:19:24 +01:00
parent 322709f13e
commit b55b539564

View File

@ -29,17 +29,17 @@ function! latex#view#init(initialized) " {{{1
" "
let data = g:latex#data[b:latex.id] let data = g:latex#data[b:latex.id]
if g:latex_view_method == 'mupdf' if g:latex_view_method == 'mupdf'
call s:check_method_mupdf() call s:init_mupdf()
let data.view = function('latex#view#mupdf') let data.view = function('latex#view#mupdf')
let data.rsearch = function('latex#view#mupdf_rsearch') let data.rsearch = function('latex#view#mupdf_rsearch')
elseif g:latex_view_method == 'okular' elseif g:latex_view_method == 'okular'
call s:check_method_okular() call s:init_okular()
let data.view = function('latex#view#okular') let data.view = function('latex#view#okular')
elseif g:latex_view_method == 'sumatrapdf' elseif g:latex_view_method == 'sumatrapdf'
call s:check_method_sumatrapdf() call s:init_sumatrapdf()
let data.view = function('latex#view#sumatrapdf') let data.view = function('latex#view#sumatrapdf')
else else
call s:check_method_general() call s:init_general()
let data.view = function('latex#view#general') let data.view = function('latex#view#general')
endif endif
@ -95,16 +95,18 @@ endfunction
" }}}1 " }}}1
function! latex#view#mupdf_poststart() "{{{1 function! latex#view#mupdf_poststart() "{{{1
" First get the window id " First get the window id
let mupdf_ids = [] if g:latex#data[b:latex.id].mupdf_id == 0
if executable('xdotool') let mupdf_ids = []
let cmd = 'xdotool search --class MuPDF' if executable('xdotool')
let mupdf_ids = systemlist(cmd) let cmd = 'xdotool search --class MuPDF'
endif let mupdf_ids = systemlist(cmd)
if len(mupdf_ids) == 0 endif
echomsg "Couldn't find MuPDF window ID!" if len(mupdf_ids) == 0
let g:latex#data[b:latex.id].mupdf_id = 0 echomsg "Couldn't find MuPDF window ID!"
else let g:latex#data[b:latex.id].mupdf_id = 0
let g:latex#data[b:latex.id].mupdf_id = mupdf_ids[-1] else
let g:latex#data[b:latex.id].mupdf_id = mupdf_ids[-1]
endif
endif endif
" Next return focus to vim and send some keys to mupdf if desired " Next return focus to vim and send some keys to mupdf if desired
@ -210,7 +212,7 @@ endfunction
" }}}1 " }}}1
function! s:check_method_general() "{{{1 function! s:init_general() "{{{1
if !executable(g:latex_view_general_viewer) if !executable(g:latex_view_general_viewer)
echoerr "General viewer is not available!" echoerr "General viewer is not available!"
echoerr "g:latex_view_general_viewer = " echoerr "g:latex_view_general_viewer = "
@ -219,24 +221,29 @@ function! s:check_method_general() "{{{1
endfunction endfunction
" }}}1 " }}}1
function! s:check_method_mupdf() "{{{1 function! s:init_mupdf() "{{{1
if !executable('mupdf') if !executable('mupdf')
echoerr "MuPDF is not available!" echoerr "MuPDF is not available!"
endif endif
" Check if forward search is possible " Check if forward search is possible
let s:mupdf_forward_search = executable('synctex') && executable('xdotool') let s:mupdf_forward_search = executable('synctex') && executable('xdotool')
" Initialize mupdf_id
if !has_key(g:latex#data[b:latex.id], 'mupdf_id')
let g:latex#data[b:latex.id].mupdf_id = 0
endif
endfunction endfunction
" }}}1 " }}}1
function! s:check_method_sumatrapdf() "{{{1 function! s:init_sumatrapdf() "{{{1
if !executable('SumatraPDF') if !executable('SumatraPDF')
echoerr "SumatraPDF is not available!" echoerr "SumatraPDF is not available!"
endif endif
endfunction endfunction
"}}}1 "}}}1
function! s:check_method_okular() "{{{1 function! s:init_okular() "{{{1
if !executable('okular') if !executable('okular')
echoerr "okular is not available!" echoerr "okular is not available!"
endif endif
@ -245,10 +252,6 @@ endfunction
"}}}1 "}}}1
function! s:mupdf_exists_win() "{{{1 function! s:mupdf_exists_win() "{{{1
if !has_key(g:latex#data[b:latex.id], 'mupdf_id')
let g:latex#data[b:latex.id].mupdf_id = 0
endif
if executable('xdotool') if executable('xdotool')
let cmd = 'xdotool search --class MuPDF' let cmd = 'xdotool search --class MuPDF'
let mupdf_ids = systemlist(cmd) let mupdf_ids = systemlist(cmd)