Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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