summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpetasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e>2012-07-13 21:39:35 (GMT)
committerpetasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e>2012-07-13 21:39:35 (GMT)
commitf690eda1284f3e483d1eddd74cda9ec89790a4d4 (patch)
tree99a651883e3ccc4c37d8818444cfed20c3a81ba0
parent79e392b7bc87517e9dec028ea2611f45e8c36c3b (diff)
downloadtkdnd-f690eda1284f3e483d1eddd74cda9ec89790a4d4.zip
tkdnd-f690eda1284f3e483d1eddd74cda9ec89790a4d4.tar.gz
tkdnd-f690eda1284f3e483d1eddd74cda9ec89790a4d4.tar.bz2
Unix tests
-rw-r--r--Changelog5
-rw-r--r--library/tkdnd_unix.tcl4
-rw-r--r--unix/tkUnixSelect.c23
3 files changed, 24 insertions, 8 deletions
diff --git a/Changelog b/Changelog
index 4213c7c..6e2ac2e 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,8 @@
+2012-07-14 Petasis George <petasis@iit.demokritos.gr>
+ * unix/tkUnixSelect.c: Tests with Tcl_ThreadAlert(). It helps
+ somewhat, but is not the solution for the problems when getting the
+ selection.
+
2012-06-17 Petasis George <petasis@iit.demokritos.gr>
TkDND 2.5 released.
* win/TkDND_OleDND.cpp: Fixes for type CF_HDROP.
diff --git a/library/tkdnd_unix.tcl b/library/tkdnd_unix.tcl
index fbaef3d..811fa88 100644
--- a/library/tkdnd_unix.tcl
+++ b/library/tkdnd_unix.tcl
@@ -341,6 +341,8 @@ proc xdnd::_GetDroppedData { time } {
} else {
# puts "_selection_get -displayof $_drop_target -selection XdndSelection \
# -type $type -time $time"
+ #after 100 [list focus -force $_drop_target]
+ #after 50 [list raise [winfo toplevel $_drop_target]]
if {![catch {
_selection_get -displayof $_drop_target -selection XdndSelection \
-type $type -time $time
@@ -410,7 +412,7 @@ proc xdnd::_normalise_data { type data } {
} string]} {
set string $data
}
- return [string map {\r\n \n} $string
+ return [string map {\r\n \n} $string]
}
text/uri-list* {
if {[catch {
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index 61f52b3..36cd1ea 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -188,7 +188,7 @@ int TkDND_ClipboardReadIncrementalProperty(Tk_Window tkwin,
}
Tk_DeleteEventHandler(tkwin, PropertyNotify,
TkDND_PropertyNotifyEventProc, &detail2);
- Tcl_DeleteTimerHandler(detail2.timeout);
+ if (detail2.timeout) Tcl_DeleteTimerHandler(detail2.timeout);
return detail2.result;
}; /* TkDND_ClipboardReadIncrementalProperty */
@@ -289,6 +289,7 @@ TkDNDSelGetSelection(
detail.result = -1;
detail.idleTime = 0;
+ XFlush(display);
if (XGetSelectionOwner(display, selection) == None) {
Tcl_SetResult(interp, "no owner for selection", TCL_STATIC);
return TCL_ERROR;
@@ -300,27 +301,28 @@ TkDNDSelGetSelection(
* could even predate the time when the selection was made; if this
* happens, the request will be rejected.
*/
-
- //XFlush(display);
+ Tcl_ThreadAlert(Tcl_GetCurrentThread());
/* Register an event handler for tkwin... */
Tk_CreateEventHandler(sel_tkwin, SelectionNotify,
TkDND_SelectionNotifyEventProc, &detail);
+ XFlush(display);
XConvertSelection(display, selection, target,
selection, Tk_WindowId(sel_tkwin), time);
+ // Tcl_QueueEvent(NULL, TCL_QUEUE_TAIL);
/*
* Enter a loop processing X events until the selection has been retrieved
* and processed. If no response is received within a few seconds, then
* timeout.
*/
- detail.timeout = Tcl_CreateTimerHandler(1000, TkDND_SelTimeoutProc,
+ detail.timeout = Tcl_CreateTimerHandler(70, TkDND_SelTimeoutProc,
&detail);
while (detail.result == -1) {
- //XFlush(display);
Tcl_DoOneEvent(0);
+ XFlush(display);
}
Tk_DeleteEventHandler(sel_tkwin, SelectionNotify,
TkDND_SelectionNotifyEventProc, &detail);
- Tcl_DeleteTimerHandler(detail.timeout);
+ if (detail.timeout) Tcl_DeleteTimerHandler(detail.timeout);
return detail.result;
}
@@ -359,8 +361,13 @@ TkDND_SelTimeoutProc(
if (retrPtr->result != -1) {
return;
}
+ XFlush(Tk_Display(retrPtr->tkwin));
+ if (retrPtr->idleTime > 3){
+ Tcl_ThreadAlert(Tcl_GetCurrentThread());
+ XFlush(Tk_Display(retrPtr->tkwin));
+ }
retrPtr->idleTime++;
- if (retrPtr->idleTime >= 5) {
+ if (retrPtr->idleTime >= 6) {
/*
* Use a careful function to store the error message, because the
* result could already be partially filled in with a partial
@@ -370,6 +377,8 @@ TkDND_SelTimeoutProc(
Tcl_SetResult(retrPtr->interp, "selection owner didn't respond",
TCL_STATIC);
retrPtr->result = TCL_ERROR;
+ retrPtr->timeout = NULL;
+
} else {
retrPtr->timeout = Tcl_CreateTimerHandler(1000, TkDND_SelTimeoutProc,
(ClientData) retrPtr);