Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Pierre Ossman | 0ff2655 | 2016-02-05 10:26:56 +0100 | [diff] [blame] | 2 | * Copyright 2014-2019 Pierre Ossman for Cendio AB |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 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 Ossman | 0d3ce87 | 2018-06-18 15:59:00 +0200 | [diff] [blame] | 20 | // ClientParams - structure describing the current state of the remote client |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 21 | // |
| 22 | |
Pierre Ossman | 0d3ce87 | 2018-06-18 15:59:00 +0200 | [diff] [blame] | 23 | #ifndef __RFB_CLIENTPARAMS_H__ |
| 24 | #define __RFB_CLIENTPARAMS_H__ |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 25 | |
Pierre Ossman | c039726 | 2014-03-14 15:59:46 +0100 | [diff] [blame] | 26 | #include <set> |
| 27 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 28 | #include <rdr/types.h> |
Pierre Ossman | 126e564 | 2014-02-13 14:40:25 +0100 | [diff] [blame] | 29 | #include <rfb/Cursor.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 30 | #include <rfb/PixelFormat.h> |
Pierre Ossman | cbd1b2c | 2009-03-20 16:05:04 +0000 | [diff] [blame] | 31 | #include <rfb/ScreenSet.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 32 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 33 | namespace rfb { |
| 34 | |
Pierre Ossman | b948a91 | 2014-01-15 13:23:43 +0100 | [diff] [blame] | 35 | 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 Ossman | 0d3ce87 | 2018-06-18 15:59:00 +0200 | [diff] [blame] | 43 | class ClientParams { |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 44 | public: |
Pierre Ossman | 0d3ce87 | 2018-06-18 15:59:00 +0200 | [diff] [blame] | 45 | ClientParams(); |
| 46 | ~ClientParams(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 47 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 48 | int majorVersion; |
| 49 | int minorVersion; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 50 | |
| 51 | void setVersion(int major, int minor) { |
| 52 | majorVersion = major; minorVersion = minor; |
| 53 | } |
Pierre Ossman | f22d350 | 2015-11-10 12:58:49 +0100 | [diff] [blame] | 54 | bool isVersion(int major, int minor) const { |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 55 | return majorVersion == major && minorVersion == minor; |
| 56 | } |
Pierre Ossman | f22d350 | 2015-11-10 12:58:49 +0100 | [diff] [blame] | 57 | bool beforeVersion(int major, int minor) const { |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 58 | return (majorVersion < major || |
| 59 | (majorVersion == major && minorVersion < minor)); |
| 60 | } |
Pierre Ossman | f22d350 | 2015-11-10 12:58:49 +0100 | [diff] [blame] | 61 | bool afterVersion(int major, int minor) const { |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 62 | return !beforeVersion(major,minor+1); |
| 63 | } |
| 64 | |
Steve Kondik | c731da1 | 2019-09-06 13:27:47 -0700 | [diff] [blame] | 65 | int width() const { return width_; } |
| 66 | int height() const { return height_; } |
Pierre Ossman | 9312b0e | 2018-06-20 12:25:14 +0200 | [diff] [blame] | 67 | const ScreenSet& screenLayout() const { return screenLayout_; } |
| 68 | void setDimensions(int width, int height); |
| 69 | void setDimensions(int width, int height, const ScreenSet& layout); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 70 | |
Pierre Ossman | f22d350 | 2015-11-10 12:58:49 +0100 | [diff] [blame] | 71 | const PixelFormat& pf() const { return pf_; } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 72 | void setPF(const PixelFormat& pf); |
| 73 | |
Pierre Ossman | f22d350 | 2015-11-10 12:58:49 +0100 | [diff] [blame] | 74 | const char* name() const { return name_; } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 75 | void setName(const char* name); |
| 76 | |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 77 | const Cursor& cursor() const { return *cursor_; } |
Pierre Ossman | 126e564 | 2014-02-13 14:40:25 +0100 | [diff] [blame] | 78 | void setCursor(const Cursor& cursor); |
| 79 | |
Pierre Ossman | f22d350 | 2015-11-10 12:58:49 +0100 | [diff] [blame] | 80 | bool supportsEncoding(rdr::S32 encoding) const; |
Pierre Ossman | 941d290 | 2014-01-15 13:51:53 +0100 | [diff] [blame] | 81 | |
Peter Åstrand | 98fe98c | 2010-02-10 07:43:02 +0000 | [diff] [blame] | 82 | void setEncodings(int nEncodings, const rdr::S32* encodings); |
Pierre Ossman | 941d290 | 2014-01-15 13:51:53 +0100 | [diff] [blame] | 83 | |
Pierre Ossman | 2fa63f8 | 2016-12-05 15:26:21 +0100 | [diff] [blame] | 84 | unsigned int ledState() { return ledState_; } |
| 85 | void setLEDState(unsigned int state); |
| 86 | |
Pierre Ossman | 0ff2655 | 2016-02-05 10:26:56 +0100 | [diff] [blame] | 87 | rdr::U32 clipboardFlags() const { return clipFlags; } |
| 88 | void setClipboardCaps(rdr::U32 flags, const rdr::U32* lengths); |
| 89 | |
Pierre Ossman | b114f5c | 2018-06-18 16:34:16 +0200 | [diff] [blame] | 90 | // Wrappers to check for functionality rather than specific |
| 91 | // encodings |
| 92 | bool supportsLocalCursor() const; |
Pierre Ossman | 2daba9b | 2018-10-29 10:03:37 +0100 | [diff] [blame] | 93 | bool supportsDesktopSize() const; |
Pierre Ossman | b114f5c | 2018-06-18 16:34:16 +0200 | [diff] [blame] | 94 | bool supportsLEDState() const; |
| 95 | bool supportsFence() const; |
| 96 | bool supportsContinuousUpdates() const; |
Pierre Ossman | cbd1b2c | 2009-03-20 16:05:04 +0000 | [diff] [blame] | 97 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 98 | int compressLevel; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 99 | int qualityLevel; |
DRC | b4a8323 | 2011-08-19 04:57:18 +0000 | [diff] [blame] | 100 | int fineQualityLevel; |
Pierre Ossman | b948a91 | 2014-01-15 13:23:43 +0100 | [diff] [blame] | 101 | int subsampling; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 102 | |
| 103 | private: |
| 104 | |
Pierre Ossman | 9312b0e | 2018-06-20 12:25:14 +0200 | [diff] [blame] | 105 | int width_; |
| 106 | int height_; |
| 107 | ScreenSet screenLayout_; |
| 108 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 109 | PixelFormat pf_; |
| 110 | char* name_; |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 111 | Cursor* cursor_; |
Pierre Ossman | c039726 | 2014-03-14 15:59:46 +0100 | [diff] [blame] | 112 | std::set<rdr::S32> encodings_; |
Pierre Ossman | 2fa63f8 | 2016-12-05 15:26:21 +0100 | [diff] [blame] | 113 | unsigned int ledState_; |
Pierre Ossman | 0ff2655 | 2016-02-05 10:26:56 +0100 | [diff] [blame] | 114 | rdr::U32 clipFlags; |
| 115 | rdr::U32 clipSizes[16]; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 116 | }; |
| 117 | } |
| 118 | #endif |