mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 02:41:50 +02:00
* mouse events in the fifo doesn't get overriden under heavy load anymore
* fixed getmousevent, see comment in source git-svn-id: trunk@60 -
This commit is contained in:
parent
b9fc96073b
commit
7257f05776
@ -35,27 +35,27 @@ procedure MouseEventHandler(var ir:INPUT_RECORD);
|
|||||||
e : TMouseEvent;
|
e : TMouseEvent;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
EnterCriticalSection(ChangeMouseEvents);
|
EnterCriticalSection(ChangeMouseEvents);
|
||||||
e.x:=ir.Event.MouseEvent.dwMousePosition.x;
|
e.x:=ir.Event.MouseEvent.dwMousePosition.x;
|
||||||
e.y:=ir.Event.MouseEvent.dwMousePosition.y;
|
e.y:=ir.Event.MouseEvent.dwMousePosition.y;
|
||||||
e.buttons:=0;
|
e.buttons:=0;
|
||||||
e.action:=0;
|
e.action:=0;
|
||||||
if (ir.Event.MouseEvent.dwButtonState and FROM_LEFT_1ST_BUTTON_PRESSED<>0) then
|
if (ir.Event.MouseEvent.dwButtonState and FROM_LEFT_1ST_BUTTON_PRESSED<>0) then
|
||||||
e.buttons:=e.buttons or MouseLeftButton;
|
e.buttons:=e.buttons or MouseLeftButton;
|
||||||
if (ir.Event.MouseEvent.dwButtonState and FROM_LEFT_2ND_BUTTON_PRESSED<>0) then
|
if (ir.Event.MouseEvent.dwButtonState and FROM_LEFT_2ND_BUTTON_PRESSED<>0) then
|
||||||
e.buttons:=e.buttons or MouseMiddleButton;
|
e.buttons:=e.buttons or MouseMiddleButton;
|
||||||
if (ir.Event.MouseEvent.dwButtonState and RIGHTMOST_BUTTON_PRESSED<>0) then
|
if (ir.Event.MouseEvent.dwButtonState and RIGHTMOST_BUTTON_PRESSED<>0) then
|
||||||
e.buttons:=e.buttons or MouseRightButton;
|
e.buttons:=e.buttons or MouseRightButton;
|
||||||
|
|
||||||
if (Lasthandlermouseevent.x<>e.x) or (LasthandlerMouseEvent.y<>e.y) then
|
if (Lasthandlermouseevent.x<>e.x) or (LasthandlerMouseEvent.y<>e.y) then
|
||||||
e.Action:=MouseActionMove;
|
e.Action:=MouseActionMove;
|
||||||
if (LastHandlerMouseEvent.Buttons<>e.Buttons) then
|
if (LastHandlerMouseEvent.Buttons<>e.Buttons) then
|
||||||
begin
|
begin
|
||||||
if (LasthandlerMouseEvent.Buttons and e.buttons<>LasthandlerMouseEvent.Buttons) then
|
if (LasthandlerMouseEvent.Buttons and e.buttons<>LasthandlerMouseEvent.Buttons) then
|
||||||
e.Action:=MouseActionUp
|
e.Action:=MouseActionUp
|
||||||
else
|
else
|
||||||
e.Action:=MouseActionDown;
|
e.Action:=MouseActionDown;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -64,27 +64,35 @@ procedure MouseEventHandler(var ir:INPUT_RECORD);
|
|||||||
// previous one. (bug 2312)
|
// previous one. (bug 2312)
|
||||||
//
|
//
|
||||||
|
|
||||||
{ can we compress the events? }
|
{ can we compress the events? }
|
||||||
if (PendingMouseEvents>0) and
|
if (PendingMouseEvents>0) and
|
||||||
(e.buttons=PendingMouseTail^.buttons) and
|
(e.buttons=PendingMouseTail^.buttons) and
|
||||||
(e.action=PendingMouseTail^.action) then
|
(e.action=PendingMouseTail^.action) then
|
||||||
begin
|
begin
|
||||||
PendingMouseTail^.x:=e.x;
|
PendingMouseTail^.x:=e.x;
|
||||||
PendingMouseTail^.y:=e.y;
|
PendingMouseTail^.y:=e.y;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
if e.action<>0 then
|
||||||
|
begin
|
||||||
|
LastHandlermouseEvent:=e;
|
||||||
|
|
||||||
if e.action<>0 then
|
{ what till there is again space in the mouse event queue }
|
||||||
begin
|
while PendingMouseEvents>=MouseEventBufSize do
|
||||||
LastHandlermouseEvent:=e;
|
begin
|
||||||
PutMouseEvent(e);
|
LeaveCriticalSection(ChangeMouseEvents);
|
||||||
end;
|
sleep(0);
|
||||||
// this should be done in PutMouseEvent, now it is PM
|
EnterCriticalSection(ChangeMouseEvents);
|
||||||
// inc(PendingMouseEvents);
|
end;
|
||||||
end;
|
|
||||||
LastMouseEvent:=e;
|
PutMouseEvent(e);
|
||||||
LeaveCriticalSection(ChangeMouseEvents);
|
end;
|
||||||
|
// this should be done in PutMouseEvent, now it is PM
|
||||||
|
// inc(PendingMouseEvents);
|
||||||
|
end;
|
||||||
|
LastMouseEvent:=e;
|
||||||
|
LeaveCriticalSection(ChangeMouseEvents);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SysInitMouse;
|
procedure SysInitMouse;
|
||||||
@ -150,9 +158,14 @@ begin
|
|||||||
EnterCriticalSection(ChangeMouseEvents);
|
EnterCriticalSection(ChangeMouseEvents);
|
||||||
MouseEvent:=PendingMouseHead^;
|
MouseEvent:=PendingMouseHead^;
|
||||||
inc(PendingMouseHead);
|
inc(PendingMouseHead);
|
||||||
if longint(PendingMouseHead)=longint(@PendingMouseEvent)+sizeof(PendingMouseEvent) then
|
if ptrint(PendingMouseHead)=ptrint(@PendingMouseEvent)+sizeof(PendingMouseEvent) then
|
||||||
PendingMouseHead:=@PendingMouseEvent;
|
PendingMouseHead:=@PendingMouseEvent;
|
||||||
dec(PendingMouseEvents);
|
dec(PendingMouseEvents);
|
||||||
|
|
||||||
|
{ LastMouseEvent is already set at the end of the mouse event handler,
|
||||||
|
so this code might compare LastMouseEvent with itself leading to
|
||||||
|
"empty" events (FK)
|
||||||
|
|
||||||
if (LastMouseEvent.x<>MouseEvent.x) or (LastMouseEvent.y<>MouseEvent.y) then
|
if (LastMouseEvent.x<>MouseEvent.x) or (LastMouseEvent.y<>MouseEvent.y) then
|
||||||
MouseEvent.Action:=MouseActionMove;
|
MouseEvent.Action:=MouseActionMove;
|
||||||
if (LastMouseEvent.Buttons<>MouseEvent.Buttons) then
|
if (LastMouseEvent.Buttons<>MouseEvent.Buttons) then
|
||||||
@ -162,8 +175,11 @@ begin
|
|||||||
else
|
else
|
||||||
MouseEvent.Action:=MouseActionDown;
|
MouseEvent.Action:=MouseActionDown;
|
||||||
end;
|
end;
|
||||||
if MouseEvent.action=0 then MousEevent.action:=MouseActionMove; // can sometimes happen due to compression of events.
|
if MouseEvent.action=0 then
|
||||||
|
MousEevent.action:=MouseActionMove; // can sometimes happen due to compression of events.
|
||||||
LastMouseEvent:=MouseEvent;
|
LastMouseEvent:=MouseEvent;
|
||||||
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(ChangeMouseEvents);
|
LeaveCriticalSection(ChangeMouseEvents);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -188,7 +204,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
PendingMouseTail^:=MouseEvent;
|
PendingMouseTail^:=MouseEvent;
|
||||||
inc(PendingMouseTail);
|
inc(PendingMouseTail);
|
||||||
if longint(PendingMouseTail)=longint(@PendingMouseEvent)+sizeof(PendingMouseEvent) then
|
if ptrint(PendingMouseTail)=ptrint(@PendingMouseEvent)+sizeof(PendingMouseEvent) then
|
||||||
PendingMouseTail:=@PendingMouseEvent;
|
PendingMouseTail:=@PendingMouseEvent;
|
||||||
{ why isn't this done here ?
|
{ why isn't this done here ?
|
||||||
so the win32 version do this by hand:}
|
so the win32 version do this by hand:}
|
||||||
|
Loading…
Reference in New Issue
Block a user