mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-16 11:59:18 +02:00
customdrawnws: Fixes the x11 list of windows, now OnPaint is called
git-svn-id: trunk@33693 -
This commit is contained in:
parent
4b1759c647
commit
9c171e073c
@ -130,8 +130,7 @@ type
|
||||
FWMDeleteWindow: TAtom; // Atom for "WM_DELETE_WINDOW"
|
||||
FWMHints: TAtom; // Atom for "_MOTIF_WM_HINTS"
|
||||
|
||||
WindowList: TFPList; // list of X.TWindow
|
||||
WindowInfoList: TFPList;// list of TX11WindowInfo
|
||||
WindowList: TFPList;// list of TX11WindowInfo
|
||||
function RectToXRect(const ARect: TRect): TXRectangle;
|
||||
function XRectToRect(const ARect: TXRectangle): TRect;
|
||||
function XButtonToMouseButton(const XButton: cint; var MouseButton: TMouseButton): Boolean;
|
||||
|
@ -71,19 +71,30 @@ function TCDWidgetSet.FindWindowByXID(XWindowID: X.TWindow; out AIndex: Integer)
|
||||
var
|
||||
i: Integer;
|
||||
EndSubSearch: Boolean; { Necessary to quit the recursion }
|
||||
lWindowInfo: TX11WindowInfo;
|
||||
begin
|
||||
{$ifdef VerboseFindX11Window}
|
||||
DbgOut(Format('[TCDWidgetSet.FindWindowByXID] XWindowID=%x', [PtrInt(XWindowID)]));
|
||||
{$endif}
|
||||
AIndex := -1;
|
||||
Result := nil;
|
||||
|
||||
{ Loops througth all windows on the application }
|
||||
for i := 0 to WindowList.Count - 1 do
|
||||
begin
|
||||
Result := TWinControl(WindowList[i]);
|
||||
lWindowInfo := TX11WindowInfo(WindowList[i]);
|
||||
Result := lWindowInfo.LCLControl;
|
||||
AIndex := i;
|
||||
|
||||
if X.TWindow(Result.Handle) = XWindowID then Break;
|
||||
{$ifdef VerboseFindX11Window}
|
||||
DbgOut(Format(' Item %d Window=%x', [i, PtrInt(lWindowInfo.Window)]));
|
||||
{$endif}
|
||||
if lWindowInfo.Window = XWindowID then Break;
|
||||
end;
|
||||
if (Result <> nil) and (X.TWindow(Result.Handle) <> XWindowID) then Result := nil;
|
||||
if (Result <> nil) and (lWindowInfo.Window <> XWindowID) then Result := nil;
|
||||
{$ifdef VerboseFindX11Window}
|
||||
DebugLn('');
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -96,7 +107,6 @@ end;
|
||||
procedure TCDWidgetSet.BackendCreate;
|
||||
begin
|
||||
WindowList := TFPList.Create();
|
||||
WindowInfoList := TFPList.Create();
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -108,7 +118,6 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCDWidgetSet.BackendDestroy;
|
||||
begin
|
||||
WindowInfoList.Free;
|
||||
WindowList.Free;
|
||||
end;
|
||||
|
||||
@ -185,20 +194,21 @@ begin
|
||||
|
||||
if not Assigned(WindowEntry) then
|
||||
begin
|
||||
DebugLn('LCL-CustomDrawn-X11: Received X event "', GetXEventName(XEvent._type), '" for unknown window');
|
||||
DebugLn('LCL-CustomDrawn-X11: Received X event "%s" for unknown window %x',
|
||||
[GetXEventName(XEvent._type), PtrInt(XEvent.XAny.Window)]);
|
||||
Continue;
|
||||
end;
|
||||
|
||||
// WindowEntry.FXEvent := @XEvent;
|
||||
TX11WindowInfo(WindowList.Items[lWindowListIndex]).XEvent := @XEvent;
|
||||
|
||||
case XEvent._type of
|
||||
X.DestroyNotify:
|
||||
begin
|
||||
WindowList.Delete(lWindowListIndex);
|
||||
WindowInfoList.Delete(lWindowListIndex);
|
||||
end;
|
||||
X.KeyPress:
|
||||
begin
|
||||
//TCDWSCustomForm.EvKeyPressed(WindowEntry, TX11WindowInfo(WindowList.Items[lWindowListIndex]));
|
||||
//WindowEntry.EvKeyPressed(XEvent.xkey.keycode);
|
||||
end;
|
||||
X.KeyRelease:
|
||||
@ -271,9 +281,9 @@ begin
|
||||
// WindowEntry.EvShow();
|
||||
end;
|
||||
X.UnmapNotify:
|
||||
begin
|
||||
begin
|
||||
// WindowEntry.EvHide();
|
||||
end;
|
||||
end;
|
||||
X.ReparentNotify:
|
||||
begin
|
||||
// WindowEntry.EvCreate();
|
||||
@ -284,7 +294,7 @@ begin
|
||||
For now we are just ignoring all expose messages where Count <> 0 }
|
||||
if XEvent.xexpose.count = 0 then
|
||||
begin
|
||||
TCDWSCustomForm.EvPaint(WindowEntry, TX11WindowInfo(WindowInfoList.Items[lWindowListIndex]));
|
||||
TCDWSCustomForm.EvPaint(WindowEntry, TX11WindowInfo(WindowList.Items[lWindowListIndex]));
|
||||
end;
|
||||
end;
|
||||
X.ConfigureNotify:
|
||||
|
@ -255,6 +255,10 @@ var
|
||||
mask: longword;
|
||||
AForm: TCustomForm absolute AWinControl;
|
||||
begin
|
||||
{$ifdef VerboseCDWindow}
|
||||
DebugLn(Format(':>[TCDWSCustomForm.CreateHandle] AWinControl=%x Name=%s: %s',
|
||||
[PtrInt(AWinControl), AWinControl.Name, AWinControl.ClassName]));
|
||||
{$endif}
|
||||
Colormap := XDefaultColormap(CDWidgetSet.FDisplay, XDefaultScreen(CDWidgetSet.FDisplay));
|
||||
Attr.Colormap := Colormap;
|
||||
|
||||
@ -344,6 +348,11 @@ begin
|
||||
// for modal windows, this is necessary
|
||||
// if (woModal in WindowOptions) then
|
||||
// XSetTransientForHint(GFApplication.Handle, Handle, Handle);
|
||||
|
||||
{$ifdef VerboseCDWindow}
|
||||
DebugLn(Format(':<[TCDWSCustomForm.CreateHandle] Result=%x',
|
||||
[Result]));
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomForm.SetBorderIcons(const AForm: TCustomForm;
|
||||
@ -360,6 +369,10 @@ end;
|
||||
class procedure TCDWSCustomForm.SetBounds(const AWinControl: TWinControl;
|
||||
const ALeft, ATop, AWidth, AHeight: Integer);
|
||||
begin
|
||||
{$ifdef VerboseCDWindow}
|
||||
DebugLn(Format('[TCDWSCustomForm.SetBounds] AWinControl=%x ALeft=%d ATop=%d AWidth=%d AHeight=%d',
|
||||
[PtrInt(AWinControl), ALeft, ATop, AWidth, AHeight]));
|
||||
{$endif}
|
||||
SetPosition(AWinControl, Point(ALeft, ATop));
|
||||
SetSize(AWinControl, Size(AWidth, AHeight));
|
||||
end;
|
||||
@ -381,16 +394,26 @@ class procedure TCDWSCustomForm.ShowHide(const AWinControl: TWinControl);
|
||||
var
|
||||
lWindow: TWindow;
|
||||
lIndex: Integer;
|
||||
lWindowInfo: TX11WindowInfo;
|
||||
begin
|
||||
lWindow := TWindow(AWinControl.Handle);
|
||||
if AWinControl.Visible then
|
||||
begin
|
||||
{$ifdef VerboseCDWindow}
|
||||
DebugLn(Format('[TCDWSCustomForm.ShowHide] Visible=True AWinControl=%x Handle=%x',
|
||||
[PtrInt(AWinControl), PtrInt(AWinControl.Handle)]));
|
||||
{$endif}
|
||||
XMapRaised(CDWidgetSet.FDisplay, lWindow);
|
||||
CDWidgetset.WindowList.Add(AWinControl);
|
||||
CDWidgetset.WindowInfoList.Add(TX11WindowInfo.Create);
|
||||
lWindowInfo := TX11WindowInfo.Create;
|
||||
lWindowInfo.Window := lWindow;
|
||||
lWindowInfo.LCLControl := AWinControl;
|
||||
CDWidgetset.WindowList.Add(lWindowInfo);
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$ifdef VerboseCDWindow}
|
||||
DebugLn(Format('[TCDWSCustomForm.ShowHide] Visible=False AWinControl=%x', [PtrInt(AWinControl)]));
|
||||
{$endif}
|
||||
// Don't remove it here, wait for a X11 Destroy event
|
||||
end;
|
||||
end;
|
||||
|
@ -8,6 +8,7 @@ uses
|
||||
// rtl+ftl
|
||||
Types, Classes, SysUtils,
|
||||
fpimage, fpcanvas,
|
||||
X, XLib,
|
||||
// Custom Drawn Canvas
|
||||
IntfGraphics, lazcanvas,
|
||||
//
|
||||
@ -16,6 +17,9 @@ uses
|
||||
type
|
||||
TX11WindowInfo = class
|
||||
public
|
||||
Window: X.TWindow;
|
||||
LCLControl: TWinControl;
|
||||
XEvent: PXEvent;
|
||||
Image: TLazIntfImage;
|
||||
Canvas: TLazCanvas;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user