From 8fa612d1a931096ff57c9b90df0f13e6cd638da8 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: 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 --- nxcompshad/CHANGELOG | 329 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 329 insertions(+) create mode 100644 nxcompshad/CHANGELOG (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG new file mode 100644 index 000000000..54c3722a4 --- /dev/null +++ b/nxcompshad/CHANGELOG @@ -0,0 +1,329 @@ +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. -- cgit v1.2.3 From c7dc0c3cdec2e0f2fa2d52f8d446d0e83623a8a0 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: Imported nxcompshad-3.2.0-1.tar.gz Summary: Imported nxcompshad-3.2.0-1.tar.gz Keywords: Imported nxcompshad-3.2.0-1.tar.gz into Git repository --- nxcompshad/CHANGELOG | 4 ++++ nxcompshad/VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG index 54c3722a4..d21d16ac7 100644 --- a/nxcompshad/CHANGELOG +++ b/nxcompshad/CHANGELOG @@ -1,5 +1,9 @@ ChangeLog: +nxcompshad-3.2.0-1 + +- Opened the 3.2.0 branch based on nxcompshad-3.1.0-2. + nxcompshad-3.1.0-2 - Updated file VERSION to match the current release version. diff --git a/nxcompshad/VERSION b/nxcompshad/VERSION index fd2a01863..944880fa1 100644 --- a/nxcompshad/VERSION +++ b/nxcompshad/VERSION @@ -1 +1 @@ -3.1.0 +3.2.0 -- cgit v1.2.3 From 9f7021392b921ad44163024ed8ca538195d3ac9c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: Imported nxcompshad-3.2.0-3.tar.gz Summary: Imported nxcompshad-3.2.0-3.tar.gz Keywords: Imported nxcompshad-3.2.0-3.tar.gz into Git repository --- nxcompshad/CHANGELOG | 24 ++ nxcompshad/Core.cpp | 16 + nxcompshad/Core.h | 4 + nxcompshad/Misc.h | 4 +- nxcompshad/Shadow.cpp | 32 ++ nxcompshad/Shadow.cpp.orig | 461 ++++++++++++++++++++++++++ nxcompshad/Shadow.h | 6 + nxcompshad/Win.cpp | 7 + nxcompshad/Win.h | 1 + nxcompshad/X11.cpp | 789 ++++++++++++++++++++++++++++++++++++++++++++- nxcompshad/X11.h | 30 ++ 11 files changed, 1371 insertions(+), 3 deletions(-) create mode 100644 nxcompshad/Shadow.cpp.orig (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG index d21d16ac7..77976867c 100644 --- a/nxcompshad/CHANGELOG +++ b/nxcompshad/CHANGELOG @@ -1,5 +1,29 @@ ChangeLog: +nxcompshad-3.2.0-3 + +- Improved keycode translation. + +nxcompshad-3.2.0-2 + +- Solved a problem when sending fake modifier events. + +- Added support for keyboard events handling for the web player. + +- Changed keycodes translation for Solaris keyboard. + +- Corrected a problem for keycodes translation from Solaris keyboard. + +- Fixed TR02F02001. In shadow session the shadower's keyboard layout + could be wrong. Now keycodes are correctly translated if master and + shadow keyboards have different layouts. + +- Added NXShadowGetScreenSize() and NXShadowSetScreenSize() functions, + so that the shadow session can handle correctly the resize of the + master session window. + +- Solved a compilation problem on GCC 4.3. + nxcompshad-3.2.0-1 - Opened the 3.2.0 branch based on nxcompshad-3.1.0-2. diff --git a/nxcompshad/Core.cpp b/nxcompshad/Core.cpp index 351fa8f45..44327cd3f 100644 --- a/nxcompshad/Core.cpp +++ b/nxcompshad/Core.cpp @@ -538,6 +538,15 @@ void CorePoller::update(char *src, XRectangle r) for (unsigned int i = 0; i < r.height; i++) { + if(((r.x * bpp_ + r.y * bpl_) + bpl) > (bpl_ * height_)) + { + // + // Out of bounds. Maybe a resize is going on. + // + + continue; + } + memcpy(dst, src, bpl); src += bpl; @@ -574,6 +583,13 @@ void CorePoller::handleEvent(Display *display, XEvent *event) } } +void CorePoller::handleWebKeyEvent(KeySym keysym, Bool isKeyPress) +{ + logTrace("CorePoller::handleWebKeyEvent"); + + handleWebKeyboardEvent(keysym, isKeyPress); +} + void CorePoller::handleInput() { while (input_ -> checkIfEvent()) diff --git a/nxcompshad/Core.h b/nxcompshad/Core.h index 6d2053bdf..17ce44881 100644 --- a/nxcompshad/Core.h +++ b/nxcompshad/Core.h @@ -68,6 +68,8 @@ class CorePoller void handleEvent(Display *, XEvent *); + void handleWebKeyEvent(KeySym keysym, Bool isKeyPress); + Display *getShadowDisplay(); void setShadowDisplay(Display *shadowDisplay); @@ -115,6 +117,8 @@ class CorePoller virtual void handleKeyboardEvent(Display *, XEvent *) = 0; + virtual void handleWebKeyboardEvent(KeySym keysym, Bool isKeyPress) = 0; + virtual void handleMouseEvent(Display *, XEvent *) = 0; Input *input_; diff --git a/nxcompshad/Misc.h b/nxcompshad/Misc.h index 674d34605..6bfbaa4fb 100644 --- a/nxcompshad/Misc.h +++ b/nxcompshad/Misc.h @@ -18,11 +18,13 @@ #ifndef Misc_H #define Misc_H -#include +#include #include #include +using namespace std; + // // Error handling macros. // diff --git a/nxcompshad/Shadow.cpp b/nxcompshad/Shadow.cpp index 72213968b..c7fb6b4a3 100644 --- a/nxcompshad/Shadow.cpp +++ b/nxcompshad/Shadow.cpp @@ -28,6 +28,15 @@ #include "Poller.h" #include "Manager.h" +typedef struct { + KeySym *map; + KeyCode minKeyCode, + maxKeyCode; + int mapWidth; +} KeySymsRec, *KeySymsPtr; + +KeySymsPtr NXShadowKeymap = NULL; + ShadowOptions NXShadowOptions = {1, 1, -1}; static int mirrorException = 0; @@ -295,6 +304,16 @@ void NXShadowDisableDamage(void) NXShadowOptions.optionDamageExtension = 0; } +void NXShadowGetScreenSize(int *w, int *h) +{ + poller -> getScreenSize(w, h); +} + +void NXShadowSetScreenSize(int *w, int *h) +{ + poller -> setScreenSize(w, h); +} + #endif void NXShadowDestroy() @@ -406,6 +425,11 @@ void NXShadowEvent(Display *display, XEvent event) poller -> handleEvent(display, &event); } +void NXShadowWebKeyEvent(KeySym keysym, Bool isKeyPress) +{ + poller -> handleWebKeyEvent(keysym, isKeyPress); +} + #ifdef __CYGWIN32__ int NXShadowCaptureCursor(unsigned int wnd, void *vis) @@ -437,3 +461,11 @@ void NXShadowUpdateBuffer(void **buffer) logTest("NXShadowUpdateBuffer","New frame buffer [0x%p]", (void *)*fBuffer); } + +void NXShadowInitKeymap(void *keysyms) +{ + NXShadowKeymap = (KeySymsPtr) keysyms; + + logTest("NXShadowInitKeymap","KeySyms pointer [0x%p] mapWidth [%d]", + (void *)NXShadowKeymap, NXShadowKeymap -> mapWidth); +} diff --git a/nxcompshad/Shadow.cpp.orig b/nxcompshad/Shadow.cpp.orig new file mode 100644 index 000000000..91ef3b85a --- /dev/null +++ b/nxcompshad/Shadow.cpp.orig @@ -0,0 +1,461 @@ +/**************************************************************************/ +/* */ +/* 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 +#include + +#define PANIC +#define WARNING +#undef TEST +#undef DEBUG + +#include "Logger.h" +#include "Shadow.h" +#include "Poller.h" +#include "Manager.h" + +typedef struct { + KeySym *map; + KeyCode minKeyCode, + maxKeyCode; + int mapWidth; +} KeySymsRec, *KeySymsPtr; + +KeySymsPtr NXShadowKeymap = NULL; + +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(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(dpy); + Display **shadowDisplay = reinterpret_cast(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); +} + +void NXShadowWebKeyEvent(KeySym keysym, Bool isKeyPress) +{ + poller -> handleWebKeyEvent(keysym, isKeyPress); +} + +#ifdef __CYGWIN32__ + +int NXShadowCaptureCursor(unsigned int wnd, void *vis) +{ + Window window = (Window)wnd; + Visual *visual = reinterpret_cast(vis); + + logTrace("NXShadowCaptureCursor"); + + logTest("NXShadowCaptureCursor","Init"); + + return poller -> updateCursor(window, visual); +} + +#endif + +void NXShadowUpdateBuffer(void **buffer) +{ + char **fBuffer = reinterpret_cast(buffer); + + if (*fBuffer != NULL) + { + poller -> destroyFrameBuffer(); + + poller -> init(); + } + + *fBuffer = poller -> getFrameBuffer(); + + logTest("NXShadowUpdateBuffer","New frame buffer [0x%p]", (void *)*fBuffer); +} + +void NXShadowInitKeymap(void *keysyms) +{ + NXShadowKeymap = (KeySymsPtr) keysyms; + + logTest("NXShadowInitKeymap","KeySyms pointer [0x%p] mapWidth [%d]", + (void *)NXShadowKeymap, NXShadowKeymap -> mapWidth); +} diff --git a/nxcompshad/Shadow.h b/nxcompshad/Shadow.h index eb3c14112..57a77255e 100644 --- a/nxcompshad/Shadow.h +++ b/nxcompshad/Shadow.h @@ -81,12 +81,18 @@ extern void NXShadowColorCorrect(int, int, unsigned int, unsigned int, extern void NXShadowUpdateBuffer(void **); extern void NXShadowEvent(Display *, XEvent); +extern void NXShadowWebKeyEvent(KeySym keysym, Bool isKeyPress); extern void NXShadowSetDisplayUid(int uid); extern void NXShadowDisableShm(void); extern void NXShadowDisableDamage(void); +extern void NXShadowGetScreenSize(int *width, int *height); +extern void NXShadowSetScreenSize(int *width, int *height); + +extern void NXShadowInitKeymap(void *keysyms); + #ifdef __cplusplus } #endif diff --git a/nxcompshad/Win.cpp b/nxcompshad/Win.cpp index 9f8cdc9dd..87ea80bf5 100644 --- a/nxcompshad/Win.cpp +++ b/nxcompshad/Win.cpp @@ -479,6 +479,13 @@ void Poller::handleKeyboardEvent(Display *display, XEvent *event) delete[] keyname; } +void Poller::handleWebKeyboardEvent(KeySym keysym, Bool isKeyPress) +{ +/* +FIXME +*/ +} + void Poller::handleMouseEvent(Display *display, XEvent *event) { DWORD flg = 0; diff --git a/nxcompshad/Win.h b/nxcompshad/Win.h index b44b5a0ac..934382190 100644 --- a/nxcompshad/Win.h +++ b/nxcompshad/Win.h @@ -72,6 +72,7 @@ class Poller : public CorePoller int Poller::updateShadowFrameBuffer(void); void handleKeyboardEvent(Display *, XEvent *); + void handleWebKeyboardEvent(KeySym keysym, Bool isKeyPress); void addToKeymap(char *keyname, unsigned char scancode, unsigned short modifiers, char *mapname); int xkeymapRead(char *mapname); FILE *xkeymapOpen(char *filename); diff --git a/nxcompshad/X11.cpp b/nxcompshad/X11.cpp index a2165d8e5..3971c8ea9 100644 --- a/nxcompshad/X11.cpp +++ b/nxcompshad/X11.cpp @@ -35,7 +35,49 @@ #define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3)) -#define TRANSLATE_KEYCODES +#undef TRANSLATE_KEYCODES +#define TRANSLATE_ALWAYS + +typedef struct { + KeySym *map; + KeyCode minKeyCode, + maxKeyCode; + int mapWidth; +} KeySymsRec, *KeySymsPtr; + +extern KeySymsPtr NXShadowKeymap; + +typedef struct _KeyPressed +{ + KeyCode keyRcvd; + KeyCode keySent; + struct _KeyPressed *next; +} KeyPressedRec; + +static KeyPressedRec *shadowKeyPressedPtr = NULL; + +static KeySym *shadowKeysyms = NULL; +static KeySym *masterKeysyms = NULL; + +static int shadowMinKey, shadowMaxKey, shadowMapWidth; +static int masterMinKey, masterMaxKey, masterMapWidth; + +static int leftShiftOn = 0; +static int rightShiftOn = 0; +static int modeSwitchOn = 0; +static int level3ShiftOn = 0; +static int altROn = 0; + +static int sentFakeLShiftPress = 0; +static int sentFakeLShiftRelease = 0; +static int sentFakeRShiftRelease = 0; +static int sentFakeModeSwitchPress = 0; +static int sentFakeModeSwitchRelease = 0; +static int sentFakeLevel3ShiftPress = 0; +static int sentFakeLevel3ShiftRelease = 0; +static int sentFakeAltRRelease = 0; + +static int shmInitTrap = 0; Poller::Poller(Input *input, Display *display, int depth) : CorePoller(input, display) { @@ -226,7 +268,10 @@ void Poller::shmInit(void) { logDebug("Poller::shmInit", "Called with shared memory already initialized."); - return; + if (shmInitTrap == 0) + { + return; + } } if (shmExtension_ < 0 && NXShadowOptions.optionShmExtension == 0) @@ -362,6 +407,520 @@ void Poller::shmInit(void) } } +void Poller::keymapShadowInit(Display *display) +{ + if (NXShadowKeymap) + { + shadowMinKey = NXShadowKeymap -> minKeyCode; + shadowMaxKey = NXShadowKeymap -> maxKeyCode; + shadowMapWidth = NXShadowKeymap -> mapWidth; + shadowKeysyms = NXShadowKeymap -> map; + } + + if (shadowKeysyms == NULL) + { + XDisplayKeycodes(display, &shadowMinKey, &shadowMaxKey); + + shadowKeysyms = XGetKeyboardMapping(display, shadowMinKey, shadowMaxKey - shadowMinKey + 1, + &shadowMapWidth); + } + + #ifdef DEBUG + if (shadowKeysyms) + { + for (int i = 0; i < (shadowMaxKey - shadowMinKey) * shadowMapWidth; i++) + { + logDebug("Poller::keymapShadowInit", "keycode %d - keysym %x %s", + (int)(i / shadowMapWidth), (unsigned int)shadowKeysyms[i], + XKeysymToString(shadowKeysyms[i])); + } + } + #endif +} + +void Poller::keymapMasterInit() +{ + XDisplayKeycodes(display_, &masterMinKey, &masterMaxKey); + + masterKeysyms = XGetKeyboardMapping(display_, masterMinKey, masterMaxKey - masterMinKey + 1, + &masterMapWidth); + + #ifdef DEBUG + if (masterKeysyms) + { + for (int i = 0; i < (masterMaxKey - masterMinKey) * masterMapWidth; i++) + { + logDebug("Poller::keymapMasterInit", "keycode %d - keysym %x %s", + (int)(i / masterMapWidth), (unsigned int)masterKeysyms[i], + XKeysymToString(masterKeysyms[i])); + } + } + #endif +} + +KeySym Poller::keymapKeycodeToKeysym(KeyCode keycode, KeySym *keysyms, + int minKey, int mapWidth, int col) +{ + int index = ((keycode - minKey) * mapWidth) + col; + return keysyms[index]; +} + +KeyCode Poller::keymapKeysymToKeycode(KeySym keysym, KeySym *keysyms, + int minKey, int maxKey, int mapWidth, int *col) +{ + for (int i = 0; i < (maxKey - minKey + 1) * mapWidth; i++) + { + if (keysyms[i] == keysym) + { + *col = i % mapWidth; + return i / mapWidth + minKey; + } + } + return 0; +} + +KeyCode Poller::translateKeysymToKeycode(KeySym keysym, int *col) +{ + KeyCode keycode; + + keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col); + + if (keycode == 0) + { + if (((keysym >> 8) == 0) && (keysym >= XK_a) && (keysym <= XK_z)) + { + /* + * The master session has a Solaris keyboard. + */ + + keysym -= XK_a - XK_A; + + keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col); + } + else if (keysym == XK_Shift_R) + { + keysym = XK_Shift_L; + + keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col); + } + else if (keysym == XK_Shift_L) + { + keysym = XK_Shift_R; + + keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col); + } + else if (keysym == XK_ISO_Level3_Shift) + { + keysym = XK_Mode_switch; + + if ((keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col)) == 0) + { + keysym = XK_Alt_R; + + keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col); + } + } + else if (keysym == XK_Alt_R) + { + keysym = XK_ISO_Level3_Shift; + + if ((keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col)) == 0) + { + keysym = XK_Mode_switch; + + keycode = keymapKeysymToKeycode(keysym, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, col); + } + } + } + return keycode; +} + +Bool Poller::checkModifierKeys(KeySym keysym, Bool isKeyPress) +{ + switch (keysym) + { + case XK_Shift_L: + leftShiftOn = isKeyPress; + return True; + case XK_Shift_R: + rightShiftOn = isKeyPress; + return True; + case XK_Mode_switch: + modeSwitchOn = isKeyPress; + return True; + case XK_ISO_Level3_Shift: + level3ShiftOn = isKeyPress; + return True; + case XK_Alt_R: + altROn = isKeyPress; + return True; + default: + return False; + } +} + +void Poller::sendFakeModifierEvents(int pos, Bool skip) +{ + KeySym fakeKeysym; + int col; + + if ((!leftShiftOn && !rightShiftOn) && + (!modeSwitchOn && !level3ShiftOn && !altROn)) + { + if (pos == 1 || pos == 3) + { + fakeKeysym = keymapKeysymToKeycode(XK_Shift_L, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + sentFakeLShiftPress = 1; + } + if (pos == 2 || pos == 3) + { + fakeKeysym = keymapKeysymToKeycode(XK_ISO_Level3_Shift, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + + if (fakeKeysym == 0) + { + fakeKeysym = keymapKeysymToKeycode(XK_Mode_switch, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + sentFakeModeSwitchPress = 1; + } + else + { + sentFakeLevel3ShiftPress = 1; + } + + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + } + } + + else if ((leftShiftOn || rightShiftOn) && + (!modeSwitchOn && !level3ShiftOn && !altROn)) + { + if ((pos == 0 && !skip) || pos == 2) + { + if (leftShiftOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Shift_L, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeLShiftRelease = 1; + } + if (rightShiftOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Shift_R, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeRShiftRelease = 1; + } + } + if (pos == 2 || pos ==3) + { + fakeKeysym = keymapKeysymToKeycode(XK_ISO_Level3_Shift, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + + if (fakeKeysym == 0) + { + fakeKeysym = keymapKeysymToKeycode(XK_Mode_switch, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + sentFakeModeSwitchPress = 1; + } + else + { + sentFakeLevel3ShiftPress = 1; + } + + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + } + } + + else if ((!leftShiftOn && !rightShiftOn) && + (modeSwitchOn || level3ShiftOn || altROn)) + { + if (pos == 1 || pos == 3) + { + fakeKeysym = keymapKeysymToKeycode(XK_Shift_L, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + sentFakeLShiftPress = 1; + } + if (pos == 0 || pos == 1) + { + if (modeSwitchOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Mode_switch, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeModeSwitchRelease = 1; + } + if (level3ShiftOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_ISO_Level3_Shift, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeLevel3ShiftRelease = 1; + } + if (altROn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Alt_R, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeAltRRelease = 1; + } + } + } + + else if ((leftShiftOn || rightShiftOn) && + (modeSwitchOn || level3ShiftOn || altROn)) + { + if (pos == 0 || pos == 2) + { + if (leftShiftOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Shift_L, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeLShiftRelease = 1; + } + if (rightShiftOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Shift_R, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeRShiftRelease = 1; + } + } + if (pos == 0 || pos == 1) + { + if (modeSwitchOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Mode_switch, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeModeSwitchRelease = 1; + } + if (level3ShiftOn) + { + fakeKeysym = keymapKeysymToKeycode(XK_ISO_Level3_Shift, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeLevel3ShiftRelease = 1; + } + if (altROn) + { + fakeKeysym = keymapKeysymToKeycode(XK_Alt_R, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + sentFakeAltRRelease = 1; + } + } + } +} + +void Poller::cancelFakeModifierEvents() +{ + KeySym fakeKeysym; + int col; + + if (sentFakeLShiftPress) + { + logTest("Poller::handleKeyboardEvent", "Fake Shift_L key press event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending fake Shift_L key release event"); + + fakeKeysym = keymapKeysymToKeycode(XK_Shift_L, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + + sentFakeLShiftPress = 0; + } + + if (sentFakeLShiftRelease) + { + logTest("Poller::handleKeyboardEvent", "Fake Shift_L key release event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending fake Shift_L key press event"); + + fakeKeysym = keymapKeysymToKeycode(XK_Shift_L, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + + sentFakeLShiftRelease = 0; + } + + if (sentFakeRShiftRelease) + { + logTest("Poller::handleKeyboardEvent", "Fake Shift_R key release event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending fake Shift_R key press event"); + + fakeKeysym = keymapKeysymToKeycode(XK_Shift_R, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + + sentFakeRShiftRelease = 0; + } + + if (sentFakeModeSwitchPress) + { + logTest("Poller::handleKeyboardEvent", "Fake Mode_switch key press event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending fake Mode_switch key release event"); + + fakeKeysym = keymapKeysymToKeycode(XK_Mode_switch, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + + sentFakeModeSwitchPress = 0; + } + + if (sentFakeModeSwitchRelease) + { + logTest("Poller::handleKeyboardEvent", "Fake Mode_switch key release event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending Mode_switch key press event"); + + fakeKeysym = keymapKeysymToKeycode(XK_Mode_switch, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + + sentFakeModeSwitchRelease = 0; + } + + if (sentFakeLevel3ShiftPress) + { + logTest("Poller::handleKeyboardEvent", "Fake ISO_Level3_Shift key press event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending fake ISO_Level3_Shift key release event"); + + fakeKeysym = keymapKeysymToKeycode(XK_ISO_Level3_Shift, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 0, 0); + + sentFakeLevel3ShiftPress = 0; + } + + if (sentFakeLevel3ShiftRelease) + { + logTest("Poller::handleKeyboardEvent", "Fake ISO_Level3_Shift key release event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending fake ISO_Level3_Shift key press event"); + + fakeKeysym = keymapKeysymToKeycode(XK_ISO_Level3_Shift, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + + sentFakeLevel3ShiftRelease = 0; + } + + if (sentFakeAltRRelease) + { + logTest("Poller::handleKeyboardEvent", "Fake XK_Alt_R key release event has been sent"); + logTest("Poller::handleKeyboardEvent", "Sending fake XK_Alt_R key press event"); + + fakeKeysym = keymapKeysymToKeycode(XK_Alt_R, masterKeysyms, masterMinKey, + masterMaxKey, masterMapWidth, &col); + XTestFakeKeyEvent(display_, fakeKeysym, 1, 0); + + sentFakeAltRRelease = 0; + } +} + +Bool Poller::keyIsDown(KeyCode keycode) +{ + KeyPressedRec *downKey; + + downKey = shadowKeyPressedPtr; + + while (downKey) + { + if (downKey -> keyRcvd == keycode) + { + return True; + } + downKey = downKey -> next; + } + + return False; +} + +void Poller::addKeyPressed(KeyCode received, KeyCode sent) +{ + KeyPressedRec *downKey; + + if (!keyIsDown(received)) + { + if (shadowKeyPressedPtr == NULL) + { + shadowKeyPressedPtr = (KeyPressedRec *) malloc(sizeof(KeyPressedRec)); + + shadowKeyPressedPtr -> keyRcvd = received; + shadowKeyPressedPtr -> keySent = sent; + shadowKeyPressedPtr -> next = NULL; + } + else + { + downKey = shadowKeyPressedPtr; + + while (downKey -> next != NULL) + { + downKey = downKey -> next; + } + + downKey -> next = (KeyPressedRec *) malloc(sizeof(KeyPressedRec)); + + downKey -> next -> keyRcvd = received; + downKey -> next -> keySent = sent; + downKey -> next -> next = NULL; + } + } +} + +KeyCode Poller::getKeyPressed(KeyCode received) +{ + KeyCode sent; + KeyPressedRec *downKey; + KeyPressedRec *tempKey; + + if (shadowKeyPressedPtr != NULL) + { + if (shadowKeyPressedPtr -> keyRcvd == received) + { + sent = shadowKeyPressedPtr -> keySent; + + tempKey = shadowKeyPressedPtr; + shadowKeyPressedPtr = shadowKeyPressedPtr -> next; + free(tempKey); + + return sent; + } + else + { + downKey = shadowKeyPressedPtr; + + while (downKey -> next != NULL) + { + if (downKey -> next -> keyRcvd == received) + { + sent = downKey -> next -> keySent; + + tempKey = downKey -> next; + downKey -> next = downKey -> next -> next; + free(tempKey); + + return sent; + } + else + { + downKey = downKey -> next; + } + } + } + } + return 0; +} + void Poller::handleKeyboardEvent(Display *display, XEvent *event) { if (xtestExtension_ == 0 || display_ == 0) @@ -371,6 +930,158 @@ void Poller::handleKeyboardEvent(Display *display, XEvent *event) logTest("Poller::handleKeyboardEvent", "Handling event at [%p]", event); +#ifdef TRANSLATE_ALWAYS + + KeyCode keycode; + KeySym keysym; + + int col = 0; + + Bool isKeyPress = False; + Bool isModifier = False; + Bool skip = False; + + if (event -> type == KeyPress) + { + isKeyPress = True; + } + + if (shadowKeysyms == NULL) + { + keymapShadowInit(event -> xkey.display); + } + + if (masterKeysyms == NULL) + { + keymapMasterInit(); + } + + if (shadowKeysyms == NULL || masterKeysyms == NULL) + { + logTest("Poller::handleKeyboardEvent", "Unable to initialize keymaps. Do not translate"); + + keycode = event -> xkey.keycode; + + goto SendKeycode; + } + + keysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, + shadowMinKey, shadowMapWidth, 0); + + isModifier = checkModifierKeys(keysym, isKeyPress); + + if (event -> type == KeyRelease) + { + KeyCode keycodeToSend; + + keycodeToSend = getKeyPressed(event -> xkey.keycode); + + if (keycodeToSend) + { + keycode = keycodeToSend; + + goto SendKeycode; + } + } + + /* + * Convert case for Solaris keyboard. + */ + + if (((keysym >> 8) == 0) && (keysym >= XK_A) && (keysym <= XK_Z)) + { + if (!leftShiftOn && !rightShiftOn) + { + keysym += XK_a - XK_A; + } + else + { + skip = True; + } + } + + if (!isModifier) + { + if ((leftShiftOn || rightShiftOn) && + (!modeSwitchOn && !level3ShiftOn && !altROn) && + !skip) + { + keysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, + shadowMinKey, shadowMapWidth, 1); + } + + if ((!leftShiftOn && !rightShiftOn) && + (modeSwitchOn || level3ShiftOn || altROn)) + { + keysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, + shadowMinKey, shadowMapWidth, 2); + } + + if ((leftShiftOn || rightShiftOn) && + (modeSwitchOn || level3ShiftOn || altROn)) + { + keysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, + shadowMinKey, shadowMapWidth, 3); + } + } + + if (keysym == 0) + { + logTest("Poller::handleKeyboardEvent", "Null keysym. Return"); + + return; + } + + logTest("Poller::handleKeyboardEvent", "keysym [%x] [%s]", + (unsigned int)keysym, XKeysymToString(keysym)); + + if (keysym == XK_Mode_switch) + { + keysym = XK_ISO_Level3_Shift; + } + + keycode = translateKeysymToKeycode(keysym, &col); + + if (keycode == 0) + { + logTest("Poller::handleKeyboardEvent", "No keycode found for keysym [%x] [%s]. Return", + (unsigned int)keysym, XKeysymToString(keysym)); + return; + } + + logTest("Poller::handleKeyboardEvent", "keycode [%d] translated into keycode [%d]", + (int)event -> xkey.keycode, (unsigned int)keycode); + + if (event -> type == KeyPress) + { + addKeyPressed(event -> xkey.keycode, keycode); + } + + /* + * Send fake modifier events. + */ + + if (!isModifier) + { + sendFakeModifierEvents(col, ((keysym >> 8) == 0) && (keysym >= XK_A) && (keysym <= XK_Z)); + } + +SendKeycode: + + /* + * Send the event. + */ + + XTestFakeKeyEvent(display_, keycode, isKeyPress, 0); + + /* + * Check if fake modifier events have been sent. + */ + + cancelFakeModifierEvents(); + +#else // TRANSLATE_ALWAYS + // // Use keysyms to translate keycodes across different // keyboard models. Unuseful when both keyboards have @@ -417,6 +1128,60 @@ void Poller::handleKeyboardEvent(Display *display, XEvent *event) { XTestFakeKeyEvent(display_, event -> xkey.keycode, 0, 0); } + +#endif // TRANSLATE_ALWAYS +} + +void Poller::handleWebKeyboardEvent(KeySym keysym, Bool isKeyPress) +{ + KeyCode keycode; + int col; + + if (masterKeysyms == NULL) + { + keymapMasterInit(); + } + + if (masterKeysyms == NULL) + { + logTest("Poller::handleWebKeyboardEvent", "Unable to initialize keymap"); + + return; + } + + keycode = translateKeysymToKeycode(keysym, &col); + + if (keycode == 0) + { + logTest("Poller::handleKeyboardEvent", "No keycode found for keysym [%x] [%s]. Return", + (unsigned int)keysym, XKeysymToString(keysym)); + return; + } + + logTest("Poller::handleKeyboardEvent", "keysym [%x] [%s] translated into keycode [%x]", + (unsigned int)keysym, XKeysymToString(keysym), (unsigned int)keycode); + + /* + * Send fake modifier events. + */ + + if (!checkModifierKeys(keysym, isKeyPress)) + { + sendFakeModifierEvents(col, False); + } + + /* + * Send the event. + */ + + XTestFakeKeyEvent(display_, keycode, isKeyPress, 0); + + /* + * Check if fake modifier events have been sent. + */ + + cancelFakeModifierEvents(); + } void Poller::handleMouseEvent(Display *display, XEvent *event) @@ -712,6 +1477,26 @@ void Poller::updateDamagedAreas(void) return; } +void Poller::getScreenSize(int *w, int *h) +{ + *w = WidthOfScreen(DefaultScreenOfDisplay(display_)); + *h = HeightOfScreen(DefaultScreenOfDisplay(display_)); +} + +void Poller::setScreenSize(int *w, int *h) +{ + setRootSize(); + + shmInitTrap = 1; + shmInit(); + shmInitTrap = 0; + + *w = width_; + *h = height_; + + logDebug("Poller::setScreenSize", "New size of screen [%d, %d]", width_, height_); +} + int anyEventPredicate(Display *display, XEvent *event, XPointer parameter) { return 1; diff --git a/nxcompshad/X11.h b/nxcompshad/X11.h index e3a62ba56..ff14aaea4 100644 --- a/nxcompshad/X11.h +++ b/nxcompshad/X11.h @@ -41,6 +41,10 @@ class Poller : public CorePoller void getEvents(void); + void getScreenSize(int *width, int *height); + + void setScreenSize(int *width, int *height); + private: Display *display_; @@ -77,8 +81,34 @@ class Poller : public CorePoller char *getRect(XRectangle); + void keymapShadowInit(Display *display); + + void keymapMasterInit(); + + KeySym keymapKeycodeToKeysym(KeyCode keycode, KeySym *keysyms, + int minKey, int per, int col); + + KeyCode keymapKeysymToKeycode(KeySym keysym, KeySym *keysyms, + int minKey, int maxKey, int per, int *col); + + KeyCode translateKeysymToKeycode(KeySym keysym, int *col); + + Bool checkModifierKeys(KeySym keysym, Bool isKeyPress); + + void sendFakeModifierEvents(int pos, Bool skip); + + void cancelFakeModifierEvents(); + + Bool keyIsDown(KeyCode keycode); + + void addKeyPressed(KeyCode received, KeyCode sent); + + KeyCode getKeyPressed(KeyCode received); + void handleKeyboardEvent(Display *display, XEvent *); + void handleWebKeyboardEvent(KeySym keysym, Bool isKeyPress); + void handleMouseEvent(Display *, XEvent *); void xtestInit(void); -- cgit v1.2.3 From 3b4404668c6794f9d0665905f4e22c1a0fafac21 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: Imported nxcompshad-3.3.0-2.tar.gz Summary: Imported nxcompshad-3.3.0-2.tar.gz Keywords: Imported nxcompshad-3.3.0-2.tar.gz into Git repository --- nxcompshad/CHANGELOG | 8 ++++++++ nxcompshad/VERSION | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG index 77976867c..79319b81a 100644 --- a/nxcompshad/CHANGELOG +++ b/nxcompshad/CHANGELOG @@ -1,5 +1,13 @@ ChangeLog: +nxcompshad-3.3.0-2 + +- Updated VERSION. + +nxcompshad-3.3.0-1 + +- Opened the 3.3.0 branch based on nxcompshad-3.2.0-3. + nxcompshad-3.2.0-3 - Improved keycode translation. diff --git a/nxcompshad/VERSION b/nxcompshad/VERSION index 944880fa1..15a279981 100644 --- a/nxcompshad/VERSION +++ b/nxcompshad/VERSION @@ -1 +1 @@ -3.2.0 +3.3.0 -- cgit v1.2.3 From 3d8e85c4749ee9e55601f6e540311008bf8f77af Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: Imported nxcompshad-3.3.0-3.tar.gz Summary: Imported nxcompshad-3.3.0-3.tar.gz Keywords: Imported nxcompshad-3.3.0-3.tar.gz into Git repository --- nxcompshad/CHANGELOG | 5 +++++ nxcompshad/Shadow.cpp | 3 +-- nxcompshad/X11.cpp | 60 +++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 52 insertions(+), 16 deletions(-) (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG index 79319b81a..8678d2159 100644 --- a/nxcompshad/CHANGELOG +++ b/nxcompshad/CHANGELOG @@ -1,5 +1,10 @@ ChangeLog: +nxcompshad-3.3.0-3 + +- Fixed TR01G02158. Keymap initialization could be incorrect because + of a type mismatch on 64 bit platforms. + nxcompshad-3.3.0-2 - Updated VERSION. diff --git a/nxcompshad/Shadow.cpp b/nxcompshad/Shadow.cpp index c7fb6b4a3..f9154aa25 100644 --- a/nxcompshad/Shadow.cpp +++ b/nxcompshad/Shadow.cpp @@ -466,6 +466,5 @@ void NXShadowInitKeymap(void *keysyms) { NXShadowKeymap = (KeySymsPtr) keysyms; - logTest("NXShadowInitKeymap","KeySyms pointer [0x%p] mapWidth [%d]", - (void *)NXShadowKeymap, NXShadowKeymap -> mapWidth); + logTest("NXShadowInitKeymap","KeySyms pointer [0x%p]", (void *)NXShadowKeymap); } diff --git a/nxcompshad/X11.cpp b/nxcompshad/X11.cpp index 3971c8ea9..99333b0ec 100644 --- a/nxcompshad/X11.cpp +++ b/nxcompshad/X11.cpp @@ -23,6 +23,7 @@ #undef DEBUG #include +#include #include #include #include @@ -59,6 +60,8 @@ static KeyPressedRec *shadowKeyPressedPtr = NULL; static KeySym *shadowKeysyms = NULL; static KeySym *masterKeysyms = NULL; +static KeySym *shadowKeymap = NULL; + static int shadowMinKey, shadowMaxKey, shadowMapWidth; static int masterMinKey, masterMaxKey, masterMapWidth; @@ -409,12 +412,35 @@ void Poller::shmInit(void) void Poller::keymapShadowInit(Display *display) { - if (NXShadowKeymap) + int i, len; + CARD32 *map; + + if (NXShadowKeymap != NULL) { - shadowMinKey = NXShadowKeymap -> minKeyCode; - shadowMaxKey = NXShadowKeymap -> maxKeyCode; + shadowMinKey = NXShadowKeymap -> minKeyCode; + shadowMaxKey = NXShadowKeymap -> maxKeyCode; shadowMapWidth = NXShadowKeymap -> mapWidth; - shadowKeysyms = NXShadowKeymap -> map; + + len = (shadowMaxKey - shadowMinKey + 1) * shadowMapWidth; + + map = (CARD32 *) NXShadowKeymap -> map; + + if (shadowKeymap != NULL) + { + free(shadowKeymap); + } + + shadowKeymap = (KeySym *) malloc(len * sizeof(KeySym)); + + if (shadowKeymap != NULL) + { + for (i = 0; i < len; i++) + { + shadowKeymap[i] = map[i]; + } + + shadowKeysyms = shadowKeymap; + } } if (shadowKeysyms == NULL) @@ -426,13 +452,16 @@ void Poller::keymapShadowInit(Display *display) } #ifdef DEBUG - if (shadowKeysyms) + if (shadowKeysyms != NULL) { - for (int i = 0; i < (shadowMaxKey - shadowMinKey) * shadowMapWidth; i++) + for (i = 0; i < (shadowMaxKey - shadowMinKey + 1) * shadowMapWidth; i++) { - logDebug("Poller::keymapShadowInit", "keycode %d - keysym %x %s", - (int)(i / shadowMapWidth), (unsigned int)shadowKeysyms[i], - XKeysymToString(shadowKeysyms[i])); + if (i % shadowMapWidth == 0) + { + logDebug("Poller::keymapShadowInit", "keycode [%d]", (int) (i / shadowMapWidth)); + } + + logDebug("\tkeysym", " [%x] [%s]", (unsigned int) shadowKeysyms[i], XKeysymToString(shadowKeysyms[i])); } } #endif @@ -446,13 +475,16 @@ void Poller::keymapMasterInit() &masterMapWidth); #ifdef DEBUG - if (masterKeysyms) + if (masterKeysyms != NULL) { - for (int i = 0; i < (masterMaxKey - masterMinKey) * masterMapWidth; i++) + for (int i = 0; i < (masterMaxKey - masterMinKey + 1) * masterMapWidth; i++) { - logDebug("Poller::keymapMasterInit", "keycode %d - keysym %x %s", - (int)(i / masterMapWidth), (unsigned int)masterKeysyms[i], - XKeysymToString(masterKeysyms[i])); + if (i % masterMapWidth == 0) + { + logDebug("Poller::keymapMasterInit", "keycode [%d]", (int) (i / masterMapWidth)); + } + + logDebug("\tkeysym", " [%x] [%s]", (unsigned int) masterKeysyms[i], XKeysymToString(masterKeysyms[i])); } } #endif -- cgit v1.2.3 From 2208f4f9ecf967579a364021f0847b3ad1d7777c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: Imported nxcompshad-3.4.0-1.tar.gz Summary: Imported nxcompshad-3.4.0-1.tar.gz Keywords: Imported nxcompshad-3.4.0-1.tar.gz into Git repository --- nxcompshad/CHANGELOG | 10 ++++++++++ nxcompshad/LICENSE | 2 +- nxcompshad/Shadow.cpp | 6 +++--- nxcompshad/VERSION | 2 +- nxcompshad/X11.cpp | 20 +++++++++++--------- 5 files changed, 26 insertions(+), 14 deletions(-) (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG index 8678d2159..27bc0aca1 100644 --- a/nxcompshad/CHANGELOG +++ b/nxcompshad/CHANGELOG @@ -1,5 +1,15 @@ ChangeLog: +nxcompshad-3.4.0-1 + +- Opened the 3.4.0 branch based on nxcompshad-3.3.0-3. + +- Updated version number. + +- Updated copyright to year 2009. + +- Improved error messages logging in case of initialization failures. + nxcompshad-3.3.0-3 - Fixed TR01G02158. Keymap initialization could be incorrect because diff --git a/nxcompshad/LICENSE b/nxcompshad/LICENSE index 0631b9dfb..bf103c899 100644 --- a/nxcompshad/LICENSE +++ b/nxcompshad/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2001, 2007 NoMachine - http://www.nomachine.com/. +Copyright (c) 2001, 2009 NoMachine - http://www.nomachine.com/. NXCOMPSHAD and NX extensions to X are copyright of NoMachine. diff --git a/nxcompshad/Shadow.cpp b/nxcompshad/Shadow.cpp index f9154aa25..e336ca679 100644 --- a/nxcompshad/Shadow.cpp +++ b/nxcompshad/Shadow.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */ +/* Copyright (c) 2001, 2009 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 */ @@ -152,7 +152,7 @@ static int NXCreatePoller(Display *display, Display **shadowDisplay) if (poller -> init() == -1) { - logTest("NXCreatePoller", "Failed to initialize poller."); + logWarning("NXCreatePoller", "Failed to initialize poller."); return -1; } @@ -270,7 +270,7 @@ int NXShadowCreate(void *dpy, char *keymap, char* shadowDisplayName, void **shad if (NXCreatePoller(display, shadowDisplay) != 1) { - logTest("NXShadowCreate", "NXCreatePoller failed."); + logWarning("NXShadowCreate", "NXCreatePoller failed."); return -1; } diff --git a/nxcompshad/VERSION b/nxcompshad/VERSION index 15a279981..18091983f 100644 --- a/nxcompshad/VERSION +++ b/nxcompshad/VERSION @@ -1 +1 @@ -3.3.0 +3.4.0 diff --git a/nxcompshad/X11.cpp b/nxcompshad/X11.cpp index 99333b0ec..837efad71 100644 --- a/nxcompshad/X11.cpp +++ b/nxcompshad/X11.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2009 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 */ @@ -1305,17 +1305,19 @@ void Poller::randrInit(void) int randrEventBase; int randrErrorBase; - randrExtension_ = 0; - - XRRSelectInput(display_, DefaultRootWindow(display_), RRScreenChangeNotifyMask); - if (XRRQueryExtension(display_, &randrEventBase, &randrErrorBase) == 0) { - #ifdef PANIC - fprintf(stderr, "nxagentShadowInit: Randr extension not supported on this display.\n"); - #endif + logWarning("Poller::randrInit", "Randr extension not supported on this " + "display."); + + randrExtension_ = 0; + + return; } + XRRSelectInput(display_, DefaultRootWindow(display_), + RRScreenChangeNotifyMask); + randrEventBase_ = randrEventBase; randrExtension_ = 1; @@ -1412,7 +1414,7 @@ void Poller::getEvents(void) { if (randrExtension_ == 1 && (X.type == randrEventBase_ + RRScreenChangeNotify || X.type == ConfigureNotify)) { - XRRUpdateConfiguration (&X); + XRRUpdateConfiguration(&X); handleRRScreenChangeNotify(&X); -- cgit v1.2.3 From c70adf725d3fea94eabdde467b8b8b106a796c0a Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: Imported nxcompshad-3.4.0-3.tar.gz Summary: Imported nxcompshad-3.4.0-3.tar.gz Keywords: Imported nxcompshad-3.4.0-3.tar.gz into Git repository --- nxcompshad/CHANGELOG | 13 +++++++ nxcompshad/Core.cpp | 2 +- nxcompshad/Core.h | 2 +- nxcompshad/Input.cpp | 2 +- nxcompshad/Input.h | 2 +- nxcompshad/LICENSE | 2 +- nxcompshad/Logger.cpp | 2 +- nxcompshad/Logger.h | 2 +- nxcompshad/Makefile.in | 2 +- nxcompshad/Manager.cpp | 2 +- nxcompshad/Manager.h | 2 +- nxcompshad/Misc.h | 2 +- nxcompshad/Poller.h | 2 +- nxcompshad/Regions.h | 2 +- nxcompshad/Shadow.cpp | 2 +- nxcompshad/Shadow.cpp.orig | 2 +- nxcompshad/Shadow.h | 2 +- nxcompshad/Updater.cpp | 2 +- nxcompshad/Updater.h | 2 +- nxcompshad/Win.cpp | 2 +- nxcompshad/Win.h | 2 +- nxcompshad/X11.cpp | 93 ++++++++++++++++++++++++++++++++-------------- nxcompshad/X11.h | 2 +- 23 files changed, 100 insertions(+), 48 deletions(-) (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG index 27bc0aca1..ea1ff455c 100644 --- a/nxcompshad/CHANGELOG +++ b/nxcompshad/CHANGELOG @@ -1,5 +1,18 @@ ChangeLog: +nxcompshad-3.4.0-3 + +- Updated copyright to year 2010. + +nxcompshad-3.4.0-2 + +- Fixed TR08G02256. Now the Shadow session is shown correctly with + MIT-SHM extension disabled. + +- Improved updateShadowFrameBuffer() and ~Poller() functions. + +- Avoided memory leak. + nxcompshad-3.4.0-1 - Opened the 3.4.0 branch based on nxcompshad-3.3.0-3. diff --git a/nxcompshad/Core.cpp b/nxcompshad/Core.cpp index 44327cd3f..6052de6cc 100644 --- a/nxcompshad/Core.cpp +++ b/nxcompshad/Core.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Core.h b/nxcompshad/Core.h index 17ce44881..b0a994329 100644 --- a/nxcompshad/Core.h +++ b/nxcompshad/Core.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Input.cpp b/nxcompshad/Input.cpp index c51c5d3b3..09e77a8ef 100644 --- a/nxcompshad/Input.cpp +++ b/nxcompshad/Input.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Input.h b/nxcompshad/Input.h index 64775c290..764508e03 100644 --- a/nxcompshad/Input.h +++ b/nxcompshad/Input.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/LICENSE b/nxcompshad/LICENSE index bf103c899..99d6e5cbc 100644 --- a/nxcompshad/LICENSE +++ b/nxcompshad/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2001, 2009 NoMachine - http://www.nomachine.com/. +Copyright (c) 2001, 2010 NoMachine - http://www.nomachine.com/. NXCOMPSHAD and NX extensions to X are copyright of NoMachine. diff --git a/nxcompshad/Logger.cpp b/nxcompshad/Logger.cpp index 1f55ce9b1..47e5e6391 100644 --- a/nxcompshad/Logger.cpp +++ b/nxcompshad/Logger.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Logger.h b/nxcompshad/Logger.h index 4eff83e5a..0a9cad95f 100644 --- a/nxcompshad/Logger.h +++ b/nxcompshad/Logger.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Makefile.in b/nxcompshad/Makefile.in index c7c22ad06..eaf5cabcf 100755 --- a/nxcompshad/Makefile.in +++ b/nxcompshad/Makefile.in @@ -1,6 +1,6 @@ ############################################################################ # # -# Copyright (c) 2001, 2005 NoMachine, http://www.nomachine.com. # +# Copyright (c) 2001, 2010 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 # diff --git a/nxcompshad/Manager.cpp b/nxcompshad/Manager.cpp index 92a7cdaee..38b92c20c 100644 --- a/nxcompshad/Manager.cpp +++ b/nxcompshad/Manager.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Manager.h b/nxcompshad/Manager.h index 22f6b159c..6f87cdccf 100644 --- a/nxcompshad/Manager.h +++ b/nxcompshad/Manager.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Misc.h b/nxcompshad/Misc.h index 6bfbaa4fb..3bcb26653 100644 --- a/nxcompshad/Misc.h +++ b/nxcompshad/Misc.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Poller.h b/nxcompshad/Poller.h index 489ba305d..914ba1d07 100644 --- a/nxcompshad/Poller.h +++ b/nxcompshad/Poller.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Regions.h b/nxcompshad/Regions.h index 6e6827fc4..8ea41ad1d 100644 --- a/nxcompshad/Regions.h +++ b/nxcompshad/Regions.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Shadow.cpp b/nxcompshad/Shadow.cpp index e336ca679..6f2856ce1 100644 --- a/nxcompshad/Shadow.cpp +++ b/nxcompshad/Shadow.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2009 NoMachine, http://www.nomachine.com. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Shadow.cpp.orig b/nxcompshad/Shadow.cpp.orig index 91ef3b85a..206eb2eaf 100644 --- a/nxcompshad/Shadow.cpp.orig +++ b/nxcompshad/Shadow.cpp.orig @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Shadow.h b/nxcompshad/Shadow.h index 57a77255e..ef65c0b2a 100644 --- a/nxcompshad/Shadow.h +++ b/nxcompshad/Shadow.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Updater.cpp b/nxcompshad/Updater.cpp index 3f0e6a4da..f1761ba66 100644 --- a/nxcompshad/Updater.cpp +++ b/nxcompshad/Updater.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Updater.h b/nxcompshad/Updater.h index 386c72639..4bcaa9176 100644 --- a/nxcompshad/Updater.h +++ b/nxcompshad/Updater.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Win.cpp b/nxcompshad/Win.cpp index 87ea80bf5..3f1e489e2 100644 --- a/nxcompshad/Win.cpp +++ b/nxcompshad/Win.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/Win.h b/nxcompshad/Win.h index 934382190..72566b8f4 100644 --- a/nxcompshad/Win.h +++ b/nxcompshad/Win.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ diff --git a/nxcompshad/X11.cpp b/nxcompshad/X11.cpp index 837efad71..cb8f55fc5 100644 --- a/nxcompshad/X11.cpp +++ b/nxcompshad/X11.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2009 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ @@ -127,7 +127,7 @@ Poller::~Poller() XCloseDisplay(display_); } - if (tmpBuffer_ != NULL && shmExtension_ == 1 && damageExtension_ == 1) + if (tmpBuffer_ != NULL && shmExtension_ != -1 && damageExtension_ == 1) { XFree(tmpBuffer_); @@ -181,13 +181,21 @@ int Poller::updateShadowFrameBuffer(void) return -1; } - - return 1; } else { - return 0; + image_ = XGetImage(display_, DefaultRootWindow(display_), 0, 0, width_, + height_, AllPlanes, ZPixmap); + + if (image_ == NULL) + { + logDebug("Poller::updateShadowFrameBuffer", "XGetImage failed!"); + + return -1; + } } + + return 1; } char *Poller::getRect(XRectangle r) @@ -255,6 +263,8 @@ char *Poller::getRect(XRectangle r) } XFree(image_); + + image_ = NULL; } return tmpBuffer_; @@ -1469,42 +1479,71 @@ void Poller::handleDamageNotify(XEvent *X) void Poller::updateDamagedAreas(void) { - if (shmExtension_ == 1) - { - BOX *boxPtr; + BOX *boxPtr; - XRectangle rectangle; + XRectangle rectangle; - int i; - int y; + int i; + int y; + + for (i = 0; i < lastUpdatedRegion_ -> numRects; i++) + { + boxPtr = lastUpdatedRegion_ -> rects + i; - for (i = 0; i < lastUpdatedRegion_ -> numRects; i++) + if (shmExtension_ == 1) { - boxPtr = lastUpdatedRegion_ -> rects + i; - image_ -> width = boxPtr -> x2 - boxPtr -> x1; - image_ -> height = boxPtr -> y2 - boxPtr -> y1; + image_ -> height = boxPtr -> y2 - boxPtr -> y1; + image_ -> bytes_per_line = + ROUNDUP((image_ -> bits_per_pixel * image_ -> width), + image_ -> bitmap_pad); + + if (XShmGetImage(display_, DefaultRootWindow(display_), image_, + boxPtr -> x1, boxPtr -> y1, AllPlanes) == 0) + { + logDebug("Poller::updateDamagedAreas", "XShmGetImage failed!"); - image_ -> bytes_per_line = ROUNDUP((image_ -> bits_per_pixel * image_ -> width), image_ -> bitmap_pad); + return; + } + } + else if (shmExtension_ == 0) + { + image_ = XGetImage(display_, DefaultRootWindow(display_), boxPtr -> x1, + boxPtr -> y1, boxPtr -> x2 - boxPtr -> x1, + boxPtr -> y2 - boxPtr -> y1, AllPlanes, + ZPixmap); - if (XShmGetImage(display_, DefaultRootWindow(display_), image_, boxPtr -> x1, boxPtr -> y1, AllPlanes) == 0) + if (image_ == NULL) { - logDebug("Poller::getRect", "XShmGetImage failed!"); + logDebug("Poller::updateDamagedAreas", "XGetImage failed!"); return; } - rectangle.height = 1; - rectangle.width = image_ -> width; - rectangle.x = boxPtr -> x1; - rectangle.y = boxPtr -> y1; + image_ -> width = boxPtr -> x2 - boxPtr -> x1; + image_ -> height = boxPtr -> y2 - boxPtr -> y1; + image_ -> bytes_per_line = + ROUNDUP((image_ -> bits_per_pixel * image_ -> width), + image_ -> bitmap_pad); + } + + rectangle.height = 1; + rectangle.width = image_ -> width; + rectangle.x = boxPtr -> x1; + rectangle.y = boxPtr -> y1; - for (y = 0; y < image_ -> height; y++) - { - update(image_ -> data + y * image_ -> bytes_per_line, rectangle); + for (y = 0; y < image_ -> height; y++) + { + update(image_ -> data + y * image_ -> bytes_per_line, rectangle); - rectangle.y++; - } + rectangle.y++; + } + + if (shmExtension_ != 1) + { + XDestroyImage(image_); + + image_ = NULL; } } diff --git a/nxcompshad/X11.h b/nxcompshad/X11.h index ff14aaea4..d34fd3dba 100644 --- a/nxcompshad/X11.h +++ b/nxcompshad/X11.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 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 */ -- cgit v1.2.3 From bf85c6e696693ef5a277c0334c01493dedf4fadd Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 13 Nov 2011 09:53:12 +0100 Subject: Imported nxcompshad-3.5.0-2.tar.gz Summary: Imported nxcompshad-3.5.0-2.tar.gz Keywords: Imported nxcompshad-3.5.0-2.tar.gz into Git repository --- nxcompshad/CHANGELOG | 11 ++ nxcompshad/Core.cpp | 2 +- nxcompshad/Core.h | 2 +- nxcompshad/Input.cpp | 2 +- nxcompshad/Input.h | 2 +- nxcompshad/LICENSE | 2 +- nxcompshad/Logger.cpp | 2 +- nxcompshad/Logger.h | 2 +- nxcompshad/Makefile.in | 2 +- nxcompshad/Manager.cpp | 2 +- nxcompshad/Manager.h | 2 +- nxcompshad/Misc.h | 2 +- nxcompshad/Poller.h | 2 +- nxcompshad/Regions.h | 2 +- nxcompshad/Shadow.cpp | 2 +- nxcompshad/Shadow.cpp.orig | 461 --------------------------------------------- nxcompshad/Shadow.h | 2 +- nxcompshad/Updater.cpp | 2 +- nxcompshad/Updater.h | 2 +- nxcompshad/VERSION | 2 +- nxcompshad/Win.cpp | 2 +- nxcompshad/Win.h | 2 +- nxcompshad/X11.cpp | 28 ++- nxcompshad/X11.h | 2 +- 24 files changed, 50 insertions(+), 492 deletions(-) mode change 100755 => 100644 nxcompshad/Makefile.in delete mode 100644 nxcompshad/Shadow.cpp.orig (limited to 'nxcompshad/CHANGELOG') diff --git a/nxcompshad/CHANGELOG b/nxcompshad/CHANGELOG index ea1ff455c..3472a4afe 100644 --- a/nxcompshad/CHANGELOG +++ b/nxcompshad/CHANGELOG @@ -1,5 +1,16 @@ ChangeLog: +nxcompshad-3.5.0-2 + +- Fixed TR03G02189. Now key combinations involving the Shift keys + are recognized correctly. + +nxcompshad-3.5.0-1 + +- Opened the 3.5.0 branch based on nxcompshad-3.4.0-3. + +- Updated copyright to year 2011. + nxcompshad-3.4.0-3 - Updated copyright to year 2010. diff --git a/nxcompshad/Core.cpp b/nxcompshad/Core.cpp index 6052de6cc..6f9449387 100644 --- a/nxcompshad/Core.cpp +++ b/nxcompshad/Core.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Core.h b/nxcompshad/Core.h index b0a994329..9bc8a645b 100644 --- a/nxcompshad/Core.h +++ b/nxcompshad/Core.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Input.cpp b/nxcompshad/Input.cpp index 09e77a8ef..f9bf1810d 100644 --- a/nxcompshad/Input.cpp +++ b/nxcompshad/Input.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Input.h b/nxcompshad/Input.h index 764508e03..6250e790b 100644 --- a/nxcompshad/Input.h +++ b/nxcompshad/Input.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/LICENSE b/nxcompshad/LICENSE index 99d6e5cbc..2c7f95a2d 100644 --- a/nxcompshad/LICENSE +++ b/nxcompshad/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2001, 2010 NoMachine - http://www.nomachine.com/. +Copyright (c) 2001, 2011 NoMachine - http://www.nomachine.com/. NXCOMPSHAD and NX extensions to X are copyright of NoMachine. diff --git a/nxcompshad/Logger.cpp b/nxcompshad/Logger.cpp index 47e5e6391..c367c5d7f 100644 --- a/nxcompshad/Logger.cpp +++ b/nxcompshad/Logger.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Logger.h b/nxcompshad/Logger.h index 0a9cad95f..94e4da857 100644 --- a/nxcompshad/Logger.h +++ b/nxcompshad/Logger.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Makefile.in b/nxcompshad/Makefile.in old mode 100755 new mode 100644 index eaf5cabcf..1580a3594 --- a/nxcompshad/Makefile.in +++ b/nxcompshad/Makefile.in @@ -1,6 +1,6 @@ ############################################################################ # # -# Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. # +# Copyright (c) 2001, 2011 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 # diff --git a/nxcompshad/Manager.cpp b/nxcompshad/Manager.cpp index 38b92c20c..ba9260a13 100644 --- a/nxcompshad/Manager.cpp +++ b/nxcompshad/Manager.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Manager.h b/nxcompshad/Manager.h index 6f87cdccf..267754906 100644 --- a/nxcompshad/Manager.h +++ b/nxcompshad/Manager.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Misc.h b/nxcompshad/Misc.h index 3bcb26653..6dc86359f 100644 --- a/nxcompshad/Misc.h +++ b/nxcompshad/Misc.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Poller.h b/nxcompshad/Poller.h index 914ba1d07..4435b5bba 100644 --- a/nxcompshad/Poller.h +++ b/nxcompshad/Poller.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Regions.h b/nxcompshad/Regions.h index 8ea41ad1d..b9303dcb7 100644 --- a/nxcompshad/Regions.h +++ b/nxcompshad/Regions.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Shadow.cpp b/nxcompshad/Shadow.cpp index 6f2856ce1..f9525adcf 100644 --- a/nxcompshad/Shadow.cpp +++ b/nxcompshad/Shadow.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Shadow.cpp.orig b/nxcompshad/Shadow.cpp.orig deleted file mode 100644 index 206eb2eaf..000000000 --- a/nxcompshad/Shadow.cpp.orig +++ /dev/null @@ -1,461 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2010 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 -#include - -#define PANIC -#define WARNING -#undef TEST -#undef DEBUG - -#include "Logger.h" -#include "Shadow.h" -#include "Poller.h" -#include "Manager.h" - -typedef struct { - KeySym *map; - KeyCode minKeyCode, - maxKeyCode; - int mapWidth; -} KeySymsRec, *KeySymsPtr; - -KeySymsPtr NXShadowKeymap = NULL; - -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(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(dpy); - Display **shadowDisplay = reinterpret_cast(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); -} - -void NXShadowWebKeyEvent(KeySym keysym, Bool isKeyPress) -{ - poller -> handleWebKeyEvent(keysym, isKeyPress); -} - -#ifdef __CYGWIN32__ - -int NXShadowCaptureCursor(unsigned int wnd, void *vis) -{ - Window window = (Window)wnd; - Visual *visual = reinterpret_cast(vis); - - logTrace("NXShadowCaptureCursor"); - - logTest("NXShadowCaptureCursor","Init"); - - return poller -> updateCursor(window, visual); -} - -#endif - -void NXShadowUpdateBuffer(void **buffer) -{ - char **fBuffer = reinterpret_cast(buffer); - - if (*fBuffer != NULL) - { - poller -> destroyFrameBuffer(); - - poller -> init(); - } - - *fBuffer = poller -> getFrameBuffer(); - - logTest("NXShadowUpdateBuffer","New frame buffer [0x%p]", (void *)*fBuffer); -} - -void NXShadowInitKeymap(void *keysyms) -{ - NXShadowKeymap = (KeySymsPtr) keysyms; - - logTest("NXShadowInitKeymap","KeySyms pointer [0x%p] mapWidth [%d]", - (void *)NXShadowKeymap, NXShadowKeymap -> mapWidth); -} diff --git a/nxcompshad/Shadow.h b/nxcompshad/Shadow.h index ef65c0b2a..e1eddb95c 100644 --- a/nxcompshad/Shadow.h +++ b/nxcompshad/Shadow.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Updater.cpp b/nxcompshad/Updater.cpp index f1761ba66..245c6ce31 100644 --- a/nxcompshad/Updater.cpp +++ b/nxcompshad/Updater.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Updater.h b/nxcompshad/Updater.h index 4bcaa9176..daa26c10b 100644 --- a/nxcompshad/Updater.h +++ b/nxcompshad/Updater.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/VERSION b/nxcompshad/VERSION index 18091983f..1545d9665 100644 --- a/nxcompshad/VERSION +++ b/nxcompshad/VERSION @@ -1 +1 @@ -3.4.0 +3.5.0 diff --git a/nxcompshad/Win.cpp b/nxcompshad/Win.cpp index 3f1e489e2..481cbcac0 100644 --- a/nxcompshad/Win.cpp +++ b/nxcompshad/Win.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/Win.h b/nxcompshad/Win.h index 72566b8f4..fe591ff02 100644 --- a/nxcompshad/Win.h +++ b/nxcompshad/Win.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ diff --git a/nxcompshad/X11.cpp b/nxcompshad/X11.cpp index cb8f55fc5..2d1140f11 100644 --- a/nxcompshad/X11.cpp +++ b/nxcompshad/X11.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ @@ -981,6 +981,7 @@ void Poller::handleKeyboardEvent(Display *display, XEvent *event) Bool isKeyPress = False; Bool isModifier = False; + Bool isShiftComb = False; Bool skip = False; if (event -> type == KeyPress) @@ -1048,19 +1049,26 @@ void Poller::handleKeyboardEvent(Display *display, XEvent *event) (!modeSwitchOn && !level3ShiftOn && !altROn) && !skip) { - keysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, - shadowMinKey, shadowMapWidth, 1); - } + KeySym tempKeysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, + shadowMinKey, shadowMapWidth, 1); - if ((!leftShiftOn && !rightShiftOn) && - (modeSwitchOn || level3ShiftOn || altROn)) + if (tempKeysym == 0) + { + isShiftComb = True; + } + else + { + keysym = tempKeysym; + } + } + else if ((!leftShiftOn && !rightShiftOn) && + (modeSwitchOn || level3ShiftOn || altROn)) { keysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, shadowMinKey, shadowMapWidth, 2); } - - if ((leftShiftOn || rightShiftOn) && - (modeSwitchOn || level3ShiftOn || altROn)) + else if ((leftShiftOn || rightShiftOn) && + (modeSwitchOn || level3ShiftOn || altROn)) { keysym = keymapKeycodeToKeysym(event -> xkey.keycode, shadowKeysyms, shadowMinKey, shadowMapWidth, 3); @@ -1103,7 +1111,7 @@ void Poller::handleKeyboardEvent(Display *display, XEvent *event) * Send fake modifier events. */ - if (!isModifier) + if (!isModifier && isShiftComb == False) { sendFakeModifierEvents(col, ((keysym >> 8) == 0) && (keysym >= XK_A) && (keysym <= XK_Z)); } diff --git a/nxcompshad/X11.h b/nxcompshad/X11.h index d34fd3dba..21275420c 100644 --- a/nxcompshad/X11.h +++ b/nxcompshad/X11.h @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 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 */ -- cgit v1.2.3