Date: Wed, 29 May 2013 16:29:40 +0000 (UTC) From: Steve Wills <swills@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r319382 - in head/net/tigervnc: . files Message-ID: <201305291629.r4TGTeaU053024@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: swills Date: Wed May 29 16:29:40 2013 New Revision: 319382 URL: http://svnweb.freebsd.org/changeset/ports/319382 Log: - Add backport patches to support xorg-server 1.12.x - Fix the build after xorg mega-update - Fix typo s/LISENCE/LICENSE/ PR: ports/179018 Submitted by: Koichiro IWAO <meta+ports@vmeta.jp> Added: head/net/tigervnc/files/extra-patch-common_rdr.patch (contents, props changed) head/net/tigervnc/files/extra-patch-common_rfb.patch (contents, props changed) head/net/tigervnc/files/extra-patch-unix_hw_vnc.patch (contents, props changed) head/net/tigervnc/files/xserver112.patch (contents, props changed) Modified: head/net/tigervnc/Makefile Modified: head/net/tigervnc/Makefile ============================================================================== --- head/net/tigervnc/Makefile Wed May 29 15:44:57 2013 (r319381) +++ head/net/tigervnc/Makefile Wed May 29 16:29:40 2013 (r319382) @@ -3,7 +3,7 @@ PORTNAME= tigervnc PORTVERSION= 1.2.0 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= net x11-servers MASTER_SITES= SF:tigervnc MASTER_SITE_SUBDIR= ${PORTNAME}/${PORTNAME}/${PORTVERSION}/:tigervnc @@ -12,12 +12,8 @@ DISTFILES= ${PORTNAME}-${PORTVERSION}.ta MAINTAINER= meta+ports@vmeta.jp COMMENT= TigerVNC is an advanced VNC implementation -LISENCE= GPLv2 -LISENCE_FILE= ${WRKSRC}/LICENCE.TXT - -.if defined(WITH_NEW_XORG) -BROKEN= Does not build -.endif +LICENSE= GPLv2 +LICENSE_FILE= ${WRKSRC}/LICENCE.TXT PATCH_DEPENDS= ${NONEXISTENT}:${PORTSDIR}/x11-servers/xorg-server:patch BUILD_DEPENDS= ${LOCALBASE}/include/GL/internal/dri_interface.h:${PORTSDIR}/graphics/dri @@ -127,7 +123,10 @@ CONFIGURE_ARGS+= \ .include <bsd.port.pre.mk> .ifdef WITH_NEW_XORG -TIGERVNC_XORG_PATCH_VER= 110 +TIGERVNC_XORG_PATCH_VER= 112 +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-unix_hw_vnc.patch \ + ${FILESDIR}/extra-patch-common_rdr.patch \ + ${FILESDIR}/extra-patch-common_rfb.patch .else TIGERVNC_XORG_PATCH_VER= 17 .endif @@ -146,6 +145,7 @@ pre-patch: @${CP} -R `${XORG_WRKDIR}`/ ${WRKSRC}/unix/xserver/ post-patch: + @${CP} ${FILESDIR}/xserver*.patch ${WRKSRC}/unix/ @cd ${WRKSRC}/unix/xserver/ && ${PATCH} -p1 < ${WRKSRC}/unix/xserver${TIGERVNC_XORG_PATCH_VER}.patch post-configure: Added: head/net/tigervnc/files/extra-patch-common_rdr.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/tigervnc/files/extra-patch-common_rdr.patch Wed May 29 16:29:40 2013 (r319382) @@ -0,0 +1,214 @@ + +--- common/rdr/TLSErrno.h 1970-01-01 09:00:00.000000000 +0900 ++++ common/rdr/TLSErrno.h 2013-05-27 19:09:50.115573000 +0900 +@@ -0,0 +1,46 @@ ++/* Copyright (C) 2012 Pierre Ossman for Cendio AB ++ * ++ * This is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This software is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this software; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ++ * USA. ++ */ ++ ++#ifndef __RDR_TLSERRNO_H__ ++#define __RDR_TLSERRNO_H__ ++ ++#ifdef HAVE_CONFIG_H ++#include <config.h> ++#endif ++ ++#ifdef HAVE_GNUTLS ++ ++#include <errno.h> ++ ++namespace rdr { ++ ++ static inline void gnutls_errno_helper(gnutls_session session, int _errno) ++ { ++#if defined(HAVE_GNUTLS_SET_ERRNO) ++ gnutls_transport_set_errno(session, _errno); ++#elif defined(HAVE_GNUTLS_SET_GLOBAL_ERRNO) ++ gnutls_transport_set_global_errno(_errno); ++#else ++ errno = _errno; ++#endif ++ } ++}; ++ ++#endif ++ ++#endif + +--- common/rdr/TLSInStream.cxx 2010-09-30 15:25:28.000000000 +0900 ++++ common/rdr/TLSInStream.cxx 2013-05-27 19:09:50.124573000 +0900 +@@ -25,25 +25,22 @@ + #include <rdr/Exception.h> + #include <rdr/TLSException.h> + #include <rdr/TLSInStream.h> ++#include <rdr/TLSErrno.h> + #include <errno.h> + +-#ifdef HAVE_OLD_GNUTLS +-#define gnutls_transport_set_global_errno(A) do { errno = (A); } while(0) +-#endif +- + #ifdef HAVE_GNUTLS + using namespace rdr; + + enum { DEFAULT_BUF_SIZE = 16384 }; + +-ssize_t rdr::gnutls_InStream_pull(gnutls_transport_ptr str, void* data, +- size_t size) ++ssize_t TLSInStream::pull(gnutls_transport_ptr str, void* data, size_t size) + { +- InStream* in= (InStream*) str; ++ TLSInStream* self= (TLSInStream*) str; ++ InStream *in = self->in; + + try { + if (!in->check(1, 1, false)) { +- gnutls_transport_set_global_errno(EAGAIN); ++ gnutls_errno_helper(self->session, EAGAIN); + return -1; + } + +@@ -53,7 +50,7 @@ + in->readBytes(data, size); + + } catch (Exception& e) { +- gnutls_transport_set_global_errno(EINVAL); ++ gnutls_errno_helper(self->session, EINVAL); + return -1; + } + +@@ -63,11 +60,19 @@ + TLSInStream::TLSInStream(InStream* _in, gnutls_session _session) + : session(_session), in(_in), bufSize(DEFAULT_BUF_SIZE), offset(0) + { ++ gnutls_transport_ptr recv, send; ++ + ptr = end = start = new U8[bufSize]; ++ ++ gnutls_transport_set_pull_function(session, pull); ++ gnutls_transport_get_ptr2(session, &recv, &send); ++ gnutls_transport_set_ptr2(session, this, send); + } + + TLSInStream::~TLSInStream() + { ++ gnutls_transport_set_pull_function(session, NULL); ++ + delete[] start; + } + + +--- common/rdr/TLSInStream.h 2010-04-23 23:12:18.000000000 +0900 ++++ common/rdr/TLSInStream.h 2013-05-27 19:09:50.086573000 +0900 +@@ -41,6 +41,7 @@ + private: + int overrun(int itemSize, int nItems, bool wait); + int readTLS(U8* buf, int len, bool wait); ++ static ssize_t pull(gnutls_transport_ptr str, void* data, size_t size); + + gnutls_session session; + InStream* in; +@@ -48,9 +49,6 @@ + int offset; + U8* start; + }; +- +- ssize_t gnutls_InStream_pull(gnutls_transport_ptr,void*, size_t); +- + }; + + #endif + +--- common/rdr/TLSOutStream.cxx 2010-09-30 15:25:28.000000000 +0900 ++++ common/rdr/TLSOutStream.cxx 2013-05-27 19:09:50.094576000 +0900 +@@ -25,27 +25,25 @@ + #include <rdr/Exception.h> + #include <rdr/TLSException.h> + #include <rdr/TLSOutStream.h> ++#include <rdr/TLSErrno.h> + #include <errno.h> + +-#ifdef HAVE_OLD_GNUTLS +-#define gnutls_transport_set_global_errno(A) do { errno = (A); } while(0) +-#endif +- + #ifdef HAVE_GNUTLS + using namespace rdr; + + enum { DEFAULT_BUF_SIZE = 16384 }; + +-ssize_t rdr::gnutls_OutStream_push(gnutls_transport_ptr str, const void* data, ++ssize_t TLSOutStream::push(gnutls_transport_ptr str, const void* data, + size_t size) + { +- OutStream* out = (OutStream*) str; ++ TLSOutStream* self= (TLSOutStream*) str; ++ OutStream *out = self->out; + + try { + out->writeBytes(data, size); + out->flush(); + } catch (Exception& e) { +- gnutls_transport_set_global_errno(EINVAL); ++ gnutls_errno_helper(self->session, EINVAL); + return -1; + } + +@@ -55,8 +53,14 @@ + TLSOutStream::TLSOutStream(OutStream* _out, gnutls_session _session) + : session(_session), out(_out), bufSize(DEFAULT_BUF_SIZE), offset(0) + { ++ gnutls_transport_ptr recv, send; ++ + ptr = start = new U8[bufSize]; + end = start + bufSize; ++ ++ gnutls_transport_set_push_function(session, push); ++ gnutls_transport_get_ptr2(session, &recv, &send); ++ gnutls_transport_set_ptr2(session, recv, this); + } + + TLSOutStream::~TLSOutStream() +@@ -67,6 +71,8 @@ + } catch (Exception&) { + } + #endif ++ gnutls_transport_set_push_function(session, NULL); ++ + delete [] start; + } + + +--- common/rdr/TLSOutStream.h 2010-04-23 23:12:18.000000000 +0900 ++++ common/rdr/TLSOutStream.h 2013-05-27 19:09:50.101573000 +0900 +@@ -43,6 +43,7 @@ + + private: + int writeTLS(const U8* data, int length); ++ static ssize_t push(gnutls_transport_ptr str, const void* data, size_t size); + + gnutls_session session; + OutStream* out; +@@ -50,8 +51,6 @@ + U8* start; + int offset; + }; +- +- ssize_t gnutls_OutStream_push(gnutls_transport_ptr, const void*, size_t); + }; + + #endif Added: head/net/tigervnc/files/extra-patch-common_rfb.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/tigervnc/files/extra-patch-common_rfb.patch Wed May 29 16:29:40 2013 (r319382) @@ -0,0 +1,259 @@ + +--- common/rfb/CConnection.cxx 2011-11-15 00:44:11.000000000 +0900 ++++ common/rfb/CConnection.cxx 2013-05-27 19:09:50.167574000 +0900 +@@ -100,7 +100,7 @@ + char msg[256]; + sprintf(msg,"Server gave unsupported RFB protocol version %d.%d", + cp.majorVersion, cp.minorVersion); +- vlog.error(msg); ++ vlog.error("%s", msg); + state_ = RFBSTATE_INVALID; + throw Exception(msg); + } else if (useProtocol3_3 || cp.beforeVersion(3,7)) { + +--- common/rfb/CMsgReader.cxx 2010-02-10 16:43:02.000000000 +0900 ++++ common/rfb/CMsgReader.cxx 2013-05-27 19:09:50.274574000 +0900 +@@ -100,7 +100,7 @@ + readCopyRect(r); + } else { + +- if (encoding > encodingMax) { ++ if (!Decoder::supported(encoding)) { + fprintf(stderr, "Unknown rect encoding %d\n", encoding); + throw Exception("Unknown rect encoding"); + } + +--- common/rfb/CSecurityTLS.cxx 2011-05-10 17:54:57.000000000 +0900 ++++ common/rfb/CSecurityTLS.cxx 2013-05-27 19:09:50.329576000 +0900 +@@ -72,7 +72,7 @@ + + static void debug_log(int level, const char* str) + { +- vlog_raw.debug(str); ++ vlog_raw.debug("[%d]: %s", level, str); + } + + void CSecurityTLS::initGlobal() +@@ -188,20 +188,20 @@ + throw AuthFailureException("gnutls_set_default_priority failed"); + + setParam(); +- +- gnutls_transport_set_pull_function(session, rdr::gnutls_InStream_pull); +- gnutls_transport_set_push_function(session, rdr::gnutls_OutStream_push); +- gnutls_transport_set_ptr2(session, +- (gnutls_transport_ptr) is, +- (gnutls_transport_ptr) os); + } + ++ rdr::TLSInStream *tlsis = new rdr::TLSInStream(is, session); ++ rdr::TLSOutStream *tlsos = new rdr::TLSOutStream(os, session); ++ + int err; + err = gnutls_handshake(session); +- if (err != GNUTLS_E_SUCCESS && !gnutls_error_is_fatal(err)) +- return false; +- + if (err != GNUTLS_E_SUCCESS) { ++ delete tlsis; ++ delete tlsos; ++ ++ if (!gnutls_error_is_fatal(err)) ++ return false; ++ + vlog.error("TLS Handshake failed: %s\n", gnutls_strerror (err)); + shutdown(false); + throw AuthFailureException("TLS Handshake failed"); +@@ -209,8 +209,7 @@ + + checkSession(); + +- cc->setStreams(fis = new rdr::TLSInStream(is, session), +- fos = new rdr::TLSOutStream(os, session)); ++ cc->setStreams(fis = tlsis, fos = tlsos); + + return true; + } + +--- common/rfb/Decoder.cxx 2010-02-10 16:43:02.000000000 +0900 ++++ common/rfb/Decoder.cxx 2013-05-27 19:09:50.186575000 +0900 +@@ -34,12 +34,12 @@ + + bool Decoder::supported(int encoding) + { +- return encoding <= encodingMax && createFns[encoding]; ++ return encoding >= 0 && encoding <= encodingMax && createFns[encoding]; + } + + Decoder* Decoder::createDecoder(int encoding, CMsgReader* reader) + { +- if (encoding <= encodingMax && createFns[encoding]) ++ if (supported(encoding)) + return (*createFns[encoding])(reader); + return 0; + } + +--- common/rfb/LogWriter.h 2011-02-18 19:54:11.000000000 +0900 ++++ common/rfb/LogWriter.h 2013-05-27 19:09:50.170575000 +0900 +@@ -25,12 +25,18 @@ + #include <rfb/Logger.h> + #include <rfb/Configuration.h> + ++#ifdef __GNUC__ ++# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) ++#else ++# define __printf_attr(a, b) ++#endif // __GNUC__ ++ + // Each log writer instance has a unique textual name, + // and is attached to a particular Log instance and + // is assigned a particular log level. + + #define DEF_LOGFUNCTION(name, level) \ +- inline void name(const char* fmt, ...) { \ ++ inline void name(const char* fmt, ...) __printf_attr(2, 3) { \ + if (m_log && (level <= m_level)) { \ + va_list ap; va_start(ap, fmt); \ + m_log->write(level, m_name, fmt, ap);\ +@@ -53,7 +59,7 @@ + void setLevel(int level); + int getLevel(void) { return m_level; } + +- inline void write(int level, const char* format, ...) { ++ inline void write(int level, const char* format, ...) __printf_attr(3, 4) { + if (m_log && (level <= m_level)) { + va_list ap; + va_start(ap, format); + +--- common/rfb/SConnection.cxx 2011-11-15 01:22:23.000000000 +0900 ++++ common/rfb/SConnection.cxx 2013-05-27 19:09:50.208576000 +0900 +@@ -239,7 +239,7 @@ + + void SConnection::throwConnFailedException(const char* msg) + { +- vlog.info(msg); ++ vlog.info("%s", msg); + if (state_ == RFBSTATE_PROTOCOL_VERSION) { + if (cp.majorVersion == 3 && cp.minorVersion == 3) { + os->writeU32(0); + +--- common/rfb/SSecurityTLS.cxx 2011-02-18 19:54:11.000000000 +0900 ++++ common/rfb/SSecurityTLS.cxx 2013-05-27 19:09:50.354575000 +0900 +@@ -49,7 +49,7 @@ + + static void debug_log(int level, const char* str) + { +- vlog.debug(str); ++ vlog.debug("[%d]: %s", level, str); + } + + void SSecurityTLS::initGlobal() +@@ -148,17 +148,19 @@ + throw; + } + +- gnutls_transport_set_pull_function(session,rdr::gnutls_InStream_pull); +- gnutls_transport_set_push_function(session,rdr::gnutls_OutStream_push); +- gnutls_transport_set_ptr2(session, +- (gnutls_transport_ptr)is, +- (gnutls_transport_ptr)os); + os->writeU8(1); + os->flush(); + } + ++ rdr::TLSInStream *tlsis = new rdr::TLSInStream(is, session); ++ rdr::TLSOutStream *tlsos = new rdr::TLSOutStream(os, session); ++ + int err; +- if ((err = gnutls_handshake(session)) != GNUTLS_E_SUCCESS) { ++ err = gnutls_handshake(session); ++ if (err != GNUTLS_E_SUCCESS) { ++ delete tlsis; ++ delete tlsos; ++ + if (!gnutls_error_is_fatal(err)) { + vlog.debug("Deferring completion of TLS handshake: %s", gnutls_strerror(err)); + return false; +@@ -170,8 +172,7 @@ + + vlog.debug("Handshake completed"); + +- sc->setStreams(fis=new rdr::TLSInStream(is,session), +- fos=new rdr::TLSOutStream(os,session)); ++ sc->setStreams(fis = tlsis, fos = tlsos); + + return true; + } + +--- common/rfb/ScreenSet.h 2010-12-01 19:11:20.000000000 +0900 ++++ common/rfb/ScreenSet.h 2013-05-27 19:09:50.103575000 +0900 +@@ -23,6 +23,7 @@ + + #include <stdio.h> + ++#include <rdr/types.h> + #include <rfb/Rect.h> + #include <list> + #include <set> + +--- common/rfb/VNCSConnectionST.cxx 2011-12-21 22:17:54.000000000 +0900 ++++ common/rfb/VNCSConnectionST.cxx 2013-05-27 19:09:50.296574000 +0900 +@@ -66,7 +66,8 @@ + VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s, + bool reverse) + : SConnection(reverse), sock(s), inProcessMessages(false), +- syncFence(false), fenceFlags(0), fenceDataLen(0), fenceData(NULL), ++ pendingSyncFence(false), syncFence(false), fenceFlags(0), ++ fenceDataLen(0), fenceData(NULL), + baseRTT(-1), minRTT(-1), seenCongestion(false), pingCounter(0), + ackedOffset(0), sentOffset(0), congWindow(0), congestionTimer(this), + server(server_), +@@ -156,7 +157,13 @@ + network::TcpSocket::cork(sock->getFd(), true); + + while (getInStream()->checkNoWait(1)) { ++ if (pendingSyncFence) { ++ syncFence = true; ++ pendingSyncFence = false; ++ } ++ + processMsg(); ++ + if (syncFence) { + writer()->writeFence(fenceFlags, fenceDataLen, fenceData); + syncFence = false; +@@ -627,10 +634,7 @@ + { + if (flags & fenceFlagRequest) { + if (flags & fenceFlagSyncNext) { +- if (syncFence) +- vlog.error("Fence trying to synchronise another fence"); +- +- syncFence = true; ++ pendingSyncFence = true; + + fenceFlags = flags & (fenceFlagBlockBefore | fenceFlagBlockAfter | fenceFlagSyncNext); + fenceDataLen = len; +@@ -1083,6 +1087,10 @@ + if (i->width() && i->height()) { + int nUpdateRects = writer()->getNumRects(*i); + if (nUpdateRects == 0 && cp.currentEncoding() == encodingTight) { ++ // With Tight encoding and LastRect support, the client does not ++ // care about the number of rectangles in the update - it will ++ // stop parsing when it encounters a LastRect "rectangle". ++ // In this case, pretend to send 65535 rectangles. + nRects = 0xFFFF; break; + } + else + +--- common/rfb/VNCSConnectionST.h 2011-11-21 00:36:11.000000000 +0900 ++++ common/rfb/VNCSConnectionST.h 2013-05-27 19:09:50.156574000 +0900 +@@ -183,7 +183,7 @@ + + bool inProcessMessages; + +- bool syncFence; ++ bool pendingSyncFence, syncFence; + rdr::U32 fenceFlags; + unsigned fenceDataLen; + char *fenceData; Added: head/net/tigervnc/files/extra-patch-unix_hw_vnc.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/tigervnc/files/extra-patch-unix_hw_vnc.patch Wed May 29 16:29:40 2013 (r319382) @@ -0,0 +1,1806 @@ + +--- unix/xserver/hw/vnc/Input.cc 2011-11-08 21:44:10.000000000 +0900 ++++ unix/xserver/hw/vnc/Input.cc 2013-05-27 18:54:41.184574000 +0900 +@@ -82,10 +82,11 @@ + /* Event queue is shared between all devices. */ + #if XORG == 15 + static xEvent *eventq = NULL; +-#else ++#elif XORG < 111 + static EventList *eventq = NULL; + #endif + ++#if XORG < 111 + static void initEventq(void) + { + /* eventq is never free()-ed because it exists during server life. */ +@@ -100,7 +101,9 @@ + #endif + } + } ++#endif /* XORG < 111 */ + ++#if XORG < 111 + static void enqueueEvents(DeviceIntPtr dev, int n) + { + int i; +@@ -122,6 +125,7 @@ + ); + } + } ++#endif /* XORG < 111 */ + + InputDevice::InputDevice(rfb::VNCServerST *_server) + : server(_server), oldButtonMask(0) +@@ -141,12 +145,17 @@ + keyboardProc, TRUE); + RegisterKeyboardDevice(keyboardDev); + #endif ++#if XORG < 111 + initEventq(); ++#endif + } + + void InputDevice::PointerButtonAction(int buttonMask) + { +- int i, n; ++ int i; ++#if XORG < 111 ++ int n; ++#endif + #if XORG >= 110 + ValuatorMask mask; + #endif +@@ -160,13 +169,17 @@ + #if XORG < 110 + n = GetPointerEvents(eventq, pointerDev, action, i + 1, + POINTER_RELATIVE, 0, 0, NULL); +-#else ++ enqueueEvents(pointerDev, n); ++#elif XORG < 111 + valuator_mask_set_range(&mask, 0, 0, NULL); + n = GetPointerEvents(eventq, pointerDev, action, i + 1, + POINTER_RELATIVE, &mask); +-#endif + enqueueEvents(pointerDev, n); +- ++#else ++ valuator_mask_set_range(&mask, 0, 0, NULL); ++ QueuePointerEvents(pointerDev, action, i + 1, ++ POINTER_RELATIVE, &mask); ++#endif + } + } + +@@ -175,7 +188,10 @@ + + void InputDevice::PointerMove(const rfb::Point &pos) + { +- int n, valuators[2]; ++ int valuators[2]; ++#if XORG < 111 ++ int n; ++#endif + #if XORG >= 110 + ValuatorMask mask; + #endif +@@ -190,12 +206,16 @@ + #if XORG < 110 + n = GetPointerEvents(eventq, pointerDev, MotionNotify, 0, POINTER_ABSOLUTE, 0, + 2, valuators); +-#else ++ enqueueEvents(pointerDev, n); ++#elif XORG < 111 + valuator_mask_set_range(&mask, 0, 2, valuators); + n = GetPointerEvents(eventq, pointerDev, MotionNotify, 0, POINTER_ABSOLUTE, + &mask); +-#endif + enqueueEvents(pointerDev, n); ++#else ++ valuator_mask_set_range(&mask, 0, 2, valuators); ++ QueuePointerEvents(pointerDev, MotionNotify, 0, POINTER_ABSOLUTE, &mask); ++#endif + + cursorPos = pos; + } +@@ -298,14 +318,20 @@ + static inline void pressKey(DeviceIntPtr dev, int kc, bool down, const char *msg) + { + int action; ++#if XORG < 111 + unsigned int n; ++#endif + + if (msg != NULL) + vlog.debug("%s %d %s", msg, kc, down ? "down" : "up"); + + action = down ? KeyPress : KeyRelease; +- n = GetKeyboardEvents(eventq, dev, action, kc); ++#if XORG < 111 ++ n = GetKeyboardEvents(eventq, dev, action, kc, NULL); + enqueueEvents(dev, n); ++#else ++ QueueKeyboardEvents(dev, action, kc, NULL); ++#endif + } + + #define IS_PRESSED(keyc, keycode) \ +@@ -340,8 +366,11 @@ + int state, maxKeysPerMod, keycode; + #if XORG >= 17 + KeyCode *modmap = NULL; +- ++#if XORG >= 111 ++ state = XkbStateFieldFromRec(&dev->master->key->xkbInfo->state); ++#else /* XORG >= 111 */ + state = XkbStateFieldFromRec(&dev->u.master->key->xkbInfo->state); ++#endif /* XORG >= 111 */ + #else + KeyClassPtr keyc = dev->key; + state = keyc->state; +@@ -379,7 +408,11 @@ + #if XORG >= 17 + KeyCode *modmap = NULL; + ++#if XORG >= 111 ++ keyc = dev->master->key; ++#else /* XORG >= 111 */ + keyc = dev->u.master->key; ++#endif /* XORG >= 111 */ + state = XkbStateFieldFromRec(&keyc->xkbInfo->state); + #else + keyc = dev->key; +@@ -595,7 +628,11 @@ + } + + #if XORG >= 17 ++#if XORG >= 111 ++ keyc = keyboardDev->master->key; ++#else /* XORG >= 111 */ + keyc = keyboardDev->u.master->key; ++#endif /* XORG >= 111 */ + + keymap = XkbGetCoreMap(keyboardDev); + if (!keymap) { +@@ -752,7 +789,11 @@ + XkbApplyMappingChange(keyboardDev, keymap, minKeyCode, + maxKeyCode - minKeyCode + 1, + NULL, serverClient); ++#if XORG >= 111 ++ XkbCopyDeviceKeymap(keyboardDev->master, keyboardDev); ++#else + XkbCopyDeviceKeymap(keyboardDev->u.master, keyboardDev); ++#endif + #endif /* XORG < 17 */ + break; + } + +--- unix/xserver/hw/vnc/Makefile.am 2011-10-31 17:14:40.000000000 +0900 ++++ unix/xserver/hw/vnc/Makefile.am 2013-05-27 18:54:41.196574000 +0900 +@@ -63,7 +63,7 @@ + BUILT_SOURCES = $(nodist_Xvnc_SOURCES) + + fb.h: $(top_srcdir)/fb/fb.h +- cat $(top_srcdir)/fb/fb.h | sed -e 's,and,c_and,' -e 's,xor,c_xor,' > $(srcdir)/fb.h ++ cat $(top_srcdir)/fb/fb.h | sed -e 's,and,c_and,g' -e 's,xor,c_xor,g' > $(srcdir)/fb.h + + pixman.h: + for i in ${XSERVERLIBS_CFLAGS}; do \ +@@ -78,4 +78,4 @@ + fi + + fbrop.h: $(top_srcdir)/fb/fbrop.h +- cat $(top_srcdir)/fb/fbrop.h | sed -e 's,and,c_and,' -e 's,xor,c_xor,' > $(srcdir)/fbrop.h ++ cat $(top_srcdir)/fb/fbrop.h | sed -e 's,and,c_and,g' -e 's,xor,c_xor,g' > $(srcdir)/fbrop.h + +--- unix/xserver/hw/vnc/XserverDesktop.cc 2012-01-24 00:54:11.000000000 +0900 ++++ unix/xserver/hw/vnc/XserverDesktop.cc 2013-05-27 18:54:41.203576000 +0900 +@@ -200,6 +200,8 @@ + + void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride) + { ++ ScreenSet layout; ++ + width_ = w; + height_ = h; + +@@ -217,9 +219,98 @@ + data = (rdr::U8*)fbptr; + stride_ = stride; + +- server->setPixelBuffer(this); ++ layout = computeScreenLayout(); ++ ++ server->setPixelBuffer(this, layout); ++} ++ ++void XserverDesktop::refreshScreenLayout() ++{ ++ server->setScreenLayout(computeScreenLayout()); ++} ++ ++ScreenSet XserverDesktop::computeScreenLayout() ++{ ++ ScreenSet layout; ++ ++#ifdef RANDR ++ rrScrPrivPtr rp = rrGetScrPriv(pScreen); ++ OutputIdMap newIdMap; ++ ++ for (int i = 0;i < rp->numOutputs;i++) { ++ RROutputPtr output; ++ RRCrtcPtr crtc; ++ ++ output = rp->outputs[i]; ++ crtc = output->crtc; ++ ++ /* Disabled? */ ++ if ((crtc == NULL) || (crtc->mode == NULL)) ++ continue; ++ ++ /* Known output? */ ++ if (outputIdMap.count(output) == 1) ++ newIdMap[output] = outputIdMap[output]; ++ else { ++ rdr::U32 id; ++ OutputIdMap::const_iterator iter; ++ ++ while (true) { ++ id = rand(); ++ for (iter = outputIdMap.begin();iter != outputIdMap.end();++iter) { ++ if (iter->second == id) ++ break; ++ } ++ if (iter == outputIdMap.end()) ++ break; ++ } ++ ++ newIdMap[output] = id; ++ } ++ ++ layout.add_screen(Screen(newIdMap[output], crtc->x, crtc->y, ++ crtc->mode->mode.width, ++ crtc->mode->mode.height, ++ 0)); ++ } ++ ++ /* Only keep the entries that are currently active */ ++ outputIdMap = newIdMap; ++#endif ++ ++ /* ++ * Make sure we have something to display. Hopefully it's just temporary ++ * that we have no active outputs... ++ */ ++ if (layout.num_screens() == 0) ++ layout.add_screen(Screen(0, 0, 0, pScreen->width, pScreen->height, 0)); ++ ++ return layout; + } + ++#ifdef RANDR ++ ++extern RRModePtr vncRandRModeGet(int width, int height); ++ ++RRModePtr XserverDesktop::findRandRMode(RROutputPtr output, int width, int height) ++{ ++ RRModePtr mode; ++ ++ for (int i = 0;i < output->numModes;i++) { ++ if ((output->modes[i]->mode.width == width) && ++ (output->modes[i]->mode.height == height)) ++ return output->modes[i]; ++ } ++ ++ mode = vncRandRModeGet(width, height); ++ if (mode != NULL) ++ return mode; ++ ++ return NULL; ++} ++ ++#endif ++ + char* XserverDesktop::substitute(const char* varName) + { + if (strcmp(varName, "$$") == 0) { +@@ -727,100 +818,251 @@ + vncClientCutText(str, len); + } + +-#ifdef RANDR ++extern RROutputPtr vncRandROutputCreate(ScreenPtr pScreen); ++ + unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height, + const rfb::ScreenSet& layout) + { +- int i; +- Bool ret; +- RRScreenSizePtr pSize; +- RROutputPtr output; +- RRModePtr mode; +- +- // Make sure all RandR tables are properly populated +-#if XORG == 15 +- ret = RRGetInfo(pScreen); ++#ifndef RANDR ++ return rfb::resultProhibited; + #else +- ret = RRGetInfo(pScreen, FALSE); +-#endif +- if (!ret) +- return resultNoResources; ++ int availableOutputs; ++ Bool ret; + +- // Register a new size, or get a reference to the existing one +- pSize = RRRegisterSize(pScreen, fb_width, fb_height, +- pScreen->mmWidth, pScreen->mmHeight); +- if (!pSize) { +- vlog.error("setScreenLayout: Could not get register new resolution"); +- return resultNoResources; +- } +- ret = RRRegisterRate(pScreen, pSize, 60); +- if (!ret) { +- vlog.error("setScreenLayout: Could not register a rate for the resolution"); +- return resultNoResources; +- } +- +- // Then we have to call RRGetInfo again for it to copy the RandR +- // 1.0 information to the 1.2 structures. +-#if XORG == 15 +- ret = RRGetInfo(pScreen); +-#else +- ret = RRGetInfo(pScreen, FALSE); +-#endif +- if (!ret) +- return resultNoResources; ++ rrScrPrivPtr rp = rrGetScrPriv(pScreen); + +- // Go via RandR to set the resolution in order for X11 notifications +- // to be sent out properly. We currently only do RandR 1.0, but Xorg +- // has dropped support for that API. So we have to emulate it via the +- // same method ProcRRSetScreenConfig() uses. +- // +- // FIXME: This will cause setPixelBuffer() to be called, resulting in +- // an unnecessary ExtendedDesktopSize to be sent. +- +- // We'll just reconfigure the first output +- output = RRFirstOutput(pScreen); +- if (!output) { +- vlog.error("setScreenLayout: Could not get first output"); +- return resultNoResources; +- } +- +- // Find first mode with matching size +- mode = NULL; +- for (i = 0;i < output->numModes;i++) { +- if ((output->modes[i]->mode.width == fb_width) && +- (output->modes[i]->mode.height == fb_height)) { +- mode = output->modes[i]; +- break; ++ /* ++ * First check that we don't have any active clone modes. That's just ++ * too messy to deal with. ++ */ ++ for (int i = 0;i < rp->numCrtcs;i++) { ++ if (rp->crtcs[i]->numOutputs > 1) { ++ vlog.error("Clone mode active. Refusing to touch screen layout."); ++ return rfb::resultInvalid; ++ } ++ } ++ ++ /* ++ * Next count how many useful outputs we have... ++ * ++ * This gets slightly complicated because we might need to hook a CRTC ++ * up to the output, but also check that we don't try to use the same ++ * CRTC for multiple outputs. ++ */ ++ std::set<RRCrtcPtr> usedCrtcs; ++ availableOutputs = 0; ++ for (int i = 0;i < rp->numOutputs;i++) { ++ RROutputPtr output; ++ ++ output = rp->outputs[i]; ++ ++ if (output->crtc != NULL) ++ availableOutputs++; ++ else { ++ for (int j = 0;j < output->numCrtcs;j++) { ++ if (output->crtcs[j]->numOutputs != 0) ++ continue; ++ if (usedCrtcs.count(output->crtcs[j]) != 0) ++ continue; ++ ++ availableOutputs++; ++ usedCrtcs.insert(output->crtcs[j]); ++ ++ break; ++ } + } + } +- if (!mode) { +- vlog.error("setScreenLayout: Could not find a matching mode"); +- return resultNoResources; ++ ++ /* Try to create more outputs if needed... (only works on Xvnc) */ ++ if (layout.num_screens() > availableOutputs) { ++ for (int i = 0;i < (layout.num_screens() - availableOutputs);i++) { ++ RROutputPtr output; ++ output = vncRandROutputCreate(pScreen); ++ if (output == NULL) { ++ vlog.error("Unable to create more screens, as needed by the new client layout."); ++ return rfb::resultInvalid; ++ } ++ } + } + +- // Adjust screen size +- ret = RRScreenSizeSet(pScreen, fb_width, fb_height, +- pScreen->mmWidth, pScreen->mmHeight); +- if (!ret) { +- vlog.error("setScreenLayout: Could not adjust screen size"); +- return resultNoResources; ++ /* First we might need to resize the screen */ ++ if ((fb_width != pScreen->width) || (fb_height != pScreen->height)) { ++ /* Try to retain DPI when we resize */ ++ ret = RRScreenSizeSet(pScreen, fb_width, fb_height, ++ pScreen->mmWidth * fb_width / pScreen->width, ++ pScreen->mmHeight * fb_height / pScreen->height); ++ if (!ret) { ++ vlog.error("Failed to resize screen to %dx%d", fb_width, fb_height); ++ return rfb::resultInvalid; ++ } ++ } ++ ++ /* Next, reconfigure all known outputs, and turn off the other ones */ ++ for (int i = 0;i < rp->numOutputs;i++) { ++ RROutputPtr output; ++ RRCrtcPtr crtc; ++ RRModePtr mode; ++ ++ ScreenSet::const_iterator iter; ++ ++ output = rp->outputs[i]; ++ crtc = output->crtc; ++ ++ /* Known? */ ++ if (outputIdMap.count(output) == 0) ++ continue; ++ ++ /* A known output should have a CRTC, but double check... */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305291629.r4TGTeaU053024>