Gtk2: improved gtk2 performance in case of pointer motions by using GDK_POINTER_MOTION_HINT_MASK.Patch by Henry Vermaak. Fixes issue #14936

git-svn-id: trunk@28107 -
This commit is contained in:
zeljko 2010-11-06 13:10:17 +00:00
parent f0374c12fd
commit cdeb7f8f68
2 changed files with 30 additions and 2 deletions

View File

@ -1217,6 +1217,25 @@ begin
Result:=true;
end;
procedure GTKGetDevicePointer(win: PGdkWindow; dev: PGdkDevice;
x, y: pgdouble; mask: PGdkModifierType);
var
axes: pgdouble;
i: Integer;
begin
axes := g_new(SizeOf(gdouble), dev^.num_axes);
gdk_device_get_state(dev, win, axes, mask);
for i := 0 to dev^.num_axes - 1 do
if (x^ <> 0) and (dev^.axes[i].use = GDK_AXIS_X) then
x^ := axes[i]
else if (y^ <> 0) and (dev^.axes[i].use = GDK_AXIS_Y) then
y^ := axes[i];
g_free(axes);
end;
{-------------------------------------------------------------------------------
GTKMotionNotify
Params: widget: PGTKWidget; event: PGDKEventMotion; data: gPointer
@ -1234,6 +1253,10 @@ var
begin
Result := CallBackDefaultReturn;
if (Event^.is_hint <> 0) and (Event^._type = GDK_MOTION_NOTIFY) then
GTKGetDevicePointer(Event^.window, Event^.device,
@Event^.x, @Event^.y, @Event^.state);
{$IFDEF VerboseMouseBugfix}
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMouseMotion);
DebugLn('[GTKMotionNotify] ',
@ -1285,6 +1308,10 @@ function GTKMotionNotifyAfter(widget:PGTKWidget; event: PGDKEventMotion;
begin
Result := true; // stop event propagation
if (Event^.is_hint <> 0) and (Event^._type = GDK_MOTION_NOTIFY) then
GTKGetDevicePointer(Event^.window, Event^.device,
@Event^.x, @Event^.y, @Event^.state);
{$IFDEF VerboseMouseBugfix}
DebugLn('[GTKMotionNotifyAfter] ',
DbgSName(TControl(Data)));

View File

@ -607,9 +607,10 @@ begin
LM_MOUSEMOVE:
begin
ConnectSenderSignal(gMouse, 'motion-notify-event', @GTKMotionNotify,
GDK_POINTER_MOTION_MASK);
GDK_POINTER_MOTION_HINT_MASK or GDK_POINTER_MOTION_MASK);
ConnectSenderSignalAfter(gMouse, 'motion-notify-event',
@GTKMotionNotifyAfter, GDK_POINTER_MOTION_MASK);
@GTKMotionNotifyAfter,
GDK_POINTER_MOTION_HINT_MASK or GDK_POINTER_MOTION_MASK);
end;
LM_LBUTTONDOWN,