mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 23:49:13 +02:00
gtk2 intf: fixed reading gtkwindow position
git-svn-id: trunk@11220 -
This commit is contained in:
parent
4698d08d12
commit
26b03893db
@ -6883,6 +6883,9 @@ procedure SetWindowSizeAndPosition(Window: PGtkWindow;
|
|||||||
AWinControl: TWinControl);
|
AWinControl: TWinControl);
|
||||||
var
|
var
|
||||||
Width, Height: integer;
|
Width, Height: integer;
|
||||||
|
{$IFDEF Gtk2}
|
||||||
|
allocation: TGdkRectangle;
|
||||||
|
{$ENDIF}
|
||||||
//Info: PGtkWindowGeometryInfo;
|
//Info: PGtkWindowGeometryInfo;
|
||||||
begin
|
begin
|
||||||
Width:=AWinControl.Width;
|
Width:=AWinControl.Width;
|
||||||
@ -6902,6 +6905,12 @@ begin
|
|||||||
gtk_window_resize(Window,Width,Height);
|
gtk_window_resize(Window,Width,Height);
|
||||||
// reposition
|
// reposition
|
||||||
gtk_window_move(Window,AWinControl.Left,AWinControl.Top);
|
gtk_window_move(Window,AWinControl.Left,AWinControl.Top);
|
||||||
|
|
||||||
|
// commit size
|
||||||
|
allocation:=PgtkWidget(Window)^.allocation;
|
||||||
|
allocation.width:=Width;
|
||||||
|
allocation.height:=Height;
|
||||||
|
gtk_widget_size_allocate(PgtkWidget(Window),@allocation);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
// resize
|
// resize
|
||||||
if assigned(PGtkWidget(Window)^.Window) then
|
if assigned(PGtkWidget(Window)^.Window) then
|
||||||
@ -6950,15 +6959,20 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if GtkWidgetIsA(aWidget,GTK_TYPE_WINDOW) then begin
|
if GtkWidgetIsA(aWidget,GTK_TYPE_WINDOW) then begin
|
||||||
GdkWindow:=GetControlWindow(aWidget);
|
GdkWindow:=GetControlWindow(aWidget);
|
||||||
if GdkWindow<>nil then begin
|
if (GdkWindow<>nil) and (GTK_WIDGET_MAPPED(aWidget)) then begin
|
||||||
|
// window is mapped = window manager has put the window somewhere
|
||||||
gdk_window_get_root_origin(GdkWindow, @GtkLeft, @GtkTop);
|
gdk_window_get_root_origin(GdkWindow, @GtkLeft, @GtkTop);
|
||||||
Left:=GtkLeft;
|
Left:=GtkLeft;
|
||||||
Top:=GtkTop;
|
Top:=GtkTop;
|
||||||
end else begin
|
end else begin
|
||||||
|
// the gtk has not yet put the window to the final position
|
||||||
|
// => the gtk/gdk position is not reliable
|
||||||
|
// => use the LCL coords
|
||||||
LCLControl:=GetLCLObject(aWidget) as TWinControl;
|
LCLControl:=GetLCLObject(aWidget) as TWinControl;
|
||||||
Left:=LCLControl.Left;
|
Left:=LCLControl.Left;
|
||||||
Top:=LCLControl.Top;
|
Top:=LCLControl.Top;
|
||||||
end;
|
end;
|
||||||
|
//DebugLn(['TGtkWidgetSet.GetWindowRelativePosition ',GetWidgetDebugReport(aWidget),' Left=',Left,' Top=',Top,' GdkWindow=',GdkWindow<>nil]);
|
||||||
end;
|
end;
|
||||||
//DebugLn(['TGtkWidgetSet.GetWindowRelativePosition ',GetWidgetDebugReport(aWidget),' Left=',Left,' Top=',Top]);
|
//DebugLn(['TGtkWidgetSet.GetWindowRelativePosition ',GetWidgetDebugReport(aWidget),' Left=',Left,' Top=',Top]);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user