You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CConn.cxx 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
  3. * Copyright 2009-2014 Pierre Ossman for Cendio AB
  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. #ifdef HAVE_CONFIG_H
  21. #include <config.h>
  22. #endif
  23. #include <assert.h>
  24. #ifndef _WIN32
  25. #include <unistd.h>
  26. #endif
  27. #include <rfb/CMsgWriter.h>
  28. #include <rfb/encodings.h>
  29. #include <rfb/Decoder.h>
  30. #include <rfb/Hostname.h>
  31. #include <rfb/LogWriter.h>
  32. #include <rfb/util.h>
  33. #include <rfb/screenTypes.h>
  34. #include <rfb/fenceTypes.h>
  35. #include <rfb/Timer.h>
  36. #include <rdr/MemInStream.h>
  37. #include <rdr/MemOutStream.h>
  38. #include <network/TcpSocket.h>
  39. #include <FL/Fl.H>
  40. #include <FL/fl_ask.H>
  41. #include "CConn.h"
  42. #include "OptionsDialog.h"
  43. #include "DesktopWindow.h"
  44. #include "i18n.h"
  45. #include "parameters.h"
  46. #include "vncviewer.h"
  47. #ifdef WIN32
  48. #include "win32.h"
  49. #endif
  50. using namespace rdr;
  51. using namespace rfb;
  52. using namespace std;
  53. static rfb::LogWriter vlog("CConn");
  54. // 8 colours (1 bit per component)
  55. static const PixelFormat verylowColourPF(8, 3,false, true,
  56. 1, 1, 1, 2, 1, 0);
  57. // 64 colours (2 bits per component)
  58. static const PixelFormat lowColourPF(8, 6, false, true,
  59. 3, 3, 3, 4, 2, 0);
  60. // 256 colours (2-3 bits per component)
  61. static const PixelFormat mediumColourPF(8, 8, false, true,
  62. 7, 7, 3, 5, 2, 0);
  63. CConn::CConn(const char* vncServerName, network::Socket* socket=NULL)
  64. : serverHost(0), serverPort(0), desktop(NULL),
  65. pendingPFChange(false),
  66. currentEncoding(encodingTight), lastServerEncoding((unsigned int)-1),
  67. formatChange(false), encodingChange(false),
  68. firstUpdate(true), pendingUpdate(false), continuousUpdates(false),
  69. forceNonincremental(true), supportsSyncFence(false)
  70. {
  71. setShared(::shared);
  72. sock = socket;
  73. memset(decoders, 0, sizeof(decoders));
  74. int encNum = encodingNum(preferredEncoding);
  75. if (encNum != -1)
  76. currentEncoding = encNum;
  77. cp.supportsLocalCursor = true;
  78. cp.supportsDesktopResize = true;
  79. cp.supportsExtendedDesktopSize = true;
  80. cp.supportsDesktopRename = true;
  81. if (customCompressLevel)
  82. cp.compressLevel = compressLevel;
  83. else
  84. cp.compressLevel = -1;
  85. if (!noJpeg)
  86. cp.qualityLevel = qualityLevel;
  87. else
  88. cp.qualityLevel = -1;
  89. if(sock == NULL) {
  90. try {
  91. getHostAndPort(vncServerName, &serverHost, &serverPort);
  92. sock = new network::TcpSocket(serverHost, serverPort);
  93. vlog.info(_("connected to host %s port %d"), serverHost, serverPort);
  94. } catch (rdr::Exception& e) {
  95. vlog.error("%s", e.str());
  96. fl_alert("%s", e.str());
  97. exit_vncviewer();
  98. return;
  99. }
  100. }
  101. Fl::add_fd(sock->getFd(), FL_READ | FL_EXCEPT, socketEvent, this);
  102. // See callback below
  103. sock->inStream().setBlockCallback(this);
  104. setServerName(serverHost);
  105. setStreams(&sock->inStream(), &sock->outStream());
  106. initialiseProtocol();
  107. OptionsDialog::addCallback(handleOptions, this);
  108. }
  109. CConn::~CConn()
  110. {
  111. OptionsDialog::removeCallback(handleOptions);
  112. Fl::remove_timeout(handleUpdateTimeout, this);
  113. for (size_t i = 0; i < sizeof(decoders)/sizeof(decoders[0]); i++)
  114. delete decoders[i];
  115. if (desktop)
  116. delete desktop;
  117. delete [] serverHost;
  118. if (sock)
  119. Fl::remove_fd(sock->getFd());
  120. delete sock;
  121. }
  122. void CConn::refreshFramebuffer()
  123. {
  124. forceNonincremental = true;
  125. // Without fences, we cannot safely trigger an update request directly
  126. // but must wait for the next update to arrive.
  127. if (supportsSyncFence)
  128. requestNewUpdate();
  129. }
  130. const char *CConn::connectionInfo()
  131. {
  132. static char infoText[1024] = "";
  133. char scratch[100];
  134. char pfStr[100];
  135. // Crude way of avoiding constant overflow checks
  136. assert((sizeof(scratch) + 1) * 10 < sizeof(infoText));
  137. infoText[0] = '\0';
  138. snprintf(scratch, sizeof(scratch),
  139. _("Desktop name: %.80s"), cp.name());
  140. strcat(infoText, scratch);
  141. strcat(infoText, "\n");
  142. snprintf(scratch, sizeof(scratch),
  143. _("Host: %.80s port: %d"), serverHost, serverPort);
  144. strcat(infoText, scratch);
  145. strcat(infoText, "\n");
  146. snprintf(scratch, sizeof(scratch),
  147. _("Size: %d x %d"), cp.width, cp.height);
  148. strcat(infoText, scratch);
  149. strcat(infoText, "\n");
  150. // TRANSLATORS: Will be filled in with a string describing the
  151. // protocol pixel format in a fairly language neutral way
  152. cp.pf().print(pfStr, 100);
  153. snprintf(scratch, sizeof(scratch),
  154. _("Pixel format: %s"), pfStr);
  155. strcat(infoText, scratch);
  156. strcat(infoText, "\n");
  157. // TRANSLATORS: Similar to the earlier "Pixel format" string
  158. serverPF.print(pfStr, 100);
  159. snprintf(scratch, sizeof(scratch),
  160. _("(server default %s)"), pfStr);
  161. strcat(infoText, scratch);
  162. strcat(infoText, "\n");
  163. snprintf(scratch, sizeof(scratch),
  164. _("Requested encoding: %s"), encodingName(currentEncoding));
  165. strcat(infoText, scratch);
  166. strcat(infoText, "\n");
  167. snprintf(scratch, sizeof(scratch),
  168. _("Last used encoding: %s"), encodingName(lastServerEncoding));
  169. strcat(infoText, scratch);
  170. strcat(infoText, "\n");
  171. snprintf(scratch, sizeof(scratch),
  172. _("Line speed estimate: %d kbit/s"), sock->inStream().kbitsPerSecond());
  173. strcat(infoText, scratch);
  174. strcat(infoText, "\n");
  175. snprintf(scratch, sizeof(scratch),
  176. _("Protocol version: %d.%d"), cp.majorVersion, cp.minorVersion);
  177. strcat(infoText, scratch);
  178. strcat(infoText, "\n");
  179. snprintf(scratch, sizeof(scratch),
  180. _("Security method: %s"), secTypeName(csecurity->getType()));
  181. strcat(infoText, scratch);
  182. strcat(infoText, "\n");
  183. return infoText;
  184. }
  185. // The RFB core is not properly asynchronous, so it calls this callback
  186. // whenever it needs to block to wait for more data. Since FLTK is
  187. // monitoring the socket, we just make sure FLTK gets to run.
  188. void CConn::blockCallback()
  189. {
  190. int next_timer;
  191. next_timer = Timer::checkTimeouts();
  192. if (next_timer == 0)
  193. next_timer = INT_MAX;
  194. Fl::wait((double)next_timer / 1000.0);
  195. if (should_exit())
  196. throw rdr::Exception("Termination requested");
  197. }
  198. void CConn::socketEvent(FL_SOCKET fd, void *data)
  199. {
  200. CConn *cc;
  201. static bool recursing = false;
  202. assert(data);
  203. cc = (CConn*)data;
  204. // I don't think processMsg() is recursion safe, so add this check
  205. if (recursing)
  206. return;
  207. recursing = true;
  208. try {
  209. // processMsg() only processes one message, so we need to loop
  210. // until the buffers are empty or things will stall.
  211. do {
  212. cc->processMsg();
  213. } while (cc->sock->inStream().checkNoWait(1));
  214. } catch (rdr::EndOfStream& e) {
  215. vlog.info("%s", e.str());
  216. exit_vncviewer();
  217. } catch (rdr::Exception& e) {
  218. vlog.error("%s", e.str());
  219. // Somebody might already have requested us to terminate, and
  220. // might have already provided an error message.
  221. if (!should_exit())
  222. exit_vncviewer(e.str());
  223. }
  224. recursing = false;
  225. }
  226. ////////////////////// CConnection callback methods //////////////////////
  227. // serverInit() is called when the serverInit message has been received. At
  228. // this point we create the desktop window and display it. We also tell the
  229. // server the pixel format and encodings to use and request the first update.
  230. void CConn::serverInit()
  231. {
  232. CConnection::serverInit();
  233. // If using AutoSelect with old servers, start in FullColor
  234. // mode. See comment in autoSelectFormatAndEncoding.
  235. if (cp.beforeVersion(3, 8) && autoSelect)
  236. fullColour.setParam(true);
  237. serverPF = cp.pf();
  238. desktop = new DesktopWindow(cp.width, cp.height, cp.name(), serverPF, this);
  239. fullColourPF = desktop->getPreferredPF();
  240. // Force a switch to the format and encoding we'd like
  241. formatChange = encodingChange = true;
  242. // And kick off the update cycle
  243. requestNewUpdate();
  244. // This initial update request is a bit of a corner case, so we need
  245. // to help out setting the correct format here.
  246. assert(pendingPFChange);
  247. cp.setPF(pendingPF);
  248. pendingPFChange = false;
  249. }
  250. // setDesktopSize() is called when the desktop size changes (including when
  251. // it is set initially).
  252. void CConn::setDesktopSize(int w, int h)
  253. {
  254. CConnection::setDesktopSize(w,h);
  255. resizeFramebuffer();
  256. }
  257. // setExtendedDesktopSize() is a more advanced version of setDesktopSize()
  258. void CConn::setExtendedDesktopSize(unsigned reason, unsigned result,
  259. int w, int h, const rfb::ScreenSet& layout)
  260. {
  261. CConnection::setExtendedDesktopSize(reason, result, w, h, layout);
  262. if ((reason == reasonClient) && (result != resultSuccess)) {
  263. vlog.error(_("SetDesktopSize failed: %d"), result);
  264. return;
  265. }
  266. resizeFramebuffer();
  267. }
  268. // setName() is called when the desktop name changes
  269. void CConn::setName(const char* name)
  270. {
  271. CConnection::setName(name);
  272. if (desktop)
  273. desktop->setName(name);
  274. }
  275. // framebufferUpdateStart() is called at the beginning of an update.
  276. // Here we try to send out a new framebuffer update request so that the
  277. // next update can be sent out in parallel with us decoding the current
  278. // one.
  279. void CConn::framebufferUpdateStart()
  280. {
  281. // Note: This might not be true if sync fences are supported
  282. pendingUpdate = false;
  283. requestNewUpdate();
  284. // Update the screen prematurely for very slow updates
  285. Fl::add_timeout(1.0, handleUpdateTimeout, this);
  286. }
  287. // framebufferUpdateEnd() is called at the end of an update.
  288. // For each rectangle, the FdInStream will have timed the speed
  289. // of the connection, allowing us to select format and encoding
  290. // appropriately, and then request another incremental update.
  291. void CConn::framebufferUpdateEnd()
  292. {
  293. Fl::remove_timeout(handleUpdateTimeout, this);
  294. desktop->updateWindow();
  295. if (firstUpdate) {
  296. // We need fences to make extra update requests and continuous
  297. // updates "safe". See fence() for the next step.
  298. if (cp.supportsFence)
  299. writer()->writeFence(fenceFlagRequest | fenceFlagSyncNext, 0, NULL);
  300. firstUpdate = false;
  301. }
  302. // A format change has been scheduled and we are now past the update
  303. // with the old format. Time to active the new one.
  304. if (pendingPFChange) {
  305. cp.setPF(pendingPF);
  306. pendingPFChange = false;
  307. }
  308. // Compute new settings based on updated bandwidth values
  309. if (autoSelect)
  310. autoSelectFormatAndEncoding();
  311. // Make sure that the FLTK handling and the timers gets some CPU time
  312. // in case of back to back framebuffer updates.
  313. Fl::check();
  314. Timer::checkTimeouts();
  315. }
  316. // The rest of the callbacks are fairly self-explanatory...
  317. void CConn::setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs)
  318. {
  319. vlog.error(_("Invalid SetColourMapEntries from server!"));
  320. }
  321. void CConn::bell()
  322. {
  323. fl_beep();
  324. }
  325. void CConn::serverCutText(const char* str, rdr::U32 len)
  326. {
  327. char *buffer;
  328. int size, ret;
  329. if (!acceptClipboard)
  330. return;
  331. size = fl_utf8froma(NULL, 0, str, len);
  332. if (size <= 0)
  333. return;
  334. size++;
  335. buffer = new char[size];
  336. ret = fl_utf8froma(buffer, size, str, len);
  337. assert(ret < size);
  338. vlog.debug("Got clipboard data (%d bytes)", (int)strlen(buffer));
  339. // RFB doesn't have separate selection and clipboard concepts, so we
  340. // dump the data into both variants.
  341. Fl::copy(buffer, ret, 0);
  342. Fl::copy(buffer, ret, 1);
  343. delete [] buffer;
  344. }
  345. void CConn::dataRect(const Rect& r, int encoding)
  346. {
  347. sock->inStream().startTiming();
  348. if (encoding != encodingCopyRect)
  349. lastServerEncoding = encoding;
  350. if (!Decoder::supported(encoding)) {
  351. // TRANSLATORS: Refers to a VNC protocol encoding type
  352. vlog.error(_("Unknown encoding %d"), encoding);
  353. throw Exception(_("Unknown encoding"));
  354. }
  355. if (!decoders[encoding]) {
  356. decoders[encoding] = Decoder::createDecoder(encoding, this);
  357. if (!decoders[encoding]) {
  358. vlog.error(_("Unknown encoding %d"), encoding);
  359. throw Exception(_("Unknown encoding"));
  360. }
  361. }
  362. decoders[encoding]->readRect(r, desktop->getFramebuffer());
  363. sock->inStream().stopTiming();
  364. }
  365. void CConn::setCursor(int width, int height, const Point& hotspot,
  366. void* data, void* mask)
  367. {
  368. desktop->setCursor(width, height, hotspot, data, mask);
  369. }
  370. void CConn::fence(rdr::U32 flags, unsigned len, const char data[])
  371. {
  372. CMsgHandler::fence(flags, len, data);
  373. if (flags & fenceFlagRequest) {
  374. // We handle everything synchronously so we trivially honor these modes
  375. flags = flags & (fenceFlagBlockBefore | fenceFlagBlockAfter);
  376. writer()->writeFence(flags, len, data);
  377. return;
  378. }
  379. if (len == 0) {
  380. // Initial probe
  381. if (flags & fenceFlagSyncNext) {
  382. supportsSyncFence = true;
  383. if (cp.supportsContinuousUpdates) {
  384. vlog.info(_("Enabling continuous updates"));
  385. continuousUpdates = true;
  386. writer()->writeEnableContinuousUpdates(true, 0, 0, cp.width, cp.height);
  387. }
  388. }
  389. } else {
  390. // Pixel format change
  391. rdr::MemInStream memStream(data, len);
  392. PixelFormat pf;
  393. pf.read(&memStream);
  394. cp.setPF(pf);
  395. }
  396. }
  397. ////////////////////// Internal methods //////////////////////
  398. void CConn::resizeFramebuffer()
  399. {
  400. if (!desktop)
  401. return;
  402. if (continuousUpdates)
  403. writer()->writeEnableContinuousUpdates(true, 0, 0, cp.width, cp.height);
  404. desktop->resizeFramebuffer(cp.width, cp.height);
  405. }
  406. // autoSelectFormatAndEncoding() chooses the format and encoding appropriate
  407. // to the connection speed:
  408. //
  409. // First we wait for at least one second of bandwidth measurement.
  410. //
  411. // Above 16Mbps (i.e. LAN), we choose the second highest JPEG quality,
  412. // which should be perceptually lossless.
  413. //
  414. // If the bandwidth is below that, we choose a more lossy JPEG quality.
  415. //
  416. // If the bandwidth drops below 256 Kbps, we switch to palette mode.
  417. //
  418. // Note: The system here is fairly arbitrary and should be replaced
  419. // with something more intelligent at the server end.
  420. //
  421. void CConn::autoSelectFormatAndEncoding()
  422. {
  423. int kbitsPerSecond = sock->inStream().kbitsPerSecond();
  424. unsigned int timeWaited = sock->inStream().timeWaited();
  425. bool newFullColour = fullColour;
  426. int newQualityLevel = qualityLevel;
  427. // Always use Tight
  428. if (currentEncoding != encodingTight) {
  429. currentEncoding = encodingTight;
  430. encodingChange = true;
  431. }
  432. // Check that we have a decent bandwidth measurement
  433. if ((kbitsPerSecond == 0) || (timeWaited < 10000))
  434. return;
  435. // Select appropriate quality level
  436. if (!noJpeg) {
  437. if (kbitsPerSecond > 16000)
  438. newQualityLevel = 8;
  439. else
  440. newQualityLevel = 6;
  441. if (newQualityLevel != qualityLevel) {
  442. vlog.info(_("Throughput %d kbit/s - changing to quality %d"),
  443. kbitsPerSecond, newQualityLevel);
  444. cp.qualityLevel = newQualityLevel;
  445. qualityLevel.setParam(newQualityLevel);
  446. encodingChange = true;
  447. }
  448. }
  449. if (cp.beforeVersion(3, 8)) {
  450. // Xvnc from TightVNC 1.2.9 sends out FramebufferUpdates with
  451. // cursors "asynchronously". If this happens in the middle of a
  452. // pixel format change, the server will encode the cursor with
  453. // the old format, but the client will try to decode it
  454. // according to the new format. This will lead to a
  455. // crash. Therefore, we do not allow automatic format change for
  456. // old servers.
  457. return;
  458. }
  459. // Select best color level
  460. newFullColour = (kbitsPerSecond > 256);
  461. if (newFullColour != fullColour) {
  462. vlog.info(_("Throughput %d kbit/s - full color is now %s"),
  463. kbitsPerSecond,
  464. newFullColour ? _("enabled") : _("disabled"));
  465. fullColour.setParam(newFullColour);
  466. formatChange = true;
  467. }
  468. }
  469. // checkEncodings() sends a setEncodings message if one is needed.
  470. void CConn::checkEncodings()
  471. {
  472. if (encodingChange && writer()) {
  473. vlog.info(_("Using %s encoding"),encodingName(currentEncoding));
  474. writer()->writeSetEncodings(currentEncoding, true);
  475. encodingChange = false;
  476. }
  477. }
  478. // requestNewUpdate() requests an update from the server, having set the
  479. // format and encoding appropriately.
  480. void CConn::requestNewUpdate()
  481. {
  482. if (formatChange) {
  483. PixelFormat pf;
  484. /* Catch incorrect requestNewUpdate calls */
  485. assert(!pendingUpdate || supportsSyncFence);
  486. if (fullColour) {
  487. pf = fullColourPF;
  488. } else {
  489. if (lowColourLevel == 0)
  490. pf = verylowColourPF;
  491. else if (lowColourLevel == 1)
  492. pf = lowColourPF;
  493. else
  494. pf = mediumColourPF;
  495. }
  496. if (supportsSyncFence) {
  497. // We let the fence carry the pixel format and switch once we
  498. // get the response back. That way we will be synchronised with
  499. // when the server switches.
  500. rdr::MemOutStream memStream;
  501. pf.write(&memStream);
  502. writer()->writeFence(fenceFlagRequest | fenceFlagSyncNext,
  503. memStream.length(), (const char*)memStream.data());
  504. } else {
  505. // New requests are sent out at the start of processing the last
  506. // one, so we cannot switch our internal format right now (doing so
  507. // would mean misdecoding the current update).
  508. pendingPFChange = true;
  509. pendingPF = pf;
  510. }
  511. char str[256];
  512. pf.print(str, 256);
  513. vlog.info(_("Using pixel format %s"),str);
  514. writer()->writeSetPixelFormat(pf);
  515. formatChange = false;
  516. }
  517. checkEncodings();
  518. if (forceNonincremental || !continuousUpdates) {
  519. pendingUpdate = true;
  520. writer()->writeFramebufferUpdateRequest(Rect(0, 0, cp.width, cp.height),
  521. !forceNonincremental);
  522. }
  523. forceNonincremental = false;
  524. }
  525. void CConn::handleOptions(void *data)
  526. {
  527. CConn *self = (CConn*)data;
  528. // Checking all the details of the current set of encodings is just
  529. // a pain. Assume something has changed, as resending the encoding
  530. // list is cheap. Avoid overriding what the auto logic has selected
  531. // though.
  532. if (!autoSelect) {
  533. int encNum = encodingNum(preferredEncoding);
  534. if (encNum != -1)
  535. self->currentEncoding = encNum;
  536. }
  537. self->cp.supportsLocalCursor = true;
  538. if (customCompressLevel)
  539. self->cp.compressLevel = compressLevel;
  540. else
  541. self->cp.compressLevel = -1;
  542. if (!noJpeg && !autoSelect)
  543. self->cp.qualityLevel = qualityLevel;
  544. else
  545. self->cp.qualityLevel = -1;
  546. self->encodingChange = true;
  547. // Format changes refreshes the entire screen though and are therefore
  548. // very costly. It's probably worth the effort to see if it is necessary
  549. // here.
  550. PixelFormat pf;
  551. if (fullColour) {
  552. pf = self->fullColourPF;
  553. } else {
  554. if (lowColourLevel == 0)
  555. pf = verylowColourPF;
  556. else if (lowColourLevel == 1)
  557. pf = lowColourPF;
  558. else
  559. pf = mediumColourPF;
  560. }
  561. if (!pf.equal(self->cp.pf())) {
  562. self->formatChange = true;
  563. // Without fences, we cannot safely trigger an update request directly
  564. // but must wait for the next update to arrive.
  565. if (self->supportsSyncFence)
  566. self->requestNewUpdate();
  567. }
  568. }
  569. void CConn::handleUpdateTimeout(void *data)
  570. {
  571. CConn *self = (CConn *)data;
  572. assert(self);
  573. self->desktop->updateWindow();
  574. Fl::repeat_timeout(1.0, handleUpdateTimeout, data);
  575. }