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
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 6734762..84d20c1 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -62,11 +62,10 @@
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 @@
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 @@
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 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 @@
{
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)