mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:39:44 +02:00
customdrawnws: Implements critical sections to avoid the flood of debugln; Fixes a bug in non-native form handling, it didnt inform the LCL that the form was getting closed; Removes the wrongly added BackendAppInit
git-svn-id: trunk@34209 -
This commit is contained in:
parent
d0fbd55816
commit
a104532170
@ -169,7 +169,6 @@ type
|
||||
//
|
||||
procedure BackendCreate;
|
||||
procedure BackendDestroy;
|
||||
procedure BackendInit;
|
||||
public
|
||||
// ScreenDC and Image for doing Canvas operations outside the Paint event
|
||||
// and also for text drawing operations
|
||||
|
@ -495,11 +495,6 @@ begin
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TCDWidgetSet.BackendInit;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TWinCEWidgetSet.AppInit
|
||||
Params: None
|
||||
|
@ -75,15 +75,6 @@ procedure TCDWidgetSet.BackendDestroy;
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TCDWidgetSet.BackendInit;
|
||||
begin
|
||||
InputMethod := XOpenIM(FDisplay, nil, nil, nil);
|
||||
if InputMethod <> nil then
|
||||
InputContext := XCreateIC(InputMethod, [XNInputStyle, XIMPreeditNothing or XIMStatusNothing, nil]);
|
||||
|
||||
if InputContext = nil then DebugLn('[TCDWidgetSet.BackendInit] Failed to initialize the Keyboard handling!');
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TWinCEWidgetSet.AppInit
|
||||
Params: None
|
||||
@ -108,7 +99,15 @@ begin
|
||||
if not Assigned(FDisplay) then
|
||||
raise Exception.Create('[TCDWidgetSet.AppInit] XOpenDisplay failed');
|
||||
|
||||
BackendInit();
|
||||
// Keyboard initialization
|
||||
|
||||
InputMethod := XOpenIM(FDisplay, nil, nil, nil);
|
||||
if InputMethod <> nil then
|
||||
InputContext := XCreateIC(InputMethod, [XNInputStyle, XIMPreeditNothing or XIMStatusNothing, nil]);
|
||||
|
||||
if InputContext = nil then DebugLn('[TCDWidgetSet.BackendInit] Failed to initialize the Keyboard handling!');
|
||||
|
||||
//
|
||||
|
||||
//if (not (woX11SkipWMHints in WindowOptions)) and (woWindow in WindowOptions) then
|
||||
//begin
|
||||
|
@ -214,6 +214,9 @@ end;
|
||||
|
||||
procedure ShowForm(ACDForm: TCDNonNativeForm);
|
||||
begin
|
||||
{$IFDEF VerboseCDForms}
|
||||
DebugLn(Format('ShowForm LCLForm=%s:%s', [ACDForm.LCLForm.Name, ACDForm.LCLForm.ClassName]));
|
||||
{$ENDIF}
|
||||
ACDForm.Visible := True;
|
||||
BringFormToFront(ACDForm);
|
||||
lCurrentForm := ACDForm;
|
||||
@ -228,6 +231,8 @@ begin
|
||||
lCurrentForm := FindTopMostVisibleForm();
|
||||
LCLIntf.InvalidateRect(HWND(lCurrentForm), nil, True);
|
||||
end;
|
||||
// Warn the LCL that the form was hidden
|
||||
LCLSendCloseQueryMsg(ACDForm.LCLForm);
|
||||
end;
|
||||
|
||||
procedure BringFormToFront(ACDForm: TCDNonNativeForm);
|
||||
@ -273,8 +278,16 @@ begin
|
||||
for i := lCount-1 downto 0 do
|
||||
begin
|
||||
lForm := TCDNonNativeForm(NonNativeForms.Items[i]);
|
||||
if lForm.Visible then Exit(lForm);
|
||||
if lForm.Visible then
|
||||
begin
|
||||
Result := lForm;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
{$IFDEF VerboseCDForms}
|
||||
DebugLn(Format('FindTopMostVisibleForm FoundIndex=%d FoundForm=%s:%s',
|
||||
[i, Result.LCLForm.Name, Result.LCLForm.ClassName]));
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
// If AForceUpdate=True then it will update even if the width and height remain the same
|
||||
@ -286,7 +299,7 @@ var
|
||||
lRawImage: TRawImage;
|
||||
lPixelSize: Byte;
|
||||
begin
|
||||
{$IFDEF VerboseCDForms}
|
||||
{$IFDEF VerboseCDLazCanvas}
|
||||
DebugLn(Format(':>[UpdateControlLazImageAndCanvas] Input Image: %x Canvas: %x',
|
||||
[PtrInt(AImage), PtrInt(ACanvas)]));
|
||||
{$ENDIF}
|
||||
@ -336,7 +349,7 @@ begin
|
||||
if (ACanvas <> nil) then ACanvas.Free;
|
||||
ACanvas := TLazCanvas.Create(AImage);
|
||||
end;
|
||||
{$IFDEF VerboseCDForms}
|
||||
{$IFDEF VerboseCDLazCanvas}
|
||||
DebugLn(Format(':<[UpdateControlLazImageAndCanvas] Output Image: %x Canvas: %x',
|
||||
[PtrInt(AImage), PtrInt(ACanvas)]));
|
||||
{$ENDIF}
|
||||
|
@ -725,14 +725,14 @@ begin
|
||||
WriteLn('Trace: [WinAPI CreateRectRgn] Result: ', dbghex(Result),
|
||||
' QRegionH: ', dbghex(PtrInt(QtRegion.Widget)));
|
||||
{$endif}
|
||||
end;
|
||||
end;*)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Procedure: DeleteCriticalSection
|
||||
Params: var CritSection: TCriticalSection
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtWidgetSet.DeleteCriticalSection(var CritSection: TCriticalSection);
|
||||
procedure TCDWidgetSet.DeleteCriticalSection(var CritSection: TCriticalSection);
|
||||
var
|
||||
ACritSec: System.PRTLCriticalSection;
|
||||
begin
|
||||
@ -742,7 +742,7 @@ begin
|
||||
CritSection:=0;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
(*{------------------------------------------------------------------------------
|
||||
Function: DeleteDC
|
||||
Params: none
|
||||
Returns: Nothing
|
||||
@ -1530,14 +1530,14 @@ begin
|
||||
{$endif}
|
||||
TQtDeviceContext(PS.HDC).Free;
|
||||
end;
|
||||
end;
|
||||
end;*)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Procedure: EnterCriticalSection
|
||||
Params: var CritSection: TCriticalSection
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtWidgetSet.EnterCriticalSection(var CritSection: TCriticalSection);
|
||||
procedure TCDWidgetSet.EnterCriticalSection(var CritSection: TCriticalSection);
|
||||
var
|
||||
ACritSec: System.PRTLCriticalSection;
|
||||
begin
|
||||
@ -1545,7 +1545,7 @@ begin
|
||||
System.EnterCriticalsection(ACritSec^);
|
||||
end;
|
||||
|
||||
function TQtWidgetSet.EnumDisplayMonitors(hdc: HDC; lprcClip: PRect;
|
||||
(*function TQtWidgetSet.EnumDisplayMonitors(hdc: HDC; lprcClip: PRect;
|
||||
lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool;
|
||||
var
|
||||
i: integer;
|
||||
@ -4535,14 +4535,14 @@ end;
|
||||
function TQtWidgetSet.HideCaret(hWnd: HWND): Boolean;
|
||||
begin
|
||||
Result := (hWnd <> 0) and QtCaret.HideCaret(TQtWidget(hWnd));
|
||||
end;
|
||||
end;*)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Procedure: InitializeCriticalSection
|
||||
Params: var CritSection: TCriticalSection
|
||||
Returns:
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtWidgetSet.InitializeCriticalSection(var CritSection: TCriticalSection);
|
||||
procedure TCDWidgetSet.InitializeCriticalSection(var CritSection: TCriticalSection);
|
||||
var
|
||||
ACritSec: System.PRTLCriticalSection;
|
||||
begin
|
||||
@ -4551,7 +4551,7 @@ begin
|
||||
CritSection:=TCriticalSection(ACritSec);
|
||||
end;
|
||||
|
||||
function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer;
|
||||
(*function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer;
|
||||
var
|
||||
QtDC: TQtDeviceContext absolute dc;
|
||||
IntersectRgn, Rgn: QRegionH;
|
||||
@ -4678,20 +4678,20 @@ begin
|
||||
TQtWidget(aHandle).UpdateRegion(TQtRegion(Rgn).FHandle)
|
||||
else
|
||||
TQtWidget(aHandle).Update;
|
||||
end;
|
||||
end;*)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Procedure: LeaveCriticalSection
|
||||
Params: var CritSection: TCriticalSection
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtWidgetSet.LeaveCriticalSection(var CritSection: TCriticalSection);
|
||||
procedure TCDWidgetSet.LeaveCriticalSection(var CritSection: TCriticalSection);
|
||||
var
|
||||
ACritSec: System.PRTLCriticalSection;
|
||||
begin
|
||||
ACritSec:=System.PRTLCriticalSection(CritSection);
|
||||
System.LeaveCriticalsection(ACritSec^);
|
||||
end;*)
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: LineTo
|
||||
|
@ -67,10 +67,10 @@ function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: strin
|
||||
function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; override;*)
|
||||
function CreatePenIndirect(const LogPen: TLogPen): HPEN; override;
|
||||
(*function CreatePolygonRgn(Points: PPoint; NumPts: Integer; FillMode: integer): HRGN; override;
|
||||
function CreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN; override;
|
||||
function CreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN; override;*)
|
||||
|
||||
procedure DeleteCriticalSection(var CritSection: TCriticalSection); override;
|
||||
function DeleteDC(hDC: HDC): Boolean; override;*)
|
||||
//function DeleteDC(hDC: HDC): Boolean; override;
|
||||
function DeleteObject(GDIObject: HGDIOBJ): Boolean; override;
|
||||
(*function DestroyCaret(Handle : HWND): Boolean; override;
|
||||
function DestroyIcon(Handle: HICON): Boolean; override;
|
||||
@ -83,9 +83,9 @@ function DrawText(DC: HDC; Str: PChar; Count: Integer; var ARect: TRect; Flags:
|
||||
function Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean; override;
|
||||
(*function EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal): Boolean; override;
|
||||
function EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; override;
|
||||
function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;
|
||||
function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;*)
|
||||
procedure EnterCriticalSection(var CritSection: TCriticalSection); override;
|
||||
function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool; override;
|
||||
(*function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool; override;
|
||||
function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
|
||||
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
||||
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
|
||||
@ -156,16 +156,16 @@ function HideCaret(hWnd: HWND): Boolean; override;*)
|
||||
|
||||
function InvalidateRect(aHandle : HWND; Rect : pRect; bErase : Boolean) : Boolean; override;
|
||||
function BackendInvalidateRect(aHandle : HWND; Rect : pRect; bErase : Boolean) : Boolean;
|
||||
(*function InvalidateRgn(aHandle: HWND; Rgn: HRGN; Erase: Boolean): Boolean; override;
|
||||
(*function InvalidateRgn(aHandle: HWND; Rgn: HRGN; Erase: Boolean): Boolean; override;*)
|
||||
procedure InitializeCriticalSection(var CritSection: TCriticalSection); override;
|
||||
function IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; override;
|
||||
(*function IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; override;
|
||||
function IsIconic(Handle: HWND): boolean; override;
|
||||
function IsWindow(handle: HWND): boolean; override;
|
||||
function IsWindowEnabled(Handle: HWND): boolean; override;
|
||||
function IsWindowVisible(Handle: HWND): boolean; override;
|
||||
function IsZoomed(Handle: HWND): boolean; override;
|
||||
function IsZoomed(Handle: HWND): boolean; override;*)
|
||||
|
||||
procedure LeaveCriticalSection(var CritSection: TCriticalSection); override;*)
|
||||
procedure LeaveCriticalSection(var CritSection: TCriticalSection); override;
|
||||
function LineTo(DC: HDC; X, Y: Integer): Boolean; override;
|
||||
//function LPtoDP(DC: HDC; var Points; Count: Integer): BOOL; override;
|
||||
|
||||
|
@ -67,20 +67,23 @@ end;
|
||||
|
||||
class procedure TCDWSCustomForm.ShowHide(const AWinControl: TWinControl);
|
||||
begin
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format(':>[TCDWSCustomForm.ShowHide] AWinControl=%x Handle=%x',
|
||||
[PtrInt(AWinControl), PtrInt(AWinControl.Handle)]));
|
||||
{$endif}
|
||||
if AWinControl.Visible then
|
||||
begin
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format('[TCDWSCustomForm.ShowHide] Visible=True AWinControl=%x Handle=%x',
|
||||
[PtrInt(AWinControl), PtrInt(AWinControl.Handle)]));
|
||||
DebugLn(':<[TCDWSCustomForm.ShowHide] Showed');
|
||||
{$endif}
|
||||
ShowForm(TCDNonNativeForm(AWinControl.Handle));
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format('[TCDWSCustomForm.ShowHide] Visible=False AWinControl=%x', [PtrInt(AWinControl)]));
|
||||
{$endif}
|
||||
HideForm(TCDNonNativeForm(AWinControl.Handle));
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(':<[TCDWSCustomForm.ShowHide] Hided');
|
||||
{$endif}
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -513,11 +513,13 @@ end;
|
||||
class procedure TCDWSCustomForm.EvMousePressed(const AWinControl: TWinControl; AWindowInfo: TX11WindowInfo;
|
||||
var Event: TXButtonEvent);
|
||||
var
|
||||
lForm: TCDForm;
|
||||
MouseButton: TMouseButton;
|
||||
begin
|
||||
lForm := TCDForm(AWinControl.Handle);
|
||||
if XButtonToMouseButton(Event.button, MouseButton) then
|
||||
begin
|
||||
CallbackMouseDown(TCDForm(AWinControl.Handle), Event.x, Event.y, MouseButton, []);
|
||||
CallbackMouseDown(lForm, Event.x, Event.y, MouseButton, []);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -545,22 +547,16 @@ end;
|
||||
class procedure TCDWSCustomForm.EvMouseReleased(const AWinControl: TWinControl; AWindowInfo: TX11WindowInfo;
|
||||
var Event: TXButtonEvent);
|
||||
var
|
||||
lForm: TCDForm;
|
||||
MouseButton: TMouseButton;
|
||||
lTarget: TWinControl;
|
||||
lEventPos: TPoint;
|
||||
begin
|
||||
lTarget := AWindowInfo.LastMouseDownControl;
|
||||
if lTarget = nil then
|
||||
lTarget := FindControlWhichReceivedEvent(TCustomForm(AWinControl), AWindowInfo.Children, Event.x, Event.y);
|
||||
lEventPos := FormPosToControlPos(lTarget, Event.x, Event.y);
|
||||
lForm := TCDForm(AWinControl.Handle);
|
||||
XButtonToMouseButton(Event.button, MouseButton);
|
||||
|
||||
{ Release events are only for mouse buttons, and not mouse wheel moviments }
|
||||
if (Event.button >= 1) and (Event.button <= 3) then
|
||||
begin
|
||||
XButtonToMouseButton(Event.button, MouseButton);
|
||||
|
||||
LCLSendMouseUpMsg(lTarget, lEventPos.x, lEventPos.y, MouseButton, []);
|
||||
LCLSendClickedMsg(lTarget);
|
||||
CallbackMouseUp(lForm, Event.x, Event.y, MouseButton, []);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user