Commit 8fa612d1 authored by Reinhard Tartler's avatar Reinhard Tartler

Imported nxcompshad-3.1.0-2.tar.gz

Summary: Imported nxcompshad-3.1.0-2.tar.gz Keywords: Imported nxcompshad-3.1.0-2.tar.gz into Git repository
parent a840692e
ChangeLog:
nxcompshad-3.1.0-2
- Updated file VERSION to match the current release version.
nxcompshad-3.1.0-1
- Opened the 3.1.0 branch based on nxcompshad-3.0.0-19.
nxcompshad-3.0.0-19
- Skip initialization of damage extension if it was already disabled.
nxcompshad-3.0.0-18
- The poller destructor checks if the damage extension is in use.
- Small changes to the function getting the screen content in the case
damage is not in use.
nxcompshad-3.0.0-17
- Cleanup of some log messages.
nxcompshad-3.0.0-16
- Disabled some log message in the functions initializing the poller.
nxcompshad-3.0.0-15
- Before calling XTest functions, it is checked if the connection to
master X server has been initialized.
nxcompshad-3.0.0-14
- After the shm segment is created, its mode is changed and it is
marked for destroying. A check on the number of attaches is done.
nxcompshad-3.0.0-13
- Creating the shm segment even if the uid of master X server can't be
retrieved.
- Fixed reallocation of update region.
- Checking if the master X server provides XTest extension.
nxcompshad-3.0.0-12
- Fixed a compiler warning on AMD64 platform.
- Changed configure script to add -fPIC option.
- Fixed a mismatch in UpdateManager destructor.
nxcompshad-3.0.0-11
- Fixed the function setting the uid of shm segment.
- Sync with the master X server before marking the shm segment to be
destroyed.
nxcompshad-3.0.0-10
- Setting the shm segments as readable only by the master X server
process.
- Mark shm segments to be destroyed when the last process detach.
- Enabled keycode translation in order to allow keyboards of different
models to work.
nxcompshad-3.0.0-9
- Changed the LICENSE file to state that the software is only made
available under the version 2 of the GPL.
- Added file COPYING.
- Changes to translate keycodes between different keyboard types. The
keycodes are translated through the keysym.
- Changes to convert a Mode_switch key to ISO_Level3_Shift if it is
needed.
nxcompshad-3.0.0-8
- Added interface function NXShadowDisableShm disabling the use of
MIT-SHM extension.
- Added interface function NXShadowDisableDamage disabling the use of
DAMAGE extension.
- Added interface function NXShadowSetDisplayUid setting the uid of
shadowed X server
- Changed the owner of shared memory segments to the uid of the sha-
dowed X server.
- Fixed logWarning method.
- Moved the code initializing the use of shared memory to shmInit
method of X11 Poller.
nxcompshad-3.0.0-7
- Removed the class qualifier in the declaration of destroyUpdate-
ManagerRegion().
nxcompshad-3.0.0-6
- Fixed build errors on 64 bit platforms.
- Called XTestGrabControl to override possible grabs of the X server.
nxcompshad-3.0.0-5
- Added some stub members to the Poller class. These are intended to
handle keyboard state.
- Changes in the default polling algorithm to disable the line pri-
ority persistence.
nxcompshad-3.0.0-4
- If a low layer handling of screen changes is available (DAMAGE in
case of X11), polling routine uses it and returns immediately.
- Creating a Damage notify object if the extension is supported.
- DamageNotify events are saved in the update region. After all avail-
able events have been handled, the content of screen is retrieved
by ShnGetImage requests.
- XDamageSubtract and XSync are done before any event handling.
- Damages are requested as raw rectangles.
- Added Xdamage and Xrandr to required libraries.
- Fixed a problem with some lines not refreshed in shadowing mode.
nxcompshad-3.0.0-3
- Added destroyUpdateManagerRegion() method to UpdateManager class.
- Turned off some log messages.
- Changed configure.in to remove warnings related to deprecated header
files and options.
- Changed Makefile.in to remove autom4te.cache dir if the target is
'distclean'.
- Removed multi-word file names.
nxcompshad-3.0.0-2
- Changes to get the screen of original display by a ShmGetImage.
- Exit the polling loop if more than 50 ms have elapsed.
nxcompshad-3.0.0-1
- Created nxcompshad based on nxshadow-3.0.0-7.
nxshadow-3.0.0-7
- Deleted files KeyCursorTmp.cpp, scancodes.h, constant.h.
- Renamed NXshadow.h to Shadow.h.
- Merged NXshadowEvent.h with Shadow.h.
- Fixed configure.in, changed Makefile.in to build Xcompshad library,
rebuilt configure script.
nxshadow-3.0.0-6
- Implemented a callback mechanism to ask the caller program if screen
polling have to be suspended.
nxshadow-3.0.0-5
- Changes to comply with the library name.
- Fixed a bug in CorePoller that could prevent the update of the last
line of a rectangle.
nxshadow-3.0.0-4
- Removed some parameters of the NXShadowAddUpdaterDisplay() function.
nxshadow-3.0.0-3
- Updated copyright notices to the current year.
- Code cleanup in KeysCursorTmp.c file.
nxshadow-3.0.0-2
- If master agent uses shared memory extension, the GetImage is rea-
lized by XShmGetImage() function.
- Added new parameters to NXShadowAddUpdaterDisplay() function, the
depth and bit mask color of the master display.
nxshadow-3.0.0-1
- Opened the nxshadow-3.0.0 branch based on the nxaccess-3.0.0-13.
- Renamed NXaccess.h NXaccessEvent.h and RegionM.h files as NXshadow.h
NXshadowEvent.h and Regions.h.
- Modified the Makefile.in file and configure scripts in order to
compile the component.
nxaccess-3.0.0-13
- Fixed X11Poller.cpp pre-processing.
nxaccess-3.0.0-12
- Fixed build problems on Solaris.
nxaccess-3.0.0-11
- Added NXShadowUpdateBuffer() function. This function creates the
buffer for the polling.
- If the scaline fails, the polling will suspend for 50 ms.
- Added some functions in order to access data member class.
nxaccess-3.0.0-10
- Used XTEST extension to make the shared display create input events.
nxaccess-3.0.0-9
- Added the mouse events.
- Now, it's possible to connect to X server display or agent display,
the display's content is captured by GetImage and sent to another
display by PutImage.
nxaccess-3.0.0-8
- Added KeysCursorTmp.cpp file.
- Solved a problem with the keys, when the window lost focus the Key-
Release events weren't propagated.
nxaccess-3.0.0-7
- Added functions in order to remove issues with some keys combina-
tion.
nxaccess-3.0.0-6
- Added functions to simulate keys Ctrl + Alt + Del in order to run
the Task Manager application.
- Now nxaccess is able to manage all switches between desktops.
nxaccess-3.0.0-5
- Solved a problem with the cursor shape. After a while, the cursor
shape are no more updated.
- Now the cursor is updated only when it changes its shape.
- Removed a dirty lines after screen updates.
- Removed the unused file Keyboard.cpp.
- Added the colorCorrect() macro in NXaccess.h.
- Removed the colorCorrect() function in Updater.cpp.
nxaccess-3.0.0-4
- Renamed some source files and functions conforming them to the name
of component.
nxaccess-3.0.0-3
- Removed the parameter of type Display in all methods of the class
Poller.
- Print, Break and Pause keys are enabled.
nxaccess-3.0.0-2
- Modified the Makefile.in in order to avoid compiling the executive
file.
- Removed the unused file Main.cpp.
- The Windows keys are enabled.
- Synchronized local and remote states of Num_Lock, Caps_Lock and
Scroll_Lock.
- Updated the NoMachine copyright notices.
nxaccess-3.0.0-1
- Opened the 3.0.0 branch based on the nxmirror-2.0.0-3.
nxmirror-2.0.0-3
- Added the keyboard events for all layouts.
- The mouse wheel button is enabled.
nxmirror-2.0.0-2
- Completed implementation of the keyboard events only for italian
layout.
- Added the mouse events and shape cursor.
nxmirror-2.0.0-1
- Opened the 2.0.0 branch based on the 1.5.0-60.
- Added CHANGELOG.
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef CorePoller_H
#define CorePoller_H
#include <stdio.h>
#include "Logger.h"
#include "Regions.h"
#include "Input.h"
typedef enum{
LINE_HAS_CHANGED,
LINE_NOT_CHECKED,
LINE_NOT_CHANGED
} LineStatus;
typedef enum{
HIGHEST_PRIORITY = 0,
PRIORITY = 30,
NOT_PRIORITY = 90
} LinePriority;
class CorePoller
{
public:
CorePoller(Input*, Display*);
virtual ~CorePoller();
virtual int init();
unsigned int width() const;
unsigned int height() const;
unsigned char depth() const;
int isChanged(int (*)(void*), void *, int *);
char *getFrameBuffer() const;
void destroyFrameBuffer();
void createFrameBuffer();
Region lastUpdatedRegion();
Region getLastUpdatedRegion();
void handleInput();
void handleEvent(Display *, XEvent *);
Display *getShadowDisplay();
void setShadowDisplay(Display *shadowDisplay);
protected:
unsigned int bpp_;
unsigned int bpl_;
unsigned int width_;
unsigned int height_;
int depth_;
char *buffer_;
unsigned long redMask_;
unsigned long greenMask_;
unsigned long blueMask_;
unsigned long colorMask_[3];
char mirror_;
char mirrorChanges_;
virtual int updateShadowFrameBuffer(void) = 0;
virtual char *getRect(XRectangle r) = 0;
int imageByteOrder_;
#ifdef __CYGWIN32__
virtual char checkDesktop(void) = 0;
#endif
Display *shadowDisplay_;
void update(char *src, XRectangle r);
Region lastUpdatedRegion_;
private:
virtual void handleKeyboardEvent(Display *, XEvent *) = 0;
virtual void handleMouseEvent(Display *, XEvent *) = 0;
Input *input_;
static const int maxSliceHeight_;
static const int minSliceHeight_;
LineStatus *lineStatus_;
int *linePriority_;
static const char interlace_[];
int *lefts_;
int *rights_;
// FIXME: Make them friend.
int differ(char *src, XRectangle r);
};
inline unsigned int CorePoller::width() const
{
return width_;
}
inline unsigned int CorePoller::height() const
{
return height_;
}
inline unsigned char CorePoller::depth() const
{
return depth_;
}
inline char *CorePoller::getFrameBuffer() const
{
return buffer_;
}
inline void CorePoller::destroyFrameBuffer()
{
if (buffer_ != NULL)
{
delete[] buffer_;
buffer_ = NULL;
}
}
inline Region CorePoller::lastUpdatedRegion()
{
Region region = lastUpdatedRegion_;
lastUpdatedRegion_ = XCreateRegion();
if (lastUpdatedRegion_ == NULL)
{
logError("CorePoller::lastUpdatedRegion", ESET(ENOMEM));
lastUpdatedRegion_ = region;
return NULL;
}
return region;
}
inline Region CorePoller::getLastUpdatedRegion()
{
return lastUpdatedRegion_;
}
inline Display *CorePoller::getShadowDisplay()
{
return shadowDisplay_ ;
}
inline void CorePoller::setShadowDisplay(Display *shadowDisplay)
{
shadowDisplay_ = shadowDisplay;
}
#endif /* CorePoller_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#include <string.h>
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
#include "Input.h"
#include "Logger.h"
Input::Input()
{
logTrace("Input::Input");
eventsHead_ = NULL;
eventsTail_ = NULL;
keymap_ = NULL;
}
Input::~Input()
{
logTrace("Input::~Input");
Event *head = eventsHead_;
while (head)
{
Event *next = head -> next;
delete head -> event;
delete head;
head = next;
}
if (keymap_ != NULL)
{
logDebug("Input::~Input", "Delete keymap_ [%p].", keymap_);
delete [] keymap_;
}
}
void Input::pushEvent(Display *display, XEvent *event)
{
Event *tail = new Event;
if (tail == NULL)
{
logError("Input::pushEvent", ESET(ENOMEM));
return;
}
tail -> next = NULL;
tail -> display = display;
tail -> event = event;
if (eventsHead_ == NULL)
{
eventsHead_ = tail;
}
else
{
eventsTail_ -> next = tail;
}
eventsTail_ = tail;
}
XEvent *Input::popEvent()
{
Event *head = eventsHead_;
if (head == NULL)
{
return 0;
}
XEvent *event = head -> event;
eventsHead_ = head -> next;
delete head;
if (eventsHead_ == NULL)
{
eventsTail_ = NULL;
}
return event;
}
int Input::removeAllEvents(Display *display)
{
logTrace("Input::removeAllEvents");
int nRemoved = 0;
Event *current = eventsHead_;
while (current)
{
if (display == current -> display)
{
//
// Update head of list.
//
if (current == eventsHead_)
{
eventsHead_ = current -> next;
}
//
// Update tail of list.
//
if (current == eventsTail_)
{
eventsTail_ = eventsHead_;
while (eventsTail_ && eventsTail_ -> next)
{
eventsTail_ = eventsTail_ -> next;
}
}
//
// Remove event.
//
Event *next = current -> next;
delete current -> event;
delete current;
current = next;
nRemoved++;
}
else
{
current = current -> next;
}
}
return nRemoved;
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef Input_H
#define Input_H
#include <X11/Xlib.h>
typedef struct Event
{
struct Event *next;
Display *display;
XEvent *event;
} Event;
class Input
{
public:
Input();
~Input();
int checkIfEvent();
void pushEvent(Display *, XEvent *);
XEvent *popEvent();
Display *currentDisplay();
int removeAllEvents(Display *);
void setKeymap(char *keymap);
char *getKeymap();
void setShadowDisplayName(char *shadowDisplayName);
char *getShadowDisplayName();
private:
Event *eventsHead_;
Event *eventsTail_;
char *keymap_;
char *shadowDisplayName_;
};
inline Display *Input::currentDisplay()
{
return eventsHead_ ? eventsHead_ -> display : NULL;
}
inline int Input::checkIfEvent()
{
return (eventsHead_ != NULL);
}
inline void Input::setKeymap(char *keymap)
{
keymap_ = keymap;
}
inline char *Input::getKeymap()
{
return keymap_;
}
inline void Input::setShadowDisplayName(char *shadowDisplayName)
{
shadowDisplayName_ = shadowDisplayName;
}
inline char *Input::getShadowDisplayName()
{
return shadowDisplayName_;
}
#endif /* Input_H */
Copyright (C) 2001, 2007 NoMachine - http://www.nomachine.com/.
NXCOMPSHAD and NX extensions to X are copyright of NoMachine.
Redistribution and use of this software is allowed according to the
following terms:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 2, and
not any other version, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA-
BILITY 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, you can request a copy to NoMachine
or write to the Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA
All rights reserved.
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#define PANIC
#define WARNING
#undef TEST
#define DEBUG
#include "Misc.h"
#include "Logger.h"
Logger logger;
void Logger::user(const char *format, va_list arguments)
{
char string[1024];
vsnprintf(string, 1024, format, arguments);
fprintf(stderr, "%s\n", string);
}
void Logger::error(const char *name, int error)
{
fprintf(stderr, "PANIC! %s: Failed with code %d: %s\n",
name, error, strerror(error));
}
void Logger::warning(const char *name, const char *format, va_list arguments)
{
char string[1024];
vsnprintf(string, 1024, format, arguments);
fprintf(stderr, "%s: WARNING! %s\n", name, string);
}
void Logger::test(const char *name, const char *format, va_list arguments)
{
char string[1024];
vsnprintf(string, 1024, format, arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
void Logger::trace(const char *name)
{
fprintf(stderr, "%s\n", name);
}
void Logger::debug(const char *name, const char *format, va_list arguments)
{
char string[1024];
vsnprintf(string, 1024, format, arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
void Logger::dump(const char *name, const char *data, int size)
{
fprintf(stderr, "%s: Dumping %d bytes of data at %p\n",
name, size, data);
for (int i = 0; i < size;)
{
fprintf(stderr, "[%d]\t", i);
int t = i;
for (unsigned int ii = 0; i < size && ii < 8; i++, ii++)
{
fprintf(stderr, "%02x/%d\t", data[i] & 0xff, data[i]);
}
for (unsigned int ii = i % 8; ii > 0 && ii < 8; ii++)
{
fprintf(stderr, "\t");
}
i = t;
for (unsigned int ii = 0; i < size && ii < 8; i++, ii++)
{
if (isprint(data[i]))
{
fprintf(stderr, "%c", data[i]);
}
else
{
fprintf(stderr, ".");
}
}
fprintf(stderr, "\n");
}
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */
/* */
/* NXCOMP, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef Logger_H
#define Logger_H
#include <errno.h>
#include <stdarg.h>
//
// Error handling macros.
//
#define ESET(e) (errno = (e))
#define EGET() (errno)
#define ESTR() strerror(errno)
extern class Logger logger;
class Logger
{
public:
void user(const char *format, va_list arguments);
void error(const char *name, int error);
void warning(const char *name, const char *format, va_list arguments);
void test(const char *name, const char *format, va_list arguments);
void trace(const char *name);
void debug(const char *name, const char *format, va_list arguments);
void dump(const char *name, const char *data, int size);
};
static inline void logUser(const char *format, ...) \
__attribute__((format(printf, 1, 2))) __attribute__((__unused__));
static inline void logError(const char *name, int error) \
__attribute__((__unused__));
static inline void logWarning(const char *name, const char *format, ...) \
__attribute__((__unused__));
static inline void logTest(const char *name, const char *format, ...) \
__attribute__((format(printf, 2, 3))) __attribute__((__unused__));
static inline void logTrace(const char *name) \
__attribute__((__unused__));
static inline void logDebug(const char *name, const char *format, ...) \
__attribute__((format(printf, 2, 3))) __attribute__((__unused__));
static inline void logDump(const char *name, const char *data, int size) \
__attribute__((__unused__));
static inline void logUser(const char *format, ...)
{
va_list arguments;
va_start(arguments, format);
logger.user(format, arguments);
va_end(arguments);
}
static inline void logError(const char *name, int error)
{
#if defined(DEBUG) || defined(TEST) || \
defined(WARNING) || defined(PANIC)
logger.error(name, error);
#endif
}
static inline void logWarning(const char *name, const char *format, ...)
{
#if defined(DEBUG) || defined(TEST) || \
defined(WARNING)
va_list arguments;
va_start(arguments, format);
logger.warning(name, format, arguments);
va_end(arguments);
#endif
}
static inline void logTest(const char *name, const char *format, ...)
{
#if defined(TEST)
va_list arguments;
va_start(arguments, format);
logger.test(name, format, arguments);
va_end(arguments);
#endif
}
static inline void logTrace(const char *name)
{
#if defined(DEBUG)
logger.trace(name);
#endif
}
static inline void logDebug(const char *name, const char *format, ...)
{
#if defined(DEBUG)
va_list arguments;
va_start(arguments, format);
logger.debug(name, format, arguments);
va_end(arguments);
#endif
}
static inline void logDump(const char *name, const char *data, int size)
{
#if defined(TEST)
logger.dump(name, data, size);
#endif
}
#endif /* Logger_H */
############################################################################
# #
# Copyright (c) 2001, 2005 NoMachine, http://www.nomachine.com. #
# #
# NXCOMP, NX protocol compression and NX extensions to this software #
# are copyright of NoMachine. Redistribution and use of the present #
# software is allowed according to terms specified in the file LICENSE #
# which comes in the source distribution. #
# #
# Check http://www.nomachine.com/licensing.html for applicability. #
# #
# NX and NoMachine are trademarks of Medialogic S.p.A. #
# #
# All rights reserved. #
# #
############################################################################
#
# Get values from configure script.
#
VERSION=@VERSION@
LIBVERSION=@LIBVERSION@
#
# We would really like to enable all warnings, -Wredundant-decls,
# though, gives a warning caused by pthread.h and unistd.h and
# GCC 3.4 was changed in a way that it now complains about some
# of the -W directives we used before (-Wmissing-declarations,
# -Wnested-externs, -Wstrict-prototypes and -Wmissing-prototypes).
#
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ @X_CFLAGS@ @DEFS@ \
-Wall -Wpointer-arith
CXXINCLUDES =
CXXDEFINES =
#
# C programs don't share the C++ flags. They should
# have their own @CCFLAGS@.
#
CC = @CC@
CCFLAGS = @X_CFLAGS@ @DEFS@ \
-Wall -Wpointer-arith
CCINCLUDES =
CCDEFINES =
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ -L/usr/X11R6/lib -lX11
#
# Only if THREADS is defined.
#
# LIBS = $(LIBS) -lpthread
#
#
# Only if you want ElectricFence.
#
# LIBS = $(LIBS) -lefence
#
#
# Only if you want mpatrol.
#
# LIBS = $(LIBS) -lmpatrol -lbfd -liberty
#
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
man1dir = @mandir@/man1
VPATH = @srcdir@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
#
# This should be autodetected.
#
MAKEDEPEND = @MAKEDEPEND@
DEPENDINCLUDES = -I/usr/include/g++ -I/usr/include/g++-3
.SUFFIXES: .cpp.c
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(CXXINCLUDES) $(CXXDEFINES) $<
.c.o:
$(CC) -c $(CCFLAGS) $(CCINCLUDES) $(CCDEFINES) $<
LIBRARY = Xcompshad
LIBNAME = lib$(LIBRARY)
LIBFULL = lib$(LIBRARY).so.$(VERSION)
LIBLOAD = lib$(LIBRARY).so.$(LIBVERSION)
LIBSHARED = lib$(LIBRARY).so
LIBARCHIVE = lib$(LIBRARY).a
MSRC = Main.c
CSRC =
CXXSRC = Core.cpp \
Input.cpp \
Logger.cpp \
Shadow.cpp \
X11.cpp \
Win.cpp \
Updater.cpp \
Manager.cpp
MOBJ = $(MSRC:.c.cpp=.o)
COBJ = $(CSRC:.c=.o)
CXXOBJ = $(CXXSRC:.cpp=.o)
MLIBS = -L. -lXShadow
ifeq ($(findstring -lgdi32,$(LIBS)),-lgdi32)
# We need a smarter way to detect windows
# platform.
LIBDLL = cyg$(LIBRARY).dll
LIBDLLSTATIC = lib${LIBRARY}.dll.a
all: depend $(LIBARCHIVE) $(LIBDLL)
else
EXTRALIBS = -lXtst -lXrandr -lXdamage
all: depend $(LIBFULL) $(LIBLOAD) $(LIBSHARED) $(LIBARCHIVE)
endif
$(LIBFULL): $(CXXOBJ) $(COBJ)
$(CXX) -o $@ $(LDFLAGS) $(CXXOBJ) $(COBJ) $(LIBS) $(EXTRALIBS)
$(LIBLOAD): $(LIBFULL)
rm -f $(LIBLOAD)
ln -s $(LIBFULL) $(LIBLOAD)
$(LIBSHARED): $(LIBFULL)
rm -f $(LIBSHARED)
ln -s $(LIBFULL) $(LIBSHARED)
$(LIBARCHIVE): $(CXXOBJ) $(COBJ)
rm -f $(LIBARCHIVE)
ar clq $(LIBARCHIVE) $(CXXOBJ) $(COBJ)
ranlib $(LIBARCHIVE)
$(LIBDLL): $(LIBARCHIVE)
$(CC) -o $@ \
-shared \
-Wl,--out-implib=$(LIBDLLSTATIC) \
-Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--whole-archive ${LIBARCHIVE} \
-Wl,--no-whole-archive \
${LIBS} -L/usr/X11R6/lib
$(PROGRAM): $(MOBJ) $(COBJ) $(CXXOBJ) $(LIBDLL)
# $(CC) $(CCFLAGS) -o $@ $(MOBJ) $(MLIBS)
depends: depend.status
depend: depend.status
depend.status:
if [ -x $(MAKEDEPEND) ] ; then \
$(MAKEDEPEND) $(CXXINCLUDES) $(CCINCLUDES) \
$(DEPENDINCLUDES) -f Makefile $(MSRC) $(CSRC) $(CXXSRC) 2>/dev/null; \
fi
touch depend.status
install: install.bin install.man
install.bin:
install.man:
clean:
-rm -f *~ *.o *.bak st?????? core core.* *.out.* *.exe.stackdump \
$(LIBFULL) $(LIBLOAD) $(LIBSHARED) $(LIBARCHIVE) $(LIBDLL) $(LIBDLLSTATIC) $(PROGRAM) $(PROGRAM).exe
distclean: clean
-rm -rf config.status config.log config.cache depend.status Makefile tags autom4te.cache
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <string.h>
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
#include "Manager.h"
#include "Logger.h"
UpdateManager::UpdateManager(int w, int h, char *f, Input *i)
: width_(w), height_(h), frameBuffer_(f), input_(i)
{
logTrace("UpdateManager::UpdateManager");
nUpdater = 0;
updaterVector = NULL;
updateManagerRegion_ = NULL;
}
UpdateManager::~UpdateManager()
{
logTrace("UpdateManager::~UpdateManager");
for (int i = 0; i < nUpdater; i++)
{
delete updaterVector[i];
}
delete [] updaterVector;
}
Updater *UpdateManager::createUpdater(char *displayName, Display *display)
{
Updater *updater = new Updater(displayName, display);
if (updater == NULL)
{
logError("UpdateManager::createUpdater", ESET(ENOMEM));
return NULL;
}
if (updater -> init(width_, height_, frameBuffer_, input_) == -1)
{
logError("UpdateManager::createUpdater", EGET());
delete updater;
return NULL;
}
return updater;
}
UpdaterHandle UpdateManager::addUpdater(char *displayName, Display *display)
{
Updater *newUpdater = createUpdater(displayName, display);
if (newUpdater == NULL)
{
logError("UpdateManager::addUpdater", EGET());
return NULL;
}
Updater **newUpdaterVector = new Updater*[nUpdater + 1];
if (newUpdaterVector == NULL)
{
logError("UpdateManager::addUpdater", ESET(ENOMEM));
delete newUpdater;
return NULL;
}
for (int i = 0; i < nUpdater; i++)
{
newUpdaterVector[i] = updaterVector[i];
}
newUpdaterVector[nUpdater] = newUpdater;
delete [] updaterVector;
updaterVector = newUpdaterVector;
nUpdater++;
logTest("UpdateManager::AddUpdater", "Number of updaters [%d].", nUpdater);
return reinterpret_cast<UpdaterHandle>(newUpdater);
}
int UpdateManager::removeAllUpdaters()
{
logTest("UpdateManager::removeAllUpdaters", "Number of updaters [%d].", nUpdater);
int nullUpdaters = 0;
for (int i = nUpdater; i > 0; i--)
{
if (removeUpdater(reinterpret_cast<UpdaterHandle>(updaterVector[i - 1])) == 0)
{
nullUpdaters++;
}
}
if (nUpdater == 0)
{
return 1;
}
if (nUpdater == nullUpdaters)
{
logTest("UpdateManager::removeAllUpdaters", "Ignored null records in Updater vector.");
return 0;
}
logTest("UpdateManager::removeAllUpdaters", "Failed to remove some updaters.");
return -1;
}
int UpdateManager::removeUpdater(UpdaterHandle handle)
{
Updater * const updater = (Updater*) handle;
logTest("UpdateManager::removeUpdater", "Removing Updater [%p].", updater);
if (updater == NULL)
{
return 0;
}
for (int i = 0; i < nUpdater; i++)
{
if (updater == updaterVector[i])
{
updaterVector[i] = updaterVector[nUpdater - 1];
nUpdater--;
delete updater;
return 1;
}
}
logTest("UpdateManager::removeUpdater", "Couldn't find Updater [%p].", updater);
return -1;
}
void UpdateManager::addRegion(Region region)
{
logTrace("UpdateManager::addRegion");
for (int i = 0; i < nUpdater; i++)
{
updaterVector[i] -> addRegion(region);
}
XDestroyRegion(region);
}
void UpdateManager::update()
{
logTrace("UpdateManager::update");
for (int i = 0; i < nUpdater; i++)
{
/*updaterVector[i] -> update();*/
if (updaterVector[i] -> getUpdateRegion())
{
logDebug("UpdateManager::update", "pRegion [%p] rect[%ld].",
updaterVector[i] -> getUpdateRegion(), (updaterVector[i] -> getUpdateRegion()) -> numRects);
updateManagerRegion_ = updaterVector[i] -> getUpdateRegion();
//
// FIXME: Remove me.
//
for (int j = 0; j < updateManagerRegion_ -> numRects; j++)
{
int x = updateManagerRegion_ -> rects[j].x1;
int y = updateManagerRegion_ -> rects[j].y1;
unsigned int width = updateManagerRegion_ -> rects[j].x2 - updateManagerRegion_ -> rects[j].x1;
unsigned int height = updateManagerRegion_ -> rects[j].y2 - updateManagerRegion_ -> rects[j].y1;
logDebug("UpdateManager::update", "x[%d]y[%d]width[%u]height[%u], updateManagerRegion_[%p]",
x, y, width, height, updateManagerRegion_);
}
}
}
}
void UpdateManager::handleInput()
{
logTrace("UpdateManager::handleInput");
for (int i = 0; i < nUpdater; i++)
{
try
{
updaterVector[i] -> handleInput();
}
catch (UpdaterClosing u)
{
logTest("UpdateManager::handleInput", "Catched exception UpdaterClosing().");
removeUpdater((UpdaterHandle)updaterVector[i]);
//
// Now the i-element of the updaterVector
// is changed. We don't want to skip it.
//
i--;
}
}
}
void UpdateManager::newRegion()
{
logTrace("UpdateManager::newRegion");
for (int i = 0; i < nUpdater; i++)
{
updaterVector[i] -> newRegion();
}
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef UpdateManager_H
#define UpdateManager_H
#include <X11/Xlib.h>
#include "Updater.h"
#include "Regions.h"
#include "Input.h"
typedef char* UpdaterHandle;
class UpdateManager
{
public:
UpdateManager(int, int, char *, Input *);
~UpdateManager();
void handleInput();
void addRegion(Region);
void update();
UpdaterHandle addUpdater(char *displayName, Display *display);
int removeUpdater(UpdaterHandle);
int removeAllUpdaters();
int numberOfUpdaters();
int getWidth();
int getHeight();
char *getBuffer();
Region getUpdateManagerRegion();
void destroyUpdateManagerRegion();
void newRegion();
private:
Updater *createUpdater(char *displayName, Display *display);
int width_;
int height_;
char *frameBuffer_;
Input *input_;
int nUpdater;
Updater **updaterVector;
Region updateManagerRegion_;
};
inline int UpdateManager::numberOfUpdaters()
{
return nUpdater;
}
inline int UpdateManager::getWidth()
{
return width_;
}
inline int UpdateManager::getHeight()
{
return height_;
}
inline char *UpdateManager::getBuffer()
{
return frameBuffer_;
}
inline Region UpdateManager::getUpdateManagerRegion()
{
return updateManagerRegion_;
}
inline void UpdateManager::destroyUpdateManagerRegion()
{
if (updateManagerRegion_ != NULL)
{
XDestroyRegion(updateManagerRegion_);
updateManagerRegion_ = NULL;
}
}
#endif /* UpdateManager_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef Misc_H
#define Misc_H
#include <iostream.h>
#include <errno.h>
#include <string.h>
//
// Error handling macros.
//
#define ESET(e) (errno = (e))
#define EGET() (errno)
#define ESTR() strerror(errno)
//
// Log file.
//
extern ostream *logofs;
#endif /* Misc_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef Poller_H
#define Poller_H
#if defined(__CYGWIN32__) || defined(WIN32)
#include "Win.h"
#else
#include "X11.h"
#endif
#endif /* Poller_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef Region_H
#define Region_H
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;
typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
};
#endif /* Region_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#include <signal.h>
#include <string.h>
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
#include "Logger.h"
#include "Shadow.h"
#include "Poller.h"
#include "Manager.h"
ShadowOptions NXShadowOptions = {1, 1, -1};
static int mirrorException = 0;
static UpdateManager *updateManager;
static Poller *poller;
static Input *input;
int NXShadowRemoveAllUpdaters();
inline bool NXShadowNotInitialized()
{
//
// updateManager depends on input and poller.
// So this test seem redundant.
//
// return (input == NULL) || (poller == NULL) || (updateManager == NULL);
//
return (updateManager == NULL);
}
#ifdef NEED_SIGNAL_HANDLER
static void NXSignalHandler(int signal)
{
logTest("NXSignalHandler", "Got signal [%d]", signal);
if (signal == SIGINT)
{
mirrorException = 1;
}
else if (signal == SIGTERM)
{
mirrorException = 1;
}
}
static int NXInitSignal()
{
logTrace("NXInitSignal");
struct sigaction sa;
sa.sa_handler = NXSignalHandler;
sigfillset(&sa.sa_mask);
sa.sa_flags = 0;
int res;
while ((res = sigaction(SIGINT, &sa, NULL)) == -1 &&
errno == EINTR);
if (res == -1)
{
logError("NXInitSignal", EGET());
return -1;
}
return 1;
}
#endif
static void NXHandleException()
{
if (mirrorException)
{
mirrorException = 0;
NXShadowRemoveAllUpdaters();
}
}
static int NXCreateInput(char *keymap, char *shadowDisplayName)
{
logTrace("NXCreateInput");
input = new Input;
if (input == NULL)
{
logError("NXCreateInput", ESET(ENOMEM));
return -1;
}
input -> setKeymap(keymap);
input -> setShadowDisplayName(shadowDisplayName);
return 1;
}
static int NXCreatePoller(Display *display, Display **shadowDisplay)
{
logTrace("NXCreatePoller");
if (input == NULL)
{
logError("NXCreatePoller", ESET(EBADFD));
return -1;
}
poller = new Poller(input,display);
if (poller == NULL)
{
logError("NXCreatePoller", ESET(ENOMEM));
return -1;
}
if (poller -> init() == -1)
{
logTest("NXCreatePoller", "Failed to initialize poller.");
return -1;
}
*shadowDisplay = poller -> getShadowDisplay();
logTest("NXCreatePoller", "Poller geometry [%d, %d], ShadowDisplay[%p].", poller -> width(),
poller -> height(), (Display *) *shadowDisplay);
return 1;
}
static int NXCreateUpdateManager()
{
logTrace("NXCreateUpdateManager");
if (input == NULL || poller == NULL)
{
logError("NXCreateUpdateManager", ESET(EBADFD));
return -1;
}
updateManager = new UpdateManager(poller -> width(), poller -> height(),
poller -> getFrameBuffer(), input);
if (updateManager == NULL)
{
logError("NXCreateUpdateManager", ESET(ENOMEM));
return -1;
}
return 1;
}
void NXShadowResetOptions()
{
NXShadowOptions.optionShmExtension = 1;
NXShadowOptions.optionDamageExtension = 1;
}
//
// Exported functions.
//
int NXShadowHasUpdaters()
{
logTrace("NXShadowHasUpdaters");
return (updateManager && updateManager -> numberOfUpdaters()) ? 1 : 0;
}
int NXShadowRemoveAllUpdaters()
{
logTrace("NXShadowRemoveAllUpdaters");
return updateManager ? updateManager -> removeAllUpdaters() : 0;
}
int NXShadowRemoveUpdater(UpdaterHandle handle)
{
logTrace("NXShadowRemoveUpdater");
return updateManager ? updateManager -> removeUpdater(handle) : 0;
}
UpdaterHandle NXShadowAddUpdater(char *displayName)
{
logTrace("NXShadowAddUpdater");
return updateManager ? updateManager -> addUpdater(displayName, NULL) : NULL;
}
int NXShadowAddUpdaterDisplay(void *dpy, int *w, int *h, unsigned char *d)
{
Display *display = reinterpret_cast<Display*>(dpy);
logTrace("NXShadowAddUpdaterDisplay");
if ((updateManager ? updateManager -> addUpdater(NULL, display) : NULL) == NULL)
{
logTest("NXShadowAddUpdaterDisplay", "Error");
return 0;
}
*w = updateManager -> getWidth();
*h = updateManager -> getHeight();
*d = poller -> depth();
return 1;
}
int NXShadowCreate(void *dpy, char *keymap, char* shadowDisplayName, void **shadowDpy)
{
logTrace("NXShadowCreate");
Display *display = reinterpret_cast<Display*>(dpy);
Display **shadowDisplay = reinterpret_cast<Display**>(shadowDpy);
/* if (NXInitSignal() != 1)
{
logError("NXShadowCreate", EGET());
return -1;
}*/
if (NXCreateInput(keymap, shadowDisplayName) != 1)
{
logError("NXShadowCreate", EGET());
return -1;
}
if (NXCreatePoller(display, shadowDisplay) != 1)
{
logTest("NXShadowCreate", "NXCreatePoller failed.");
return -1;
}
if (NXCreateUpdateManager() != 1)
{
logError("NXShadowCreate", EGET());
return -1;
}
return 1;
}
#if !defined(__CYGWIN32__) && !defined(WIN32)
void NXShadowSetDisplayUid(int uid)
{
NXShadowOptions.optionShadowDisplayUid = uid;
}
void NXShadowDisableShm(void)
{
logUser("NXShadowDisableShm: Disabling SHM.\n");
NXShadowOptions.optionShmExtension = 0;
}
void NXShadowDisableDamage(void)
{
NXShadowOptions.optionDamageExtension = 0;
}
#endif
void NXShadowDestroy()
{
if (poller)
{
delete poller;
poller = NULL;
}
if (updateManager)
{
delete updateManager;
updateManager = NULL;
}
if (input)
{
delete input;
input = NULL;
}
}
void NXShadowHandleInput()
{
logTrace("NXShadowHandleInput");
if (NXShadowNotInitialized())
{
logError("NXShadowHandleInput - NXShadow not properly initialized.", ESET(EBADFD));
return;
}
NXHandleException();
updateManager -> handleInput();
poller -> handleInput();
}
int NXShadowHasChanged(int (*callback)(void *), void *arg, int *suspended)
{
int result;
logTrace("NXShadowHasChanged");
if (NXShadowNotInitialized())
{
logError("NXShadowHasChanged - NXShadow not properly initialized.", ESET(EBADFD));
return -1;
}
//
// FIXME
//updateManager -> destroyUpdateManagerRegion();
//
updateManager -> newRegion();
#if !defined(__CYGWIN32__) && !defined(WIN32)
poller -> getEvents();
#endif
result = poller -> isChanged(callback, arg, suspended);
if (result == 1)
{
updateManager -> addRegion(poller -> lastUpdatedRegion());
return 1;
}
else if (result == -1)
{
logTest("NXShadowHasChanged", "Scanline error.");
return -1;
}
return 0;
}
void NXShadowExportChanges(long *numRects, char **pBox)
{
Region pReg;
logTrace("NXShadowExportChanges");
if (NXShadowNotInitialized())
{
logError("NXShadowExportChanges - NXShadow not properly initialized.", ESET(EBADFD));
}
updateManager -> update();
pReg = updateManager -> getUpdateManagerRegion();
*numRects = pReg -> numRects;
*pBox = (char *)pReg -> rects;
logTest("NXShadowExportChanges", "numRects [%ld] pBox[%p], pReg->numRects[%ld], rects[%p], size[%lu]",
*numRects, *pBox, pReg -> numRects, &(pReg -> rects -> x2),
(unsigned long) sizeof(pReg -> rects -> x2));
}
void NXShadowEvent(Display *display, XEvent event)
{
poller -> handleEvent(display, &event);
}
#ifdef __CYGWIN32__
int NXShadowCaptureCursor(unsigned int wnd, void *vis)
{
Window window = (Window)wnd;
Visual *visual = reinterpret_cast<Visual*>(vis);
logTrace("NXShadowCaptureCursor");
logTest("NXShadowCaptureCursor","Init");
return poller -> updateCursor(window, visual);
}
#endif
void NXShadowUpdateBuffer(void **buffer)
{
char **fBuffer = reinterpret_cast<char **>(buffer);
if (*fBuffer != NULL)
{
poller -> destroyFrameBuffer();
poller -> init();
}
*fBuffer = poller -> getFrameBuffer();
logTest("NXShadowUpdateBuffer","New frame buffer [0x%p]", (void *)*fBuffer);
}
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef Shadow_H
#define Shadow_H
#include <X11/Xlib.h>
#define NXShadowCorrectColor(length, buffer) \
\
{ \
unsigned short a; \
unsigned short b; \
unsigned short *shorts; \
int i; \
\
length >>= 1; \
shorts = (unsigned short *)buffer; \
for (i = 0; i < length ; i++) \
{ \
a = shorts[i]; \
\
b = a & 63; \
a <<= 1; \
a = (a & ~127) | b; \
\
shorts[i] = a; \
} \
}
#ifdef __cplusplus
extern "C" {
#endif
typedef char* UpdaterHandle;
typedef struct _ShadowOptions
{
char optionShmExtension;
char optionDamageExtension;
int optionShadowDisplayUid;
} ShadowOptions;
extern ShadowOptions NXShadowOptions;
extern int NXShadowCreate(void *, char *, char *, void **);
extern void NXShadowDestroy(void);
/*
* Use an already opened Display connection.
* We use <void *> instead of <Display *> to avoid
* useless dependences from Xlib headers.
*/
extern int NXShadowAddUpdaterDisplay(void *display, int *width, int *height,
unsigned char *depth);
extern UpdaterHandle NXShadowAddUpdater(char *displayName);
extern int NXShadowRemoveUpdater(UpdaterHandle handle);
extern int NXShadowRemoveAllUpdaters(void);
extern void NXShadowHandleInput(void);
extern int NXShadowHasChanged(int (*)(void *), void *, int *);
extern void NXShadowExportChanges(long *, char **);
extern int NXShadowHasUpdaters(void);
extern int NXShadowCaptureCursor(unsigned int wnd, void *vis);
extern void NXShadowColorCorrect(int, int, unsigned int, unsigned int, char *);
extern void NXShadowUpdateBuffer(void **);
extern void NXShadowEvent(Display *, XEvent);
extern void NXShadowSetDisplayUid(int uid);
extern void NXShadowDisableShm(void);
extern void NXShadowDisableDamage(void);
#ifdef __cplusplus
}
#endif
#endif /* Shadow_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <string.h>
#define PANIC
#define WARNING
#undef TEST
#undef DEBUG
//
#include <stdio.h>
//
#include "Updater.h"
#include "Logger.h"
Updater::Updater(char *displayName, Display *display)
{
logTrace("Updater::Updater");
displayName_ = displayName;
display_ = display;
closeDisplay_ = false;
image_ = NULL;
updateRegion_ = NULL;
buffer_ = NULL;
}
Updater::~Updater()
{
logTrace("Updater::~Updater");
if (input_)
{
int removedEvents = input_ -> removeAllEvents(display_);
logTest("Updater::~Updater", "Removed events in input queue is [%d].", removedEvents);
}
if (display_)
{
XDestroyWindow(display_, window_);
XFreePixmap(display_, pixmap_);
if (closeDisplay_)
{
XCloseDisplay(display_);
}
}
if (image_)
{
image_ -> data = NULL;
XDestroyImage(image_);
}
if (updateRegion_)
{
XDestroyRegion(updateRegion_);
}
}
int Updater::init(int width, int height, char *fb, Input *input)
{
logTrace("Updater::init");
if (fb == NULL || input == NULL || width <= 0 || height <= 0)
{
logError("Updater::init", ESET(EINVAL));
return -1;
}
width_ = width;
height_ = height;
buffer_ = fb;
input_ = input;
/*
if (display_ == NULL)
{
display_ = XOpenDisplay(displayName_);
closeDisplay_ = true;
if (display_ == NULL)
{
logError("Updater::init", ESET(ENOMSG));
return -1;
}
}
*/
depth_ = DefaultDepth(display_, DefaultScreen(display_));
if (depth_ == 8) bpl_ = width_;
else if (depth_ == 16) bpl_ = width_ * 2;
else bpl_ = width_ * 4;
logTest("Updater::init", "Server geometry [%d, %d] depth [%d] bpl [%d].", width_, height_, depth_, bpl_);
/* int bitmap_pad = 8;
image_ = XCreateImage(display_, DefaultVisual(display_, DefaultScreen(display_)), depth_, ZPixmap, 0,
buffer_, width_, height_, bitmap_pad, 0);
if (image_ == NULL)
{
logError("Updater::init", ESET(ENOMSG));
logTest("Updater::init", "Failed to create default image.");
return -1;
}
pixmap_ = XCreatePixmap(display_, DefaultRootWindow(display_), width_, height_, depth_);
unsigned int mask = CWBackPixmap | CWBorderPixel | CWEventMask;
XSetWindowAttributes attributes;
attributes.background_pixmap = pixmap_;
attributes.border_pixel = WhitePixel(display_, DefaultScreen(display_));
attributes.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask;
window_ = XCreateWindow(display_, DefaultRootWindow(display_),
0, 0, width_, height_, 0, depth_, InputOutput,
DefaultVisual(display_, DefaultScreen(display_)), mask, &attributes);
if (window_ == None)
{
logError("Updater::init", ESET(ENOMSG));
return -1;
}
XSizeHints *size_hints;
if ((size_hints = XAllocSizeHints()) == NULL)
{
logError("Updater::init", ESET(ENOMEM));
return -1;
}
size_hints -> flags = PMinSize | PMaxSize;
size_hints -> min_width = width_;
size_hints -> max_width = width_;
size_hints -> min_height = height_;
size_hints -> max_height = height_;
XSetWMNormalHints(display_, window_, size_hints);
XFree(size_hints);
Atom deleteWMatom = XInternAtom(display_, "WM_DELETE_WINDOW", 1);
XSetWMProtocols(display_, window_, &deleteWMatom, 1);
XMapWindow(display_, window_);*/
updateRegion_ = XCreateRegion();
logTest("Updater::init", "updateRegion_[%p]", updateRegion_);
return 1;
}
void Updater::addRegion(Region region)
{
//
// FIXME: Is this too paranoid ?
//
if (updateRegion_ == NULL)
{
logError("Updater::addRegion", ESET(EINVAL));
return;
}
XUnionRegion(region, updateRegion_, updateRegion_);
}
void Updater::update()
{
logTrace("Updater::update");
if (updateRegion_ == NULL)
{
logError("Updater::update", ESET(EINVAL));
return;
}
logTest("Updater::update", "Number of rectangles [%ld].", updateRegion_ -> numRects);
/* for (; updateRegion_ -> numRects > 0; updateRegion_ -> numRects--)
{
int n = updateRegion_ -> numRects - 1;
int x = updateRegion_ -> rects[n].x1;
int y = updateRegion_ -> rects[n].y1;
unsigned int width = updateRegion_ -> rects[n].x2 - updateRegion_ -> rects[n].x1;
unsigned int height = updateRegion_ -> rects[n].y2 - updateRegion_ -> rects[n].y1;
logDebug("Updater::update", "Sending rectangle: [%d, %d, %d, %d].", x, y, width, height);
//
// We need to update the extents.
//
int bitmap_pad;
if (depth_ == 32 || depth_ == 24)
{
bitmap_pad = 32;
}
else if (depth_ == 16)
{
if ((width & 1) == 0)
{
bitmap_pad = 32;
}
else
{
bitmap_pad = 16;
}
}
else if ((width & 3) == 0)
{
bitmap_pad = 32;
}
else if ((width & 1) == 0)
{
bitmap_pad = 16;
}
else
{
bitmap_pad = 8;
}*/
/* image_ -> bitmap_pad = bitmap_pad;*/
/* NXShadowCorrectColor(x, y, width, height);*/
/* XPutImage(display_, pixmap_, DefaultGC(display_, DefaultScreen(display_)),
image_, x, y, x, y, width, height);
XClearArea(display_, window_, x, y, width, height, 0);
}*/
//
// Should we reduces the box vector ?
//
// BOX *box = Xrealloc(updateRegion_ -> rects,
// updateRegion_ -> numRects == 0 ? sizeof(BOX) :
// updateRegion_ -> numRects * sizeof(BOX));
//
// if (box)
// {
// updateRegion_ -> rects = box;
// updateRegion_ -> size = 1;
// }
//
if (updateRegion_ -> numRects == 0)
{
updateRegion_ -> extents.x1 = 0;
updateRegion_ -> extents.y1 = 0;
updateRegion_ -> extents.x2 = 0;
updateRegion_ -> extents.y2 = 0;
}
else
{
//
// FIXME: We have to update the region extents.
//
logTest("Updater::update", "Region extents has not been updated.");
}
}
void Updater::handleInput()
{
logTrace("Updater::handleInput");
XEvent *event = new XEvent;
if (event == NULL)
{
logError("Updater::handleInput", ESET(ENOMEM));
return;
}
while (XCheckIfEvent(display_, event, anyEventPredicate, NULL))
{
switch (event -> type)
{
/* case ClientMessage:
{
Atom wmProtocols = XInternAtom(display_, "WM_PROTOCOLS", 0);
Atom wmDeleteWindow = XInternAtom(display_, "WM_DELETE_WINDOW", 0);
if (event -> xclient.message_type == wmProtocols &&
(Atom)event -> xclient.data.l[0] == wmDeleteWindow)
{
logTest("Updater::handleInput", "Got client message of type WM_PROTOCOLS and value WM_DELETE_WINDOW,"
" throwing exception UpdaterClosing.");
delete event;
throw UpdaterClosing();
}
else
{
logTest("Updater::handleInput", "Unexpected client message type [%ld] format [%d] first value [%ld]",
event -> xclient.message_type, event -> xclient.format, event -> xclient.data.l[0]);
}
break;
}*/
case KeyPress:
case KeyRelease:
case ButtonPress:
case ButtonRelease:
case MotionNotify:
{
input_ -> pushEvent(display_, event);
event = new XEvent;
if (event == NULL)
{
logError("Updater::handleInput", ESET(ENOMEM));
return;
}
break;
}
default:
{
logTest("Updater::handleInput", "Handling unexpected event [%d].", event -> type);
break;
}
}
}
delete event;
}
void Updater::newRegion()
{
if (updateRegion_ != NULL)
{
XDestroyRegion(updateRegion_);
}
updateRegion_ = XCreateRegion();
logTest("Updater::newRegion", "updateRegion_ [%p].", updateRegion_);
}
//
// Private functions.
//
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef Updater_H
#define Updater_H
#include <X11/Xlib.h>
#include "Regions.h"
#include "Input.h"
class UpdaterClosing {};
class Updater
{
public:
Updater(char *displayName, Display *display);
~Updater();
int init(int, int, char *, Input*);
void addRegion(Region r);
void update();
void handleInput();
XImage *getImage();
Region getUpdateRegion();
void newRegion();
private:
Input *input_;
static inline Bool anyEventPredicate(Display*, XEvent*, XPointer);
void handleKeyboardEvent(XEvent &event);
char *displayName_;
char *buffer_;
bool closeDisplay_;
Display *display_;
int depth_;
int width_;
int height_;
int bpl_;
Window window_;
XImage *image_;
Pixmap pixmap_;
Region updateRegion_;
};
Bool Updater::anyEventPredicate(Display*, XEvent*, XPointer)
{
return true;
}
inline XImage* Updater::getImage()
{
return image_;
}
inline Region Updater::getUpdateRegion()
{
return updateRegion_;
}
#endif /* Updater_H */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifdef __CYGWIN32__
#ifndef Win32Poller_H
#define Win32Poller_H
//#include <X11/X.h>
#include <Windows.h>
#include <wingdi.h>
#include <winable.h>
#include <winuser.h>
#define CAPTUREBLT 0x40000000
#define KEYEVENTF_SCANCODE 0x00000008
#define MAPVK_VSC_TO_VK_EX 3
//
// The CAPTUREBLT is a raster operation used
// in bit blit transfer.
//
// Using this operation includes any windows
// that are layered on top of your window in
// the resulting image. By default, the image
// only contains your window.
//
#include "Core.h"
typedef struct _keyTranslation
{
unsigned char scancode;
unsigned short modifiers;
}keyTranslation;
class Poller : public CorePoller
{
public:
Display *display_;
keyTranslation *keymap_;
unsigned char keymapLoaded_;
int minKeycode_;
Poller(Input *, Display *display, int = 16);
~Poller();
int init();
int updateCursor(Window, Visual*);
private:
int Poller::updateShadowFrameBuffer(void);
void handleKeyboardEvent(Display *, XEvent *);
void addToKeymap(char *keyname, unsigned char scancode, unsigned short modifiers, char *mapname);
int xkeymapRead(char *mapname);
FILE *xkeymapOpen(char *filename);
void xkeymapInit(char *keyMapName);
keyTranslation xkeymapTranslateKey(unsigned int keysym, unsigned int keycode, unsigned int state);
unsigned char getKeyState(unsigned int state, unsigned int keysym);
char *getKsname(unsigned int keysym);
unsigned char specialKeys(unsigned int keysym, unsigned int state, int pressed);
unsigned char toggleSwitch(unsigned char ToggleStateClient, unsigned char ToggleStateServer, UINT scancode,
int *lengthArrayINPUT);
void updateModifierState(UINT, unsigned char);
unsigned char toggleServerState(UINT scancode);
unsigned char keyState(UINT scancode, UINT mapType);
unsigned char keyStateAsync(UINT scancode);
void handleMouseEvent(Display *, XEvent *);
Cursor createCursor(Window wnd, Visual *vis, unsigned int x, unsigned int y, int width,
int height, unsigned char *xormask, unsigned char *andmask);
Pixmap createGlyph(Window wnd, Visual *visual, int width, int height, unsigned char *data);
char isWinNT();
char selectDesktop(HDESK new_desktop);
char selectDesktopByName(char *name);
void platformOS();
char simulateCtrlAltDel(void);
DWORD platformID_;
INPUT *pKey_, *pMouse_;
char *keymapName_;
char *path_;
unsigned char toggleButtonState_;
unsigned short serverModifierState_;
unsigned short savedServerModifierState_;
void ensureServerModifiers(keyTranslation tr, int *lenghtArrayINPUT);
void restoreServerModifiers(UINT scancode);
unsigned char isModifier(UINT scancode);
char sendInput(unsigned char scancode, unsigned char pressed, int *lengthArrayINPUT);
char *getRect(XRectangle);
char checkDesktop();
char *DIBBuffer_;
HCURSOR oldCursor_;
VOID *pDIBbits_;
HDC screenDC_;
HDC memoryDC_;
BITMAPINFO bmi_;
HBITMAP screenBmp_;
Cursor xCursor_;
};
#undef TEST
inline unsigned char Poller::toggleSwitch(unsigned char ToggleStateClient, unsigned char ToggleStateServer,
UINT scancode, int *lengthArrayINPUT)
{
return 1;
}
inline unsigned char Poller::toggleServerState(UINT scancode)
{
return (GetKeyState(MapVirtualKeyEx(scancode, 3, GetKeyboardLayout((DWORD)NULL))) & 0x1);
}
inline unsigned char Poller::keyStateAsync(UINT vKeycode)
{
return GetAsyncKeyState(vKeycode);
}
inline unsigned char Poller::keyState(UINT code, UINT mapType)
{
if (mapType == 0)
{
//
// Virtual Keycode
//
return ((GetKeyState(code) & 0x80) == 0x80);
}
else
{
//
// scancode
//
return ((GetKeyState(MapVirtualKeyEx(code, 3, GetKeyboardLayout((DWORD)NULL))) & 0x80) == 0x80);
}
}
inline char Poller::isWinNT()
{
return (platformID_ == VER_PLATFORM_WIN32_NT);
}
inline char Poller::sendInput(unsigned char scancode, unsigned char pressed, int *lengthArrayINPUT)
{
DWORD keyEvent = 0;
DWORD extended = 0;
if (scancode > 0)
{
if (pressed == 0)
{
keyEvent = KEYEVENTF_KEYUP;
}
if (scancode & 0x80)
{
scancode &= ~0x80;
extended = KEYEVENTF_EXTENDEDKEY;
}
pKey_[*lengthArrayINPUT].ki.wScan = (WORD) scancode;
pKey_[*lengthArrayINPUT].ki.dwFlags = (DWORD) (keyEvent | KEYEVENTF_SCANCODE | extended);
(*lengthArrayINPUT)++;
}
if (*lengthArrayINPUT > 0) {
// FIXME: Remove me.
logTest("Poller::sendInput", "length Input [%d] event: %s", *lengthArrayINPUT,
pressed == 1 ? "KeyPress": "KeyRelease");
if (SendInput(*lengthArrayINPUT, pKey_, sizeof(INPUT)) == 0)
{
logTest("Poller::sendInput", "Failed SendInput, event: %s", pressed == 1 ? "KeyPress": "KeyRelease");
*lengthArrayINPUT = 0;
return 0;
}
*lengthArrayINPUT = 0;
}
return 1;
}
#endif /* Win32Poller_H */
#endif /* __CYGWIN32__ */
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef X11Poller_H
#define X11Poller_H
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xrandr.h>
#include "Core.h"
class Poller : public CorePoller
{
public:
Poller(Input *, Display *display, int = 0);
~Poller();
int init();
void setRootSize();
void destroyShmImage();
void getEvents(void);
private:
Display *display_;
char *shadowDisplayName_;
int shadowDisplayUid_;
char *tmpBuffer_;
char xtestExtension_;
char shmExtension_;
char randrExtension_;
int randrEventBase_;
char damageExtension_;
int damageEventBase_;
Damage damage_;
Region repair_;
char damageChanges_;
XShmSegmentInfo *shminfo_;
XImage *image_;
int updateShadowFrameBuffer(void);
char *getRect(XRectangle);
void handleKeyboardEvent(Display *display, XEvent *);
void handleMouseEvent(Display *, XEvent *);
void xtestInit(void);
void shmInit(void);
void randrInit(void);
void damageInit(void);
void handleRRScreenChangeNotify(XEvent *);
void handleDamageNotify(XEvent *);
void updateDamagedAreas(void);
};
int anyEventPredicate(Display *display, XEvent *event, XPointer parameter);
#endif /* X11Poller_H */
This source diff could not be displayed because it is too large. You can view the blob instead.
dnl Process this file with autoconf to produce a configure script.
dnl Prolog
AC_INIT(Shadow.h)
AC_PREREQ(2.13)
dnl Reset default compilation flags.
CXXFLAGS="-O3"
CPPFLAGS="-O3"
dnl Reset default linking directives.
LIBSTATIC=""
LIBSHARED=""
dnl Prefer headers and libraries from nx-X11, if present.
if test -d "../nx-X11/exports/include" ; then
CXXFLAGS="$CXXFLAGS -I../nx-X11/exports/include"
LIBS="$LIBS -L../nx-X11/exports/lib"
fi
dnl Check whether --with-ipaq was given.
if test "${with_ipaq}" = yes; then
echo -e "enabling IPAQ configuration"
CXX="arm-linux-c++"
CC="arm-linux-gcc"
unset ac_cv_prog_armcxx
unset ac_cv_prog_armcc
unset ac_cv_prog_CXXCPP
AC_CHECK_PROG([armcxx],["$CXX"],[yes],[no],[$PATH])
AC_CHECK_PROG([armcc],["$CC"],[yes],[no],[$PATH])
if test $armcxx = "yes" && test $armcc = "yes" ; then
ac_cv_prog_CXX="$CXX"
ac_cv_prog_CC="$CC"
else
AC_MSG_ERROR(installation or configuration problem: I cannot find compiler for arm-linux)
fi
else
unset ac_cv_prog_CXX
unset ac_cv_prog_CC
unset ac_cv_prog_CXXCPP
fi
dnl Check for programs.
AC_PROG_CXX
AC_PROG_CC
AC_LANG_CPLUSPLUS
dnl Check whether option -Wno-deprecated
dnl is needed by GCC compiler.
AC_MSG_CHECKING([whether compiler needs -Wno-deprecated])
gcc_version=`${CC} --version | grep 'gcc (GCC) [[3-4]].' | head -n 1`
case "${gcc_version}" in
gcc*)
AC_MSG_RESULT([yes])
CXXFLAGS="$CXXFLAGS -Wno-deprecated"
CPPFLAGS="$CPPFLAGS -Wno-deprecated"
;;
*)
AC_MSG_RESULT([no])
;;
esac
AC_MSG_CHECKING([whether compiler accepts -Wmissing-declarations and -Wnested-externs])
gcc_version=`${CC} --version | grep 'gcc (GCC) [[3-4]].' | head -n 1`
case "${gcc_version}" in
gcc*)
AC_MSG_RESULT([no])
;;
*)
AC_MSG_RESULT([yes])
CXXFLAGS="$CXXFLAGS -Wmissing-declarations -Wnested-externs"
CPPFLAGS="$CPPFLAGS -Wmissing-declarations -Wnested-externs"
;;
esac
dnl Check for BSD compatible install.
AC_PROG_INSTALL
dnl Check for extra header files.
AC_PATH_XTRA
dnl Custom addition.
ac_help="$ac_help
--with-symbols give -g flag to compiler to produce debug symbols
--with-info define INFO at compile time to get basic log output
--with-valgrind clean up allocated buffers to avoid valgrind warnings
--with-version use this version for produced libraries
--with-static-jpeg enable static linking of JPEG library
--with-static-z enable static linking of Z library"
dnl Check to see if we're running under Cygwin32.
AC_DEFUN(nxconf_CYGWIN32,
[AC_CACHE_CHECK(for Cygwin32 environment, nxconf_cv_cygwin32,
[AC_TRY_COMPILE(,[return __CYGWIN32__;],
nxconf_cv_cygwin32=yes, nxconf_cv_cygwin32=no)
rm -f conftest*])
CYGWIN32=
test "$nxconf_cv_cygwin32" = yes && CYGWIN32=yes])
nxconf_CYGWIN32
dnl Cygwin32 requires the stdc++ library explicitly linked.
if test "$CYGWIN32" = yes; then
LIBS="$LIBS -lstdc++ -lcygipc -lgdi32"
fi
dnl Check for Darwin environment.
AC_DEFUN(nxconf_DARWIN,
[AC_CACHE_CHECK(for Darwin environment, nxconf_cv_darwin,
[AC_TRY_COMPILE(,[return __APPLE__;],
nxconf_cv_darwin=yes, nxconf_cv_darwin=no)
rm -f conftest*])
DARWIN=
test "$nxconf_cv_darwin" = yes && DARWIN=yes])
nxconf_DARWIN
dnl Check to see if we're running under Solaris.
AC_DEFUN(nxconf_SUN,
[AC_CACHE_CHECK(for Solaris environment, nxconf_cv_sun,
[AC_TRY_COMPILE(,[return __sun;],
nxconf_cv_sun=yes, nxconf_cv_sun=no)
rm -f conftest*])
SUN=
test "$nxconf_cv_sun" = yes && SUN=yes])
nxconf_SUN
dnl Check to see if we're running under FreeBSD.
AC_DEFUN(nxconf_FreeBSD,
[AC_CACHE_CHECK(for FreeBSD environment, nxconf_cv_freebsd,
[AC_TRY_COMPILE(,[return __FreeBSD__;],
nxconf_cv_freebsd=yes, nxconf_cv_freebsd=no)
rm -f conftest*])
FreeBSD=
test "$nxconf_cv_freebsd" = yes && FreeBSD=yes])
nxconf_FreeBSD
dnl Build PIC libraries.
if test "$CYGWIN32" != yes -a "$DARWIN" != yes; then
CXXFLAGS="$CXXFLAGS -fPIC"
CFLAGS="$CFLAGS -fPIC"
fi
dnl Solaris requires the socket and gcc_s libs explicitly linked.
dnl Note also that headers from default /usr/openwin/include/X11
dnl cause a warning due to pragma in Xmd.h.
if test "$SUN" = yes; then
LIBS="$LIBS -L/usr/sfw/lib -lsocket "
CXXFLAGS="$CXXFLAGS -I/usr/sfw/include"
fi
dnl On FreeBSD search libraries and includes under /usr/local.
if test "$FreeBSD" = yes; then
LIBS="$LIBS -L/usr/local/lib"
CXXFLAGS="$CXXFLAGS -I/usr/local/include"
fi
dnl Under Darwin we don't have support for -soname option and
dnl we need the -bundle flag. Under Solaris, instead, we need
dnl the options -G -h.
if test "$DARWIN" = yes; then
LDFLAGS="$LDFLAGS -bundle"
elif test "$SUN" = yes; then
LDFLAGS="$LDFLAGS -G -h \$(LIBLOAD)"
else
LDFLAGS="$LDFLAGS -Wl,-soname,\$(LIBLOAD)"
fi
dnl Check to see if in_addr_t is defined.
dnl Could use a specific configure test.
AC_DEFUN(nxconf_INADDRT,
[AC_CACHE_CHECK(for in_addr_t, nxconf_cv_inaddrt,
[AC_TRY_COMPILE([#include <netinet/in.h>],[in_addr_t t; t = 1; return t;],
nxconf_cv_inaddrt=yes, nxconf_cv_inaddrt=no)
rm -f conftest*])
INADDRT=
test "$nxconf_cv_inaddrt" = yes && INADDRT=yes])
nxconf_INADDRT
dnl If in_addr_t is not defined use unsigned int.
if test "$INADDRT" != yes ; then
echo -e "using unsigned int for type in_addr_t"
CXXFLAGS="$CXXFLAGS -DIN_ADDR_T=unsigned"
CPPFLAGS="$CPPFLAGS -DIN_ADDR_T=unsigned"
else
CXXFLAGS="$CXXFLAGS -DIN_ADDR_T=in_addr_t"
CPPFLAGS="$CPPFLAGS -DIN_ADDR_T=in_addr_t"
fi
dnl Check whether --with-version was given.
AC_SUBST(LIBVERSION)
AC_SUBST(VERSION)
if test "${with_version}" = yes; then
VERSION=${ac_option}
else
VERSION=`cat VERSION`
fi
echo -e "compiling version ${VERSION}"
LIBVERSION=`echo ${VERSION} | cut -d '.' -f 1`
CXXFLAGS="$CXXFLAGS -DVERSION=\\\"${VERSION}\\\""
CPPFLAGS="$CPPFLAGS -DVERSION=\\\"${VERSION}\\\""
dnl Finally compose the LIB variable.
if test "$DARWIN" = yes ; then
LIBS="$LIBS $LIBSTATIC $LIBSHARED"
elif test "$SUN" = yes ; then
LIBS="$LIBS $LIBSTATIC $LIBSHARED"
else
LIBS="$LIBS $LIBSTATIC -shared $LIBSHARED"
fi
dnl Check whether --with-symbols or --without-symbols was
dnl given and set the required optimization level.
if test "${with_symbols}" = yes; then
echo -e "enabling production of debug symbols"
CXXFLAGS="-g $CXXFLAGS"
CPPFLAGS="-g $CPPFLAGS"
else
echo -e "disabling production of debug symbols"
fi
dnl Check whether --with-info or --without-info was given.
if test "${with_info}" = yes; then
echo -e "enabling info output in the log file"
CXXFLAGS="$CXXFLAGS -DINFO"
CPPFLAGS="$CPPFLAGS -DINFO"
else
echo -e "disabling info output in the log file"
fi
dnl Check whether --with-valgrind or --without-valgrind was given.
if test "${with_valgrind}" = yes; then
echo -e "enabling valgrind memory checker workarounds"
CXXFLAGS="$CXXFLAGS -DVALGRIND"
CPPFLAGS="$CPPFLAGS -DVALGRIND"
else
echo -e "disabling valgrind memory checker workarounds"
fi
dnl Find makedepend somewhere.
AC_SUBST(MAKEDEPEND)
if test -x "../nx-X11/config/makedepend/makedepend" ; then
MAKEDEPEND=../nx-X11/config/makedepend/makedepend
else
if test -x "/usr/X11R6/bin/makedepend" ; then
MAKEDEPEND=/usr/X11R6/bin/makedepend
else
if test -x "/usr/openwin/bin/makedepend" ; then
MAKEDEPEND=/usr/openwin/bin/makedepend
else
MAKEDEPEND=makedepend
fi
fi
fi
AC_OUTPUT(Makefile)
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment