Skip to content

Commit

Permalink
Add GuiWindowOpacity command
Browse files Browse the repository at this point in the history
Directly maps to QWidget::setWindowOpacity().
Takes a double as an argument, the valid range is 0.0 to 1.0.
  • Loading branch information
equalsraf committed Sep 5, 2020
1 parent 117f68c commit 29f9010
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ void MainWindow::init(NeovimConnector *c)
this, &MainWindow::neovimFullScreen);
connect(m_shell, &Shell::neovimGuiCloseRequest,
this, &MainWindow::neovimGuiCloseRequest);
connect(m_shell, &Shell::neovimOpacity,
this, &MainWindow::setWindowOpacity);
connect(m_nvim, &NeovimConnector::processExited,
this, &MainWindow::neovimExited);
connect(m_nvim, &NeovimConnector::error,
Expand Down
5 changes: 5 additions & 0 deletions src/gui/runtime/plugin/nvim_gui_shim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,8 @@ function! s:GuiScrollBar(enable) abort
endfunction

command! -nargs=1 GuiScrollBar call s:GuiScrollBar(<args>)

function! s:GuiWindowOpacityCommand(value) abort
call rpcnotify(0, 'Gui', 'WindowOpacity', a:value)
endfunction
command! -nargs=1 GuiWindowOpacity call s:GuiWindowOpacityCommand("<args>")
6 changes: 6 additions & 0 deletions src/gui/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,12 @@ void Shell::handleNeovimNotification(const QByteArray &name, const QVariantList&

qDebug() << "Neovim changed clipboard" << data << type << reg_name << clipboard;
QGuiApplication::clipboard()->setMimeData(clipData, clipboard);
} else if (guiEvName == "WindowOpacity" && args.size() == 2) {
bool ok = false;
auto val = args.at(1).toDouble(&ok);
if (ok) {
emit neovimOpacity(val);
}
} else if (guiEvName == "ShowContextMenu") {
emit neovimShowContextMenu();
}
Expand Down
1 change: 1 addition & 0 deletions src/gui/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Shell: public ShellWidget
void neovimResized(int rows, int cols);
void neovimAttached(bool);
void neovimMaximized(bool);
void neovimOpacity(double);
void neovimSuspend();
void neovimFullScreen(bool);
void neovimGuiCloseRequest();
Expand Down

0 comments on commit 29f9010

Please sign in to comment.