diff -up vnc-4_1_2-unixsrc/unix/xorg-x11-server-source/hw/vnc/vncExtInit.cc.selections vnc-4_1_2-unixsrc/unix/xorg-x11-server-source/hw/vnc/vncExtInit.cc --- vnc-4_1_2-unixsrc/unix/xorg-x11-server-source/hw/vnc/vncExtInit.cc.selections 2008-03-10 15:34:24.000000000 +0100 +++ vnc-4_1_2-unixsrc/unix/xorg-x11-server-source/hw/vnc/vncExtInit.cc 2008-03-11 10:55:44.000000000 +0100 @@ -62,11 +62,9 @@ extern "C" { static void SendSelectionChangeEvent(Atom selection); static int ProcVncExtDispatch(ClientPtr client); static int SProcVncExtDispatch(ClientPtr client); + static void vncSelectionCallback(CallbackListPtr *callbacks, pointer data, pointer args); extern char *display; - - extern Selection *CurrentSelections; - extern int NumCurrentSelections; } using namespace rfb; @@ -99,7 +97,6 @@ struct VncInputSelect { VncInputSelect* next; }; -static int nPrevSelections = 0; static TimeStamp* prevSelectionTimes = 0; static int vncErrorBase = 0; @@ -147,6 +144,10 @@ void vncExtensionInit() FatalError("AddCallback failed\n"); } + if (!AddCallback(&SelectionCallback, vncSelectionCallback, 0)) { + FatalError("Add selection callback failed\n"); + } + try { if (!initialised) { rfb::initStdIOLoggers(); @@ -212,6 +213,14 @@ static void vncResetProc(ExtensionEntry* { } +static void vncSelectionCallback(CallbackListPtr *callbacks, pointer data, pointer args) +{ + SelectionInfoRec *info = (SelectionInfoRec *) args; + Selection *selection = info->selection; + + SendSelectionChangeEvent(selection->selection); +} + // // vncBlockHandler - called just before the X server goes into select(). Call // on to the block handler for each desktop. Then check whether any of the @@ -227,27 +236,6 @@ static void vncBlockHandler(pointer data desktop[scr]->blockHandler(fds); } } - - if (nPrevSelections != NumCurrentSelections) { - prevSelectionTimes - = (TimeStamp*)xnfrealloc(prevSelectionTimes, - NumCurrentSelections * sizeof(TimeStamp)); - for (int i = nPrevSelections; i < NumCurrentSelections; i++) { - prevSelectionTimes[i].months = 0; - prevSelectionTimes[i].milliseconds = 0; - } - nPrevSelections = NumCurrentSelections; - } - for (int i = 0; i < NumCurrentSelections; i++) { - if (CurrentSelections[i].lastTimeChanged.months - != prevSelectionTimes[i].months || - CurrentSelections[i].lastTimeChanged.milliseconds - != prevSelectionTimes[i].milliseconds) - { - SendSelectionChangeEvent(CurrentSelections[i].selection); - prevSelectionTimes[i] = CurrentSelections[i].lastTimeChanged; - } - } } static void vncWakeupHandler(pointer data, int nfds, pointer readmask)