Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion common/rfb/CConnection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ CConnection::CConnection()
supportsDesktopResize(false), supportsLEDState(false),
is(nullptr), os(nullptr), reader_(nullptr), writer_(nullptr),
shared(false),
state_(RFBSTATE_UNINITIALISED),
state_(RFBSTATE_UNINITIALISED), updatesEnabled(true),
pendingPFChange(false), preferredEncoding(encodingTight),
compressLevel(2), qualityLevel(-1),
formatChange(false), encodingChange(false),
Expand Down Expand Up @@ -950,10 +950,35 @@ bool CConnection::isSecure() const
return csecurity ? csecurity->isSecure() : false;
}

void CConnection::enableUpdates(bool enabled) {
if (updatesEnabled == enabled)
return;

updatesEnabled = enabled;

if (enabled) {
if (continuousUpdates)
writer()->writeEnableContinuousUpdates(true, 0, 0,
server.width(),
server.height());
pendingUpdate = true;
writer()->writeFramebufferUpdateRequest({0, 0,
server.width(),
server.height()},
!forceNonincremental);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if there already is a pending update request?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I based this code on what CConnection::requestNewUpdate() does.
Should it be done differently here? I'm not very familiar with how these updates are handled in vncviewer.

Comment on lines +965 to +968

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed if we're using continuous updates?

Comment on lines +965 to +968

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to look at forceNonincremental, then you need to reset it as well.

} else {
if (continuousUpdates)
writer()->writeEnableContinuousUpdates(false, 0, 0, 0, 0);
}
}

// requestNewUpdate() requests an update from the server, having set the
// format and encoding appropriately.
void CConnection::requestNewUpdate()
{
if (!updatesEnabled)
return;

if (formatChange && !pendingPFChange) {
/* Catch incorrect requestNewUpdate calls */
assert(!pendingUpdate || continuousUpdates);
Expand Down
4 changes: 4 additions & 0 deletions common/rfb/CConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ namespace rfb {
virtual bool verifyHostKey(const uint8_t* key, size_t length,
const char* fingerprint) = 0;

void enableUpdates(bool enabled);

protected:

// Methods overridden from CMsgHandler
Expand Down Expand Up @@ -321,6 +323,8 @@ namespace rfb {

std::string serverName;

bool updatesEnabled;

bool pendingPFChange;
rfb::PixelFormat pendingPF;

Expand Down
7 changes: 7 additions & 0 deletions vncviewer/DesktopWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,13 @@ int DesktopWindow::handle(int event)
}
// Continue processing so that the viewport also gets mouse events
break;

case FL_SHOW:
cc->enableUpdates(true);
break;
case FL_HIDE:
cc->enableUpdates(false);
break;
}

return Fl_Window::handle(event);
Expand Down
Loading