Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame] | 2 | * Copyright (C) 2011 D. R. Commander. All Rights Reserved. |
Pierre Ossman | fdba3fe | 2014-01-31 13:12:18 +0100 | [diff] [blame] | 3 | * Copyright 2009-2014 Pierre Ossman for Cendio AB |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 4 | * |
| 5 | * This is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This software is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this software; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 18 | * USA. |
| 19 | */ |
| 20 | |
Peter Åstrand | c359f36 | 2011-08-23 12:04:46 +0000 | [diff] [blame] | 21 | #ifdef HAVE_CONFIG_H |
| 22 | #include <config.h> |
| 23 | #endif |
| 24 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 25 | #include <assert.h> |
DRC | b65bb93 | 2011-06-24 03:17:00 +0000 | [diff] [blame] | 26 | #ifndef _WIN32 |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 27 | #include <unistd.h> |
DRC | b65bb93 | 2011-06-24 03:17:00 +0000 | [diff] [blame] | 28 | #endif |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 29 | |
| 30 | #include <rfb/CMsgWriter.h> |
Pierre Ossman | 0068a4f | 2015-11-09 15:48:19 +0100 | [diff] [blame] | 31 | #include <rfb/CSecurity.h> |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 32 | #include <rfb/Hostname.h> |
| 33 | #include <rfb/LogWriter.h> |
Pierre Ossman | 0068a4f | 2015-11-09 15:48:19 +0100 | [diff] [blame] | 34 | #include <rfb/Security.h> |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 35 | #include <rfb/util.h> |
| 36 | #include <rfb/screenTypes.h> |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 37 | #include <rfb/fenceTypes.h> |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 38 | #include <rfb/Timer.h> |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 39 | #include <rdr/MemInStream.h> |
| 40 | #include <rdr/MemOutStream.h> |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 41 | #include <network/TcpSocket.h> |
| 42 | |
| 43 | #include <FL/Fl.H> |
| 44 | #include <FL/fl_ask.H> |
| 45 | |
| 46 | #include "CConn.h" |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 47 | #include "OptionsDialog.h" |
Pierre Ossman | 947b48d | 2014-01-27 16:52:35 +0100 | [diff] [blame] | 48 | #include "DesktopWindow.h" |
Pierre Ossman | c9dd3a4 | 2015-11-18 16:24:16 +0100 | [diff] [blame] | 49 | #include "PlatformPixelBuffer.h" |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 50 | #include "i18n.h" |
| 51 | #include "parameters.h" |
Pierre Ossman | 39ceb50 | 2011-07-12 15:54:25 +0000 | [diff] [blame] | 52 | #include "vncviewer.h" |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 53 | |
DRC | b65bb93 | 2011-06-24 03:17:00 +0000 | [diff] [blame] | 54 | #ifdef WIN32 |
| 55 | #include "win32.h" |
| 56 | #endif |
| 57 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 58 | using namespace rdr; |
| 59 | using namespace rfb; |
| 60 | using namespace std; |
| 61 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 62 | static rfb::LogWriter vlog("CConn"); |
| 63 | |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 64 | // 8 colours (1 bit per component) |
| 65 | static const PixelFormat verylowColourPF(8, 3,false, true, |
| 66 | 1, 1, 1, 2, 1, 0); |
| 67 | // 64 colours (2 bits per component) |
| 68 | static const PixelFormat lowColourPF(8, 6, false, true, |
| 69 | 3, 3, 3, 4, 2, 0); |
Pierre Ossman | b6b4dc6 | 2014-01-20 15:05:21 +0100 | [diff] [blame] | 70 | // 256 colours (2-3 bits per component) |
| 71 | static const PixelFormat mediumColourPF(8, 8, false, true, |
| 72 | 7, 7, 3, 5, 2, 0); |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 73 | |
Pierre Ossman | 2a7a8d6 | 2013-02-15 08:33:39 +0000 | [diff] [blame] | 74 | CConn::CConn(const char* vncServerName, network::Socket* socket=NULL) |
| 75 | : serverHost(0), serverPort(0), desktop(NULL), |
Pierre Ossman | 921f6c8 | 2017-02-24 12:33:09 +0100 | [diff] [blame] | 76 | frameCount(0), pixelCount(0), pendingPFChange(false), |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 77 | currentEncoding(encodingTight), lastServerEncoding((unsigned int)-1), |
| 78 | formatChange(false), encodingChange(false), |
Pierre Ossman | aa73c89 | 2011-11-15 12:13:37 +0000 | [diff] [blame] | 79 | firstUpdate(true), pendingUpdate(false), continuousUpdates(false), |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 80 | forceNonincremental(true), supportsSyncFence(false) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 81 | { |
| 82 | setShared(::shared); |
Pierre Ossman | 2a7a8d6 | 2013-02-15 08:33:39 +0000 | [diff] [blame] | 83 | sock = socket; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 84 | |
| 85 | int encNum = encodingNum(preferredEncoding); |
| 86 | if (encNum != -1) |
| 87 | currentEncoding = encNum; |
| 88 | |
Pierre Ossman | da38956 | 2011-06-09 08:24:37 +0000 | [diff] [blame] | 89 | cp.supportsLocalCursor = true; |
| 90 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 91 | cp.supportsDesktopResize = true; |
| 92 | cp.supportsExtendedDesktopSize = true; |
| 93 | cp.supportsDesktopRename = true; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 94 | |
Pierre Ossman | a22459d | 2014-03-17 14:42:10 +0100 | [diff] [blame] | 95 | if (customCompressLevel) |
| 96 | cp.compressLevel = compressLevel; |
| 97 | else |
| 98 | cp.compressLevel = -1; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 99 | |
Pierre Ossman | a22459d | 2014-03-17 14:42:10 +0100 | [diff] [blame] | 100 | if (!noJpeg) |
| 101 | cp.qualityLevel = qualityLevel; |
| 102 | else |
| 103 | cp.qualityLevel = -1; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 104 | |
Pierre Ossman | 2a7a8d6 | 2013-02-15 08:33:39 +0000 | [diff] [blame] | 105 | if(sock == NULL) { |
| 106 | try { |
| 107 | getHostAndPort(vncServerName, &serverHost, &serverPort); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 108 | |
Pierre Ossman | 2a7a8d6 | 2013-02-15 08:33:39 +0000 | [diff] [blame] | 109 | sock = new network::TcpSocket(serverHost, serverPort); |
| 110 | vlog.info(_("connected to host %s port %d"), serverHost, serverPort); |
| 111 | } catch (rdr::Exception& e) { |
| 112 | vlog.error("%s", e.str()); |
Dr. David Alan Gilbert | f4d1d89 | 2017-07-11 12:11:50 +0100 | [diff] [blame^] | 113 | if (alertOnFatalError) |
| 114 | fl_alert("%s", e.str()); |
Pierre Ossman | 2a7a8d6 | 2013-02-15 08:33:39 +0000 | [diff] [blame] | 115 | exit_vncviewer(); |
| 116 | return; |
| 117 | } |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | Fl::add_fd(sock->getFd(), FL_READ | FL_EXCEPT, socketEvent, this); |
| 121 | |
| 122 | // See callback below |
| 123 | sock->inStream().setBlockCallback(this); |
| 124 | |
| 125 | setServerName(serverHost); |
| 126 | setStreams(&sock->inStream(), &sock->outStream()); |
| 127 | |
| 128 | initialiseProtocol(); |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 129 | |
| 130 | OptionsDialog::addCallback(handleOptions, this); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | CConn::~CConn() |
| 134 | { |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 135 | OptionsDialog::removeCallback(handleOptions); |
Pierre Ossman | d9b9003 | 2015-09-23 12:18:52 +0200 | [diff] [blame] | 136 | Fl::remove_timeout(handleUpdateTimeout, this); |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 137 | |
Pierre Ossman | 6a9e2e6 | 2011-05-19 14:47:43 +0000 | [diff] [blame] | 138 | if (desktop) |
| 139 | delete desktop; |
| 140 | |
Pierre Ossman | 5e04c26 | 2011-11-09 11:31:12 +0000 | [diff] [blame] | 141 | delete [] serverHost; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 142 | if (sock) |
| 143 | Fl::remove_fd(sock->getFd()); |
| 144 | delete sock; |
| 145 | } |
| 146 | |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 147 | void CConn::refreshFramebuffer() |
| 148 | { |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 149 | forceNonincremental = true; |
| 150 | |
| 151 | // Without fences, we cannot safely trigger an update request directly |
| 152 | // but must wait for the next update to arrive. |
| 153 | if (supportsSyncFence) |
| 154 | requestNewUpdate(); |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 157 | const char *CConn::connectionInfo() |
| 158 | { |
| 159 | static char infoText[1024] = ""; |
| 160 | |
Pierre Ossman | b204643 | 2014-09-22 11:17:34 +0200 | [diff] [blame] | 161 | char scratch[100]; |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 162 | char pfStr[100]; |
Pierre Ossman | b204643 | 2014-09-22 11:17:34 +0200 | [diff] [blame] | 163 | |
| 164 | // Crude way of avoiding constant overflow checks |
| 165 | assert((sizeof(scratch) + 1) * 10 < sizeof(infoText)); |
| 166 | |
| 167 | infoText[0] = '\0'; |
| 168 | |
| 169 | snprintf(scratch, sizeof(scratch), |
| 170 | _("Desktop name: %.80s"), cp.name()); |
| 171 | strcat(infoText, scratch); |
| 172 | strcat(infoText, "\n"); |
| 173 | |
| 174 | snprintf(scratch, sizeof(scratch), |
| 175 | _("Host: %.80s port: %d"), serverHost, serverPort); |
| 176 | strcat(infoText, scratch); |
| 177 | strcat(infoText, "\n"); |
| 178 | |
| 179 | snprintf(scratch, sizeof(scratch), |
| 180 | _("Size: %d x %d"), cp.width, cp.height); |
| 181 | strcat(infoText, scratch); |
| 182 | strcat(infoText, "\n"); |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 183 | |
Pierre Ossman | 744e55c | 2014-12-03 14:00:54 +0100 | [diff] [blame] | 184 | // TRANSLATORS: Will be filled in with a string describing the |
| 185 | // protocol pixel format in a fairly language neutral way |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 186 | cp.pf().print(pfStr, 100); |
Pierre Ossman | b204643 | 2014-09-22 11:17:34 +0200 | [diff] [blame] | 187 | snprintf(scratch, sizeof(scratch), |
| 188 | _("Pixel format: %s"), pfStr); |
| 189 | strcat(infoText, scratch); |
| 190 | strcat(infoText, "\n"); |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 191 | |
Pierre Ossman | 744e55c | 2014-12-03 14:00:54 +0100 | [diff] [blame] | 192 | // TRANSLATORS: Similar to the earlier "Pixel format" string |
Pierre Ossman | b204643 | 2014-09-22 11:17:34 +0200 | [diff] [blame] | 193 | serverPF.print(pfStr, 100); |
| 194 | snprintf(scratch, sizeof(scratch), |
| 195 | _("(server default %s)"), pfStr); |
| 196 | strcat(infoText, scratch); |
| 197 | strcat(infoText, "\n"); |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 198 | |
Pierre Ossman | b204643 | 2014-09-22 11:17:34 +0200 | [diff] [blame] | 199 | snprintf(scratch, sizeof(scratch), |
| 200 | _("Requested encoding: %s"), encodingName(currentEncoding)); |
| 201 | strcat(infoText, scratch); |
| 202 | strcat(infoText, "\n"); |
| 203 | |
| 204 | snprintf(scratch, sizeof(scratch), |
| 205 | _("Last used encoding: %s"), encodingName(lastServerEncoding)); |
| 206 | strcat(infoText, scratch); |
| 207 | strcat(infoText, "\n"); |
| 208 | |
| 209 | snprintf(scratch, sizeof(scratch), |
| 210 | _("Line speed estimate: %d kbit/s"), sock->inStream().kbitsPerSecond()); |
| 211 | strcat(infoText, scratch); |
| 212 | strcat(infoText, "\n"); |
| 213 | |
| 214 | snprintf(scratch, sizeof(scratch), |
| 215 | _("Protocol version: %d.%d"), cp.majorVersion, cp.minorVersion); |
| 216 | strcat(infoText, scratch); |
| 217 | strcat(infoText, "\n"); |
| 218 | |
| 219 | snprintf(scratch, sizeof(scratch), |
| 220 | _("Security method: %s"), secTypeName(csecurity->getType())); |
| 221 | strcat(infoText, scratch); |
| 222 | strcat(infoText, "\n"); |
Pierre Ossman | 2eb1d11 | 2011-05-16 12:18:08 +0000 | [diff] [blame] | 223 | |
| 224 | return infoText; |
| 225 | } |
| 226 | |
Pierre Ossman | 921f6c8 | 2017-02-24 12:33:09 +0100 | [diff] [blame] | 227 | unsigned CConn::getFrameCount() |
| 228 | { |
| 229 | return frameCount; |
| 230 | } |
| 231 | |
| 232 | unsigned CConn::getPixelCount() |
| 233 | { |
| 234 | return pixelCount; |
| 235 | } |
| 236 | |
| 237 | unsigned CConn::getPosition() |
| 238 | { |
| 239 | return sock->inStream().pos(); |
| 240 | } |
| 241 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 242 | // The RFB core is not properly asynchronous, so it calls this callback |
| 243 | // whenever it needs to block to wait for more data. Since FLTK is |
| 244 | // monitoring the socket, we just make sure FLTK gets to run. |
| 245 | |
| 246 | void CConn::blockCallback() |
| 247 | { |
Pierre Ossman | 5102fa9 | 2015-11-18 16:23:21 +0100 | [diff] [blame] | 248 | run_mainloop(); |
Pierre Ossman | 1db7324 | 2015-09-23 12:20:32 +0200 | [diff] [blame] | 249 | |
| 250 | if (should_exit()) |
| 251 | throw rdr::Exception("Termination requested"); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 252 | } |
| 253 | |
DRC | 3e7ed81 | 2013-02-26 10:34:22 +0000 | [diff] [blame] | 254 | void CConn::socketEvent(FL_SOCKET fd, void *data) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 255 | { |
| 256 | CConn *cc; |
| 257 | static bool recursing = false; |
| 258 | |
| 259 | assert(data); |
| 260 | cc = (CConn*)data; |
| 261 | |
| 262 | // I don't think processMsg() is recursion safe, so add this check |
| 263 | if (recursing) |
| 264 | return; |
| 265 | |
| 266 | recursing = true; |
| 267 | |
| 268 | try { |
| 269 | // processMsg() only processes one message, so we need to loop |
| 270 | // until the buffers are empty or things will stall. |
| 271 | do { |
| 272 | cc->processMsg(); |
Pierre Ossman | 9a73adf | 2016-12-29 16:52:56 +0100 | [diff] [blame] | 273 | |
| 274 | // Make sure that the FLTK handling and the timers gets some CPU |
| 275 | // time in case of back to back messages |
| 276 | Fl::check(); |
| 277 | Timer::checkTimeouts(); |
| 278 | |
| 279 | // Also check if we need to stop reading and terminate |
| 280 | if (should_exit()) |
| 281 | break; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 282 | } while (cc->sock->inStream().checkNoWait(1)); |
| 283 | } catch (rdr::EndOfStream& e) { |
Pierre Ossman | ad8609a | 2012-04-26 09:04:14 +0000 | [diff] [blame] | 284 | vlog.info("%s", e.str()); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 285 | exit_vncviewer(); |
| 286 | } catch (rdr::Exception& e) { |
Pierre Ossman | ad8609a | 2012-04-26 09:04:14 +0000 | [diff] [blame] | 287 | vlog.error("%s", e.str()); |
Pierre Ossman | 1db7324 | 2015-09-23 12:20:32 +0200 | [diff] [blame] | 288 | // Somebody might already have requested us to terminate, and |
| 289 | // might have already provided an error message. |
| 290 | if (!should_exit()) |
| 291 | exit_vncviewer(e.str()); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | recursing = false; |
| 295 | } |
| 296 | |
| 297 | ////////////////////// CConnection callback methods ////////////////////// |
| 298 | |
| 299 | // serverInit() is called when the serverInit message has been received. At |
| 300 | // this point we create the desktop window and display it. We also tell the |
| 301 | // server the pixel format and encodings to use and request the first update. |
| 302 | void CConn::serverInit() |
| 303 | { |
| 304 | CConnection::serverInit(); |
| 305 | |
| 306 | // If using AutoSelect with old servers, start in FullColor |
| 307 | // mode. See comment in autoSelectFormatAndEncoding. |
| 308 | if (cp.beforeVersion(3, 8) && autoSelect) |
| 309 | fullColour.setParam(true); |
| 310 | |
| 311 | serverPF = cp.pf(); |
| 312 | |
| 313 | desktop = new DesktopWindow(cp.width, cp.height, cp.name(), serverPF, this); |
| 314 | fullColourPF = desktop->getPreferredPF(); |
| 315 | |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 316 | // Force a switch to the format and encoding we'd like |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 317 | formatChange = encodingChange = true; |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 318 | |
| 319 | // And kick off the update cycle |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 320 | requestNewUpdate(); |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 321 | |
| 322 | // This initial update request is a bit of a corner case, so we need |
| 323 | // to help out setting the correct format here. |
| 324 | assert(pendingPFChange); |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 325 | cp.setPF(pendingPF); |
| 326 | pendingPFChange = false; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | // setDesktopSize() is called when the desktop size changes (including when |
| 330 | // it is set initially). |
| 331 | void CConn::setDesktopSize(int w, int h) |
| 332 | { |
| 333 | CConnection::setDesktopSize(w,h); |
| 334 | resizeFramebuffer(); |
| 335 | } |
| 336 | |
| 337 | // setExtendedDesktopSize() is a more advanced version of setDesktopSize() |
Pierre Ossman | 28c1d54 | 2015-03-03 16:27:44 +0100 | [diff] [blame] | 338 | void CConn::setExtendedDesktopSize(unsigned reason, unsigned result, |
| 339 | int w, int h, const rfb::ScreenSet& layout) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 340 | { |
| 341 | CConnection::setExtendedDesktopSize(reason, result, w, h, layout); |
| 342 | |
| 343 | if ((reason == reasonClient) && (result != resultSuccess)) { |
| 344 | vlog.error(_("SetDesktopSize failed: %d"), result); |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | resizeFramebuffer(); |
| 349 | } |
| 350 | |
| 351 | // setName() is called when the desktop name changes |
| 352 | void CConn::setName(const char* name) |
| 353 | { |
| 354 | CConnection::setName(name); |
| 355 | if (desktop) |
| 356 | desktop->setName(name); |
| 357 | } |
| 358 | |
| 359 | // framebufferUpdateStart() is called at the beginning of an update. |
| 360 | // Here we try to send out a new framebuffer update request so that the |
| 361 | // next update can be sent out in parallel with us decoding the current |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 362 | // one. |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 363 | void CConn::framebufferUpdateStart() |
| 364 | { |
Pierre Ossman | 3da238d | 2015-11-12 12:20:05 +0100 | [diff] [blame] | 365 | CConnection::framebufferUpdateStart(); |
| 366 | |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 367 | // Note: This might not be true if sync fences are supported |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 368 | pendingUpdate = false; |
| 369 | |
| 370 | requestNewUpdate(); |
Pierre Ossman | d9b9003 | 2015-09-23 12:18:52 +0200 | [diff] [blame] | 371 | |
| 372 | // Update the screen prematurely for very slow updates |
| 373 | Fl::add_timeout(1.0, handleUpdateTimeout, this); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | // framebufferUpdateEnd() is called at the end of an update. |
| 377 | // For each rectangle, the FdInStream will have timed the speed |
| 378 | // of the connection, allowing us to select format and encoding |
| 379 | // appropriately, and then request another incremental update. |
| 380 | void CConn::framebufferUpdateEnd() |
| 381 | { |
Pierre Ossman | 3da238d | 2015-11-12 12:20:05 +0100 | [diff] [blame] | 382 | CConnection::framebufferUpdateEnd(); |
| 383 | |
Pierre Ossman | 921f6c8 | 2017-02-24 12:33:09 +0100 | [diff] [blame] | 384 | frameCount++; |
| 385 | |
Pierre Ossman | d9b9003 | 2015-09-23 12:18:52 +0200 | [diff] [blame] | 386 | Fl::remove_timeout(handleUpdateTimeout, this); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 387 | desktop->updateWindow(); |
| 388 | |
| 389 | if (firstUpdate) { |
Pierre Ossman | aa73c89 | 2011-11-15 12:13:37 +0000 | [diff] [blame] | 390 | // We need fences to make extra update requests and continuous |
| 391 | // updates "safe". See fence() for the next step. |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 392 | if (cp.supportsFence) |
| 393 | writer()->writeFence(fenceFlagRequest | fenceFlagSyncNext, 0, NULL); |
| 394 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 395 | firstUpdate = false; |
| 396 | } |
| 397 | |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 398 | // A format change has been scheduled and we are now past the update |
| 399 | // with the old format. Time to active the new one. |
| 400 | if (pendingPFChange) { |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 401 | cp.setPF(pendingPF); |
| 402 | pendingPFChange = false; |
| 403 | } |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 404 | |
| 405 | // Compute new settings based on updated bandwidth values |
| 406 | if (autoSelect) |
| 407 | autoSelectFormatAndEncoding(); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | // The rest of the callbacks are fairly self-explanatory... |
| 411 | |
| 412 | void CConn::setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs) |
| 413 | { |
Pierre Ossman | 8ca4c1d | 2014-09-22 12:54:26 +0200 | [diff] [blame] | 414 | vlog.error(_("Invalid SetColourMapEntries from server!")); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | void CConn::bell() |
| 418 | { |
| 419 | fl_beep(); |
| 420 | } |
| 421 | |
| 422 | void CConn::serverCutText(const char* str, rdr::U32 len) |
| 423 | { |
Pierre Ossman | 689c458 | 2011-05-26 15:39:41 +0000 | [diff] [blame] | 424 | char *buffer; |
| 425 | int size, ret; |
Pierre Ossman | d81e8f4 | 2011-05-19 14:47:15 +0000 | [diff] [blame] | 426 | |
Pierre Ossman | 5010488 | 2013-05-24 10:47:27 +0000 | [diff] [blame] | 427 | if (!acceptClipboard) |
| 428 | return; |
| 429 | |
Pierre Ossman | 689c458 | 2011-05-26 15:39:41 +0000 | [diff] [blame] | 430 | size = fl_utf8froma(NULL, 0, str, len); |
| 431 | if (size <= 0) |
Pierre Ossman | d81e8f4 | 2011-05-19 14:47:15 +0000 | [diff] [blame] | 432 | return; |
Pierre Ossman | 689c458 | 2011-05-26 15:39:41 +0000 | [diff] [blame] | 433 | |
| 434 | size++; |
| 435 | |
| 436 | buffer = new char[size]; |
| 437 | |
| 438 | ret = fl_utf8froma(buffer, size, str, len); |
| 439 | assert(ret < size); |
Pierre Ossman | d81e8f4 | 2011-05-19 14:47:15 +0000 | [diff] [blame] | 440 | |
Pierre Ossman | fb450fb | 2015-03-03 16:34:56 +0100 | [diff] [blame] | 441 | vlog.debug("Got clipboard data (%d bytes)", (int)strlen(buffer)); |
Pierre Ossman | d81e8f4 | 2011-05-19 14:47:15 +0000 | [diff] [blame] | 442 | |
Pierre Ossman | cf2443c | 2011-09-07 09:01:20 +0000 | [diff] [blame] | 443 | // RFB doesn't have separate selection and clipboard concepts, so we |
| 444 | // dump the data into both variants. |
Pierre Ossman | f862c2e | 2016-03-29 14:15:38 +0200 | [diff] [blame] | 445 | if (setPrimary) |
| 446 | Fl::copy(buffer, ret, 0); |
Pierre Ossman | d81e8f4 | 2011-05-19 14:47:15 +0000 | [diff] [blame] | 447 | Fl::copy(buffer, ret, 1); |
Pierre Ossman | 689c458 | 2011-05-26 15:39:41 +0000 | [diff] [blame] | 448 | |
| 449 | delete [] buffer; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Pierre Ossman | fdba3fe | 2014-01-31 13:12:18 +0100 | [diff] [blame] | 452 | void CConn::dataRect(const Rect& r, int encoding) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 453 | { |
| 454 | sock->inStream().startTiming(); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 455 | |
Pierre Ossman | fdba3fe | 2014-01-31 13:12:18 +0100 | [diff] [blame] | 456 | if (encoding != encodingCopyRect) |
| 457 | lastServerEncoding = encoding; |
| 458 | |
Pierre Ossman | 9f273e9 | 2015-11-09 16:34:54 +0100 | [diff] [blame] | 459 | CConnection::dataRect(r, encoding); |
Pierre Ossman | fdba3fe | 2014-01-31 13:12:18 +0100 | [diff] [blame] | 460 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 461 | sock->inStream().stopTiming(); |
Pierre Ossman | 921f6c8 | 2017-02-24 12:33:09 +0100 | [diff] [blame] | 462 | |
| 463 | pixelCount += r.area(); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 464 | } |
| 465 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 466 | void CConn::setCursor(int width, int height, const Point& hotspot, |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 467 | const rdr::U8* data) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 468 | { |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 469 | desktop->setCursor(width, height, hotspot, data); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 470 | } |
| 471 | |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 472 | void CConn::fence(rdr::U32 flags, unsigned len, const char data[]) |
| 473 | { |
| 474 | CMsgHandler::fence(flags, len, data); |
| 475 | |
| 476 | if (flags & fenceFlagRequest) { |
| 477 | // We handle everything synchronously so we trivially honor these modes |
| 478 | flags = flags & (fenceFlagBlockBefore | fenceFlagBlockAfter); |
| 479 | |
| 480 | writer()->writeFence(flags, len, data); |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | if (len == 0) { |
| 485 | // Initial probe |
Pierre Ossman | aa73c89 | 2011-11-15 12:13:37 +0000 | [diff] [blame] | 486 | if (flags & fenceFlagSyncNext) { |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 487 | supportsSyncFence = true; |
Pierre Ossman | aa73c89 | 2011-11-15 12:13:37 +0000 | [diff] [blame] | 488 | |
| 489 | if (cp.supportsContinuousUpdates) { |
| 490 | vlog.info(_("Enabling continuous updates")); |
| 491 | continuousUpdates = true; |
| 492 | writer()->writeEnableContinuousUpdates(true, 0, 0, cp.width, cp.height); |
| 493 | } |
| 494 | } |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 495 | } else { |
| 496 | // Pixel format change |
| 497 | rdr::MemInStream memStream(data, len); |
| 498 | PixelFormat pf; |
| 499 | |
| 500 | pf.read(&memStream); |
| 501 | |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 502 | cp.setPF(pf); |
| 503 | } |
| 504 | } |
| 505 | |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame] | 506 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 507 | ////////////////////// Internal methods ////////////////////// |
| 508 | |
| 509 | void CConn::resizeFramebuffer() |
| 510 | { |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 511 | if (!desktop) |
| 512 | return; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 513 | |
Pierre Ossman | aa73c89 | 2011-11-15 12:13:37 +0000 | [diff] [blame] | 514 | if (continuousUpdates) |
| 515 | writer()->writeEnableContinuousUpdates(true, 0, 0, cp.width, cp.height); |
| 516 | |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 517 | desktop->resizeFramebuffer(cp.width, cp.height); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | // autoSelectFormatAndEncoding() chooses the format and encoding appropriate |
| 521 | // to the connection speed: |
| 522 | // |
| 523 | // First we wait for at least one second of bandwidth measurement. |
| 524 | // |
| 525 | // Above 16Mbps (i.e. LAN), we choose the second highest JPEG quality, |
| 526 | // which should be perceptually lossless. |
| 527 | // |
| 528 | // If the bandwidth is below that, we choose a more lossy JPEG quality. |
| 529 | // |
| 530 | // If the bandwidth drops below 256 Kbps, we switch to palette mode. |
| 531 | // |
| 532 | // Note: The system here is fairly arbitrary and should be replaced |
| 533 | // with something more intelligent at the server end. |
| 534 | // |
| 535 | void CConn::autoSelectFormatAndEncoding() |
| 536 | { |
| 537 | int kbitsPerSecond = sock->inStream().kbitsPerSecond(); |
| 538 | unsigned int timeWaited = sock->inStream().timeWaited(); |
| 539 | bool newFullColour = fullColour; |
| 540 | int newQualityLevel = qualityLevel; |
| 541 | |
| 542 | // Always use Tight |
| 543 | if (currentEncoding != encodingTight) { |
| 544 | currentEncoding = encodingTight; |
| 545 | encodingChange = true; |
| 546 | } |
| 547 | |
| 548 | // Check that we have a decent bandwidth measurement |
| 549 | if ((kbitsPerSecond == 0) || (timeWaited < 10000)) |
| 550 | return; |
| 551 | |
| 552 | // Select appropriate quality level |
| 553 | if (!noJpeg) { |
| 554 | if (kbitsPerSecond > 16000) |
| 555 | newQualityLevel = 8; |
| 556 | else |
| 557 | newQualityLevel = 6; |
| 558 | |
| 559 | if (newQualityLevel != qualityLevel) { |
| 560 | vlog.info(_("Throughput %d kbit/s - changing to quality %d"), |
| 561 | kbitsPerSecond, newQualityLevel); |
| 562 | cp.qualityLevel = newQualityLevel; |
| 563 | qualityLevel.setParam(newQualityLevel); |
| 564 | encodingChange = true; |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | if (cp.beforeVersion(3, 8)) { |
| 569 | // Xvnc from TightVNC 1.2.9 sends out FramebufferUpdates with |
| 570 | // cursors "asynchronously". If this happens in the middle of a |
| 571 | // pixel format change, the server will encode the cursor with |
| 572 | // the old format, but the client will try to decode it |
| 573 | // according to the new format. This will lead to a |
| 574 | // crash. Therefore, we do not allow automatic format change for |
| 575 | // old servers. |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | // Select best color level |
| 580 | newFullColour = (kbitsPerSecond > 256); |
| 581 | if (newFullColour != fullColour) { |
| 582 | vlog.info(_("Throughput %d kbit/s - full color is now %s"), |
| 583 | kbitsPerSecond, |
| 584 | newFullColour ? _("enabled") : _("disabled")); |
| 585 | fullColour.setParam(newFullColour); |
| 586 | formatChange = true; |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | // checkEncodings() sends a setEncodings message if one is needed. |
| 591 | void CConn::checkEncodings() |
| 592 | { |
| 593 | if (encodingChange && writer()) { |
| 594 | vlog.info(_("Using %s encoding"),encodingName(currentEncoding)); |
| 595 | writer()->writeSetEncodings(currentEncoding, true); |
| 596 | encodingChange = false; |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | // requestNewUpdate() requests an update from the server, having set the |
| 601 | // format and encoding appropriately. |
| 602 | void CConn::requestNewUpdate() |
| 603 | { |
| 604 | if (formatChange) { |
| 605 | PixelFormat pf; |
| 606 | |
| 607 | /* Catch incorrect requestNewUpdate calls */ |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 608 | assert(!pendingUpdate || supportsSyncFence); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 609 | |
| 610 | if (fullColour) { |
| 611 | pf = fullColourPF; |
| 612 | } else { |
| 613 | if (lowColourLevel == 0) |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 614 | pf = verylowColourPF; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 615 | else if (lowColourLevel == 1) |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 616 | pf = lowColourPF; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 617 | else |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 618 | pf = mediumColourPF; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 619 | } |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 620 | |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 621 | if (supportsSyncFence) { |
| 622 | // We let the fence carry the pixel format and switch once we |
| 623 | // get the response back. That way we will be synchronised with |
| 624 | // when the server switches. |
| 625 | rdr::MemOutStream memStream; |
| 626 | |
| 627 | pf.write(&memStream); |
| 628 | |
| 629 | writer()->writeFence(fenceFlagRequest | fenceFlagSyncNext, |
| 630 | memStream.length(), (const char*)memStream.data()); |
| 631 | } else { |
| 632 | // New requests are sent out at the start of processing the last |
| 633 | // one, so we cannot switch our internal format right now (doing so |
| 634 | // would mean misdecoding the current update). |
| 635 | pendingPFChange = true; |
| 636 | pendingPF = pf; |
| 637 | } |
Pierre Ossman | 5d512c3 | 2011-11-04 11:42:16 +0000 | [diff] [blame] | 638 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 639 | char str[256]; |
| 640 | pf.print(str, 256); |
| 641 | vlog.info(_("Using pixel format %s"),str); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 642 | writer()->writeSetPixelFormat(pf); |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 643 | |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 644 | formatChange = false; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 645 | } |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 646 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 647 | checkEncodings(); |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 648 | |
Pierre Ossman | aa73c89 | 2011-11-15 12:13:37 +0000 | [diff] [blame] | 649 | if (forceNonincremental || !continuousUpdates) { |
| 650 | pendingUpdate = true; |
| 651 | writer()->writeFramebufferUpdateRequest(Rect(0, 0, cp.width, cp.height), |
| 652 | !forceNonincremental); |
| 653 | } |
Pierre Ossman | d4c61ce | 2011-04-29 11:18:12 +0000 | [diff] [blame] | 654 | |
| 655 | forceNonincremental = false; |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 656 | } |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 657 | |
| 658 | void CConn::handleOptions(void *data) |
| 659 | { |
| 660 | CConn *self = (CConn*)data; |
| 661 | |
| 662 | // Checking all the details of the current set of encodings is just |
| 663 | // a pain. Assume something has changed, as resending the encoding |
| 664 | // list is cheap. Avoid overriding what the auto logic has selected |
| 665 | // though. |
| 666 | if (!autoSelect) { |
| 667 | int encNum = encodingNum(preferredEncoding); |
| 668 | |
| 669 | if (encNum != -1) |
| 670 | self->currentEncoding = encNum; |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 671 | } |
| 672 | |
Pierre Ossman | da38956 | 2011-06-09 08:24:37 +0000 | [diff] [blame] | 673 | self->cp.supportsLocalCursor = true; |
| 674 | |
Pierre Ossman | a22459d | 2014-03-17 14:42:10 +0100 | [diff] [blame] | 675 | if (customCompressLevel) |
| 676 | self->cp.compressLevel = compressLevel; |
| 677 | else |
| 678 | self->cp.compressLevel = -1; |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 679 | |
Pierre Ossman | a22459d | 2014-03-17 14:42:10 +0100 | [diff] [blame] | 680 | if (!noJpeg && !autoSelect) |
| 681 | self->cp.qualityLevel = qualityLevel; |
| 682 | else |
| 683 | self->cp.qualityLevel = -1; |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 684 | |
| 685 | self->encodingChange = true; |
| 686 | |
| 687 | // Format changes refreshes the entire screen though and are therefore |
| 688 | // very costly. It's probably worth the effort to see if it is necessary |
| 689 | // here. |
| 690 | PixelFormat pf; |
| 691 | |
| 692 | if (fullColour) { |
| 693 | pf = self->fullColourPF; |
| 694 | } else { |
| 695 | if (lowColourLevel == 0) |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 696 | pf = verylowColourPF; |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 697 | else if (lowColourLevel == 1) |
| 698 | pf = lowColourPF; |
| 699 | else |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 700 | pf = mediumColourPF; |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 703 | if (!pf.equal(self->cp.pf())) { |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 704 | self->formatChange = true; |
Pierre Ossman | e28bdb2 | 2011-11-14 16:02:06 +0000 | [diff] [blame] | 705 | |
| 706 | // Without fences, we cannot safely trigger an update request directly |
| 707 | // but must wait for the next update to arrive. |
| 708 | if (self->supportsSyncFence) |
| 709 | self->requestNewUpdate(); |
| 710 | } |
Pierre Ossman | f4f3094 | 2011-05-17 09:39:07 +0000 | [diff] [blame] | 711 | } |
Pierre Ossman | d9b9003 | 2015-09-23 12:18:52 +0200 | [diff] [blame] | 712 | |
| 713 | void CConn::handleUpdateTimeout(void *data) |
| 714 | { |
| 715 | CConn *self = (CConn *)data; |
| 716 | |
| 717 | assert(self); |
| 718 | |
| 719 | self->desktop->updateWindow(); |
| 720 | |
| 721 | Fl::repeat_timeout(1.0, handleUpdateTimeout, data); |
| 722 | } |