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.

ServerParams.cxx 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
  3. * Copyright 2014-2019 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 <rfb/Exception.h>
  24. #include <rfb/ledStates.h>
  25. #include <rfb/ServerParams.h>
  26. using namespace rfb;
  27. ServerParams::ServerParams()
  28. : majorVersion(0), minorVersion(0),
  29. supportsQEMUKeyEvent(false),
  30. supportsSetDesktopSize(false), supportsFence(false),
  31. supportsContinuousUpdates(false),
  32. width_(0), height_(0),
  33. ledState_(ledUnknown)
  34. {
  35. setName("");
  36. cursor_ = new Cursor(0, 0, Point(), NULL);
  37. clipFlags = 0;
  38. memset(clipSizes, 0, sizeof(clipSizes));
  39. }
  40. ServerParams::~ServerParams()
  41. {
  42. delete cursor_;
  43. }
  44. void ServerParams::setDimensions(int width, int height)
  45. {
  46. ScreenSet layout;
  47. layout.add_screen(rfb::Screen(0, 0, 0, width, height, 0));
  48. setDimensions(width, height, layout);
  49. }
  50. void ServerParams::setDimensions(int width, int height, const ScreenSet& layout)
  51. {
  52. if (!layout.validate(width, height))
  53. throw Exception("Attempted to configure an invalid screen layout");
  54. width_ = width;
  55. height_ = height;
  56. screenLayout_ = layout;
  57. }
  58. void ServerParams::setPF(const PixelFormat& pf)
  59. {
  60. pf_ = pf;
  61. if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
  62. throw Exception("setPF: not 8, 16 or 32 bpp?");
  63. }
  64. void ServerParams::setName(const char* name)
  65. {
  66. name_ = name;
  67. }
  68. void ServerParams::setCursor(const Cursor& other)
  69. {
  70. delete cursor_;
  71. cursor_ = new Cursor(other);
  72. }
  73. void ServerParams::setLEDState(unsigned int state)
  74. {
  75. ledState_ = state;
  76. }
  77. uint32_t ServerParams::clipboardSize(unsigned int format) const
  78. {
  79. int i;
  80. for (i = 0;i < 16;i++) {
  81. if (((unsigned)1 << i) == format)
  82. return clipSizes[i];
  83. }
  84. throw Exception("Invalid clipboard format 0x%x", format);
  85. }
  86. void ServerParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
  87. {
  88. int i, num;
  89. clipFlags = flags;
  90. num = 0;
  91. for (i = 0;i < 16;i++) {
  92. if (!(flags & (1 << i)))
  93. continue;
  94. clipSizes[i] = lengths[num++];
  95. }
  96. }