mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-10 21:09:32 +01:00
opengl: added support for carbonglcontrol delayed window embedding
git-svn-id: trunk@27165 -
This commit is contained in:
parent
0544c85136
commit
d81c7d3203
@ -121,12 +121,15 @@ var
|
|||||||
r : array [0..3] of Integer;
|
r : array [0..3] of Integer;
|
||||||
bnd : HIRect;
|
bnd : HIRect;
|
||||||
str : MacOSAll.Rect;
|
str : MacOSAll.Rect;
|
||||||
|
win : WindowRef;
|
||||||
begin
|
begin
|
||||||
info:=GetAGLControlInfo(AWidget.Widget);
|
info:=GetAGLControlInfo(AWidget.Widget);
|
||||||
if not Assigned(info) then Exit;
|
if not Assigned(info) then Exit;
|
||||||
|
win:=HIViewGetWindow(AWidget.Widget);
|
||||||
|
if not Assigned(win) then Exit;
|
||||||
|
GetWindowBounds(win, kWindowStructureRgn, str);
|
||||||
HIViewGetBounds(AWidget.Widget, bnd);
|
HIViewGetBounds(AWidget.Widget, bnd);
|
||||||
HIViewConvertPoint(bnd.origin, AWidget.Widget, nil);
|
HIViewConvertPoint(bnd.origin, AWidget.Widget, nil);
|
||||||
GetWindowBounds( HIViewGetWindow(AWidget.Widget), kWindowStructureRgn, str);
|
|
||||||
|
|
||||||
r[0]:=Round(bnd.origin.x);
|
r[0]:=Round(bnd.origin.x);
|
||||||
r[1]:=Round((str.bottom-str.top)- bnd.origin.y-bnd.size.height);
|
r[1]:=Round((str.bottom-str.top)- bnd.origin.y-bnd.size.height);
|
||||||
@ -145,6 +148,18 @@ begin
|
|||||||
ResizeOGLControl(AWidget);
|
ResizeOGLControl(AWidget);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CarbonGLControl_WindowChange(ANextHandler: EventHandlerCallRef;
|
||||||
|
AEvent: EventRef;
|
||||||
|
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||||
|
var
|
||||||
|
win : WindowRef;
|
||||||
|
begin
|
||||||
|
Result:=CallNextEventHandler(ANextHandler, AEvent);
|
||||||
|
if GetEventParameter(AEvent, kEventParamControlCurrentOwningWindow, typeWindowRef,
|
||||||
|
nil, sizeof(win), nil, @win) = noErr then
|
||||||
|
if Assigned(win) then ResizeOGLControl(AWidget);
|
||||||
|
end;
|
||||||
|
|
||||||
function LOpenGLCreateContext(AWinControl: TWinControl;
|
function LOpenGLCreateContext(AWinControl: TWinControl;
|
||||||
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
WSPrivate: TWSPrivateClass; SharedControl: TWinControl;
|
||||||
DoubleBuffered, RGBA: boolean;
|
DoubleBuffered, RGBA: boolean;
|
||||||
@ -191,6 +206,11 @@ begin
|
|||||||
TempSpec:=MakeEventSpec(kEventClassControl, kEventControlBoundsChanged);
|
TempSpec:=MakeEventSpec(kEventClassControl, kEventControlBoundsChanged);
|
||||||
InstallControlEventHandler(Control.Widget, RegisterEventHandler(@CarbonGLControl_Resize),
|
InstallControlEventHandler(Control.Widget, RegisterEventHandler(@CarbonGLControl_Resize),
|
||||||
1, @TempSpec, Control, nil);
|
1, @TempSpec, Control, nil);
|
||||||
|
TempSpec:=MakeEventSpec(kEventClassControl, kEventControlOwningWindowChanged);
|
||||||
|
// The control might be embeded into a window, after the its creation
|
||||||
|
// the example of the situation is give at bug report #17244
|
||||||
|
InstallControlEventHandler(Control.Widget, RegisterEventHandler(@CarbonGLControl_WindowChange),
|
||||||
|
1, @TempSpec, Control, nil);
|
||||||
|
|
||||||
Result:=HWnd(Control);
|
Result:=HWnd(Control);
|
||||||
//debugln(['LOpenGLCreateContext ',dbgs(Result)]);
|
//debugln(['LOpenGLCreateContext ',dbgs(Result)]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user