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

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