Skip to content

Commit

Permalink
#5634: Fire the change event when the contents are different
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jun 10, 2021
1 parent fd77a0f commit 04e988e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions radiant/clipboard/ClipboardModule.cpp
@@ -1,6 +1,7 @@
#include "ClipboardModule.h"

#include "itextstream.h"
#include "math/Hash.h"
#include <wx/clipbrd.h>
#include <wx/app.h>

Expand Down Expand Up @@ -74,9 +75,18 @@ void ClipboardModule::onAppActivated(wxActivateEvent& ev)
{
if (ev.GetActive())
{
// Update the shader clipboard when the main window regains focus
// TODO
rMessage() << "App activated" << std::endl;
// Inspect the clipboard when the main window regains focus
// and fire the event if the contents changed
math::Hash hash;
hash.addString(getString());

std::string newHash = hash;

if (newHash != _contentHash)
{
_contentHash.swap(newHash);
_sigContentsChanged.emit();
}
}

ev.Skip();
Expand Down
1 change: 1 addition & 0 deletions radiant/clipboard/ClipboardModule.h
Expand Up @@ -12,6 +12,7 @@ class ClipboardModule :
{
private:
sigc::signal<void> _sigContentsChanged;
std::string _contentHash;

public:
std::string getString() override;
Expand Down

0 comments on commit 04e988e

Please sign in to comment.