Skip to content

Commit a239d6b

Browse files
committed
Make it possible to disable "always on top" on Windows (issues #9 & #10)
1 parent 52c9b24 commit a239d6b

File tree

7 files changed

+43
-16
lines changed

7 files changed

+43
-16
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ This variable is a string containing any combination of the following characters
7474

7575
By default all the above items are hidden in full-screen mode. You can also set the buffer local variable `b:shell_fullscreen_items` to change these settings for specific buffers.
7676

77+
### The `g:shell_fullscreen_always_on_top` option
78+
79+
On Windows the `:Fullscreen` command sets the Vim window to "always on top". Some people don't like this which is why this option was added. Its default value is true (1) so to disable the "always on top" feature you would add this to your [vimrc script] [vimrc]:
80+
81+
:let g:shell_fullscreen_always_on_top = 0
82+
7783
### The `g:shell_mappings_enabled` option
7884

7985
If you don't like the default mappings for the `:Open` and `:Fullscreen` commands then add the following to your [vimrc script] [vimrc]:

autoload/xolox/shell.vim

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: May 2, 2013
44
" URL: http://peterodding.com/code/vim/shell/
55

6-
let g:xolox#shell#version = '0.10'
6+
let g:xolox#shell#version = '0.11'
77

88
call xolox#misc#compat#check('shell', 2)
99

@@ -226,7 +226,11 @@ function! xolox#shell#fullscreen() " -- toggle Vim between normal and full-scree
226226
" custom dynamic link library on Windows or the "wmctrl" program on UNIX.
227227
try
228228
if xolox#misc#os#is_win() && s:has_dll()
229-
let error = s:library_call('fullscreen', !s:fullscreen_enabled)
229+
let options = s:fullscreen_enabled ? 'disable' : 'enable'
230+
if g:shell_fullscreen_always_on_top
231+
let options .= ', always on top'
232+
endif
233+
let error = s:library_call('fullscreen', options)
230234
if error != ''
231235
throw "shell.dll failed with: " . error
232236
endif
@@ -337,12 +341,14 @@ if xolox#misc#os#is_win()
337341
let s:library = expand('<sfile>:p:h:h:h') . '\misc\shell\shell-' . s:cpu_arch . '.dll'
338342

339343
function! s:library_call(fn, arg) " {{{2
340-
return libcall(s:library, a:fn, a:arg)
344+
let result = libcall(s:library, a:fn, a:arg)
345+
call xolox#misc#msg#debug("Called %s:%s, returning %s", s:library, a:fn, result)
346+
return result
341347
endfunction
342348

343349
function! s:has_dll() " {{{2
344350
try
345-
return s:library_call('libversion', '') == '0.3'
351+
return s:library_call('libversion', '') == '0.4'
346352
catch
347353
return 0
348354
endtry

doc/shell.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Contents ~
1414
6. The |xolox#shell#fullscreen()| function
1515
7. The |xolox#shell#is_fullscreen()| function
1616
8. The |g:shell_fullscreen_items| option
17-
9. The |g:shell_mappings_enabled| option
18-
10. The |g:shell_make_override| option
17+
9. The |g:shell_fullscreen_always_on_top| option
18+
10. The |g:shell_mappings_enabled| option
1919
11. The |g:shell_verify_urls| option
2020
3. Background |shell-background|
2121
4. Other full-screen implementations |shell-other-full-screen-implementations|
@@ -172,6 +172,16 @@ By default all the above items are hidden in full-screen mode. You can also
172172
set the buffer local variable 'b:shell_fullscreen_items' to change these
173173
settings for specific buffers.
174174

175+
-------------------------------------------------------------------------------
176+
The *g:shell_fullscreen_always_on_top* option
177+
178+
On Windows the |:Fullscreen| command sets the Vim window to "always on top".
179+
Some people don't like this which is why this option was added. Its default
180+
value is true (1) so to disable the "always on top" feature you would add this
181+
to your |vimrc| script:
182+
>
183+
:let g:shell_fullscreen_always_on_top = 0
184+
175185
-------------------------------------------------------------------------------
176186
The *g:shell_mappings_enabled* option
177187

@@ -188,9 +198,6 @@ to your |vimrc| script:
188198
:inoremap <Leader>op <C-o>:Open<CR>
189199
:nnoremap <Leader>op :Open<CR>
190200
191-
-------------------------------------------------------------------------------
192-
The *g:shell_make_override* option
193-
194201
-------------------------------------------------------------------------------
195202
The *g:shell_verify_urls* option
196203

misc/shell/shell-x64.dll

-512 Bytes
Binary file not shown.

misc/shell/shell-x86.dll

-6 KB
Binary file not shown.

misc/shell/shell.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* CL /LD shell.c shell32.lib user32.lib
1919
*
2020
* This should create the dynamic link library "shell.dll" which you can call
21-
* from Vim using for example :call libcall('c:/shell.dll', 'fullscreen', 1).
21+
* from Vim using for example :call libcall('c:/shell.dll', 'fullscreen', 'enable').
2222
*
2323
* Happy vimming!
2424
*
@@ -29,6 +29,7 @@
2929
#define WIN32_LEAN_AND_MEAN
3030
#include <windows.h>
3131
#include <ctype.h>
32+
#include <string.h>
3233
#include <shellapi.h> /* ShellExecute? */
3334

3435
/* Dynamic strings are returned using a static buffer to avoid memory leaks */
@@ -100,7 +101,7 @@ __declspec(dllexport)
100101
const char *libversion(const char *ignored) /* {{{1 */
101102
{
102103
(void)ignored;
103-
return Success("0.3");
104+
return Success("0.4");
104105
}
105106

106107
__declspec(dllexport)
@@ -111,7 +112,7 @@ const char *openurl(const char *path) /* {{{1 */
111112
}
112113

113114
__declspec(dllexport)
114-
const char *fullscreen(long enable) /* {{{1 */
115+
const char *fullscreen(const char *options) /* {{{1 */
115116
{
116117
HWND window;
117118
LONG styles;
@@ -131,12 +132,14 @@ const char *fullscreen(long enable) /* {{{1 */
131132
if (!exStyle)
132133
return Failure("Could not query window ex style!");
133134

134-
if (enable) {
135+
if (strstr(options, "enable")) {
135136
styles ^= WS_CAPTION | WS_THICKFRAME;
136-
exStyle |= WS_EX_TOPMOST;
137+
if (strstr(options, "always on top"))
138+
exStyle |= WS_EX_TOPMOST;
137139
} else {
138140
styles |= WS_CAPTION | WS_THICKFRAME;
139-
exStyle &= ~WS_EX_TOPMOST;
141+
if (strstr(options, "always on top"))
142+
exStyle &= ~WS_EX_TOPMOST;
140143
}
141144

142145
if (!SetWindowLong(window, GWL_STYLE, styles))
@@ -145,7 +148,7 @@ const char *fullscreen(long enable) /* {{{1 */
145148
if (!SetWindowLong(window, GWL_EXSTYLE, exStyle))
146149
return Failure("Could not apply window ex style!");
147150

148-
if (enable) {
151+
if (strstr(options, "enable")) {
149152
monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST);
150153
if (!monitor)
151154
return Failure("Could not get handle to monitor!");

plugin/shell.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ endif
1313

1414
" Configuration defaults. {{{1
1515

16+
if !exists('g:shell_fullscreen_always_on_top')
17+
" Set this to false (0) if you don't like the "always on top" behavior.
18+
let g:shell_fullscreen_always_on_top = 1
19+
endif
20+
1621
if !exists('g:shell_mappings_enabled')
1722
" Set this to false (0) if you don't like the default mappings.
1823
let g:shell_mappings_enabled = 1

0 commit comments

Comments
 (0)