1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-04-04 06:13:33 +02:00

Fixed secure textfields not to allow text selection, to avoid

compromising sensitive information by pasting it to a terminal.
This commit is contained in:
dan
2001-03-23 02:26:15 +00:00
parent 1a3fd2f795
commit 7e8bff904f
2 changed files with 31 additions and 25 deletions

View File

@@ -16,6 +16,9 @@ Changes since wmaker 0.64.0:
- better and more robust handling of events (timer, idle, input, X) in
WMMaskEvent(). Also fixed a bug where input and timer events were not
treated for undefined periods of time under some circumstances.
- fixed secure textfields not to allow text selection, to avoid compromising
sensitive information by pasting it to a terminal.
changes since wmaker 0.63.1:
............................

View File

@@ -1256,14 +1256,21 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
break;
}
if (relay) {
WMRelayToNextResponder(W_VIEW(tPtr), event);
return;
}
/* Do not allow text selection in secure text fields */
if (cancelSelection || tPtr->flags.secure) {
lostHandler(tPtr->view, XA_PRIMARY, NULL);
if (!cancelSelection) {
if (tPtr->selection.count) {
tPtr->selection.count = 0;
refresh = 1;
}
tPtr->selection.position = tPtr->cursorPosition;
} else {
if (tPtr->selection.count != tPtr->cursorPosition - tPtr->selection.position) {
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
@@ -1272,15 +1279,6 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
refresh = 1;
}
} else {
lostHandler(tPtr->view, XA_PRIMARY, NULL);
if (tPtr->selection.count) {
tPtr->selection.count = 0;
refresh = 1;
}
tPtr->selection.position = tPtr->cursorPosition;
}
/*printf("(%d,%d)\n", tPtr->selection.position, tPtr->selection.count);*/
@@ -1427,6 +1425,11 @@ handleTextFieldActionEvents(XEvent *event, void *data)
tPtr->cursorPosition =
pointToCursorPosition(tPtr, event->xmotion.x);
/* Do not allow text selection in secure textfields */
if (tPtr->flags.secure) {
tPtr->selection.position = tPtr->cursorPosition;
}
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
if (tPtr->selection.count != 0) {
@@ -1464,7 +1467,6 @@ handleTextFieldActionEvents(XEvent *event, void *data)
textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen);
if (tPtr->flags.enabled && !tPtr->flags.focused) {
WMSetFocusToWidget(tPtr);
} else if (tPtr->flags.focused) {
tPtr->selection.position = tPtr->cursorPosition;
tPtr->selection.count = 0;
@@ -1544,7 +1546,8 @@ handleTextFieldActionEvents(XEvent *event, void *data)
move = 0;
if (event->xbutton.time - lastButtonReleasedEvent
if (!tPtr->flags.secure &&
event->xbutton.time - lastButtonReleasedEvent
<= WINGsConfiguration.doubleClickDelay) {
tPtr->selection.position = 0;
tPtr->selection.count = tPtr->textLen;