Skip to content

Commit

Permalink
Bug fix for changes to "always on top" behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed May 3, 2013
1 parent a239d6b commit 427f408
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions autoload/xolox/shell.vim
@@ -1,9 +1,9 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: May 2, 2013
" Last Change: May 3, 2013
" URL: http://peterodding.com/code/vim/shell/

let g:xolox#shell#version = '0.11'
let g:xolox#shell#version = '0.11.2'

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

Expand Down Expand Up @@ -348,7 +348,7 @@ if xolox#misc#os#is_win()

function! s:has_dll() " {{{2
try
return s:library_call('libversion', '') == '0.4'
return s:library_call('libversion', '') == '0.5'
catch
return 0
endtry
Expand Down
Binary file modified misc/shell/shell-x64.dll
Binary file not shown.
Binary file modified misc/shell/shell-x86.dll
Binary file not shown.
19 changes: 11 additions & 8 deletions misc/shell/shell.c
Expand Up @@ -101,7 +101,7 @@ __declspec(dllexport)
const char *libversion(const char *ignored) /* {{{1 */
{
(void)ignored;
return Success("0.4");
return Success("0.5");
}

__declspec(dllexport)
Expand All @@ -115,11 +115,13 @@ __declspec(dllexport)
const char *fullscreen(const char *options) /* {{{1 */
{
HWND window;
LONG styles;
LONG exStyle;
LONG styles, exStyle, enable, always_on_top;
HMONITOR monitor;
MONITORINFO info = { sizeof info };

enable = (strstr(options, "enable") != NULL);
always_on_top = (strstr(options, "always on top") != NULL);

window = GetForegroundWindow();
if (!window)
return Failure("Could not get handle to foreground window!");
Expand All @@ -132,13 +134,13 @@ const char *fullscreen(const char *options) /* {{{1 */
if (!exStyle)
return Failure("Could not query window ex style!");

if (strstr(options, "enable")) {
if (enable) {
styles ^= WS_CAPTION | WS_THICKFRAME;
if (strstr(options, "always on top"))
if (always_on_top)
exStyle |= WS_EX_TOPMOST;
} else {
styles |= WS_CAPTION | WS_THICKFRAME;
if (strstr(options, "always on top"))
if (always_on_top)
exStyle &= ~WS_EX_TOPMOST;
}

Expand All @@ -148,13 +150,14 @@ const char *fullscreen(const char *options) /* {{{1 */
if (!SetWindowLong(window, GWL_EXSTYLE, exStyle))
return Failure("Could not apply window ex style!");

if (strstr(options, "enable")) {
if (enable) {
monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST);
if (!monitor)
return Failure("Could not get handle to monitor!");
if (!GetMonitorInfo(monitor, &info))
return Failure("Could not get monitor information!");
if (!SetWindowPos(window, HWND_TOPMOST,
if (!SetWindowPos(window,
always_on_top ? HWND_TOPMOST : HWND_TOP,
info.rcMonitor.left,
info.rcMonitor.top,
info.rcMonitor.right - info.rcMonitor.left,
Expand Down

0 comments on commit 427f408

Please sign in to comment.