Skip to content

Commit

Permalink
Bug fix: Only toggle active window using `wmctrl'
Browse files Browse the repository at this point in the history
The :set titlestring= hack turns out to be unreliable: sometimes the
wrong Vim window would be toggled between normal / full screen mode.
Therefor the plug-in now always toggles the :ACTIVE: window state.

Also reports errors from libcall('fullscreen') now.
  • Loading branch information
xolox committed Aug 30, 2010
1 parent 6457749 commit ca43642
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
3 changes: 2 additions & 1 deletion TODO.md
@@ -1,6 +1,7 @@
* Test the `shell.dll` library on as many configurations as possible! (different Windows versions, 32 vs. 64 bit, etc.)

* Bug: On Windows when I enter full-screen for the 1st time it works and I can leave full-screen. But when I then try to enter full-screen a second time (without changing Vim's window state in any way) then it fails to actually toggle the full-screen state on!
* **Bug:** On Windows when I enter full-screen for the 1st time it works and I can leave full-screen. But when I then try to enter full-screen a second time (without changing Vim's window state in any way) then it fails to actually toggle the full-screen state on!
**Update:** This might just be a redraw bug in VirtualBox after all?! Vim does switch to full-screen

* Document how to pass standard input to shell commands using xolox#shell#execute().

Expand Down
27 changes: 6 additions & 21 deletions autoload.vim
@@ -1,6 +1,6 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 15, 2010
" Last Change: August 30, 2010
" URL: http://peterodding.com/code/vim/shell/

if !exists('s:script')
Expand Down Expand Up @@ -215,31 +215,16 @@ function! xolox#shell#fullscreen() " -- toggle Vim between normal and full-scree
let msg = "The DLL library %s is missing!"
throw printf(msg, string(s:library))
endif
call s:library_call('fullscreen', !s:fullscreen_enabled)
let error = s:library_call('fullscreen', !s:fullscreen_enabled)
if error != ''
throw "shell.dll failed with: " . error
endif
elseif has('unix')
if !executable('wmctrl')
let msg = "Full-screen on UNIX requires the `wmctrl' program!"
throw msg . " On Debian/Ubuntu you can install it by executing `sudo apt-get install wmctrl'."
endif
let ts_save = &titlestring
try
set titlestring=fc3fa0ca4b
redraw
for line in split(s:execute('wmctrl -l', []), "\n")
if line =~ &titlestring
let window_id = matchstr(line, '^\S\+')
break
endif
endfor
finally
let &titlestring = ts_save
endtry
if exists('window_id') && window_id != ''
call s:execute('wmctrl -ir %s -b toggle,fullscreen 2>&1', [window_id])
else
let title = v:servername != '' ? v:servername : 'vim'
call s:execute('wmctrl -r %s -b toggle,fullscreen 2>&1', [title])
endif
call s:execute('wmctrl -r %s -b toggle,fullscreen 2>&1', [':ACTIVE:'])
else
throw printf(s:enoimpl, 'fullscreen', s:contact)
endif
Expand Down
4 changes: 2 additions & 2 deletions shell.vim
@@ -1,9 +1,9 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 15, 2010
" Last Change: August 30, 2010
" URL: http://peterodding.com/code/vim/shell/
" License: MIT
" Version: 0.7.2
" Version: 0.7.3

" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3123 1 :AutoInstall: shell.zip
Expand Down

0 comments on commit ca43642

Please sign in to comment.