Explorar o código

* mouse works again

peter %!s(int64=21) %!d(string=hai) anos
pai
achega
dc5a88c813
Modificáronse 2 ficheiros con 83 adicións e 74 borrados
  1. 5 2
      rtl/unix/gpm.pp
  2. 78 72
      rtl/unix/mouse.pp

+ 5 - 2
rtl/unix/gpm.pp

@@ -637,7 +637,7 @@ var count:longint;
 
 begin
   gpm_getevent:=0;
-  if not gpm_flag then
+  if gpm_fd=-1 then
     exit;
 
   count:=fpread(gpm_fd,event,sizeof(Tgpm_event));
@@ -954,7 +954,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.12  2004-11-03 16:51:05  peter
+  Revision 1.13  2004-11-06 20:06:19  peter
+    * mouse works again
+
+  Revision 1.12  2004/11/03 16:51:05  peter
     * fixed valgrind issues
 
   Revision 1.11  2004/11/02 09:37:35  peter

+ 78 - 72
rtl/unix/mouse.pp

@@ -189,7 +189,6 @@ end;
 function SysDetectMouse:byte;
 {$ifndef NOGPM}
 var
-  x : longint;
   connect : TGPMConnect;
 {$endif ndef NOGPM}
 begin
@@ -219,6 +218,69 @@ begin
 end;
 
 
+procedure SysGetMouseEvent(var MouseEvent: TMouseEvent);
+{$ifndef NOGPM}
+var
+  e : TGPMEvent;
+{$endif ndef NOGPM}
+begin
+  fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
+  if gpm_fs<0 then
+   exit;
+{$ifndef NOGPM}
+  Gpm_GetEvent(e);
+  GPMEvent2MouseEvent(e,MouseEvent);
+  SysLastMouseEvent:=MouseEvent;
+{ update mouse cursor }
+  if PrintMouseCur then
+   PlaceMouseCur(MouseEvent.y*ScreenWidth+MouseEvent.x);
+{$endif ndef NOGPM}
+end;
+
+
+
+function SysPollMouseEvent(var MouseEvent: TMouseEvent):boolean;
+{$ifndef NOGPM}
+var
+  e : TGPMEvent;
+  fds : tFDSet;
+{$endif ndef NOGPM}
+begin
+  fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
+{$ifndef NOGPM}
+  if gpm_fs<0 then
+   exit(false);
+  if gpm_fs>0 then
+    begin
+      fpFD_ZERO(fds);
+      fpFD_SET(gpm_fs,fds);
+    end;
+  if (fpSelect(gpm_fs+1,@fds,nil,nil,1)>0) then
+   begin
+     FillChar(e,SizeOf(e),#0);
+     { Gpm_snapshot does not work here PM }
+     Gpm_GetEvent(e);
+     GPMEvent2MouseEvent(e,MouseEvent);
+     SysLastMouseEvent:=MouseEvent;
+     if (MouseEvent.Action<>0) then
+       begin
+         { As we now use Gpm_GetEvent, we need to put in
+           in the MouseEvent queue PM }
+         PutMouseEvent(MouseEvent);
+         SysPollMouseEvent:=true;
+         { update mouse cursor is also required here
+           as next call will read MouseEvent from queue }
+         if PrintMouseCur then
+           PlaceMouseCur(MouseEvent.y*ScreenWidth+MouseEvent.x);
+       end
+     else
+       SysPollMouseEvent:=false;
+   end
+  else
+{$endif NOGPM}
+   SysPollMouseEvent:=false;
+end;
+
 function SysGetMouseX:word;
 {$ifndef NOGPM}
 var
@@ -230,6 +292,8 @@ begin
 {$ifndef NOGPM}
   if PollMouseEvent(ME) then
    begin
+     { Remove mouse event, we are only interrested in
+       the X,Y so all other events can be thrown away }
      GetMouseEvent(ME);
      SysGetMouseX:=ME.X
    end
@@ -252,6 +316,8 @@ begin
 {$ifndef NOGPM}
   if PollMouseEvent(ME) then
    begin
+     { Remove mouse event, we are only interrested in
+       the X,Y so all other events can be thrown away }
      GetMouseEvent(ME);
      SysGetMouseY:=ME.Y
    end
@@ -305,83 +371,20 @@ begin
    exit(0);
 {$ifndef NOGPM}
   if PollMouseEvent(ME) then
-    begin
-      // why should we remove that event ?? PM
-      // GetMouseEvent(ME);
-      SysGetMouseButtons:=ME.buttons
-    end
+   begin
+     { Remove mouse event, we are only interrested in
+       the buttons so all other events can be thrown away }
+     GetMouseEvent(ME);
+     SysGetMouseButtons:=ME.Buttons;
+   end
   else
     begin
-      SysGetMouseButtons:=SysLastMouseEvent.Buttons;
+      SysGetMouseButtons:=SysLastMouseEvent.buttons;
     end;
 {$endif ndef NOGPM}
 end;
 
 
-procedure SysGetMouseEvent(var MouseEvent: TMouseEvent);
-{$ifndef NOGPM}
-var
-  e : TGPMEvent;
-{$endif ndef NOGPM}
-begin
-  fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
-  if gpm_fs<0 then
-   exit;
-{$ifndef NOGPM}
-  Gpm_GetEvent(e);
-  GPMEvent2MouseEvent(e,MouseEvent);
-  SysLastMouseEvent:=MouseEvent;
-{ update mouse cursor }
-  if PrintMouseCur then
-   PlaceMouseCur(MouseEvent.y*ScreenWidth+MouseEvent.x);
-{$endif ndef NOGPM}
-end;
-
-
-
-function SysPollMouseEvent(var MouseEvent: TMouseEvent):boolean;
-{$ifndef NOGPM}
-var
-  e : TGPMEvent;
-  fds : tFDSet;
-{$endif ndef NOGPM}
-begin
-  fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
-{$ifndef NOGPM}
-  if gpm_fs<0 then
-   exit(false);
-  if gpm_fs>0 then
-    begin
-      fpFD_ZERO(fds);
-      fpFD_SET(gpm_fs,fds);
-    end;
-  if (fpSelect(gpm_fs+1,@fds,nil,nil,1)>0) then
-   begin
-     FillChar(e,SizeOf(e),#0);
-     { Gpm_snapshot does not work here PM }
-     Gpm_GetEvent(e);
-     GPMEvent2MouseEvent(e,MouseEvent);
-     SysLastMouseEvent:=MouseEvent;
-     if (MouseEvent.Action<>0) then
-       begin
-         { As we now use Gpm_GetEvent, we need to put in
-           in the MouseEvent queue PM }
-         PutMouseEvent(MouseEvent);
-         SysPollMouseEvent:=true;
-         { update mouse cursor is also required here
-           as next call will read MouseEvent from queue }
-         if PrintMouseCur then
-           PlaceMouseCur(MouseEvent.y*ScreenWidth+MouseEvent.x);
-       end
-     else
-       SysPollMouseEvent:=false;
-   end
-  else
-{$endif NOGPM}
-   SysPollMouseEvent:=false;
-end;
-
-
 Const
   SysMouseDriver : TMouseDriver = (
     UseDefaultQueue : true;
@@ -426,7 +429,10 @@ end.
 
 {
   $Log$
-  Revision 1.13  2004-11-03 16:51:05  peter
+  Revision 1.14  2004-11-06 20:06:19  peter
+    * mouse works again
+
+  Revision 1.13  2004/11/03 16:51:05  peter
     * fixed valgrind issues
 
   Revision 1.12  2003/10/24 18:09:56  marco