diff --git a/lcl/interfaces/gtk/gtkcallback.inc b/lcl/interfaces/gtk/gtkcallback.inc index be2b378488..94460b252f 100644 --- a/lcl/interfaces/gtk/gtkcallback.inc +++ b/lcl/interfaces/gtk/gtkcallback.inc @@ -28,6 +28,10 @@ {$ENDIF} function DoDeliverPaintMessage(const Target: TObject; var PaintMsg: TLMPaint): PtrInt; +{$ifdef gtk2} +var + WidgetInfo: PWidgetInfo; +{$endif} begin { erase backgound of custom controls @@ -46,6 +50,14 @@ begin end; Result := DeliverMessage(Target, PaintMsg); + + {$ifdef gtk2} + if (TObject(Target) is TCustomControl) then begin + WidgetInfo := GetWidgetInfo(PGtkWidget(TCustomControl(Target).Handle), False); + if WidgetInfo <> nil then + WidgetInfo^.UpdateRect := Rect(0,0,0,0); + end; + {$endif} end; function DeliverPaintMessage(const Target: Pointer; var TheMessage): GBoolean; diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index 6102b61c50..b0d304f5f2 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -6842,6 +6842,10 @@ var gdkRect : TGDKRectangle; Widget, PaintWidget: PGtkWidget; LCLObject: TObject; + {$IfDef GTK2} + WidgetInfo: PWidgetInfo; + {$ENDIF} + r: TRect; begin // DebugLn(format('Rect = %d,%d,%d,%d',[rect^.left,rect^.top,rect^.Right,rect^.Bottom])); Widget:=PGtkWidget(aHandle); @@ -6870,18 +6874,16 @@ begin if PaintWidget=nil then PaintWidget:=Widget; if Rect = nil then begin - gdkRect.X := 0;//PaintWidget^.Allocation.X; - gdkRect.Y := 0;//PaintWidget^.Allocation.Y; - gdkRect.Width:=PaintWidget^.Allocation.Width; - gdkRect.Height:=PaintWidget^.Allocation.Height; - - end else begin - gdkRect.X := Rect^.Left; - gdkRect.Y := Rect^.Top; - gdkRect.Width := (Rect^.Right - Rect^.Left); - gdkRect.Height := (Rect^.Bottom - Rect^.Top); - end; - + Rect := @r; + Rect^.Left := 0;//PaintWidget^.Allocation.X; + Rect^.Top := 0;//PaintWidget^.Allocation.Y; + Rect^.Right := PaintWidget^.Allocation.Width; + Rect^.Bottom := PaintWidget^.Allocation.Height; + end; + gdkRect.X := Rect^.Left; + gdkRect.Y := Rect^.Top; + gdkRect.Width := (Rect^.Right - Rect^.Left); + gdkRect.Height := (Rect^.Bottom - Rect^.Top); {$IfDef GTK2} if (PaintWidget<>nil) and GTK_WIDGET_NO_WINDOW(PaintWidget) @@ -6891,6 +6893,10 @@ begin Inc(gdkRect.X, PaintWidget^.Allocation.x); Inc(gdkRect.Y, PaintWidget^.Allocation.y); end; + + WidgetInfo := GetWidgetInfo(Widget, False); // True ?? + if WidgetInfo <> nil then + UnionRect(WidgetInfo^.UpdateRect, WidgetInfo^.UpdateRect, Rect^); {$EndIf} if bErase then diff --git a/lcl/interfaces/gtk2/gtk2extrah.inc b/lcl/interfaces/gtk2/gtk2extrah.inc index 5b8b23482f..87e4b4793d 100644 --- a/lcl/interfaces/gtk2/gtk2extrah.inc +++ b/lcl/interfaces/gtk2/gtk2extrah.inc @@ -176,6 +176,7 @@ function gdk_pixbuf_flip(src: PGdkPixbuf; horizontal: gboolean): PGdkPixbuf; cde // gdk 2.8 procedure gdk_display_warp_pointer(display: PGdkDisplay; screen: PGdkScreen; x, y: gint); cdecl; external gdklib; function gdk_screen_get_rgba_colormap(screen: PGdkScreen): PGdkColormap; cdecl; external gdklib; +procedure gdk_window_move_region(window: PGdkWindow ; region: PGdkRegion; dx, dy: gint);cdecl; external gdklib; type TGtkPackDirection = longint; diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index 64d4634980..c2fed32cb4 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -599,8 +599,12 @@ function TGtk2WidgetSet.ScrollWindowEx(hWnd: HWND; dx, dy: Integer; prcScroll, p var Widget: PGtkWidget; Window: PGdkWindow; + {$ifdef GTK_2_8} Region: PGdkRegion; - Rect: TGdkRectangle; + Rect1: TGdkRectangle; + Rect2: TRect; + WidgetInfo: PWidgetInfo; + {$ENDIF} begin Result := False; {$IFDEF DisableGtk2ScrollWindow} @@ -608,10 +612,35 @@ begin {$ENDIF} // prcScroll, prcClip are not supported under gdk yet if (hWnd = 0) or (prcScroll <> nil) or (prcClip <> nil) then Exit; + Widget := pgtkwidget(hWnd); Widget := GetFixedWidget(Widget); Window:=GetControlWindow(Widget); + {$ifdef GTK_2_8} + Rect1.X := 0;//Widget^.Allocation.X; + Rect1.Y := 0; //Widget^.Allocation.Y; + Rect1.width := Widget^.Allocation.Width; + Rect1.height := Widget^.Allocation.Height; + + WidgetInfo := GetWidgetInfo(Widget, False); + if WidgetInfo <> nil then begin + if (dy < 0) and (WidgetInfo^.UpdateRect.Bottom > 0) then begin + Rect1.Height := Min(Rect1.height, WidgetInfo^.UpdateRect.Top); + Rect2 := Rect(0, Rect1.height, Rect1.width, Widget^.Allocation.Height); + InvalidateRect(hWnd, @Rect2, false); + end; + if dy > 0 then begin + Rect1.y := Max(Rect1.y, WidgetInfo^.UpdateRect.Bottom); + Rect2 := Rect(0, 0, Rect1.width, Rect1.y); + InvalidateRect(hWnd, @Rect2, false); + end; + end; + + Region := gdk_region_rectangle(@Rect1); + gdk_window_move_region(Window, Region, dx, dy); + {$ELSE} gdk_window_scroll(Window, dx, dy); + {$ENDIF} Result := true; end;