blob: 46dcd22880eb007c32915912f5427c6d38823cd0 [file] [log] [blame]
Pierre Ossman5156d5e2011-03-09 09:42:34 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 * Copyright 2009-2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
DRC33c15e32011-11-03 18:49:21 +00003 * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
Pierre Ossman5156d5e2011-03-09 09:42:34 +00004 *
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 Åstrandc359f362011-08-23 12:04:46 +000021#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
Pierre Ossman5156d5e2011-03-09 09:42:34 +000025#include <assert.h>
DRCb65bb932011-06-24 03:17:00 +000026#ifndef _WIN32
Pierre Ossman5156d5e2011-03-09 09:42:34 +000027#include <unistd.h>
DRCb65bb932011-06-24 03:17:00 +000028#endif
Pierre Ossman5156d5e2011-03-09 09:42:34 +000029
30#include <rfb/CMsgWriter.h>
31#include <rfb/encodings.h>
32#include <rfb/Hostname.h>
33#include <rfb/LogWriter.h>
34#include <rfb/util.h>
35#include <rfb/screenTypes.h>
36#include <rfb/Timer.h>
37#include <network/TcpSocket.h>
38
39#include <FL/Fl.H>
40#include <FL/fl_ask.H>
41
42#include "CConn.h"
Pierre Ossmanf4f30942011-05-17 09:39:07 +000043#include "OptionsDialog.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000044#include "i18n.h"
45#include "parameters.h"
Pierre Ossman39ceb502011-07-12 15:54:25 +000046#include "vncviewer.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000047
DRCb65bb932011-06-24 03:17:00 +000048#ifdef WIN32
49#include "win32.h"
50#endif
51
Pierre Ossman5156d5e2011-03-09 09:42:34 +000052using namespace rdr;
53using namespace rfb;
54using namespace std;
55
Pierre Ossman5156d5e2011-03-09 09:42:34 +000056static rfb::LogWriter vlog("CConn");
57
Pierre Ossmancf836f22011-07-14 14:34:09 +000058// 8 colours (1 bit per component)
59static const PixelFormat verylowColourPF(8, 3,false, true,
60 1, 1, 1, 2, 1, 0);
61// 64 colours (2 bits per component)
62static const PixelFormat lowColourPF(8, 6, false, true,
63 3, 3, 3, 4, 2, 0);
64// 256 colours (palette)
65static const PixelFormat mediumColourPF(8, 8, false, false);
Pierre Ossmanf4f30942011-05-17 09:39:07 +000066
Pierre Ossman5156d5e2011-03-09 09:42:34 +000067CConn::CConn(const char* vncServerName)
68 : serverHost(0), serverPort(0), sock(NULL), desktop(NULL),
Pierre Ossman5d512c32011-11-04 11:42:16 +000069 pendingPFChange(false),
Pierre Ossman5156d5e2011-03-09 09:42:34 +000070 currentEncoding(encodingTight), lastServerEncoding((unsigned int)-1),
71 formatChange(false), encodingChange(false),
Pierre Ossmand4c61ce2011-04-29 11:18:12 +000072 firstUpdate(true), pendingUpdate(false),
Pierre Ossmanfba3e862011-07-15 13:45:19 +000073 forceNonincremental(true)
Pierre Ossman5156d5e2011-03-09 09:42:34 +000074{
75 setShared(::shared);
76
77 int encNum = encodingNum(preferredEncoding);
78 if (encNum != -1)
79 currentEncoding = encNum;
80
Pierre Ossmanda389562011-06-09 08:24:37 +000081 cp.supportsLocalCursor = true;
82
Pierre Ossman5156d5e2011-03-09 09:42:34 +000083 cp.supportsDesktopResize = true;
84 cp.supportsExtendedDesktopSize = true;
85 cp.supportsDesktopRename = true;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000086
87 cp.customCompressLevel = customCompressLevel;
88 cp.compressLevel = compressLevel;
89
90 cp.noJpeg = noJpeg;
91 cp.qualityLevel = qualityLevel;
92
93 try {
94 getHostAndPort(vncServerName, &serverHost, &serverPort);
95
96 sock = new network::TcpSocket(serverHost, serverPort);
97 vlog.info(_("connected to host %s port %d"), serverHost, serverPort);
98 } catch (rdr::Exception& e) {
99 vlog.error(e.str());
100 fl_alert(e.str());
101 exit_vncviewer();
102 return;
103 }
104
105 Fl::add_fd(sock->getFd(), FL_READ | FL_EXCEPT, socketEvent, this);
106
107 // See callback below
108 sock->inStream().setBlockCallback(this);
109
110 setServerName(serverHost);
111 setStreams(&sock->inStream(), &sock->outStream());
112
113 initialiseProtocol();
Pierre Ossmanf4f30942011-05-17 09:39:07 +0000114
115 OptionsDialog::addCallback(handleOptions, this);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000116}
117
118CConn::~CConn()
119{
Pierre Ossmanf4f30942011-05-17 09:39:07 +0000120 OptionsDialog::removeCallback(handleOptions);
121
Pierre Ossman6a9e2e62011-05-19 14:47:43 +0000122 if (desktop)
123 delete desktop;
124
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000125 free(serverHost);
126 if (sock)
127 Fl::remove_fd(sock->getFd());
128 delete sock;
129}
130
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000131void CConn::refreshFramebuffer()
132{
133 // FIXME: We cannot safely trigger an update request directly but must
134 // wait for the next update to arrive.
135 if (!formatChange)
136 forceNonincremental = true;
137}
138
Pierre Ossman2eb1d112011-05-16 12:18:08 +0000139const char *CConn::connectionInfo()
140{
141 static char infoText[1024] = "";
142
143 char pfStr[100];
144 char spfStr[100];
145
146 cp.pf().print(pfStr, 100);
147 serverPF.print(spfStr, 100);
148
149 int secType = csecurity->getType();
150
151 snprintf(infoText, sizeof(infoText),
152 _("Desktop name: %.80s\n"
153 "Host: %.80s port: %d\n"
154 "Size: %d x %d\n"
155 "Pixel format: %s\n"
156 "(server default %s)\n"
157 "Requested encoding: %s\n"
158 "Last used encoding: %s\n"
159 "Line speed estimate: %d kbit/s\n"
160 "Protocol version: %d.%d\n"
161 "Security method: %s\n"),
162 cp.name(), serverHost, serverPort, cp.width, cp.height,
163 pfStr, spfStr, encodingName(currentEncoding),
164 encodingName(lastServerEncoding),
165 sock->inStream().kbitsPerSecond(),
166 cp.majorVersion, cp.minorVersion,
167 secTypeName(secType));
168
169 return infoText;
170}
171
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000172// The RFB core is not properly asynchronous, so it calls this callback
173// whenever it needs to block to wait for more data. Since FLTK is
174// monitoring the socket, we just make sure FLTK gets to run.
175
176void CConn::blockCallback()
177{
178 int next_timer;
179
180 next_timer = Timer::checkTimeouts();
181 if (next_timer == 0)
182 next_timer = INT_MAX;
183
184 Fl::wait((double)next_timer / 1000.0);
185}
186
187void CConn::socketEvent(int fd, void *data)
188{
189 CConn *cc;
190 static bool recursing = false;
191
192 assert(data);
193 cc = (CConn*)data;
194
195 // I don't think processMsg() is recursion safe, so add this check
196 if (recursing)
197 return;
198
199 recursing = true;
200
201 try {
202 // processMsg() only processes one message, so we need to loop
203 // until the buffers are empty or things will stall.
204 do {
205 cc->processMsg();
206 } while (cc->sock->inStream().checkNoWait(1));
207 } catch (rdr::EndOfStream& e) {
208 vlog.info(e.str());
209 exit_vncviewer();
210 } catch (rdr::Exception& e) {
211 vlog.error(e.str());
Pierre Ossmane2ef5c12011-07-12 16:56:34 +0000212 exit_vncviewer(e.str());
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000213 }
214
215 recursing = false;
216}
217
218////////////////////// CConnection callback methods //////////////////////
219
220// serverInit() is called when the serverInit message has been received. At
221// this point we create the desktop window and display it. We also tell the
222// server the pixel format and encodings to use and request the first update.
223void CConn::serverInit()
224{
225 CConnection::serverInit();
226
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
232 serverPF = cp.pf();
233
234 desktop = new DesktopWindow(cp.width, cp.height, cp.name(), serverPF, this);
235 fullColourPF = desktop->getPreferredPF();
236
Pierre Ossman5d512c32011-11-04 11:42:16 +0000237 // Force a switch to the format and encoding we'd like
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000238 formatChange = encodingChange = true;
Pierre Ossman5d512c32011-11-04 11:42:16 +0000239
240 // And kick off the update cycle
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000241 requestNewUpdate();
Pierre Ossman5d512c32011-11-04 11:42:16 +0000242
243 // This initial update request is a bit of a corner case, so we need
244 // to help out setting the correct format here.
245 assert(pendingPFChange);
246 desktop->setServerPF(pendingPF);
247 cp.setPF(pendingPF);
248 pendingPFChange = false;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000249}
250
251// setDesktopSize() is called when the desktop size changes (including when
252// it is set initially).
253void CConn::setDesktopSize(int w, int h)
254{
255 CConnection::setDesktopSize(w,h);
256 resizeFramebuffer();
257}
258
259// setExtendedDesktopSize() is a more advanced version of setDesktopSize()
260void CConn::setExtendedDesktopSize(int reason, int result, int w, int h,
261 const rfb::ScreenSet& layout)
262{
263 CConnection::setExtendedDesktopSize(reason, result, w, h, layout);
264
265 if ((reason == reasonClient) && (result != resultSuccess)) {
266 vlog.error(_("SetDesktopSize failed: %d"), result);
267 return;
268 }
269
270 resizeFramebuffer();
271}
272
273// setName() is called when the desktop name changes
274void CConn::setName(const char* name)
275{
276 CConnection::setName(name);
277 if (desktop)
278 desktop->setName(name);
279}
280
281// framebufferUpdateStart() is called at the beginning of an update.
282// Here we try to send out a new framebuffer update request so that the
283// next update can be sent out in parallel with us decoding the current
Pierre Ossman5d512c32011-11-04 11:42:16 +0000284// one.
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000285void CConn::framebufferUpdateStart()
286{
Pierre Ossman5d512c32011-11-04 11:42:16 +0000287 pendingUpdate = false;
288
289 requestNewUpdate();
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000290}
291
292// framebufferUpdateEnd() is called at the end of an update.
293// For each rectangle, the FdInStream will have timed the speed
294// of the connection, allowing us to select format and encoding
295// appropriately, and then request another incremental update.
296void CConn::framebufferUpdateEnd()
297{
298 desktop->updateWindow();
299
300 if (firstUpdate) {
301 int width, height;
302
303 if (cp.supportsSetDesktopSize &&
304 sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) == 2) {
305 ScreenSet layout;
306
307 layout = cp.screenLayout;
308
309 if (layout.num_screens() == 0)
310 layout.add_screen(rfb::Screen());
311 else if (layout.num_screens() != 1) {
312 ScreenSet::iterator iter;
313
314 while (true) {
315 iter = layout.begin();
316 ++iter;
317
318 if (iter == layout.end())
319 break;
320
321 layout.remove_screen(iter->id);
322 }
323 }
324
325 layout.begin()->dimensions.tl.x = 0;
326 layout.begin()->dimensions.tl.y = 0;
327 layout.begin()->dimensions.br.x = width;
328 layout.begin()->dimensions.br.y = height;
329
330 writer()->writeSetDesktopSize(width, height, layout);
331 }
332
333 firstUpdate = false;
334 }
335
Pierre Ossman5d512c32011-11-04 11:42:16 +0000336 // A format change has been scheduled and we are now past the update
337 // with the old format. Time to active the new one.
338 if (pendingPFChange) {
339 desktop->setServerPF(pendingPF);
340 cp.setPF(pendingPF);
341 pendingPFChange = false;
342 }
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000343
344 // Compute new settings based on updated bandwidth values
345 if (autoSelect)
346 autoSelectFormatAndEncoding();
347
348 // Make sure that the FLTK handling and the timers gets some CPU time
349 // in case of back to back framebuffer updates.
350 Fl::check();
351 Timer::checkTimeouts();
352}
353
354// The rest of the callbacks are fairly self-explanatory...
355
356void CConn::setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs)
357{
358 desktop->setColourMapEntries(firstColour, nColours, rgbs);
359}
360
361void CConn::bell()
362{
363 fl_beep();
364}
365
366void CConn::serverCutText(const char* str, rdr::U32 len)
367{
Pierre Ossman689c4582011-05-26 15:39:41 +0000368 char *buffer;
369 int size, ret;
Pierre Ossmand81e8f42011-05-19 14:47:15 +0000370
Pierre Ossman689c4582011-05-26 15:39:41 +0000371 size = fl_utf8froma(NULL, 0, str, len);
372 if (size <= 0)
Pierre Ossmand81e8f42011-05-19 14:47:15 +0000373 return;
Pierre Ossman689c4582011-05-26 15:39:41 +0000374
375 size++;
376
377 buffer = new char[size];
378
379 ret = fl_utf8froma(buffer, size, str, len);
380 assert(ret < size);
Pierre Ossmand81e8f42011-05-19 14:47:15 +0000381
382 vlog.debug("Got clipboard data: '%s'", buffer);
383
Pierre Ossmancf2443c2011-09-07 09:01:20 +0000384 // RFB doesn't have separate selection and clipboard concepts, so we
385 // dump the data into both variants.
386 Fl::copy(buffer, ret, 0);
Pierre Ossmand81e8f42011-05-19 14:47:15 +0000387 Fl::copy(buffer, ret, 1);
Pierre Ossman689c4582011-05-26 15:39:41 +0000388
389 delete [] buffer;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000390}
391
392// We start timing on beginRect and stop timing on endRect, to
393// avoid skewing the bandwidth estimation as a result of the server
394// being slow or the network having high latency
395void CConn::beginRect(const Rect& r, int encoding)
396{
397 sock->inStream().startTiming();
398 if (encoding != encodingCopyRect) {
399 lastServerEncoding = encoding;
400 }
401}
402
403void CConn::endRect(const Rect& r, int encoding)
404{
405 sock->inStream().stopTiming();
406}
407
408void CConn::fillRect(const rfb::Rect& r, rfb::Pixel p)
409{
410 desktop->fillRect(r,p);
411}
412void CConn::imageRect(const rfb::Rect& r, void* p)
413{
414 desktop->imageRect(r,p);
415}
416void CConn::copyRect(const rfb::Rect& r, int sx, int sy)
417{
418 desktop->copyRect(r,sx,sy);
419}
420void CConn::setCursor(int width, int height, const Point& hotspot,
421 void* data, void* mask)
422{
Pierre Ossman835b4ef2011-06-08 17:02:36 +0000423 desktop->setCursor(width, height, hotspot, data, mask);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000424}
425
DRC33c15e32011-11-03 18:49:21 +0000426rdr::U8* CConn::getRawPixelsRW(const rfb::Rect& r, int* stride) {
427 return desktop->getPixelsRW(r, stride);
428}
429void CConn::releaseRawPixels(const rfb::Rect& r) {
430 desktop->damageRect(r);
431}
432
433
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000434////////////////////// Internal methods //////////////////////
435
436void CConn::resizeFramebuffer()
437{
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000438 if (!desktop)
439 return;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000440
Pierre Ossman6455d852011-06-01 09:33:00 +0000441 desktop->resizeFramebuffer(cp.width, cp.height);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000442}
443
444// autoSelectFormatAndEncoding() chooses the format and encoding appropriate
445// to the connection speed:
446//
447// First we wait for at least one second of bandwidth measurement.
448//
449// Above 16Mbps (i.e. LAN), we choose the second highest JPEG quality,
450// which should be perceptually lossless.
451//
452// If the bandwidth is below that, we choose a more lossy JPEG quality.
453//
454// If the bandwidth drops below 256 Kbps, we switch to palette mode.
455//
456// Note: The system here is fairly arbitrary and should be replaced
457// with something more intelligent at the server end.
458//
459void CConn::autoSelectFormatAndEncoding()
460{
461 int kbitsPerSecond = sock->inStream().kbitsPerSecond();
462 unsigned int timeWaited = sock->inStream().timeWaited();
463 bool newFullColour = fullColour;
464 int newQualityLevel = qualityLevel;
465
466 // Always use Tight
467 if (currentEncoding != encodingTight) {
468 currentEncoding = encodingTight;
469 encodingChange = true;
470 }
471
472 // Check that we have a decent bandwidth measurement
473 if ((kbitsPerSecond == 0) || (timeWaited < 10000))
474 return;
475
476 // Select appropriate quality level
477 if (!noJpeg) {
478 if (kbitsPerSecond > 16000)
479 newQualityLevel = 8;
480 else
481 newQualityLevel = 6;
482
483 if (newQualityLevel != qualityLevel) {
484 vlog.info(_("Throughput %d kbit/s - changing to quality %d"),
485 kbitsPerSecond, newQualityLevel);
486 cp.qualityLevel = newQualityLevel;
487 qualityLevel.setParam(newQualityLevel);
488 encodingChange = true;
489 }
490 }
491
492 if (cp.beforeVersion(3, 8)) {
493 // Xvnc from TightVNC 1.2.9 sends out FramebufferUpdates with
494 // cursors "asynchronously". If this happens in the middle of a
495 // pixel format change, the server will encode the cursor with
496 // the old format, but the client will try to decode it
497 // according to the new format. This will lead to a
498 // crash. Therefore, we do not allow automatic format change for
499 // old servers.
500 return;
501 }
502
503 // Select best color level
504 newFullColour = (kbitsPerSecond > 256);
505 if (newFullColour != fullColour) {
506 vlog.info(_("Throughput %d kbit/s - full color is now %s"),
507 kbitsPerSecond,
508 newFullColour ? _("enabled") : _("disabled"));
509 fullColour.setParam(newFullColour);
510 formatChange = true;
511 }
512}
513
514// checkEncodings() sends a setEncodings message if one is needed.
515void CConn::checkEncodings()
516{
517 if (encodingChange && writer()) {
518 vlog.info(_("Using %s encoding"),encodingName(currentEncoding));
519 writer()->writeSetEncodings(currentEncoding, true);
520 encodingChange = false;
521 }
522}
523
524// requestNewUpdate() requests an update from the server, having set the
525// format and encoding appropriately.
526void CConn::requestNewUpdate()
527{
528 if (formatChange) {
529 PixelFormat pf;
530
531 /* Catch incorrect requestNewUpdate calls */
532 assert(pendingUpdate == false);
533
534 if (fullColour) {
535 pf = fullColourPF;
536 } else {
537 if (lowColourLevel == 0)
Pierre Ossmancf836f22011-07-14 14:34:09 +0000538 pf = verylowColourPF;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000539 else if (lowColourLevel == 1)
Pierre Ossmanf4f30942011-05-17 09:39:07 +0000540 pf = lowColourPF;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000541 else
Pierre Ossmancf836f22011-07-14 14:34:09 +0000542 pf = mediumColourPF;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000543 }
Pierre Ossman5d512c32011-11-04 11:42:16 +0000544
545 // New requests are sent out at the start of processing the last
546 // one, so we cannot switch our internal format right now (doing so
547 // would mean misdecoding the current update).
548 pendingPFChange = true;
549 pendingPF = pf;
550
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000551 char str[256];
552 pf.print(str, 256);
553 vlog.info(_("Using pixel format %s"),str);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000554 writer()->writeSetPixelFormat(pf);
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000555
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000556 formatChange = false;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000557 }
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000558
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000559 checkEncodings();
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000560
Pierre Ossman5d512c32011-11-04 11:42:16 +0000561 pendingUpdate = true;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000562 writer()->writeFramebufferUpdateRequest(Rect(0, 0, cp.width, cp.height),
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000563 !forceNonincremental);
564
565 forceNonincremental = false;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000566}
Pierre Ossmanf4f30942011-05-17 09:39:07 +0000567
568void CConn::handleOptions(void *data)
569{
570 CConn *self = (CConn*)data;
571
572 // Checking all the details of the current set of encodings is just
573 // a pain. Assume something has changed, as resending the encoding
574 // list is cheap. Avoid overriding what the auto logic has selected
575 // though.
576 if (!autoSelect) {
577 int encNum = encodingNum(preferredEncoding);
578
579 if (encNum != -1)
580 self->currentEncoding = encNum;
581
582 self->cp.qualityLevel = qualityLevel;
583 }
584
Pierre Ossmanda389562011-06-09 08:24:37 +0000585 self->cp.supportsLocalCursor = true;
586
Pierre Ossmanf4f30942011-05-17 09:39:07 +0000587 self->cp.customCompressLevel = customCompressLevel;
588 self->cp.compressLevel = compressLevel;
589
590 self->cp.noJpeg = noJpeg;
591
592 self->encodingChange = true;
593
594 // Format changes refreshes the entire screen though and are therefore
595 // very costly. It's probably worth the effort to see if it is necessary
596 // here.
597 PixelFormat pf;
598
599 if (fullColour) {
600 pf = self->fullColourPF;
601 } else {
602 if (lowColourLevel == 0)
Pierre Ossmancf836f22011-07-14 14:34:09 +0000603 pf = verylowColourPF;
Pierre Ossmanf4f30942011-05-17 09:39:07 +0000604 else if (lowColourLevel == 1)
605 pf = lowColourPF;
606 else
Pierre Ossmancf836f22011-07-14 14:34:09 +0000607 pf = mediumColourPF;
Pierre Ossmanf4f30942011-05-17 09:39:07 +0000608 }
609
610 if (!pf.equal(self->cp.pf()))
611 self->formatChange = true;
612}