From 2d776b14fddc5ec70c97aa82672f3a7c9caef6a3 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 5 May 2015 10:24:24 +0200 Subject: library clean-up: Don't build libNX_Xinerama anymore. Use system's libXinerama shared library. (Fixes ArcticaProject/nx-libs#49). This commit goes along with a patch from Ulrich Sibiller who managed to move the Xinerama awareness for NX sessions into the Xserver code. This makes Xinerama support for NX in libNX_Xinerama.so obsolete. Fixes ArcticaProject/nx-libs#49 --- Makefile | 8 - debian/control | 46 ++-- debian/libnx-xinerama-dev.install.in | 3 - debian/libnx-xinerama1.install.in | 1 - debian/libnx-xinerama1.symbols | 11 - debian/nx-x11-common.install | 1 - debian/nx-x11proto-xinerama-dev.install.in | 1 - debian/nxagent.postinst.in | 57 ----- debian/nxagent.prerm | 53 ---- debian/rules | 5 - nx-X11/config/cf/X11.tmpl | 37 --- nx-X11/include/extensions/Imakefile | 4 +- nx-X11/lib/Imakefile | 4 - nx-X11/lib/Xinerama/Imakefile | 30 --- nx-X11/lib/Xinerama/Xinerama-def.cpp | 14 -- nx-X11/lib/Xinerama/Xinerama.c | 361 ---------------------------- nx-X11/programs/Xserver/Imakefile | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 4 + nx-libs.spec | 45 +--- 19 files changed, 25 insertions(+), 662 deletions(-) delete mode 100644 debian/libnx-xinerama-dev.install.in delete mode 100644 debian/libnx-xinerama1.install.in delete mode 100644 debian/libnx-xinerama1.symbols delete mode 100644 debian/nx-x11proto-xinerama-dev.install.in delete mode 100755 debian/nxagent.postinst.in delete mode 100755 debian/nxagent.prerm delete mode 100644 nx-X11/lib/Xinerama/Imakefile delete mode 100644 nx-X11/lib/Xinerama/Xinerama-def.cpp delete mode 100644 nx-X11/lib/Xinerama/Xinerama.c diff --git a/Makefile b/Makefile index 2b5b4946a..14f6e4266 100644 --- a/Makefile +++ b/Makefile @@ -154,14 +154,6 @@ install-full: "$$(string_rep "$$dirname" nx-X11/.build-exports/include "$(DESTDIR)$(INCLUDEDIR)/")"/ || true; \ done; \ - # Provide means for Xinerama support in NX/X2Go sessions. This - # This also requires three post-install symlinks created by libnx-xinerama1: - # $(DESTDIR)$(NXLIBDIR)/X11/Xinerama/libNX_X11.so.6 -> /usr//libX11.so.6 - # $(DESTDIR)$(NXLIBDIR)/X11/Xinerama/libNX_Xext.so.6 -> /usr//libXext.so.6 - # $(DESTDIR)$(NXLIBDIR)/X11/Xinerama/libXinerama.so.1 -> /usr//libNX_Xinerama.so.1 - # Only create the owned directory here for nx-x11-common. - $(INSTALL_DIR) $(DESTDIR)$(NXLIBDIR)/X11/Xinerama - $(INSTALL_DIR) $(DESTDIR)/$(ETCDIR_NX) $(INSTALL_DIR) $(DESTDIR)/$(ETCDIR_X2GO) $(INSTALL_FILE) etc/keystrokes.cfg $(DESTDIR)/$(ETCDIR_NX)/ diff --git a/debian/control b/debian/control index 946dd4b2a..94aa64014 100644 --- a/debian/control +++ b/debian/control @@ -22,12 +22,11 @@ Build-Depends: libxrandr-dev, libxfixes-dev, libxtst-dev, + libxinerama-dev, autoconf, pkg-config, x11proto-core-dev, expat, -Build-Conflicts: - x11proto-xinerama-dev, Standards-Version: 3.9.6 Homepage: http://code.x2go.org/gitweb?p=nx-libs.git;a=summary Vcs-Git: git://code.x2go.org/nx-libs.git @@ -548,21 +547,17 @@ Multi-Arch: same Pre-Depends: ${misc:Pre-Depends}, Depends: - ${shlibs:Depends}, ${misc:Depends}, -Breaks: nxlibs (<= 3.5.1), - libnx-x11 (<< 2:3.5.0.29-0x2go2~), Description: nx-X11 Xinerama extension library NX is a software suite which implements very efficient compression of the X11 protocol. This increases performance when using X applications over a network, especially a slow one. . - libNX_Xinerama provides an X Window System client interface to the XINERAMA - extension to the X protocol. + This package removes the obsoleted libNX_Xinerama.so.1 library. + Xinerama support in NX has been moved into nxagent whereas X-Clients + can now use the libXinerama library shipped with X.Org. . - The Xinerama (also known as panoramiX) extension allows for multiple screens - attached to a single display to be treated as belonging together, and to give - desktop applications a better idea of the monitor layout. + This package can be safely removed. Package: libnx-xinerama-dev Provides: libnx-xinerama1-dev @@ -570,24 +565,16 @@ Section: libdevel Architecture: any Multi-Arch: same Depends: - libnx-xinerama1 (= ${binary:Version}), - nx-x11proto-xinerama-dev (= ${binary:Version}), ${misc:Depends}, -Breaks: nxlibs (<= 3.5.1), - libnx-x11-dev (<< 2:3.5.0.29-0x2go2~), Description: nx-X11 Xinerama extension library (development headers) NX is a software suite which implements very efficient compression of the X11 protocol. This increases performance when using X applications over a network, especially a slow one. . - libNX_Xinerama provides an X Window System client interface to the XINERAMA - extension to the X protocol. + This package removes the obsoleted headers for the libNX_Xinerama.so.1 + library. . - The Xinerama (also known as panoramiX) extension allows for multiple screens - attached to a single display to be treated as belonging together, and to give - desktop applications a better idea of the monitor layout. - . - This package contains the development headers for this library. + This package can be safely removed. Package: nx-x11proto-xinerama-dev Section: libdevel @@ -595,16 +582,15 @@ Architecture: any Multi-Arch: same Depends: ${misc:Depends}, -Breaks: nxlibs (<= 3.5.1), - libnx-x11-dev (<< 2:3.5.0.29-0x2go2~), Description: nx-X11 Xinerama extension wire protocol NX is a software suite which implements very efficient compression of the X11 protocol. This increases performance when using X applications over a network, especially a slow one. . - This package provides development headers describing the wire protocol - for the XINERAMA extension, used to use and manage a multiple-screen - display. + This package removes the obsoleted headers for the libNX_Xinerama.so.1 + library. + . + This package can be safely removed. Package: libnx-xinerama1-dbg Architecture: any @@ -624,12 +610,10 @@ Description: nx-X11 Xinerama extension library (debug package) libNX_Xinerama provides an X Window System client interface to the XINERAMA extension to the X protocol. . - The Xinerama (also known as panoramiX) extension allows for multiple - screens attached to a single display to be treated as belonging - together, and to give desktop applications a better idea of the monitor - layout. + This package removes the obsoleted debug symbols for the libNX_Xinerama.so.1 + library. . - This package contains debug symbols for this library. + This package can be safely removed. Package: libnx-xpm4 Architecture: any diff --git a/debian/libnx-xinerama-dev.install.in b/debian/libnx-xinerama-dev.install.in deleted file mode 100644 index 59c0456aa..000000000 --- a/debian/libnx-xinerama-dev.install.in +++ /dev/null @@ -1,3 +0,0 @@ -usr/lib/*/libNX_Xinerama.so -usr/include/*/nx-X11/extensions/Xinerama.h -usr/include/*/nx-X11/extensions/panoramiXext.h diff --git a/debian/libnx-xinerama1.install.in b/debian/libnx-xinerama1.install.in deleted file mode 100644 index d53de9c4f..000000000 --- a/debian/libnx-xinerama1.install.in +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/libNX_Xinerama.so.* diff --git a/debian/libnx-xinerama1.symbols b/debian/libnx-xinerama1.symbols deleted file mode 100644 index f8f73a3fd..000000000 --- a/debian/libnx-xinerama1.symbols +++ /dev/null @@ -1,11 +0,0 @@ -libNX_Xinerama.so.1 libnx-xinerama1 #MINVER# - XPanoramiXAllocInfo@Base 3.5.0.29 - XPanoramiXGetScreenCount@Base 3.5.0.29 - XPanoramiXGetScreenSize@Base 3.5.0.29 - XPanoramiXGetState@Base 3.5.0.29 - XPanoramiXQueryExtension@Base 3.5.0.29 - XPanoramiXQueryVersion@Base 3.5.0.29 - XineramaIsActive@Base 3.5.0.29 - XineramaQueryExtension@Base 3.5.0.29 - XineramaQueryScreens@Base 3.5.0.29 - XineramaQueryVersion@Base 3.5.0.29 diff --git a/debian/nx-x11-common.install b/debian/nx-x11-common.install index 1131e7291..b6fc46613 100644 --- a/debian/nx-x11-common.install +++ b/debian/nx-x11-common.install @@ -1,2 +1 @@ usr/share/nx/SecurityPolicy -usr/lib/nx/X11/ diff --git a/debian/nx-x11proto-xinerama-dev.install.in b/debian/nx-x11proto-xinerama-dev.install.in deleted file mode 100644 index dca06ddee..000000000 --- a/debian/nx-x11proto-xinerama-dev.install.in +++ /dev/null @@ -1 +0,0 @@ -usr/include/*/nx-X11/extensions/panoramiXproto.h \ No newline at end of file diff --git a/debian/nxagent.postinst.in b/debian/nxagent.postinst.in deleted file mode 100755 index 95879b943..000000000 --- a/debian/nxagent.postinst.in +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# postinst script for nxagent -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - ### FIXME: this is a work-around while we have not implemented - ### multiarch support into the Debian source package of - ### nx-libs. - - libdir=/usr/lib/#DEB_BUILD_MULTIARCH# - - mkdir -p /usr/lib/nx/X11/Xinerama/ - # Already existent files are not removed. - # Users will need to explicitly remove them and (re-) configure this package. - if test -e $libdir/libX11.so.6; then - ln -sf $libdir/libX11.so.6 /usr/lib/nx/X11/Xinerama/libNX_X11.so.6 - fi - if test -e $libdir/libXext.so.6; then - ln -sf $libdir/libXext.so.6 /usr/lib/nx/X11/Xinerama/libNX_Xext.so.6 - fi - if test -e $libdir/libNX_Xinerama.so.1; then - ln -sf $libdir/libNX_Xinerama.so.1 /usr/lib/nx/X11/Xinerama/libXinerama.so.1 - fi - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/nxagent.prerm b/debian/nxagent.prerm deleted file mode 100755 index 019284a16..000000000 --- a/debian/nxagent.prerm +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# prerm script for nxagent -# -# see: dh_installdeb(1) -# summary of how this script can be called: -# * `remove' -# * `upgrade' -# * `failed-upgrade' -# * `remove' `in-favour' -# * `deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - -set -e - - - -case "$1" in - remove) - if test -d /usr/lib/nx/X11/Xinerama; then - if test -e /usr/lib/nx/X11/Xinerama/libNX_X11.so.6; then - rm -f /usr/lib/nx/X11/Xinerama/libNX_X11.so.6 - fi - - if test -e /usr/lib/nx/X11/Xinerama/libNX_Xext.so.6; then - rm -f /usr/lib/nx/X11/Xinerama/libNX_Xext.so.6 - fi - - if test -e /usr/lib/nx/X11/Xinerama/libXinerama.so.1; then - rm -f /usr/lib/nx/X11/Xinerama/libXinerama.so.1 - fi - - rmdir --ignore-fail-on-non-empty /usr/lib/nx/X11/Xinerama - - fi - ;; - deconfigure|upgrade|failed-upgrade) - : - ;; - *) - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/rules b/debian/rules index 729a2c6f4..c90bb6451 100755 --- a/debian/rules +++ b/debian/rules @@ -20,7 +20,6 @@ override_dh_auto_clean: override_dh_clean: rm -f nx*/configure . ./replace.sh; set -x; ls debian/*.install.in | while read file; do rm -f $$(string_rep $$file .install.in .install); done - rm -f debian/nxagent.postinst rm -fR .preserve/ dh_clean @@ -72,16 +71,12 @@ override_dh_auto_install: override_dh_auto_build: - # let's prep the nxagent.postinst script with the value of the build systems's DEB_BUILD_MULTIARCH variable - sed debian/nxagent.postinst.in -e 's/#DEB_BUILD_MULTIARCH#/$(DEB_BUILD_MULTIARCH)/' > debian/nxagent.postinst - LOCAL_LDFLAGS="$(LDFLAGS)" SHLIBGLOBALSFLAGS="$(LDFLAGS)" SHLIBDIR="$(LIBDIR)" PREFIX=/usr dh_auto_build --parallel override_dh_strip: dh_strip -plibnx-x11-6 --dbg-package=libnx-x11-6-dbg dh_strip -plibnx-xau6 --dbg-package=libnx-xau6-dbg dh_strip -plibnx-xext6 --dbg-package=libnx-xext6-dbg - dh_strip -plibnx-xinerama1 --dbg-package=libnx-xinerama1-dbg dh_strip -plibnx-xrender1 --dbg-package=libnx-xrender1-dbg dh_strip -plibxcomp3 --dbg-package=libxcomp3-dbg dh_strip -plibxcompshad3 --dbg-package=libxcompshad3-dbg diff --git a/nx-X11/config/cf/X11.tmpl b/nx-X11/config/cf/X11.tmpl index af466b47f..3e7423040 100644 --- a/nx-X11/config/cf/X11.tmpl +++ b/nx-X11/config/cf/X11.tmpl @@ -226,9 +226,6 @@ XORGRELSTRING = XorgManVersionString #ifndef BuildXinerama #define BuildXinerama NO #endif -#ifndef BuildXineramaLibrary -#define BuildXineramaLibrary (BuildXinerama) -#endif #ifndef BuildXCSecurity #define BuildXCSecurity YES #endif @@ -1321,30 +1318,6 @@ ProjectUnsharedLibReferences(XONLY,NX_X11,$(XLIBSRC),XBuildLibDir) XLIBONLY = $(XONLYLIB) LINTXONLYLIB = $(LINTXONLY) -#if BuildXineramaLibrary -#ifndef SharedLibXinerama -#define SharedLibXinerama HasSharedLibraries -#endif -#ifndef NormalLibXinerama -#define NormalLibXinerama (!SharedLibXinerama || ForceNormalLib) -#endif -#ifndef DebugLibXinerama -#define DebugLibXinerama NO -#endif -#ifndef ProfileLibXinerama -#define ProfileLibXinerama NO -#endif -#else -#undef SharedLibXinerama -#define SharedLibXinerama NO -#undef NormalLibXinerama -#define NormalLibXinerama NO -#undef DebugLibXinerama -#define DebugLibXinerama NO -#undef ProfileLibXinerama -#define ProfileLibXinerama NO -#endif - #if BuildRenderLibrary #ifndef SharedLibXrender #define SharedLibXrender HasSharedLibraries @@ -1395,16 +1368,6 @@ LINTEXTENSIONLIB = $(LINTEXTENSION) XLIB = $(EXTENSIONLIB) $(XONLYLIB) LINTXLIB = $(LINTXONLYLIB) - XINERAMALIBSRC = $(LIBSRC)/Xinerama -#if SharedLibXinerama -#ifndef SharedXineramaRev -#define SharedXineramaRev 1.0 -#endif -SharedLibReferences(XINERAMA,NX_Xinerama,$(XINERAMALIBSRC),SOXINERAMAREV,SharedXineramaRev) -#else -ProjectUnsharedLibReferences(XINERAMA,NX_Xinerama,$(XINERAMALIBSRC),XBuildLibDir) -#endif - XRENDERLIBSRC = $(LIBSRC)/Xrender #if SharedLibXrender #ifndef SharedXrenderRev diff --git a/nx-X11/include/extensions/Imakefile b/nx-X11/include/extensions/Imakefile index 33e854058..eb7763535 100644 --- a/nx-X11/include/extensions/Imakefile +++ b/nx-X11/include/extensions/Imakefile @@ -35,8 +35,8 @@ XVMCHEADERS = XvMC.h XvMClib.h XvMCproto.h vldXvMC.h #if BuildFontCache FONTCACHEHEADERS = fontcache.h fontcacheP.h fontcachstr.h #endif -#if BuildXinerama || BuildXineramaLibrary -XINERAMAHEADERS = Xinerama.h panoramiXext.h panoramiXproto.h +#if BuildXinerama +XINERAMAHEADERS = panoramiXext.h panoramiXproto.h #endif #if BuildRandR RANDRHEADERS = randr.h randrproto.h diff --git a/nx-X11/lib/Imakefile b/nx-X11/lib/Imakefile index b97ef6b22..dbe4e4280 100644 --- a/nx-X11/lib/Imakefile +++ b/nx-X11/lib/Imakefile @@ -15,10 +15,6 @@ NULL = XKBLIBDIR = xkbfile #endif -#if BuildXineramaLibrary -XINERAMADIR=Xinerama -#endif - #if BuildRenderLibrary RENDERLIBDIR = Xrender #endif diff --git a/nx-X11/lib/Xinerama/Imakefile b/nx-X11/lib/Xinerama/Imakefile deleted file mode 100644 index 910f98da6..000000000 --- a/nx-X11/lib/Xinerama/Imakefile +++ /dev/null @@ -1,30 +0,0 @@ -XCOMM $XFree86: xc/lib/Xinerama/Imakefile,v 1.4 2002/10/16 00:37:31 dawes Exp $ - -#define DoNormalLib NormalLibXinerama -#define DoSharedLib SharedLibXinerama -#define DoDebugLib DebugLibXinerama -#define DoProfileLib ProfileLibXinerama -#define LibName NX_Xinerama -#define SoRev SOXINERAMAREV -#define LibHeaders NO - -#include - -#ifdef SharedXineramaReqs -REQUIREDLIBS = SharedXineramaReqs -#endif - -#if Malloc0ReturnsNull -ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL -#endif - - DEFINES = $(ALLOC_DEFINES) - SRCS = Xinerama.c - OBJS = Xinerama.o - LINTLIBS = $(LINTXLIB) - -#define IncludeSharedObjectInNormalLib - -#include - -DependTarget() diff --git a/nx-X11/lib/Xinerama/Xinerama-def.cpp b/nx-X11/lib/Xinerama/Xinerama-def.cpp deleted file mode 100644 index 01449d15b..000000000 --- a/nx-X11/lib/Xinerama/Xinerama-def.cpp +++ /dev/null @@ -1,14 +0,0 @@ -LIBRARY Xinerama -VERSION LIBRARY_VERSION -EXPORTS - XPanoramiXAllocInfo - XPanoramiXGetScreenCount - XPanoramiXGetScreenSize - XPanoramiXGetState - XPanoramiXQueryExtension - XPanoramiXQueryVersion - XineramaIsActive - XineramaQueryExtension - XineramaQueryScreens - XineramaQueryVersion -/* $XFree86$ */ diff --git a/nx-X11/lib/Xinerama/Xinerama.c b/nx-X11/lib/Xinerama/Xinerama.c deleted file mode 100644 index 0256336be..000000000 --- a/nx-X11/lib/Xinerama/Xinerama.c +++ /dev/null @@ -1,361 +0,0 @@ -/* $Xorg: XPanoramiX.c,v 1.4 2000/08/17 19:45:51 cpqbld Exp $ */ -/***************************************************************** -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. -******************************************************************/ -/* $XFree86: xc/lib/Xinerama/Xinerama.c,v 1.2 2001/07/23 17:20:28 dawes Exp $ */ - -#define NEED_EVENTS -#define NEED_REPLIES -#include -#include -#include -#include -#include -#include -#include -#include - -static XExtensionInfo _panoramiX_ext_info_data; -static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data; -static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME; - -#define PanoramiXCheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, panoramiX_extension_name, val) -#define PanoramiXSimpleCheckExtension(dpy,i) \ - XextSimpleCheckExtension (dpy, i, panoramiX_extension_name) - -static int close_display(); -static /* const */ XExtensionHooks panoramiX_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static XEXT_GENERATE_FIND_DISPLAY (find_display, panoramiX_ext_info, - panoramiX_extension_name, - &panoramiX_extension_hooks, - 0, NULL) - -static XEXT_GENERATE_CLOSE_DISPLAY (close_display, panoramiX_ext_info) - - - -/**************************************************************************** - * * - * PanoramiX public interfaces * - * * - ****************************************************************************/ - -Bool XPanoramiXQueryExtension ( - Display *dpy, - int *event_basep, - int *error_basep -) -{ - XExtDisplayInfo *info = find_display (dpy); - - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - return True; - } else { - return False; - } -} - - -Status XPanoramiXQueryVersion( - Display *dpy, - int *major_versionp, - int *minor_versionp -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXQueryVersionReply rep; - register xPanoramiXQueryVersionReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXQueryVersion; - req->clientMajor = PANORAMIX_MAJOR_VERSION; - req->clientMinor = PANORAMIX_MINOR_VERSION; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - *major_versionp = rep.majorVersion; - *minor_versionp = rep.minorVersion; - UnlockDisplay (dpy); - SyncHandle (); - return 1; -} - -XPanoramiXInfo *XPanoramiXAllocInfo(void) -{ - return (XPanoramiXInfo *) Xmalloc (sizeof (XPanoramiXInfo)); -} - -Status XPanoramiXGetState ( - Display *dpy, - Drawable drawable, - XPanoramiXInfo *panoramiX_info -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXGetStateReply rep; - register xPanoramiXGetStateReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXGetState, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetState; - req->window = drawable; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - UnlockDisplay (dpy); - SyncHandle (); - panoramiX_info->window = rep.window; - panoramiX_info->State = rep.state; - return 1; -} - -Status XPanoramiXGetScreenCount ( - Display *dpy, - Drawable drawable, - XPanoramiXInfo *panoramiX_info -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXGetScreenCountReply rep; - register xPanoramiXGetScreenCountReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXGetScreenCount, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetScreenCount; - req->window = drawable; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - UnlockDisplay (dpy); - SyncHandle (); - panoramiX_info->window = rep.window; - panoramiX_info->ScreenCount = rep.ScreenCount; - return 1; -} - -Status XPanoramiXGetScreenSize ( - Display *dpy, - Drawable drawable, - int screen_num, - XPanoramiXInfo *panoramiX_info -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXGetScreenSizeReply rep; - register xPanoramiXGetScreenSizeReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXGetScreenSize, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetScreenSize; - req->window = drawable; - req->screen = screen_num; /* need to define */ - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - UnlockDisplay (dpy); - SyncHandle (); - panoramiX_info->window = rep.window; - panoramiX_info->screen = rep.screen; - panoramiX_info->width = rep.width; - panoramiX_info->height = rep.height; - return 1; -} - -/*******************************************************************\ - Alternate interface to make up for shortcomings in the original, - namely, the omission of the screen origin. The new interface is - in the "Xinerama" namespace instead of "PanoramiX". -\*******************************************************************/ - -Bool XineramaQueryExtension ( - Display *dpy, - int *event_base, - int *error_base -) -{ - return XPanoramiXQueryExtension(dpy, event_base, error_base); -} - -Status XineramaQueryVersion( - Display *dpy, - int *major, - int *minor -) -{ - return XPanoramiXQueryVersion(dpy, major, minor); -} - -Bool XineramaIsActive(Display *dpy) -{ - xXineramaIsActiveReply rep; - xXineramaIsActiveReq *req; - XExtDisplayInfo *info = find_display (dpy); - - - FILE* fptr; - if((fptr=fopen(getenv("NX_XINERAMA_CONF"),"r"))!=NULL) { - fclose (fptr); - return True; - } - else { - return False; - } - - if(!XextHasExtension(info)) - return False; /* server doesn't even have the extension */ - - LockDisplay (dpy); - GetReq (XineramaIsActive, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_XineramaIsActive; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - UnlockDisplay (dpy); - SyncHandle (); - return rep.state; -} - - -XineramaScreenInfo * -XineramaQueryScreens( - Display *dpy, - int *number -) -{ - XExtDisplayInfo *info = find_display (dpy); - xXineramaQueryScreensReply rep; - xXineramaQueryScreensReq *req; - XineramaScreenInfo *scrnInfo = NULL; - - int i; - int x,y,w,h; - FILE* fptr; - if((fptr=fopen(getenv("NX_XINERAMA_CONF"),"r"))==NULL) { - PanoramiXCheckExtension (dpy, info, 0); - LockDisplay (dpy); - GetReq (XineramaQueryScreens, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_XineramaQueryScreens; - if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); - return NULL; - } - if(rep.number) { - if((scrnInfo = Xmalloc(sizeof(XineramaScreenInfo) * rep.number))) { - xXineramaScreenInfo scratch; - int i; - - for(i = 0; i < rep.number; i++) { - _XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo); - scrnInfo[i].screen_number = i; - scrnInfo[i].x_org = scratch.x_org; - scrnInfo[i].y_org = scratch.y_org; - scrnInfo[i].width = scratch.width; - scrnInfo[i].height = scratch.height; - } - - *number = rep.number; - } else { - _XEatData(dpy, rep.length << 2); - } - } - - UnlockDisplay (dpy); - SyncHandle (); - - } else { - - i=0; - while(!feof(fptr)) { - w=h=0; - fscanf(fptr,"%d %d %d %d",&x,&y,&w,&h); - if(w&&h) - i++; - } - rewind(fptr); - *number=i; - if((scrnInfo = Xmalloc(sizeof(XineramaScreenInfo) * i))) { - i=0; - while(!feof(fptr)){ - w=h=0; - fscanf(fptr,"%d %d %d %d",&x,&y,&w,&h); - if(w&&h){ - scrnInfo[i].screen_number=i; - scrnInfo[i].x_org=x; - scrnInfo[i].y_org=y; - scrnInfo[i].width=w; - scrnInfo[i].height=h; - i++; - } - } - } - fclose(fptr); - } - - return scrnInfo; -} - - - diff --git a/nx-X11/programs/Xserver/Imakefile b/nx-X11/programs/Xserver/Imakefile index 309d5d98f..d034c2672 100644 --- a/nx-X11/programs/Xserver/Imakefile +++ b/nx-X11/programs/Xserver/Imakefile @@ -413,7 +413,7 @@ NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext \ #else NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext -L ../../../nxcompshad \ -lXcomp -lXcompext -lXcompshad -lNX_Xrender -lNX_X11 -lNX_Xext -lXfixes -lXfont \ - -L../../../nx-X11/exports/lib -lXtst -lXrandr -lXcomposite -lNX_Xinerama -lXdmcp \ + -L../../../nx-X11/exports/lib -lXtst -lXrandr -lXcomposite -lXinerama -lXdmcp \ `pkg-config --libs libxml-2.0` #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 491a92c2f..2f70334d4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -79,6 +79,10 @@ is" without express or implied warranty. #include "X11/include/Xrandr_nxagent.h" +#include +#include "X11/include/Xinerama_nxagent.h" + + #define GC XlibGC #define Font XlibFont #define KeySym XlibKeySym diff --git a/nx-libs.spec b/nx-libs.spec index 22094c2a5..01341a4ca 100644 --- a/nx-libs.spec +++ b/nx-libs.spec @@ -39,6 +39,7 @@ BuildRequires: pkgconfig(xcomposite) BuildRequires: pkgconfig(xrandr) BuildRequires: pkgconfig(xfixes) BuildRequires: pkgconfig(xtst) +BuildRequires: pkgconfig(xinerama) %else BuildRequires: libexpat-devel BuildRequires: libpng-devel @@ -53,6 +54,7 @@ BuildRequires: xorg-x11-libXcomposite-devel BuildRequires: xorg-x11-libXrandr-devel BuildRequires: xorg-x11-libXfixes-devel BuildRequires: xorg-x11-libXtst-devel +BuildRequires: xorg-x11-libXinerama-devel %endif BuildRequires: xorg-x11-util-devel %endif @@ -67,6 +69,7 @@ BuildRequires: libXcomposite-devel BuildRequires: libXrandr-devel BuildRequires: libXfixes-devel BuildRequires: libXtst-devel +BuildRequires: libXinerama-devel %endif # For imake @@ -84,20 +87,6 @@ Provides: nx = %{version}-%{release} Obsoletes: nx%{?_isa} < 3.5.0-19 Provides: nx%{?_isa} = %{version}-%{release} -# for Xinerama in NX to work: -%if 0%{?suse_version} -%if 0%{?suse_version} < 1140 -Requires: xorg-x11-libX11%{?_isa} -Requires: xorg-x11-libXext%{?_isa} -%else -Requires: libX11-6%{?_isa} -Requires: libXext6%{?_isa} -%endif -%else -Requires: libX11%{?_isa} -Requires: libXext%{?_isa} -%endif - %if 0%{?el5} # For compatibility with EPEL5 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -244,22 +233,6 @@ The NX_Xext library contains a handful of X11 extensions: - X11 Double-Buffering, Multi-Buffering, and Stereo extension (Xmbuf) -%package -n libNX_Xinerama1 -Group: System Environment/Libraries -Summary: Xinerama extension to the NX Protocol -Requires: %{name}%{?_isa} >= 3.5.0.29 -Obsoletes: libNX_Xinerama - -%description -n libNX_Xinerama1 -NX is a software suite which implements very efficient compression of -the X11 protocol. This increases performance when using X -applications over a network, especially a slow one. - -Xinerama is an extension to the X Window System which enables -multi-headed X applications and window managers to use two or more -physical displays as one large virtual display. - - %package -n libNX_Xrender-devel Group: Development/Libraries Summary: Development files for the NX Render Extension library @@ -553,11 +526,6 @@ rm -r %{buildroot}%{_includedir}/nx-X11/extensions/XK*.h rm -r %{buildroot}%{_includedir}/nx-X11/extensions/*Xv*.h rm -r %{buildroot}%{_includedir}/nx-X11/Xtrans -# Needed for Xinerama support -ln -s -f ../../../../%{_lib}/libX11.so.6 %{buildroot}%{_libdir}/nx/X11/Xinerama/libNX_X11.so.6 -ln -s -f ../../../../%{_lib}/libXext.so.6 %{buildroot}%{_libdir}/nx/X11/Xinerama/libNX_Xext.so.6 -ln -s -f ../../../../%{_lib}/libNX_Xinerama.so.1 %{buildroot}%{_libdir}/nx/X11/Xinerama/libXinerama.so.1 - %if 0%{?fdupes:1} %fdupes %buildroot/%_prefix %endif @@ -566,7 +534,6 @@ ln -s -f ../../../../%{_lib}/libNX_Xinerama.so.1 %{buildroot}%{_libdir}/nx/X11/X %post -n libNX_X11-6 -p /sbin/ldconfig %post -n libNX_Xau6 -p /sbin/ldconfig %post -n libNX_Xext6 -p /sbin/ldconfig -%post -n libNX_Xinerama1 -p /sbin/ldconfig %post -n libNX_Xrender1 -p /sbin/ldconfig %post -n libXcomp3 -p /sbin/ldconfig %post -n libXcompext3 -p /sbin/ldconfig @@ -575,7 +542,6 @@ ln -s -f ../../../../%{_lib}/libNX_Xinerama.so.1 %{buildroot}%{_libdir}/nx/X11/X %postun -n libNX_X11-6 -p /sbin/ldconfig %postun -n libNX_Xau6 -p /sbin/ldconfig %postun -n libNX_Xext6 -p /sbin/ldconfig -%postun -n libNX_Xinerama1 -p /sbin/ldconfig %postun -n libNX_Xrender1 -p /sbin/ldconfig %postun -n libXcomp3 -p /sbin/ldconfig %postun -n libXcompext3 -p /sbin/ldconfig @@ -654,10 +620,6 @@ ln -s -f ../../../../%{_lib}/libNX_Xinerama.so.1 %{buildroot}%{_libdir}/nx/X11/X %defattr(-,root,root) %{_libdir}/libNX_Xext.so.6* -%files -n libNX_Xinerama1 -%defattr(-,root,root) -%{_libdir}/libNX_Xinerama.so.1* - %files -n libNX_Xrender-devel %defattr(-,root,root) %{_libdir}/libNX_Xrender.so @@ -722,7 +684,6 @@ ln -s -f ../../../../%{_lib}/libNX_Xinerama.so.1 %{buildroot}%{_libdir}/nx/X11/X %files devel %defattr(-,root,root) -%{_libdir}/libNX_Xinerama.so %{_includedir}/nx-X11/X10.h %dir %{_includedir}/nx-X11/extensions %{_includedir}/nx-X11/extensions/Xevie.h -- cgit v1.2.3 From c6482d24fff982d5e11636167c719766f8207d48 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 2 May 2015 21:53:25 +0200 Subject: Reimplement xinerama via randr in nxagent (not libNX_Xinerama). (Fixes ArcticaProject/nx-libs#23). No more xinerama faking, just use existing xrandr extension and initalize it properly. Xinerama then works automatically. Fixes ArcticaProject/nx-libs#23 --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 46 ++- nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 36 ++ nx-X11/programs/Xserver/hw/nxagent/Options.c | 2 + nx-X11/programs/Xserver/hw/nxagent/Options.h | 11 + nx-X11/programs/Xserver/hw/nxagent/Screen.c | 428 ++++++++++++++++++++---- 5 files changed, 452 insertions(+), 71 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 9f7d6280f..03b14f0dc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -568,6 +568,10 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) { XSizeHints sizeHints; + #ifdef DEBUG + fprintf(stderr, "nxagentSwitchResizeMode called.\n"); + #endif + int desktopResize = nxagentOption(DesktopResize); nxagentChangeOption(DesktopResize, !desktopResize); @@ -3366,7 +3370,9 @@ int nxagentHandleConfigureNotify(XEvent* X) if (nxagentOption(DesktopResize) == 1) { if (nxagentOption(Width) != X -> xconfigure.width || - nxagentOption(Height) != X -> xconfigure.height) + nxagentOption(Height) != X -> xconfigure.height || + nxagentOption(X) != X -> xconfigure.x || + nxagentOption(Y) != X -> xconfigure.y) { Bool newEvents = False; @@ -3423,11 +3429,16 @@ int nxagentHandleConfigureNotify(XEvent* X) nxagentMoveViewport(pScreen, 0, 0); + /* if in shadowing mode or if neither size nor position have + changed we do not need to adjust RandR */ + /* FIXME: Comment makes no sense */ if (nxagentOption(Shadow) == 1 || (nxagentOption(Width) == nxagentOption(RootWidth) && - nxagentOption(Height) == nxagentOption(RootHeight))) + nxagentOption(Height) == nxagentOption(RootHeight) && + nxagentOption(X) == nxagentOption(RootX) && + nxagentOption(Y) == nxagentOption(RootY))) { - doRandR = 0; + doRandR = False; } nxagentChangeOption(Width, X -> xconfigure.width); @@ -3466,12 +3477,31 @@ int nxagentHandleConfigureNotify(XEvent* X) #endif nxagentChangeScreenConfig(0, nxagentOption(Width), - nxagentOption(Height), 0, 0); + nxagentOption(Height), 0, 0); } } return 1; } + else + { + if (X -> xconfigure.window == DefaultRootWindow(nxagentDisplay)) + { + #ifdef TEST + fprintf(stderr, "nxagentHandleConfigureNotify: remote root window has changed: %d,%d %dx%d\n", X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height); + #endif + + nxagentChangeOption(RootX, X -> xconfigure.x); + nxagentChangeOption(RootY, X -> xconfigure.y); + nxagentChangeOption(RootWidth, X -> xconfigure.width); + nxagentChangeOption(RootHeight, X -> xconfigure.height); + + nxagentChangeScreenConfig(0, nxagentOption(Width), + nxagentOption(Height), 0, 0); + + return 1; + } + } } return 0; @@ -4416,6 +4446,10 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X) { XRRScreenChangeNotifyEvent *Xr; + #ifdef DEBUG + fprintf(stderr, "nxagentHandleRRScreenChangeNotify called.\n"); + #endif + Xr = (XRRScreenChangeNotifyEvent *) X; nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height, @@ -4504,6 +4538,10 @@ int nxagentWaitEvents(Display *dpy, struct timeval *tm) { XEvent ev; + #ifdef DEBUG + fprintf(stderr, "nxagentWaitEvents called.\n"); + #endif + NXFlushDisplay(dpy, NXFlushLink); /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index 6dce644ae..103eaa92c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -35,6 +35,11 @@ static int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, static int nxagentRandRInitSizes(ScreenPtr pScreen); +static Bool nxagentRandRCrtcSet (ScreenPtr pScreen, RRCrtcPtr crtc, + RRModePtr mode, int x, int y, + Rotation rotation, int numOutputs, + RROutputPtr *outputs); + #ifdef __DARWIN__ void DarwinHandleGUI(int argc, char *argv[]) @@ -83,6 +88,8 @@ void nxagentInitRandRExtension(ScreenPtr pScreen) fprintf(stderr, "Warning: Failed to initialize the RandR extension.\n"); } + + /* FIXME: do we need this at all with the new rand/xinerama stuff? */ nxagentRandRInitSizes(pScreen); /* @@ -97,6 +104,7 @@ void nxagentInitRandRExtension(ScreenPtr pScreen) #if RANDR_12_INTERFACE pRandRScrPriv -> rrScreenSetSize = nxagentRandRScreenSetSize; + pRandRScrPriv -> rrCrtcSet = nxagentRandRCrtcSet; #endif #if RANDR_10_INTERFACE @@ -104,6 +112,34 @@ void nxagentInitRandRExtension(ScreenPtr pScreen) #endif } +void +RRResetProc (ExtensionEntry *extEntry) +{ + fprintf(stderr, "RANDR going down - NX version\n"); +} + + + +#if RANDR_12_INTERFACE +/* + * Request that the Crtc be reconfigured + */ + +static Bool +nxagentRandRCrtcSet (ScreenPtr pScreen, + RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutputs, + RROutputPtr *outputs) +{ + return RRCrtcNotify(crtc, mode, x, y, rotation, numOutputs, outputs); +} +#endif + + int nxagentRandRGetInfo(ScreenPtr pScreen, Rotation *pRotations) { /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.c b/nx-X11/programs/Xserver/hw/nxagent/Options.c index 7eac3d8a2..dbe200273 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.c @@ -154,6 +154,8 @@ void nxagentInitOptions() nxagentOptions.CopyBufferSize = COPY_UNLIMITED; nxagentOptions.ImageRateLimit = 0; + + nxagentOptions.Xinerama = 0; } /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.h b/nx-X11/programs/Xserver/hw/nxagent/Options.h index 0e4869926..5bf1597d5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.h @@ -388,6 +388,17 @@ typedef struct _AgentOptions int NoRootlessExit; + /* + * Store if the user wants Xinerama. There's a variable called + * noPanoramiXExtension in os/utils.c but we cannot rely on that + * because RandR and Panoramix change its value when trying to + * initialize. So we use this variable to save the user preference + * provided by the -/+xinerama parameter before initalizing those + * extensions. + */ + + int Xinerama; + } AgentOptionsRec; typedef AgentOptionsRec *AgentOptionsPtr; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 2f70334d4..ec34eddb6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -133,14 +133,6 @@ extern Pixmap nxagentIconPixmap; extern Pixmap nxagentIconShape; extern Bool useXpmIcon; -/* - * From randr/randr.c. - */ - -extern Bool RRGetInfo(ScreenPtr pScreen); -extern void RRSendConfigNotify(ScreenPtr pScreen); -extern void RREditConnectionInfo(ScreenPtr pScreen); - Window nxagentDefaultWindows[MAXSCREENS]; Window nxagentInputWindows[MAXSCREENS]; Window nxagentScreenSaverWindows[MAXSCREENS]; @@ -323,7 +315,7 @@ void nxagentMaximizeToFullScreen(ScreenPtr pScreen) XUnmapWindow(nxagentDisplay, nxagentIconWindow); */ /* -FIXME: We'll chech for ReparentNotify and LeaveNotify events after XReparentWindow() +FIXME: We'll check for ReparentNotify and LeaveNotify events after XReparentWindow() in order to avoid the session window is iconified. We could avoid the sesssion window is iconified when a LeaveNotify event is received, so this check would be unnecessary. @@ -1121,6 +1113,9 @@ Bool nxagentOpenScreen(int index, ScreenPtr pScreen, nxagentChangeOption(ViewportXSpan, nxagentOption(Width) - nxagentOption(RootWidth)); nxagentChangeOption(ViewportYSpan, nxagentOption(Height) - nxagentOption(RootHeight)); + /* store the user's preference provided via cmdline */ + nxagentOption(Xinerama) = !noPanoramiXExtension; + if (nxagentReconnectTrap == 0) { if (nxagentOption(Persistent)) @@ -2039,6 +2034,9 @@ N/A nxagentCompositeExtensionInit(); + /* We use this to get informed about RandR changes on the real display. + FIXME: It would probably be better to use an RRScreenChangeNotifyEvent here. */ + XSelectInput(nxagentDisplay, DefaultRootWindow(nxagentDisplay), StructureNotifyMask); #ifdef NXAGENT_TIMESTAMP @@ -2075,6 +2073,10 @@ Bool nxagentCloseScreen(int index, ScreenPtr pScreen) { int i; + #ifdef DEBUG + fprintf(stderr, "running nxagentCloseScreen()\n"); + #endif + for (i = 0; i < pScreen->numDepths; i++) { xfree(pScreen->allowedDepths[i].vids); @@ -3589,21 +3591,61 @@ Bool nxagentReconnectScreen(void *p0) return True; } -RRModePtr nxagentRRCustomMode = NULL; +/* FIXME: there must be such macros somewhere already...*/ +#define MAX(a,b) ((a) > (b)) ? (a) : (b); +#define MIN(a,b) ((a) < (b)) ? (a) : (b); + +/* intersect two rectangles */ +Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, + int bx1, int by1, unsigned int bw, unsigned int bh, + int *x, int *y, unsigned int *w, unsigned int *h) +{ + int tx1, ty1, tx2, ty2, ix, iy; + unsigned int iw, ih; + + int ax2 = ax1 + aw; + int ay2 = ay1 + ah; + int bx2 = bx1 + bw; + int by2 = by1 + bh; + + /* thanks to http://silentmatt.com/rectangle-intersection */ + + /* check if there's any intersection at all */ + if (ax2 < bx1 || bx2 < ax1 || ay2 < by1 || by2 < ay1) { + return FALSE; + } + + tx1 = MAX(ax1, bx1); + ty1 = MAX(ay1, by1); + tx2 = MIN(ax2, bx2); + ty2 = MIN(ay2, by2); + + ix = tx1 - ax1; + iy = ty1 - ay1; + iw = tx2 - tx1; + ih = ty2 - ty1; + + /* check if the resulting rectangle is feasible */ + if (iw <= 0 || ih <= 0) { + return FALSE; + } + *x = ix; + *y = iy; + *w = iw; + *h = ih; + return TRUE; +} int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, int mmHeight) { ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RROutputPtr output; - RRCrtcPtr crtc; - RRModePtr mode; - xRRModeInfo modeInfo; - char name[100]; - int r, c, m; - int refresh = 60; - int doNotify = 1; + /* FIXME: when is this needed? */ + int doNotify = TRUE; + int r; + #ifdef TEST + fprintf(stderr, "nxagentChangeScreenConfig: WindowTable[%d] is %p\n", screen, WindowTable[screen]); + #endif if (WindowTable[screen] == NULL) { return 0; @@ -3611,16 +3653,16 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in UpdateCurrentTime(); - if (nxagentGrabServerInfo.grabstate == SERVER_GRABBED) + if (nxagentGrabServerInfo.grabstate == SERVER_GRABBED && nxagentGrabServerInfo.client != NULL) { /* * If any client grabbed the server it won't expect that screen * configuration changes until it releases the grab. That could - * get an X error because available modes are chanded meanwhile. + * get an X error because available modes are changed meanwhile. */ #ifdef TEST - fprintf(stderr, "nxagentChangeScreenConfig: Cancel with grabbed server.\n"); + fprintf(stderr, "nxagentChangeScreenConfig: Cancel with grabbed server (grab held by %p).\n", nxagentGrabServerInfo.client); #endif return 0; @@ -3636,76 +3678,328 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in if (r != 0) { - pScrPriv = rrGetScrPriv(pScreen); + nxagentAdjustRandRXinerama(pScreen); + } + + if (doNotify) + { + RRScreenSizeNotify(pScreen); + } + +#ifdef DEBUG + fprintf(stderr, "nxagentChangeScreenConfig: Geometry: %d,%d %dx%d\n", nxagentOption(X), nxagentOption(Y),nxagentOption(Width),nxagentOption(Height)); + fprintf(stderr, "nxagentChangeScreenConfig: return %d\n", r); +#endif + + return r; +} - if (pScrPriv) +int nxagentAdjustRandRXinerama(ScreenPtr pScreen) +{ + rrScrPrivPtr pScrPriv; + RROutputPtr output; + xRRModeInfo modeInfo; + char name[100]; + int refresh = 60; + int width = nxagentOption(Width); + int height = nxagentOption(Height); + + pScrPriv = rrGetScrPriv(pScreen); + + if (pScrPriv) + { + int i, j; + int number = 0; + + XineramaScreenInfo *screeninfo = NULL; + + if (nxagentOption(Xinerama)) { + screeninfo = XineramaQueryScreens(nxagentDisplay, &number); +#ifdef DEBUG + if (number) { + fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() returned %d screens\n", number); + } + else + { + fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without xinerama\n"); + } + } + else + { + fprintf(stderr, "nxagentAdjustRandRXinerama: Xinerama is disabled\n"); +#endif + } + + /* + * if there's no xinerama on the real server or xinerama is + * disabled in nxagent we only report one big screen. Clients + * still see xinerama enabled but it will report only one (big) + * screen. This is consistent with the way rrxinerama always + * behaved. The single PanoramiX/Xinerama extension however + * disables xinerama if only one screen exists. + */ + if (number == 0) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: faking xinerama\n" ); + #endif + number = 1; + + if (screeninfo) { + xfree(screeninfo); + } + if (!(screeninfo = xalloc(sizeof(XineramaScreenInfo)))) { + return FALSE; + } + + /* fake a xinerama screeninfo that covers the whole screen */ + screeninfo->x_org = nxagentOption(X); + screeninfo->y_org = nxagentOption(Y); + screeninfo->width = nxagentOption(Width); + screeninfo->height = nxagentOption(Height); + } + +#ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs = %d, numOutputs = %d\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); { - output = RRFirstOutput(pScreen); + Bool rrgetinfo; - if (output && output -> crtc) + /* + * Convert old RANDR 1.0 data (if any) to current structure. This + * is needed once at the first run of this function. If we don't + * do this here it will be done implicitely later and add mode(s) to + * our crtc(s)! + */ + rrgetinfo = RRGetInfo(pScreen); + + fprintf(stderr, "nxagentAdjustRandRXinerama: RRGetInfo returned %d\n", rrgetinfo); + } +#else + /* we are not interested in the return code */ + RRGetInfo(pScreen); +#endif + + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs = %d, numOutputs = %d\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); + #endif + + /* adjust the number of CRTCs to match the number of reported + xinerama screens on the real server */ + while (number != pScrPriv->numCrtcs) { + if (number < pScrPriv->numCrtcs) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying crtc\n"); + #endif + RRCrtcDestroy(pScrPriv->crtcs[pScrPriv->numCrtcs - 1]); + } + else { - crtc = output -> crtc; + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: adding crtc\n"); + #endif + RRCrtcCreate(pScreen, NULL); + } + } - for (c = 0; c < pScrPriv -> numCrtcs; c++) - { - RRCrtcSet(pScrPriv -> crtcs[c], NULL, 0, 0, RR_Rotate_0, 0, NULL); + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs = %d, numOutputs = %d\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); + #endif + + /* set gamma. Currently the only reason for doing this is + preventing the xrandr command from complaining about missing + gamma. */ + for (i = 0; i < pScrPriv->numCrtcs; i++) { + if (pScrPriv->crtcs[i]->gammaSize == 0) { + CARD16 gamma = 0; + RRCrtcGammaSetSize(pScrPriv->crtcs[i], 1); + RRCrtcGammaSet(pScrPriv->crtcs[i], &gamma, &gamma, &gamma); + RRCrtcGammaNotify(pScrPriv->crtcs[i]); + } + } + + /* delete superfluous non-NX outputs */ + for (i = pScrPriv->numOutputs - 1; i >= 0; i--) { + if (strncmp(pScrPriv->outputs[i]->name, "NX", 2)) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying output %s\n", pScrPriv->outputs[i]->name); + #endif + RROutputDestroy(pScrPriv->outputs[i]); + } + } + + /* at this stage only NX outputs are left - we delete the superfluous ones */ + for (i = pScrPriv->numOutputs - 1; i >= number; i--) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying output %s\n", pScrPriv->outputs[i]->name); + #endif + RROutputDestroy(pScrPriv->outputs[i]); + } + + /* add and init outputs */ + for (i = 0; i < number; i++) { + if (i >= pScrPriv->numOutputs) { + sprintf(name, "NX%d", i+1); + output = RROutputCreate(pScreen, name, strlen(name), NULL); + /* will be done later + RROutputSetConnection(output, RR_Disconnected); + */ + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: created new output %s\n", name); + #endif + } + else + { + output = pScrPriv->outputs[i]; + } + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: adjusting output %s\n", pScrPriv->outputs[i]->name); + #endif + RROutputSetCrtcs(output, &(pScrPriv->crtcs[i]), 1); + /* FIXME: Isn't there a function for setting this? */ + output->crtc = pScrPriv->crtcs[i]; + /* FIXME: get SubPixelOrder from real X server */ + RROutputSetSubpixelOrder(output, SubPixelUnknown); + /* FIXME: What is the correct physical size here? */ + RROutputSetPhysicalSize(output, 0, 0); + } + + for (i = 0; i < pScrPriv->numOutputs; i++ ) { + Bool disable_output = FALSE; + RRModePtr mymode, prevmode; + int new_x, new_y; + unsigned int new_w, new_h; + + /* if there's no intersection disconnect the output */ + disable_output = !intersect(nxagentOption(X), nxagentOption(Y), + width, height, + screeninfo[i].x_org, screeninfo[i].y_org, + screeninfo[i].width, screeninfo[i].height, + &new_x, &new_y, &new_w, &new_h); + + RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1); + + /* save previous mode */ + prevmode = pScrPriv->crtcs[i]->mode; + + if (disable_output) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: no (valid) intersection - disconnecting\n", i); + #endif + RROutputSetConnection(pScrPriv->outputs[i], RR_Disconnected); + + /* + * Tests revealed that some window managers (e.g. LXDE) also + * take disconnected outputs into account when calculating + * stuff like wallpaper tile size and maximum window + * size. This is problematic when the disconnected output is + * smaller than any of the connected ones. Solution: unset + * the mode of the output's crtc. This also leads to + * xinerama not showing the disconnected head anymore. + */ + RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); + RROutputSetModes(pScrPriv->outputs[i], NULL, 0, 0); + if(prevmode) { + if(prevmode->refcnt == 1) + FreeResource(prevmode->mode.id, 0); } + } + else + { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc %d: intersection is x=%d, y=%d, width=%d, height=%d'\n", i, new_x, new_y, new_w, new_h); + #endif + RROutputSetConnection(pScrPriv->outputs[i], RR_Connected); memset(&modeInfo, '\0', sizeof(modeInfo)); - sprintf(name, "%dx%d", width, height); - - modeInfo.width = width; - modeInfo.height = height; - modeInfo.hTotal = width; - modeInfo.vTotal = height; - modeInfo.dotClock = ((CARD32) width * (CARD32) height * - (CARD32) refresh); + /* avoid collisions with pre-existing default modes by using a + separate namespace. If we'd simply use XxY we could not + distinguish between pre-existing modes which should stay + and our own modes that should be removed after use. */ + /*sprintf(name, "nx%d", i+1);*/ + /*sprintf(name, "%dx%d", new_w, new_h);*/ + sprintf(name, "nx_%dx%d", new_w, new_h); + + modeInfo.width = new_w; + modeInfo.height = new_h; + modeInfo.hTotal = new_w; + modeInfo.vTotal = new_h; + modeInfo.dotClock = ((CARD32) new_w * (CARD32) new_h * (CARD32) refresh); modeInfo.nameLength = strlen(name); - if (nxagentRRCustomMode != NULL) + mymode = RRModeGet(&modeInfo, name); + +#ifdef DEBUG + if (mymode) { + fprintf(stderr, "nxagentAdjustRandRXinerama: mode %s (%p) created/received, refcnt=%d\n", name, mymode, mymode->refcnt); + } + else { - RROutputDeleteUserMode(output, nxagentRRCustomMode); - FreeResource(nxagentRRCustomMode -> mode.id, 0); + fprintf(stderr, "nxagentAdjustRandRXinerama: mode %s creation failed!\n", name); + } +#endif - if (crtc != NULL && crtc -> mode == nxagentRRCustomMode) + if (prevmode) { + if (mymode == prevmode) { - RRCrtcSet(crtc, NULL, 0, 0, RR_Rotate_0, 0, NULL); + /* if they are the same RRModeGet() has increased the + refcnt by 1. We decrease it again by calling only + RRModeDestroy() and forget about prevmode */ + } else { + RROutputSetModes(pScrPriv->outputs[i], &mymode, 1, 0); + RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); } - - #ifdef TEST - fprintf(stderr, "nxagentChangeScreenConfig: " - "Going to destroy mode %p with refcnt %d.\n", - nxagentRRCustomMode, nxagentRRCustomMode->refcnt); - #endif - - RRModeDestroy(nxagentRRCustomMode); + if(prevmode->refcnt == 1) + FreeResource(prevmode->mode.id, 0); + } + else + { + /* we do not have a previous mode, so there's no need to handle it here */ + RROutputSetModes(pScrPriv->outputs[i], &mymode, 1, 0); + RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); } - nxagentRRCustomMode = RRModeGet(&modeInfo, name); - - RROutputAddUserMode(output, nxagentRRCustomMode); + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: mode %s (%p) added to output and crtc %d\n", name, mymode, i); + #endif + } /* if disable_output */ - RRCrtcSet(crtc, nxagentRRCustomMode, 0, 0, RR_Rotate_0, 1, &output); + RROutputChanged(pScrPriv->outputs[i], TRUE); + RRCrtcChanged(pScrPriv->crtcs[i], TRUE); + } - RROutputChanged(output, 1); + /* release allocated memory */ + if (screeninfo) { + xfree(screeninfo); + screeninfo = NULL; + } - doNotify = 0; +#ifdef DEBUG + for (i = 0; i < pScrPriv->numCrtcs; i++) { + RRModePtr mode = pScrPriv->crtcs[i]->mode; + if (mode) { + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc %d has mode %s and %d outputs\n", i, pScrPriv->crtcs[i]->mode->name, pScrPriv->crtcs[i]->numOutputs); + } + else + { + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc %d has no mode and %d outputs\n", i, pScrPriv->crtcs[i]->numOutputs); } - pScrPriv -> lastSetTime = currentTime; - - pScrPriv->changed = 1; - pScrPriv->configChanged = 1; + fprintf(stderr, "nxagentAdjustRandRXinerama: output[%d]->crtc=%p\n", i, pScrPriv->outputs[i]->crtc); } +#endif - if (doNotify -) - { - RRScreenSizeNotify(pScreen); - } + pScrPriv -> lastSetTime = currentTime; + + pScrPriv->changed = TRUE; + pScrPriv->configChanged = TRUE; } - return r; + /* FIXME: adjust maximum screen size according to remote randr/xinerama setup */ + + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: Min %dx%d, Max %dx%d \n", pScrPriv->minWidth,pScrPriv->minHeight,pScrPriv->maxWidth,pScrPriv->maxHeight); + #endif + + return TRUE; } void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin) -- cgit v1.2.3 From 8b0e2af3600dc6ae585eb5426bb7f48fbcfbdebf Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 6 Oct 2015 22:27:10 +0200 Subject: rrmode.c: add debug output --- nx-X11/programs/Xserver/randr/rrmode.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/randr/rrmode.c b/nx-X11/programs/Xserver/randr/rrmode.c index cb45bf74a..c3740b5f8 100644 --- a/nx-X11/programs/Xserver/randr/rrmode.c +++ b/nx-X11/programs/Xserver/randr/rrmode.c @@ -104,11 +104,13 @@ RRModeCreate (xRRModeInfo *modeInfo, } modes = newModes; modes[num_modes++] = mode; - /* * give the caller a reference to this mode */ ++mode->refcnt; +#ifdef DEBUG + fprintf(stderr, "RRModeCreate: num_modes [%d] new mode [%s] ([%p]) refcnt [%d]\n", num_modes, mode->name, mode, mode->refcnt); +#endif return mode; } @@ -144,11 +146,22 @@ RRModeGet (xRRModeInfo *modeInfo, !memcmp (name, mode->name, modeInfo->nameLength)) { ++mode->refcnt; +#ifdef DEBUG + fprintf(stderr, "RRModeGet: return existing mode [%s] ([%p]) refcnt [%d]\n", mode->name, mode, mode->refcnt); +#endif return mode; } } +#ifdef DEBUG + { + RRModePtr mode = RRModeCreate (modeInfo, name, NULL); + fprintf(stderr, "RRModeGet: return new mode [%s] ([%p]) refcnt [%d]\n", mode->name, mode, mode->refcnt); + return mode; + } +#else return RRModeCreate (modeInfo, name, NULL); +#endif } static RRModePtr @@ -252,8 +265,12 @@ RRModeDestroy (RRModePtr mode) { int m; - if (--mode->refcnt > 0) + if (--mode->refcnt > 0) { +#ifdef DEBUG + fprintf(stderr, "RRModeDestroy: mode [%s] ([%p]) refcnt [%d -> %d]\n", mode->name, mode, mode->refcnt + 1, mode->refcnt); +#endif return; + } for (m = 0; m < num_modes; m++) { if (modes[m] == mode) @@ -270,12 +287,18 @@ RRModeDestroy (RRModePtr mode) } } +#ifdef DEBUG + fprintf(stderr, "RRModeDestroy: destroyed mode [%s] ([%p])\n", mode->name, mode); +#endif xfree (mode); } static int RRModeDestroyResource (void * value, XID pid) { +#ifdef DEBUG + fprintf(stderr, "RRModeDestroyResource: mode [%s] ([%p]) refcnt [%d]\n", ((RRModePtr)value)->name, (RRModePtr)value, ((RRModePtr)value)->refcnt); +#endif RRModeDestroy ((RRModePtr) value); return 1; } -- cgit v1.2.3 From 76a203410f19de13f8c1b34cabd08f70fa027995 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 6 Oct 2015 22:30:39 +0200 Subject: Screen.c: improve comments and DEBUG output --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 83 ++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index ec34eddb6..26971d025 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3656,9 +3656,10 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in if (nxagentGrabServerInfo.grabstate == SERVER_GRABBED && nxagentGrabServerInfo.client != NULL) { /* - * If any client grabbed the server it won't expect that screen + * If any client grabbed the server it won't expect screen * configuration changes until it releases the grab. That could - * get an X error because available modes are changed meanwhile. + * lead to an X error because available modes are changed + * in the meantime. */ #ifdef TEST @@ -3721,7 +3722,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) } else { - fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without xinerama\n"); + fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without Xinerama\n"); } } else @@ -3759,7 +3760,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) } #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs = %d, numOutputs = %d\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs [%d], numOutputs [%d]\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); { Bool rrgetinfo; @@ -3771,7 +3772,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) */ rrgetinfo = RRGetInfo(pScreen); - fprintf(stderr, "nxagentAdjustRandRXinerama: RRGetInfo returned %d\n", rrgetinfo); + fprintf(stderr, "nxagentAdjustRandRXinerama: RRGetInfo returned [%d]\n", rrgetinfo); } #else /* we are not interested in the return code */ @@ -3779,7 +3780,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) #endif #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs = %d, numOutputs = %d\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs [%d], numOutputs [%d]\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); #endif /* adjust the number of CRTCs to match the number of reported @@ -3801,7 +3802,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) } #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs = %d, numOutputs = %d\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs [%d], numOutputs [%d]\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); #endif /* set gamma. Currently the only reason for doing this is @@ -3820,7 +3821,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) for (i = pScrPriv->numOutputs - 1; i >= 0; i--) { if (strncmp(pScrPriv->outputs[i]->name, "NX", 2)) { #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: destroying output %s\n", pScrPriv->outputs[i]->name); + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying output [%s]\n", pScrPriv->outputs[i]->name); #endif RROutputDestroy(pScrPriv->outputs[i]); } @@ -3829,7 +3830,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* at this stage only NX outputs are left - we delete the superfluous ones */ for (i = pScrPriv->numOutputs - 1; i >= number; i--) { #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: destroying output %s\n", pScrPriv->outputs[i]->name); + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying output [%s]\n", pScrPriv->outputs[i]->name); #endif RROutputDestroy(pScrPriv->outputs[i]); } @@ -3843,7 +3844,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetConnection(output, RR_Disconnected); */ #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: created new output %s\n", name); + fprintf(stderr, "nxagentAdjustRandRXinerama: created new output [%s]\n", name); #endif } else @@ -3851,7 +3852,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) output = pScrPriv->outputs[i]; } #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: adjusting output %s\n", pScrPriv->outputs[i]->name); + fprintf(stderr, "nxagentAdjustRandRXinerama: adjusting output [%s]\n", pScrPriv->outputs[i]->name); #endif RROutputSetCrtcs(output, &(pScrPriv->crtcs[i]), 1); /* FIXME: Isn't there a function for setting this? */ @@ -3875,10 +3876,18 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) screeninfo[i].width, screeninfo[i].height, &new_x, &new_y, &new_w, &new_h); - RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1); - /* save previous mode */ prevmode = pScrPriv->crtcs[i]->mode; + #ifdef DEBUG + if (prevmode) { + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: prevmode [%s] ([%p]) refcnt [%d]\n", i, prevmode->name, prevmode, prevmode->refcnt); + } else { + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: no prevmode\n", i); + } + #endif + + RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1); + if (disable_output) { #ifdef DEBUG @@ -3897,15 +3906,23 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) */ RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); RROutputSetModes(pScrPriv->outputs[i], NULL, 0, 0); - if(prevmode) { - if(prevmode->refcnt == 1) + + if (prevmode) { + /* throw away the previous mode, we do not need it + anymore. If refcnt is 1 we call FreeResource() to ensure + the system will not try to free it again on shutdown */ + + if (prevmode->refcnt == 1) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s] ([%p])\n", prevmode->name, prevmode); + #endif FreeResource(prevmode->mode.id, 0); } } else { #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: crtc %d: intersection is x=%d, y=%d, width=%d, height=%d'\n", i, new_x, new_y, new_w, new_h); + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: intersection is x [%d] y [%d] width [%d] height [%d]\n", i, new_x, new_y, new_w, new_h); #endif RROutputSetConnection(pScrPriv->outputs[i], RR_Connected); @@ -3929,22 +3946,35 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) #ifdef DEBUG if (mymode) { - fprintf(stderr, "nxagentAdjustRandRXinerama: mode %s (%p) created/received, refcnt=%d\n", name, mymode, mymode->refcnt); + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: mode [%s] ([%p]) created/received, refcnt [%d]\n", i, name, mymode, mymode->refcnt); } else { - fprintf(stderr, "nxagentAdjustRandRXinerama: mode %s creation failed!\n", name); + /* FIXME: what is the correct behaviour in this case? */ + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: mode [%s] creation failed!\n", i, name); } #endif if (prevmode) { if (mymode == prevmode) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: mymode [%s] ([%p]) == prevmode [%s] ([%p])\n", mymode->name, mymode, prevmode->name, prevmode); + #endif + /* if they are the same RRModeGet() has increased the refcnt by 1. We decrease it again by calling only RRModeDestroy() and forget about prevmode */ } else { + + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d\n", mymode->name, mymode, mymode->refcnt, i); + #endif RROutputSetModes(pScrPriv->outputs[i], &mymode, 1, 0); + + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for crtc %d\n", mymode->name, mymode, mymode->refcnt, i); + #endif RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); } if(prevmode->refcnt == 1) @@ -3953,13 +3983,17 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) else { /* we do not have a previous mode, so there's no need to handle it here */ + + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d\n", mymode->name, mymode, mymode->refcnt, i); + #endif RROutputSetModes(pScrPriv->outputs[i], &mymode, 1, 0); + + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for crtc %d\n", mymode->name, mymode, mymode->refcnt, i); + #endif RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); } - - #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: mode %s (%p) added to output and crtc %d\n", name, mymode, i); - #endif } /* if disable_output */ RROutputChanged(pScrPriv->outputs[i], TRUE); @@ -3976,14 +4010,15 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) for (i = 0; i < pScrPriv->numCrtcs; i++) { RRModePtr mode = pScrPriv->crtcs[i]->mode; if (mode) { - fprintf(stderr, "nxagentAdjustRandRXinerama: crtc %d has mode %s and %d outputs\n", i, pScrPriv->crtcs[i]->mode->name, pScrPriv->crtcs[i]->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc %d has mode [%s] ([%p]), refcnt [%d] and %d outputs\n", i, pScrPriv->crtcs[i]->mode->name, pScrPriv->crtcs[i]->mode, pScrPriv->crtcs[i]->mode->refcnt, pScrPriv->crtcs[i]->numOutputs); } else { fprintf(stderr, "nxagentAdjustRandRXinerama: crtc %d has no mode and %d outputs\n", i, pScrPriv->crtcs[i]->numOutputs); } - fprintf(stderr, "nxagentAdjustRandRXinerama: output[%d]->crtc=%p\n", i, pScrPriv->outputs[i]->crtc); + if (pScrPriv->crtcs[i]->numOutputs > 0) + fprintf(stderr, " output[%d]->crtc=[%p]\n", i, pScrPriv->outputs[i]->crtc); } #endif -- cgit v1.2.3 From 359f48dd7e036b5a009efe04033041bda8bd954f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 6 Oct 2015 22:32:12 +0200 Subject: Screen.c: Fix freeing of unsued modes --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 37 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 26971d025..e844517bf 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3904,10 +3904,17 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) * the mode of the output's crtc. This also leads to * xinerama not showing the disconnected head anymore. */ - RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); - RROutputSetModes(pScrPriv->outputs[i], NULL, 0, 0); - if (prevmode) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from ctrc %d\n", i); + #endif + RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); + + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from output %d\n", i); + #endif + RROutputSetModes(pScrPriv->outputs[i], NULL, 0, 0); + /* throw away the previous mode, we do not need it anymore. If refcnt is 1 we call FreeResource() to ensure the system will not try to free it again on shutdown */ @@ -3917,6 +3924,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s] ([%p])\n", prevmode->name, prevmode); #endif FreeResource(prevmode->mode.id, 0); + } } } else @@ -3932,8 +3940,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) distinguish between pre-existing modes which should stay and our own modes that should be removed after use. */ /*sprintf(name, "nx%d", i+1);*/ - /*sprintf(name, "%dx%d", new_w, new_h);*/ - sprintf(name, "nx_%dx%d", new_w, new_h); + sprintf(name, "%dx%d", new_w, new_h); + /*sprintf(name, "nx_%dx%d", new_w, new_h);*/ modeInfo.width = new_w; modeInfo.height = new_h; @@ -3954,7 +3962,6 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: mode [%s] creation failed!\n", i, name); } #endif - if (prevmode) { if (mymode == prevmode) { @@ -3965,6 +3972,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* if they are the same RRModeGet() has increased the refcnt by 1. We decrease it again by calling only RRModeDestroy() and forget about prevmode */ + RRModeDestroy(mymode); + } else { #ifdef DEBUG @@ -3976,9 +3985,18 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for crtc %d\n", mymode->name, mymode, mymode->refcnt, i); #endif RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); - } - if(prevmode->refcnt == 1) - FreeResource(prevmode->mode.id, 0); + + /* throw away the mode if otherwise unused. We do not need + it anymore. We call FreeResource() to ensure the system + will not try to free it again on shutdown */ + + if (prevmode->refcnt == 1) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s]\n", prevmode->name); + #endif + FreeResource(prevmode->mode.id, 0); + } + } } else { @@ -3998,6 +4016,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputChanged(pScrPriv->outputs[i], TRUE); RRCrtcChanged(pScrPriv->crtcs[i], TRUE); + } /* release allocated memory */ -- cgit v1.2.3 From 9b87a384e24a4b8873e0dc5853e6b573791f0d33 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 6 Oct 2015 22:53:16 +0200 Subject: Screen.c: restructure xinerama code, much shorter now --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 104 +++++++++++----------------- 1 file changed, 40 insertions(+), 64 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index e844517bf..4638b261c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1780,7 +1780,9 @@ N/A XSetClassHint(nxagentDisplay,nxagentDefaultWindows[pScreen->myNum],&hint); free(hint.res_name); free(hint.res_class); - } else { + } + else + { #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window withid [%ld].\n", nxagentDefaultWindows[pScreen->myNum]); @@ -2246,7 +2248,7 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) if (pWin->realized) WindowsRestructured (); FlushAllOutput (); -} +} Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, int mmWidth, int mmHeight) @@ -3888,7 +3890,6 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1); - if (disable_output) { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: no (valid) intersection - disconnecting\n", i); @@ -3899,32 +3900,21 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) * Tests revealed that some window managers (e.g. LXDE) also * take disconnected outputs into account when calculating * stuff like wallpaper tile size and maximum window - * size. This is problematic when the disconnected output is - * smaller than any of the connected ones. Solution: unset - * the mode of the output's crtc. This also leads to - * xinerama not showing the disconnected head anymore. + * size. This is problematic when a disconnected output is + * smaller than any of the connected ones. Solution: unset the + * mode of the output's crtc. This also leads to xinerama not + * showing the disconnected head anymore. */ if (prevmode) { - #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from ctrc %d\n", i); - #endif - RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); - #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from output %d\n", i); #endif RROutputSetModes(pScrPriv->outputs[i], NULL, 0, 0); - /* throw away the previous mode, we do not need it - anymore. If refcnt is 1 we call FreeResource() to ensure - the system will not try to free it again on shutdown */ - - if (prevmode->refcnt == 1) { - #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s] ([%p])\n", prevmode->name, prevmode); - #endif - FreeResource(prevmode->mode.id, 0); - } + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from ctrc %d\n", i); + #endif + RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); } } else @@ -3935,14 +3925,17 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetConnection(pScrPriv->outputs[i], RR_Connected); memset(&modeInfo, '\0', sizeof(modeInfo)); + +#ifdef NX_USE_MODE_PREFIX /* avoid collisions with pre-existing default modes by using a separate namespace. If we'd simply use XxY we could not distinguish between pre-existing modes which should stay and our own modes that should be removed after use. */ + sprintf(name, "nx_%dx%d", new_w, new_h);*/ /*sprintf(name, "nx%d", i+1);*/ +#else sprintf(name, "%dx%d", new_w, new_h); - /*sprintf(name, "nx_%dx%d", new_w, new_h);*/ - +#endif modeInfo.width = new_w; modeInfo.height = new_h; modeInfo.hTotal = new_w; @@ -3958,50 +3951,22 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) } else { - /* FIXME: what is the correct behaviour in this case? */ + /* FIXME: what is the correct behaviour in this case? */ fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: mode [%s] creation failed!\n", i, name); } #endif - if (prevmode) { - if (mymode == prevmode) - { - #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: mymode [%s] ([%p]) == prevmode [%s] ([%p])\n", mymode->name, mymode, prevmode->name, prevmode); - #endif - - /* if they are the same RRModeGet() has increased the - refcnt by 1. We decrease it again by calling only - RRModeDestroy() and forget about prevmode */ - RRModeDestroy(mymode); - - } else { - - #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d\n", mymode->name, mymode, mymode->refcnt, i); - #endif - RROutputSetModes(pScrPriv->outputs[i], &mymode, 1, 0); - - #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for crtc %d\n", mymode->name, mymode, mymode->refcnt, i); - #endif - RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); - - /* throw away the mode if otherwise unused. We do not need - it anymore. We call FreeResource() to ensure the system - will not try to free it again on shutdown */ - - if (prevmode->refcnt == 1) { - #ifdef DEBUG - fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s]\n", prevmode->name); - #endif - FreeResource(prevmode->mode.id, 0); - } - } + if (prevmode && mymode == prevmode) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: mymode [%s] ([%p]) == prevmode [%s] ([%p])\n", mymode->name, mymode, prevmode->name, prevmode); + #endif + + /* if they are the same RRModeGet() has increased the + refcnt by 1. We decrease it again by calling only + RRModeDestroy() and forget about prevmode */ + RRModeDestroy(mymode); } else - { - /* we do not have a previous mode, so there's no need to handle it here */ - + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d\n", mymode->name, mymode, mymode->refcnt, i); #endif @@ -4011,12 +3976,23 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for crtc %d\n", mymode->name, mymode, mymode->refcnt, i); #endif RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); + } } /* if disable_output */ + /* throw away the mode if otherwise unused. We do not need it + anymore. We call FreeResource() to ensure the system will not + try to free it again on shutdown */ + + if (prevmode && prevmode->refcnt == 1) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s]\n", prevmode->name); + #endif + FreeResource(prevmode->mode.id, 0); + } + RROutputChanged(pScrPriv->outputs[i], TRUE); RRCrtcChanged(pScrPriv->crtcs[i], TRUE); - } /* release allocated memory */ -- cgit v1.2.3 From f1eafeaa456b1544384bb6a68d8a56c0a216a875 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 7 Oct 2015 15:17:59 +0200 Subject: Screen.c: Rename NX_USE_MODE_PREFIX to NXAGENT_RANDR_MODE_PREFIX, fix unclosed comment. --- nx-X11/programs/Xserver/hw/nxagent/Imakefile | 2 ++ nx-X11/programs/Xserver/hw/nxagent/Screen.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index 794864cf3..8cae91331 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -179,6 +179,7 @@ INCLUDES = -I. -I$(XBUILDINCDIR) \ # NXAGENT_CLIPBOARD Enables clipboard cut and paste function between X servers. # NXAGENT_FONTEXCLUDE Exclude some specific font names (only "-ult1mo" at this moment). # NXAGENT FULLSCREEN Fullscreen mode +# NXAGENT_RANDR_MODE_PREFIX Use prefixed (i.e., nx_x) RandR modes # #if nxVersion @@ -203,6 +204,7 @@ DEFINES = -g $(OS_DEFINES) $(EXT_DEFINES) $(NX_DEFINES) \ -DNXAGENT_ONSTART \ -DNXAGENT_SPLASH \ -DNXAGENT_ARTSD \ + -DNXAGENT_RANDR_MODE_PREFIX \ -UNX_DEBUG_INPUT \ -DRANDR_10_INTERFACE \ -DRANDR_12_INTERFACE \ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 4638b261c..087f3f41a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3926,13 +3926,12 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) memset(&modeInfo, '\0', sizeof(modeInfo)); -#ifdef NX_USE_MODE_PREFIX +#ifdef NXAGENT_RANDR_MODE_PREFIX /* avoid collisions with pre-existing default modes by using a separate namespace. If we'd simply use XxY we could not distinguish between pre-existing modes which should stay and our own modes that should be removed after use. */ - sprintf(name, "nx_%dx%d", new_w, new_h);*/ - /*sprintf(name, "nx%d", i+1);*/ + sprintf(name, "nx_%dx%d", new_w, new_h); #else sprintf(name, "%dx%d", new_w, new_h); #endif -- cgit v1.2.3 From e7e2f164b9bcf05d4cc1eb0e69879addec718824 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 7 Oct 2015 17:23:13 +0200 Subject: Only declare nxagentRandRCrtcSet if RANDR_12_INTERFACE is defined. --- nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index 103eaa92c..d77d27674 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -35,10 +35,12 @@ static int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, static int nxagentRandRInitSizes(ScreenPtr pScreen); +#if RANDR_12_INTERFACE static Bool nxagentRandRCrtcSet (ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, int x, int y, Rotation rotation, int numOutputs, RROutputPtr *outputs); +#endif #ifdef __DARWIN__ -- cgit v1.2.3 From f40792c436c2e0678f46478002830367b683f20c Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 7 Oct 2015 17:24:01 +0200 Subject: Initialize XRandR based Xinerama extension properly when session is started with "-geometry fullscreen". --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 03b14f0dc..c04481c92 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3485,7 +3485,7 @@ int nxagentHandleConfigureNotify(XEvent* X) } else { - if (X -> xconfigure.window == DefaultRootWindow(nxagentDisplay)) + if ( (X -> xconfigure.window == DefaultRootWindow(nxagentDisplay)) || nxagentFullscreenWindow ) { #ifdef TEST fprintf(stderr, "nxagentHandleConfigureNotify: remote root window has changed: %d,%d %dx%d\n", X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height); -- cgit v1.2.3 From 0297567cd501b6fc012c41ff4a1ae27304ff6a10 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 7 Oct 2015 20:51:12 +0200 Subject: Provide support for re-enabling Xinerama on session resumptions. By design, when resuming a session, Xinerama can only be re-enabled by NX option parsing. Thus, this change introduces a "xinerama" NX option that can be loaded via an options file into NX agent when resuming a session. The new xinerame NX session option also allows switching on Xinerama at session startup via an option file. When implementing the new NX Xinerama support into clients (like TheQVD, X2Go Client, etc., this new xinerama NX option should be used for activating Xinerama in the NX / QVD / X2Go session. --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 31 ++++++++++++++++++++++++++ nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 6 +++-- nxcomp/Misc.cpp | 1 + 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 5c5a1e8f8..309f08d0e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -42,6 +42,7 @@ is" without express or implied warranty. #include "screenint.h" #include "input.h" #include "misc.h" +#include "globals.h" #include "scrnintstr.h" #include "dixstruct.h" #include "servermd.h" @@ -1202,6 +1203,36 @@ static void nxagentParseOptions(char *name, char *value) return; } + else if (!strcmp(name, "xinerama")) + { +#ifdef PANORAMIX + if (!PanoramiXExtensionDisabledHack) + { + if (!strcmp(value, "1")) + { + nxagentChangeOption(Xinerama, 1); + } + else if (!strcmp(value, "0")) + { + nxagentChangeOption(Xinerama, 0); + } + else + { + fprintf(stderr, "Warning: Ignoring bad value '%s' for option 'xinerama'.\n", + validateString(value)); + } + } + else + { + nxagentChangeOption(Xinerama, 0); + fprintf(stderr, "Warning: Xinerama extension has been disabled via -disablexineramaextension cmdline switch.\n"); + } +#else + nxagentChangeOption(Xinerama, 0); + fprintf(stderr, "Warning: No Xinerama support compiled into nxagent.\n") +#endif /* of PANORAMIX */ + return; + } else if (!strcmp(name, "resize")) { if (nxagentOption(DesktopResize) == 0 || strcmp(value, "0") == 0) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index b26fa9cfe..660d30863 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -624,7 +624,7 @@ Bool nxagentReconnectSession(void) nxagentRedirectDefaultWindows(); - if (nxagentResizeDesktopAtStartup || nxagentOption(Rootless) == True) + if (nxagentResizeDesktopAtStartup || nxagentOption(Rootless) == True || nxagentOption(Xinerama) == True) { nxagentChangeScreenConfig(0, nxagentOption(RootWidth), nxagentOption(RootHeight), 0, 0); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 087f3f41a..17e749a6b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1113,8 +1113,10 @@ Bool nxagentOpenScreen(int index, ScreenPtr pScreen, nxagentChangeOption(ViewportXSpan, nxagentOption(Width) - nxagentOption(RootWidth)); nxagentChangeOption(ViewportYSpan, nxagentOption(Height) - nxagentOption(RootHeight)); - /* store the user's preference provided via cmdline */ - nxagentOption(Xinerama) = !noPanoramiXExtension; + /* PanoramiXExtension enabled via cmdline, turn on Xinerama in nxagent + */ + if( (!noPanoramiXExtension) && (!PanoramiXExtensionDisabledHack) ) + nxagentOption(Xinerama) = True; if (nxagentReconnectTrap == 0) { diff --git a/nxcomp/Misc.cpp b/nxcomp/Misc.cpp index 3297d8ee8..ee73f19d8 100644 --- a/nxcomp/Misc.cpp +++ b/nxcomp/Misc.cpp @@ -306,6 +306,7 @@ clipboard=n\n\ streaming=n\n\ backingstore=n\n\ composite=n\n\ +xinerama=n\n\ shmem=b\n\ shpix=b\n\ kbtype=s\n\ -- cgit v1.2.3 From 522cf0089e4db707346c25d826c33e92ef09db8a Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 7 Oct 2015 21:33:55 +0200 Subject: X2Go Agent: Add x2goagent.features file that informs X2Go clients about the new RandR based Xinerama feature. --- Makefile | 9 +++++++++ debian/x2goagent.install | 1 + x2goagent.features | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 x2goagent.features diff --git a/Makefile b/Makefile index 14f6e4266..c9a52ac02 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ USRLIBDIR ?= $(LIBDIR) INCLUDEDIR ?= $(PREFIX)/include NXLIBDIR ?= $(PREFIX)/lib/nx X2GOLIBDIR ?= $(PREFIX)/lib/x2go +X2GODATADIR ?= $(PREFIX)/share/x2go CONFIGURE ?= ./configure NX_VERSION_MAJOR=$(shell ./version.sh 1) @@ -163,6 +164,10 @@ install-full: $(INSTALL_FILE) etc/nxagent.keyboard $(DESTDIR)$(ETCDIR_NX)/ $(INSTALL_FILE) etc/x2goagent.keyboard $(DESTDIR)$(ETCDIR_X2GO)/ + # x2goagent.features file for X2Go + $(INSTALL_DIR) $(DESTDIR)$(X2GODATADIR)/x2gofeature.d/ + $(INSTALL_FILE) x2goagent.features $(DESTDIR)$(X2GODATADIR)/x2gofeature.d/ + $(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/x2go $(INSTALL_SYMLINK) $(ETCDIR_X2GO)/rgb $(DESTDIR)$(PREFIX)/share/x2go/rgb @@ -191,6 +196,10 @@ uninstall-full: $(RM_FILE) $(DESTDIR)$(X2GOLIBDIR)/bin/x2goagent $(RM_DIR) $(DESTDIR)$(X2GOLIBDIR)/bin/ + # x2goagent.features file for X2Go + $(RM_FILE) $(DESTDIR)$(X2GODATADIR)/x2gofeature.d/x2goagent.features + $(RM_DIR) $(DESTDIR)$(X2GODATADIR)/x2gofeature.d/ + if test -d nx-X11; then \ if test -f nxcompext/Makefile; then ${MAKE} -C nxcompext $@; fi; \ if test -f nxcompshad/Makefile; then ${MAKE} -C nxcompshad $@; fi; \ diff --git a/debian/x2goagent.install b/debian/x2goagent.install index 9ef17d9c6..0603507ef 100644 --- a/debian/x2goagent.install +++ b/debian/x2goagent.install @@ -5,5 +5,6 @@ usr/share/x2go/rgb usr/share/man/man1/x2goagent.1* etc/x2go/rgb usr/share/x2go/versions/VERSION.x2goagent +usr/share/x2go/x2gofeature.d/x2goagent.features etc/x2go/keystrokes.cfg etc/x2go/x2goagent.keyboard diff --git a/x2goagent.features b/x2goagent.features new file mode 100644 index 000000000..12d62e01c --- /dev/null +++ b/x2goagent.features @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright (C) 2015, Mike Gabriel +# +# This program 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 program 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 program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +# silently bail out if X2Go Server is not installed +if ! which x2gopath 1>/dev/null; then + exit 0 +fi + +X2GO_LIB_PATH="$(x2gopath libexec)"; + +$X2GO_LIB_PATH/x2gosyslog "$0" "info" "$(basename $0) called with options: $@" + +X2GO_FEATURE=$1 + +# check for X2Go Agent features +case "$X2GO_FEATURE" in + + "X2GOAGENT_RANDRXINERAMA") echo "ok"; exit 0;; + *) exit -1;; + +esac -- cgit v1.2.3 From d49b0625ecdbdc18398e80feaa23af874e0d6359 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 7 Oct 2015 20:44:19 +0200 Subject: Xserver help: Document -disablexineramaextension cmdline option. --- nx-X11/programs/Xserver/os/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index 3ab08897a..4934b5ca3 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -701,6 +701,7 @@ void UseMsg(void) #ifdef PANORAMIX ErrorF("+xinerama Enable XINERAMA extension\n"); ErrorF("-xinerama Disable XINERAMA extension\n"); + ErrorF("-disablexineramaextension Disable XINERAMA extension\n"); #endif #ifdef SMART_SCHEDULE ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n"); -- cgit v1.2.3 From 4ba8df855379c631e7afb1a6bba8f1fb93621d19 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 7 Oct 2015 20:45:14 +0200 Subject: Xserver globals.h: Make PanoramiXExtensionDisabledHack globally available. --- nx-X11/programs/Xserver/include/globals.h | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/include/globals.h b/nx-X11/programs/Xserver/include/globals.h index 0f2864825..bb6aa80d3 100644 --- a/nx-X11/programs/Xserver/include/globals.h +++ b/nx-X11/programs/Xserver/include/globals.h @@ -46,6 +46,7 @@ extern Bool PanoramiXMapped; extern Bool PanoramiXVisibilityNotifySent; extern Bool PanoramiXWindowExposureSent; extern Bool PanoramiXOneExposeRequest; +extern Bool PanoramiXExtensionDisabledHack; #endif #ifdef BIGREQS -- cgit v1.2.3 From c4a388937baad8215f2650d746d3ddba4d4d1ee3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 8 Oct 2015 22:25:09 +0200 Subject: Xinerama: do not cut off at outer edges This fixes the problem Mike Gabriel describes like this: - Launch a session on a system with a single monitor. Enable Xinerama for this session. - Open a desktop session in that session window (e.g. MATE or XFCE). - Move the NX/MATE-or-XFCE session window around on that one monitor. Bump at the borders, so that the session window moves into the invisible parts around your monitor. What you see is that the MATE-or-XFCE window manager will become really busy with resizing the windows and panels in the NX session, because moving the window over the physical borders of the display will trigger resize events. This is non-intuitive, I think. Same with multi-monitors on the outside edges of the physical Xorg RandR setup. --- nx-X11/programs/Xserver/hw/nxagent/Imakefile | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 78 +++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index 8cae91331..160d01e60 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -180,7 +180,7 @@ INCLUDES = -I. -I$(XBUILDINCDIR) \ # NXAGENT_FONTEXCLUDE Exclude some specific font names (only "-ult1mo" at this moment). # NXAGENT FULLSCREEN Fullscreen mode # NXAGENT_RANDR_MODE_PREFIX Use prefixed (i.e., nx_x) RandR modes -# +# NXAGENT_RANDR_XINERAMA_CLIPPING cut off invisible window parts in xinerama mode (you probably do not want this) #if nxVersion NX_DEFINES=-DNX_VERSION_CURRENT="$(NX_VERSION_CURRENT)" \ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 17e749a6b..a677b7eb4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -106,8 +106,8 @@ is" without express or implied warranty. #define PANIC #define WARNING -#undef TEST -#undef DEBUG +#define TEST +#define DEBUG #undef WATCH #undef DUMP @@ -3640,6 +3640,36 @@ Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, return TRUE; } +#ifndef NXAGENT_RANDR_XINERAMA_CLIPPING +/* intersect two rectangles, return aw/ah for w/h if resulting + rectangle is (partly) outside of bounding box */ +Bool intersect_bb(int ax1, int ay1, unsigned int aw, unsigned int ah, + int bx1, int by1, unsigned int bw, unsigned int bh, + int bbx1, int bby1, int bbx2, int bby2, + int *x, int *y, unsigned int *w, unsigned int *h) +{ + Bool result = intersect(ax1, ay1, aw, ah, bx1, by1, bw, bh, x, y, w, h); + if (result == TRUE) { + /* check if outside of bounding box */ + if (ax1 < bbx1 || ax1 + aw > bbx2) { + #ifdef DEBUG + fprintf(stderr, "intersect: box has parts outside bounding box - width stays unchanged [%d]\n", aw); + #endif + *w = aw; + } + + if (ay1 < bby1 || ay1 + ah > bby2) { + #ifdef DEBUG + fprintf(stderr, "intersect: box has parts outside bounding box - height stays unchanged [%d]\n", ah); + #endif + *h = ah; + } + } + + return result; +} +#endif + int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, int mmHeight) { ScreenPtr pScreen; @@ -3783,6 +3813,23 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RRGetInfo(pScreen); #endif +#ifndef NXAGENT_RANDR_XINERAMA_CLIPPING + /* calculate bounding box (outer edges) */ + int bbx2, bbx1, bby1, bby2; + bbx2 = bby2 = 0; + bbx1 = bby1 = INT_MAX; + + for (i = 0; i < number; i++) { + bbx2 = MAX(bbx2, screeninfo[i].x_org + screeninfo[i].width); + bby2 = MAX(bby2, screeninfo[i].y_org + screeninfo[i].height); + bbx1 = MIN(bbx1, screeninfo[i].x_org); + bby1 = MIN(bby1, screeninfo[i].y_org); + } + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: bounding box: left [%d] right [%d] top [%d] bottom[%d]\n", bbx1, bbx2, bby1, bby2); + #endif +#endif + #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs [%d], numOutputs [%d]\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); #endif @@ -3873,12 +3920,37 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) int new_x, new_y; unsigned int new_w, new_h; + /* + if ((nxagentOption(X) < bbx1 || (nxagentOption(X) + width >= bbx2 )) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: window has parts outside visible area - width stays unchanged [%d]\n", width); + #endif + new_w = width; + } + + if ((nxagentOption(Y) < bby1 || (nxagentOption(Y) + height >= bby2 ) { + #ifdef DEBUG + fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: window has parts outside visible area - height stays unchanged [%d]\n", height); + #endif + new_h = height; + } + */ + /* if there's no intersection disconnect the output */ +#ifdef NXAGENT_RANDR_XINERAMA_CLIPPING disable_output = !intersect(nxagentOption(X), nxagentOption(Y), width, height, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height, &new_x, &new_y, &new_w, &new_h); +#else + disable_output = !intersect_bb(nxagentOption(X), nxagentOption(Y), + width, height, + screeninfo[i].x_org, screeninfo[i].y_org, + screeninfo[i].width, screeninfo[i].height, + bbx1, bby1, bbx2, bby2, + &new_x, &new_y, &new_w, &new_h); +#endif /* save previous mode */ prevmode = pScrPriv->crtcs[i]->mode; @@ -3924,6 +3996,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: intersection is x [%d] y [%d] width [%d] height [%d]\n", i, new_x, new_y, new_w, new_h); #endif + RROutputSetConnection(pScrPriv->outputs[i], RR_Connected); memset(&modeInfo, '\0', sizeof(modeInfo)); @@ -3937,6 +4010,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) #else sprintf(name, "%dx%d", new_w, new_h); #endif + modeInfo.width = new_w; modeInfo.height = new_h; modeInfo.hTotal = new_w; -- cgit v1.2.3