blob: ca5199a319302c7ced46402c50645717e24ffa15 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman0ff26552016-02-05 10:26:56 +01002 * Copyright 2014-2019 Pierre Ossman for Cendio AB
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19//
Pierre Ossman0d3ce872018-06-18 15:59:00 +020020// ClientParams - structure describing the current state of the remote client
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000021//
22
Pierre Ossman0d3ce872018-06-18 15:59:00 +020023#ifndef __RFB_CLIENTPARAMS_H__
24#define __RFB_CLIENTPARAMS_H__
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000025
Pierre Ossmanc0397262014-03-14 15:59:46 +010026#include <set>
27
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000028#include <rdr/types.h>
Pierre Ossman126e5642014-02-13 14:40:25 +010029#include <rfb/Cursor.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000030#include <rfb/PixelFormat.h>
Pierre Ossmancbd1b2c2009-03-20 16:05:04 +000031#include <rfb/ScreenSet.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000032
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000033namespace rfb {
34
Pierre Ossmanb948a912014-01-15 13:23:43 +010035 const int subsampleUndefined = -1;
36 const int subsampleNone = 0;
37 const int subsampleGray = 1;
38 const int subsample2X = 2;
39 const int subsample4X = 3;
40 const int subsample8X = 4;
41 const int subsample16X = 5;
42
Pierre Ossman0d3ce872018-06-18 15:59:00 +020043 class ClientParams {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000044 public:
Pierre Ossman0d3ce872018-06-18 15:59:00 +020045 ClientParams();
46 ~ClientParams();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000047
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000048 int majorVersion;
49 int minorVersion;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000050
51 void setVersion(int major, int minor) {
52 majorVersion = major; minorVersion = minor;
53 }
Pierre Ossmanf22d3502015-11-10 12:58:49 +010054 bool isVersion(int major, int minor) const {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000055 return majorVersion == major && minorVersion == minor;
56 }
Pierre Ossmanf22d3502015-11-10 12:58:49 +010057 bool beforeVersion(int major, int minor) const {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000058 return (majorVersion < major ||
59 (majorVersion == major && minorVersion < minor));
60 }
Pierre Ossmanf22d3502015-11-10 12:58:49 +010061 bool afterVersion(int major, int minor) const {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000062 return !beforeVersion(major,minor+1);
63 }
64
Steve Kondikc731da12019-09-06 13:27:47 -070065 int width() const { return width_; }
66 int height() const { return height_; }
Pierre Ossman9312b0e2018-06-20 12:25:14 +020067 const ScreenSet& screenLayout() const { return screenLayout_; }
68 void setDimensions(int width, int height);
69 void setDimensions(int width, int height, const ScreenSet& layout);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000070
Pierre Ossmanf22d3502015-11-10 12:58:49 +010071 const PixelFormat& pf() const { return pf_; }
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000072 void setPF(const PixelFormat& pf);
73
Pierre Ossmanf22d3502015-11-10 12:58:49 +010074 const char* name() const { return name_; }
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000075 void setName(const char* name);
76
Pierre Ossman6a1a0d02017-02-19 15:48:17 +010077 const Cursor& cursor() const { return *cursor_; }
Pierre Ossman126e5642014-02-13 14:40:25 +010078 void setCursor(const Cursor& cursor);
79
Pierre Ossmanf22d3502015-11-10 12:58:49 +010080 bool supportsEncoding(rdr::S32 encoding) const;
Pierre Ossman941d2902014-01-15 13:51:53 +010081
Peter Åstrand98fe98c2010-02-10 07:43:02 +000082 void setEncodings(int nEncodings, const rdr::S32* encodings);
Pierre Ossman941d2902014-01-15 13:51:53 +010083
Pierre Ossman2fa63f82016-12-05 15:26:21 +010084 unsigned int ledState() { return ledState_; }
85 void setLEDState(unsigned int state);
86
Pierre Ossman0ff26552016-02-05 10:26:56 +010087 rdr::U32 clipboardFlags() const { return clipFlags; }
88 void setClipboardCaps(rdr::U32 flags, const rdr::U32* lengths);
89
Pierre Ossmanb114f5c2018-06-18 16:34:16 +020090 // Wrappers to check for functionality rather than specific
91 // encodings
92 bool supportsLocalCursor() const;
Pierre Ossman2daba9b2018-10-29 10:03:37 +010093 bool supportsDesktopSize() const;
Pierre Ossmanb114f5c2018-06-18 16:34:16 +020094 bool supportsLEDState() const;
95 bool supportsFence() const;
96 bool supportsContinuousUpdates() const;
Pierre Ossmancbd1b2c2009-03-20 16:05:04 +000097
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000098 int compressLevel;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000099 int qualityLevel;
DRCb4a83232011-08-19 04:57:18 +0000100 int fineQualityLevel;
Pierre Ossmanb948a912014-01-15 13:23:43 +0100101 int subsampling;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +0000102
103 private:
104
Pierre Ossman9312b0e2018-06-20 12:25:14 +0200105 int width_;
106 int height_;
107 ScreenSet screenLayout_;
108
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +0000109 PixelFormat pf_;
110 char* name_;
Pierre Ossman6a1a0d02017-02-19 15:48:17 +0100111 Cursor* cursor_;
Pierre Ossmanc0397262014-03-14 15:59:46 +0100112 std::set<rdr::S32> encodings_;
Pierre Ossman2fa63f82016-12-05 15:26:21 +0100113 unsigned int ledState_;
Pierre Ossman0ff26552016-02-05 10:26:56 +0100114 rdr::U32 clipFlags;
115 rdr::U32 clipSizes[16];
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +0000116 };
117}
118#endif