From 90a93ea844587ae92f53f069eb076993a0c2ab7a Mon Sep 17 00:00:00 2001 From: Adam Tkac Date: Wed, 26 Mar 2008 18:32:20 +0000 Subject: [PATCH] Use SelectionCallback to handle selection changes. They should never be touched directly and they have been converted to linear list instead array. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/1.5-xserver@2451 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/xserver/hw/vnc/vncExtInit.cc | 49 +++++++++++-------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index 6734762a..84d20c14 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -62,11 +62,10 @@ 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,9 +98,6 @@ struct VncInputSelect { VncInputSelect* next; }; -static int nPrevSelections = 0; -static TimeStamp* prevSelectionTimes = 0; - static int vncErrorBase = 0; static int vncEventBase = 0; static char* vncPasswdFile = 0; @@ -144,7 +140,11 @@ void vncExtensionInit() vlog.info("VNC extension running!"); if (!AddCallback(&ClientStateCallback, vncClientStateChange, 0)) { - FatalError("AddCallback failed\n"); + FatalError("Add ClientStateCallback failed\n"); + } + + if (!AddCallback(&SelectionCallback, vncSelectionCallback, 0)) { + FatalError("Add SelectionCallback failed\n"); } try { @@ -212,6 +212,14 @@ static void vncResetProc(ExtensionEntry* extEntry) { } +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 @@ -222,32 +230,9 @@ static void vncBlockHandler(pointer data, OSTimePtr timeout, pointer readmask) { fd_set* fds = (fd_set*)readmask; - for (int scr = 0; scr < screenInfo.numScreens; scr++) { - if (desktop[scr]) { + for (int scr = 0; scr < screenInfo.numScreens; scr++) + if (desktop[scr]) 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) -- 2.39.5