added winapi-call to flush clipboard (#778)

This commit is contained in:
Marco Schmid 2018-10-09 18:37:51 +02:00 committed by fourtf
parent 845c595b70
commit 770e36c10c
3 changed files with 23 additions and 0 deletions

View file

@ -11,6 +11,10 @@
#include "singletons/Updates.hpp" #include "singletons/Updates.hpp"
#include "widgets/dialogs/LastRunCrashDialog.hpp" #include "widgets/dialogs/LastRunCrashDialog.hpp"
#ifdef USEWINSDK
# include "util/WindowsHelper.hpp"
#endif
#ifdef C_USE_BREAKPAD #ifdef C_USE_BREAKPAD
# include <QBreakpadHandler.h> # include <QBreakpadHandler.h>
#endif #endif
@ -133,6 +137,11 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
chatterino::NetworkManager::deinit(); chatterino::NetworkManager::deinit();
#ifdef USEWINSDK
// flushing windows clipboard to keep copied messages
flushClipboard();
#endif
_exit(0); _exit(0);
} }
} // namespace chatterino } // namespace chatterino

View file

@ -34,6 +34,18 @@ boost::optional<UINT> getWindowDpi(HWND hwnd)
return boost::none; return boost::none;
} }
typedef HRESULT(CALLBACK *OleFlushClipboard_)();
void flushClipboard()
{
static HINSTANCE ole32 = LoadLibrary(L"Ole32.dll");
if (ole32 != nullptr) {
if (auto oleFlushClipboard = OleFlushClipboard_(GetProcAddress(ole32, "OleFlushClipboard"))) {
oleFlushClipboard();
}
}
}
} // namespace chatterino } // namespace chatterino
#endif #endif

View file

@ -8,6 +8,8 @@
namespace chatterino { namespace chatterino {
boost::optional<UINT> getWindowDpi(HWND hwnd); boost::optional<UINT> getWindowDpi(HWND hwnd);
void flushClipboard();
} // namespace chatterino } // namespace chatterino