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.

vncModule.c 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2015 Pierre Ossman for Cendio AB
  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. /* This is the xf86 module code for the vnc extension.
  20. */
  21. #ifdef HAVE_DIX_CONFIG_H
  22. #include <dix-config.h>
  23. #endif
  24. #include "opaque.h"
  25. #ifdef RANDR
  26. #include "randrstr.h"
  27. #endif
  28. #include "xorg-version.h"
  29. #if XORG <= 111
  30. typedef pointer XF86OptionPtr;
  31. #endif
  32. #include "xf86.h"
  33. #include "xf86Module.h"
  34. #include "vncExtInit.h"
  35. #include "RFBGlue.h"
  36. #include "XorgGlue.h"
  37. #include "RandrGlue.h"
  38. static void vncModuleInit(INITARGS);
  39. static MODULESETUPPROTO(vncSetup);
  40. ExtensionModule vncExt =
  41. {
  42. vncModuleInit,
  43. "VNC",
  44. #if XORG < 112
  45. NULL,
  46. NULL,
  47. #endif
  48. NULL
  49. };
  50. static XF86ModuleVersionInfo vncVersRec =
  51. {
  52. "vnc",
  53. "TigerVNC Project",
  54. MODINFOSTRING1,
  55. MODINFOSTRING2,
  56. XORG_VERSION_CURRENT,
  57. 1, 0, 0,
  58. ABI_CLASS_EXTENSION, /* needs the server extension ABI */
  59. ABI_EXTENSION_VERSION,
  60. MOD_CLASS_EXTENSION,
  61. {0,0,0,0}
  62. };
  63. _X_EXPORT XF86ModuleData vncModuleData = { &vncVersRec, vncSetup, NULL };
  64. static void *
  65. vncSetup(void * module, void * opts, int *errmaj, int *errmin) {
  66. #if XORG >= 116
  67. LoadExtensionList(&vncExt, 1, FALSE);
  68. #else
  69. LoadExtension(&vncExt, FALSE);
  70. #endif
  71. /* Need a non-NULL return value to indicate success */
  72. return (void *)1;
  73. }
  74. static void vncModuleInit(INITARGS)
  75. {
  76. static char once = 0;
  77. if (!once) {
  78. once++;
  79. vncInitRFB();
  80. for (int scr = 0; scr < screenInfo.numScreens; scr++) {
  81. ScrnInfoPtr pScrn;
  82. XF86OptionPtr option;
  83. pScrn = xf86Screens[scr];
  84. option = pScrn->options;
  85. while (option != NULL) {
  86. vncSetParam(xf86OptionName(option), xf86OptionValue(option));
  87. option = xf86NextOption(option);
  88. }
  89. }
  90. }
  91. vncExtensionInit();
  92. }
  93. void vncClientGone(int fd)
  94. {
  95. }
  96. #ifdef RANDR
  97. int vncRandRCreateOutputs(int scrIdx, int extraOutputs)
  98. {
  99. return -1;
  100. }
  101. void *vncRandRCreatePreferredMode(void *out, int width, int height)
  102. {
  103. RROutputPtr output;
  104. /*
  105. * We're not going to change which modes are preferred, but let's
  106. * see if we can at least find a mode with matching dimensions.
  107. */
  108. output = out;
  109. for (int i = 0;i < output->numModes;i++) {
  110. if ((output->modes[i]->mode.width == width) &&
  111. (output->modes[i]->mode.height == height))
  112. return output->modes[i];
  113. }
  114. return NULL;
  115. }
  116. #endif