simplifies the gtk 1 and 2 Get/SetMousePos from Andrew Haines

git-svn-id: trunk@7280 -
This commit is contained in:
mattias 2005-06-25 09:46:23 +00:00
parent eb7ec65675
commit 42bb427048

View File

@ -4233,46 +4233,24 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TGtkWidgetSet.GetCursorPos(var lpPoint: TPoint ): Boolean; function TGtkWidgetSet.GetCursorPos(var lpPoint: TPoint ): Boolean;
{$IFDEF GTK2} {$IFDEF unix}
begin
// TODO: GTK2 GetCursorPos
DebugLn('TGtkWidgetSet.GetCursorPos ToDo');
Result:=false;
end;
{$ELSE}
{$IFDEF UNIX}
var var
dpy: PDisplay;
root, child: pointer; root, child: pointer;
winx, winy: Integer; winx, winy: Integer;
xmask: Cardinal; xmask: Cardinal;
TopList, List: PGList; TopList, List: PGList;
begin begin
Result := False; Result := False;
{$IFDEF DebugGDKTraps} {$IFDEF DebugGDKTraps}
BeginGDKErrorTrap; BeginGDKErrorTrap;
{$ENDIF} {$ENDIF}
try try
TopList := gdk_window_get_toplevels; dpy := gdk_display;
List := TopList; XQueryPointer(dpy, RootWindow(dpy, DefaultScreen(dpy)), @root,@child,
while List <> nil do @lpPoint.X,@lpPoint.Y,@winx,@winy,@xmask);
begin Result := True;
if (List^.Data <> nil)
and gdk_window_is_visible(List^.Data)
then begin
XQueryPointer(gdk_window_xdisplay(List^.Data),
gdk_window_xwindow(List^.Data),
@root,@child,@lpPoint.X,@lpPoint.Y,@winx,@winy,@xmask);
Result := True;
Break;
end;
List := g_list_next(List);
end;
if TopList <> nil
then g_list_free(TopList);
finally finally
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF} {$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
end; end;
@ -4283,7 +4261,6 @@ begin
Result := False; Result := False;
end; end;
{$ENDIF unix} {$ENDIF unix}
{$ENDIF gkt2}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: GetDC Function: GetDC
@ -7885,46 +7862,16 @@ function TGtkWidgetSet.SetCursorPos(X, Y: Integer): Boolean;
{$IFDEF UNIX} {$IFDEF UNIX}
var var
dpy: PDisplay; dpy: PDisplay;
TopList, List: PGList;
begin begin
Result := False; Result := False;
{$IFDEF DebugGDKTraps} {$IFDEF DebugGDKTraps}
BeginGDKErrorTrap; BeginGDKErrorTrap;
{$ENDIF} {$ENDIF}
try try
TopList := gdk_window_get_toplevels; dpy := gdk_display;
List := TopList; XWarpPointer(dpy, 0, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, 0, 0, X, Y);
while List <> nil do Result := True;
begin XFlush(dpy);
if (List^.Data <> nil)
and gdk_window_is_visible(List^.Data)
then begin
{$IFDEF GTK2}
//the pascal Gtk2 bindings don't seem to have gdk_window_xdisplay
dpy := XOpenDisplay(nil);
if dpy <> nil then begin
{$ELSE GTK2}
dpy := gdk_window_xdisplay(List^.Data);
{$ENDIF GTK2}
XWarpPointer(dpy,
0,
RootWindow(dpy, DefaultScreen(dpy)),
0, 0, 0, 0,
X,
Y);
{$IFDEF GTK2}
XCloseDisplay(dpy);
end;
{$ENDIF GTK2}
Result := True;
Break;
end;
List := g_list_next(List);
end;
if TopList <> nil
then g_list_free(TopList);
finally finally
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF} {$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
end; end;
@ -9081,6 +9028,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.423 2005/06/25 09:46:23 mattias
simplifies the gtk 1 and 2 Get/SetMousePos from Andrew Haines
Revision 1.422 2005/06/22 17:37:06 mattias Revision 1.422 2005/06/22 17:37:06 mattias
implemented TMouse.SetCursorPos from Andrew implemented TMouse.SetCursorPos from Andrew