Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Nov 2, 2021
2 parents b99b789 + 02c4fdd commit 5e3036e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
5 changes: 5 additions & 0 deletions java/com/turbovnc/rfb/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ public boolean equals(DesktopSize size) {
size.height == height && size.layout.equals(layout);
}

public boolean equalsIgnoreID(DesktopSize size) {
return size.mode == mode && size.width == width &&
size.height == height && size.layout.equalsIgnoreID(layout);
}

public String getString() {
if (mode == Options.SIZE_AUTO)
return "Auto";
Expand Down
6 changes: 5 additions & 1 deletion java/com/turbovnc/rfb/Screen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright 2009 Pierre Ossman for Cendio AB
* Copyright (C) 2011 Brian P. Hinz
* Copyright (C) 2017-2018 D. R. Commander. All Rights Reserved.
* Copyright (C) 2017-2018, 2021 D. R. Commander. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -44,6 +44,10 @@ public Screen(int id_, int x_, int y_, int w_, int h_, int flags_) {
public final boolean equals(Screen r) {
if (id != r.id)
return false;
return equalsIgnoreID(r);
}

public final boolean equalsIgnoreID(Screen r) {
if (!dimensions.equals(r.dimensions))
return false;
if (flags != r.flags)
Expand Down
21 changes: 20 additions & 1 deletion java/com/turbovnc/rfb/ScreenSet.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright 2009 Pierre Ossman for Cendio AB
* Copyright 2011 Brian P. Hinz
* Copyright (C) 2017-2018 D. R. Commander. All Rights Reserved.
* Copyright (C) 2017-2018, 2021 D. R. Commander. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -59,6 +59,25 @@ public final boolean equals(ScreenSet ref) {
return true;
}

public final boolean equalsIgnoreID(ScreenSet ref) {
if (this == ref)
return true;
if (numScreens() != ref.numScreens())
return false;

Iterator<Screen> iter = screens.iterator();
Iterator<Screen> riter = ref.screens.iterator();
while (iter.hasNext() && riter.hasNext()) {
Screen screen = (Screen)iter.next();
Screen rscreen = (Screen)riter.next();

if (!screen.equalsIgnoreID(rscreen))
return false;
}

return true;
}

public final int numScreens() { return screens.size(); }

public final void addScreen(Screen screen) {
Expand Down
36 changes: 33 additions & 3 deletions java/com/turbovnc/vncviewer/CConn.java
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,32 @@ private void reconfigureViewport(boolean restore) {
}
}

private void reconfigureAndRepaintViewport(boolean restore) {
reconfigureViewport(false);
// The viewport's componentResized() method isn't guaranteed to be called
// when reconfiguring the viewport, and it generally won't be called if
// only the scaling factor has changed while in full-screen mode. Thus, we
// need to ensure that the appropriate scrollbar policy is set and the
// viewport is repainted.
if (desktop != null) {
if (opts.scalingFactor == Options.SCALE_AUTO ||
opts.scalingFactor == Options.SCALE_FIXEDRATIO) {
viewport.sp.setHorizontalScrollBarPolicy(
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
viewport.sp.setVerticalScrollBarPolicy(
ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
} else {
viewport.sp.setHorizontalScrollBarPolicy(
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
viewport.sp.setVerticalScrollBarPolicy(
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
}
viewport.sp.validate();
desktop.resize();
desktop.paintImmediately(desktop.getBounds());
}
}

// RFB thread: requestNewUpdate() requests an update from the server, having
// set the format and encoding appropriately.
private void requestNewUpdate() {
Expand Down Expand Up @@ -1604,13 +1630,17 @@ public void getOptions() {
deleteRestore = true;
savedState = -1;
savedRect = new Rectangle(-1, -1, 0, 0);
// Ideally we could recreate the viewport on all platforms, but due to a
// Java bug, doing so on macOS causes the viewer to exit full-screen
// mode.
if (!viewport.lionFSSupported() || !opts.fullScreen)
recreate = true;
else
reconfigure = true;
}

if (desktop != null && !opts.desktopSize.equals(oldOpts.desktopSize)) {
if (desktop != null &&
!opts.desktopSize.equalsIgnoreID(oldOpts.desktopSize)) {
deleteRestore = true;
savedState = -1;
savedRect = new Rectangle(-1, -1, 0, 0);
Expand Down Expand Up @@ -1662,7 +1692,7 @@ public void getOptions() {
} else if (recreate)
recreateViewport();
else if (reconfigure)
reconfigureViewport(false);
reconfigureAndRepaintViewport(false);
if (opts.showToolbar != oldOpts.showToolbar) {
if (viewport != null)
viewport.showToolbar(opts.showToolbar);
Expand All @@ -1678,7 +1708,7 @@ else if (reconfigure)
// desktop resize. Otherwise, it won't occur until the mouse is moved or
// something changes on the server (manual) or until the window is resized
// (auto.)
if (firstUpdate && state() == RFBSTATE_NORMAL) {
if ((encodingChange || firstUpdate) && state() == RFBSTATE_NORMAL) {
forceNonincremental = true;
requestNewUpdate();
}
Expand Down

0 comments on commit 5e3036e

Please sign in to comment.