Permalink
Browse files

Make it possible to disable "always on top" on Windows (issues #9 & #10)

  • Loading branch information...
1 parent 52c9b24 commit a239d6b06a3e474f99ee6d079d9165634aca8e34 @xolox committed May 2, 2013
View
@@ -74,6 +74,12 @@ This variable is a string containing any combination of the following characters
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.
+### The `g:shell_fullscreen_always_on_top` option
+
+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]:
+
+ :let g:shell_fullscreen_always_on_top = 0
+
### The `g:shell_mappings_enabled` option
If you don't like the default mappings for the `:Open` and `:Fullscreen` commands then add the following to your [vimrc script] [vimrc]:
View
@@ -3,7 +3,7 @@
" Last Change: May 2, 2013
" URL: http://peterodding.com/code/vim/shell/
-let g:xolox#shell#version = '0.10'
+let g:xolox#shell#version = '0.11'
call xolox#misc#compat#check('shell', 2)
@@ -226,7 +226,11 @@ function! xolox#shell#fullscreen() " -- toggle Vim between normal and full-scree
" custom dynamic link library on Windows or the "wmctrl" program on UNIX.
try
if xolox#misc#os#is_win() && s:has_dll()
- let error = s:library_call('fullscreen', !s:fullscreen_enabled)
+ let options = s:fullscreen_enabled ? 'disable' : 'enable'
+ if g:shell_fullscreen_always_on_top
+ let options .= ', always on top'
+ endif
+ let error = s:library_call('fullscreen', options)
if error != ''
throw "shell.dll failed with: " . error
endif
@@ -337,12 +341,14 @@ if xolox#misc#os#is_win()
let s:library = expand('<sfile>:p:h:h:h') . '\misc\shell\shell-' . s:cpu_arch . '.dll'
function! s:library_call(fn, arg) " {{{2
- return libcall(s:library, a:fn, a:arg)
+ let result = libcall(s:library, a:fn, a:arg)
+ call xolox#misc#msg#debug("Called %s:%s, returning %s", s:library, a:fn, result)
+ return result
endfunction
function! s:has_dll() " {{{2
try
- return s:library_call('libversion', '') == '0.3'
+ return s:library_call('libversion', '') == '0.4'
catch
return 0
endtry
View
@@ -14,8 +14,8 @@ Contents ~
6. The |xolox#shell#fullscreen()| function
7. The |xolox#shell#is_fullscreen()| function
8. The |g:shell_fullscreen_items| option
- 9. The |g:shell_mappings_enabled| option
- 10. The |g:shell_make_override| option
+ 9. The |g:shell_fullscreen_always_on_top| option
+ 10. The |g:shell_mappings_enabled| option
11. The |g:shell_verify_urls| option
3. Background |shell-background|
4. Other full-screen implementations |shell-other-full-screen-implementations|
@@ -173,6 +173,16 @@ set the buffer local variable 'b:shell_fullscreen_items' to change these
settings for specific buffers.
-------------------------------------------------------------------------------
+The *g:shell_fullscreen_always_on_top* option
+
+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:
+>
+ :let g:shell_fullscreen_always_on_top = 0
+
+-------------------------------------------------------------------------------
The *g:shell_mappings_enabled* option
If you don't like the default mappings for the |:Open| and |:Fullscreen|
@@ -189,9 +199,6 @@ to your |vimrc| script:
:nnoremap <Leader>op :Open<CR>
-------------------------------------------------------------------------------
-The *g:shell_make_override* option
-
--------------------------------------------------------------------------------
The *g:shell_verify_urls* option
When you use the |:Open| command or the '<F6>' mapping to open the URL under
View
Binary file not shown.
View
Binary file not shown.
View
@@ -18,7 +18,7 @@
* CL /LD shell.c shell32.lib user32.lib
*
* This should create the dynamic link library "shell.dll" which you can call
- * from Vim using for example :call libcall('c:/shell.dll', 'fullscreen', 1).
+ * from Vim using for example :call libcall('c:/shell.dll', 'fullscreen', 'enable').
*
* Happy vimming!
*
@@ -29,6 +29,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ctype.h>
+#include <string.h>
#include <shellapi.h> /* ShellExecute? */
/* Dynamic strings are returned using a static buffer to avoid memory leaks */
@@ -100,7 +101,7 @@ __declspec(dllexport)
const char *libversion(const char *ignored) /* {{{1 */
{
(void)ignored;
- return Success("0.3");
+ return Success("0.4");
}
__declspec(dllexport)
@@ -111,7 +112,7 @@ const char *openurl(const char *path) /* {{{1 */
}
__declspec(dllexport)
-const char *fullscreen(long enable) /* {{{1 */
+const char *fullscreen(const char *options) /* {{{1 */
{
HWND window;
LONG styles;
@@ -131,12 +132,14 @@ const char *fullscreen(long enable) /* {{{1 */
if (!exStyle)
return Failure("Could not query window ex style!");
- if (enable) {
+ if (strstr(options, "enable")) {
styles ^= WS_CAPTION | WS_THICKFRAME;
- exStyle |= WS_EX_TOPMOST;
+ if (strstr(options, "always on top"))
+ exStyle |= WS_EX_TOPMOST;
} else {
styles |= WS_CAPTION | WS_THICKFRAME;
- exStyle &= ~WS_EX_TOPMOST;
+ if (strstr(options, "always on top"))
+ exStyle &= ~WS_EX_TOPMOST;
}
if (!SetWindowLong(window, GWL_STYLE, styles))
@@ -145,7 +148,7 @@ const char *fullscreen(long enable) /* {{{1 */
if (!SetWindowLong(window, GWL_EXSTYLE, exStyle))
return Failure("Could not apply window ex style!");
- if (enable) {
+ if (strstr(options, "enable")) {
monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST);
if (!monitor)
return Failure("Could not get handle to monitor!");
View
@@ -13,6 +13,11 @@ endif
" Configuration defaults. {{{1
+if !exists('g:shell_fullscreen_always_on_top')
+ " Set this to false (0) if you don't like the "always on top" behavior.
+ let g:shell_fullscreen_always_on_top = 1
+endif
+
if !exists('g:shell_mappings_enabled')
" Set this to false (0) if you don't like the default mappings.
let g:shell_mappings_enabled = 1

0 comments on commit a239d6b

Please sign in to comment.