Fixed an annoying problem with the scroll bar repeat feature. If you clicked
a button or within the bar background within the timeout for the repeat-thread, the thread would exit and there would be no repeating. I think there is still a race condition somewhere since I managed to see it stall once again, probably because it locks the looper twice in the loop... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33666 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -58,6 +58,8 @@ typedef enum {
|
|||||||
#define NOARROW -1
|
#define NOARROW -1
|
||||||
|
|
||||||
|
|
||||||
|
static const bigtime_t kRepeatDelay = 300000;
|
||||||
|
|
||||||
// Because the R5 version kept a lot of data on server-side, we need to kludge
|
// Because the R5 version kept a lot of data on server-side, we need to kludge
|
||||||
// our way into binary compatibility
|
// our way into binary compatibility
|
||||||
class BScrollBar::Private {
|
class BScrollBar::Private {
|
||||||
@@ -68,6 +70,7 @@ public:
|
|||||||
fEnabled(true),
|
fEnabled(true),
|
||||||
fRepeaterThread(-1),
|
fRepeaterThread(-1),
|
||||||
fExitRepeater(false),
|
fExitRepeater(false),
|
||||||
|
fRepeaterDelay(0),
|
||||||
fThumbFrame(0.0, 0.0, -1.0, -1.0),
|
fThumbFrame(0.0, 0.0, -1.0, -1.0),
|
||||||
fDoRepeat(false),
|
fDoRepeat(false),
|
||||||
fClickOffset(0.0, 0.0),
|
fClickOffset(0.0, 0.0),
|
||||||
@@ -114,6 +117,7 @@ public:
|
|||||||
|
|
||||||
thread_id fRepeaterThread;
|
thread_id fRepeaterThread;
|
||||||
volatile bool fExitRepeater;
|
volatile bool fExitRepeater;
|
||||||
|
bigtime_t fRepeaterDelay;
|
||||||
|
|
||||||
BRect fThumbFrame;
|
BRect fThumbFrame;
|
||||||
volatile bool fDoRepeat;
|
volatile bool fDoRepeat;
|
||||||
@@ -144,8 +148,13 @@ BScrollBar::Private::button_repeater_thread(void *data)
|
|||||||
int32
|
int32
|
||||||
BScrollBar::Private::ButtonRepeaterThread()
|
BScrollBar::Private::ButtonRepeaterThread()
|
||||||
{
|
{
|
||||||
// wait a bit before auto scrolling starts
|
// Wait a bit before auto scrolling starts. As long as the user releases
|
||||||
snooze(500000);
|
// and presses the button again while the repeat delay has not yet
|
||||||
|
// triggered, the value is pushed into the future, so we need to loop such
|
||||||
|
// that repeating starts at exactly the correct delay after the last
|
||||||
|
// button press.
|
||||||
|
while (fRepeaterDelay > system_time() && !fExitRepeater)
|
||||||
|
snooze_until(fRepeaterDelay, B_SYSTEM_TIMEBASE);
|
||||||
|
|
||||||
// repeat loop
|
// repeat loop
|
||||||
while (!fExitRepeater) {
|
while (!fExitRepeater) {
|
||||||
@@ -713,12 +722,17 @@ BScrollBar::MouseDown(BPoint where)
|
|||||||
// launch the repeat thread
|
// launch the repeat thread
|
||||||
if (fPrivateData->fRepeaterThread == -1) {
|
if (fPrivateData->fRepeaterThread == -1) {
|
||||||
fPrivateData->fExitRepeater = false;
|
fPrivateData->fExitRepeater = false;
|
||||||
|
fPrivateData->fRepeaterDelay = system_time() + kRepeatDelay;
|
||||||
fPrivateData->fThumbInc = scrollValue;
|
fPrivateData->fThumbInc = scrollValue;
|
||||||
fPrivateData->fDoRepeat = true;
|
fPrivateData->fDoRepeat = true;
|
||||||
fPrivateData->fRepeaterThread
|
fPrivateData->fRepeaterThread
|
||||||
= spawn_thread(fPrivateData->button_repeater_thread,
|
= spawn_thread(fPrivateData->button_repeater_thread,
|
||||||
"scroll repeater", B_NORMAL_PRIORITY, fPrivateData);
|
"scroll repeater", B_NORMAL_PRIORITY, fPrivateData);
|
||||||
resume_thread(fPrivateData->fRepeaterThread);
|
resume_thread(fPrivateData->fRepeaterThread);
|
||||||
|
} else {
|
||||||
|
fPrivateData->fExitRepeater = false;
|
||||||
|
fPrivateData->fRepeaterDelay = system_time() + kRepeatDelay;
|
||||||
|
fPrivateData->fDoRepeat = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user