mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 14:29:31 +02:00
Qt: fixed visibility of THintWindow class when virtual desktop is switched or application minimized.issue #24363
git-svn-id: trunk@40995 -
This commit is contained in:
parent
7aabf4415d
commit
efb76fb76b
@ -87,6 +87,7 @@ type
|
||||
FSysColorBrushes: array[0..MAX_SYS_COLORS] of HBrush;
|
||||
|
||||
{$IFDEF HASX11}
|
||||
SavedHintHandlesList: TFPList;
|
||||
FWindowManagerName: String; // Track various incompatibilities between WM. Initialized at WS start.
|
||||
{$ENDIF}
|
||||
|
||||
@ -159,6 +160,15 @@ type
|
||||
procedure RemoveHandle(AHandle: TObject);
|
||||
function IsValidHandle(AHandle: HWND): Boolean;
|
||||
|
||||
{$IFDEF HASX11}
|
||||
// qt hints handles map (needed on X11 only)
|
||||
procedure AddHintHandle(AHandle: TObject);
|
||||
procedure RemoveHintHandle(AHandle: TObject);
|
||||
function IsValidHintHandle(AHandle: TObject): Boolean;
|
||||
procedure HideAllHints;
|
||||
procedure RestoreAllHints;
|
||||
{$ENDIF}
|
||||
|
||||
// application global actions (mainform mainmenu mnemonics Alt+XX)
|
||||
procedure ClearGlobalActions;
|
||||
procedure AddGlobalAction(AnAction: QActionH);
|
||||
|
@ -100,6 +100,7 @@ begin
|
||||
StayOnTopList := nil;
|
||||
FAppActive := False;
|
||||
{$IFDEF HASX11}
|
||||
SavedHintHandlesList := TFPList.Create;
|
||||
FMinimizedByPager := False;
|
||||
FLastMinimizeEvent := 0;
|
||||
if not FIsLibraryInstance and
|
||||
@ -152,6 +153,13 @@ begin
|
||||
SavedHandlesList.Free;
|
||||
SavedHandlesList := nil;
|
||||
end;
|
||||
{$IFDEF HASX11}
|
||||
if SavedHintHandlesList <> nil then
|
||||
begin
|
||||
SavedHintHandlesList.Free;
|
||||
SavedHintHandlesList := nil;
|
||||
end;
|
||||
{$ENDIF}
|
||||
FSocketEventMap.Free;
|
||||
FGlobalActions.Free;
|
||||
|
||||
@ -309,6 +317,7 @@ begin
|
||||
if (Application.MainForm <> nil) and (Application.MainForm.HandleAllocated) then
|
||||
begin
|
||||
{$IFDEF HASX11}
|
||||
HideAllHints;
|
||||
for i := 0 to Screen.CustomFormZOrderCount-1 do
|
||||
begin
|
||||
AForm := Screen.CustomFormsZOrdered[i];
|
||||
@ -353,6 +362,7 @@ begin
|
||||
TQtMainWindow(AForm.Handle).setWindowState(States and not QtWindowMinimized);
|
||||
end;
|
||||
end;
|
||||
RestoreAllHints;
|
||||
{$ELSE}
|
||||
TQtMainWindow(Application.MainForm.Handle).ShowNormal;
|
||||
{$ENDIF}
|
||||
@ -1065,6 +1075,86 @@ begin
|
||||
System.LeaveCriticalsection(CriticalSection);
|
||||
end;
|
||||
|
||||
{$IFDEF HASX11}
|
||||
procedure TQtWidgetSet.AddHintHandle(AHandle: TObject);
|
||||
begin
|
||||
System.EnterCriticalsection(CriticalSection);
|
||||
if SavedHintHandlesList.IndexOf(AHandle) < 0 then
|
||||
SavedHintHandlesList.Add(AHandle);
|
||||
System.LeaveCriticalsection(CriticalSection);
|
||||
end;
|
||||
|
||||
procedure TQtWidgetSet.RemoveHintHandle(AHandle: TObject);
|
||||
var
|
||||
AIndex: Integer;
|
||||
begin
|
||||
System.EnterCriticalsection(CriticalSection);
|
||||
AIndex := SavedHintHandlesList.IndexOf(AHandle);
|
||||
if AIndex >= 0 then
|
||||
SavedHintHandlesList.Delete(AIndex);
|
||||
System.LeaveCriticalsection(CriticalSection);
|
||||
end;
|
||||
|
||||
function TQtWidgetSet.IsValidHintHandle(AHandle: TObject): Boolean;
|
||||
begin
|
||||
if (AHandle = nil) then
|
||||
Exit(False);
|
||||
System.EnterCriticalsection(CriticalSection);
|
||||
Result := SavedHintHandlesList.IndexOf(AHandle) >= 0;
|
||||
System.LeaveCriticalsection(CriticalSection);
|
||||
end;
|
||||
|
||||
procedure TQtWidgetSet.HideAllHints;
|
||||
var
|
||||
i: Integer;
|
||||
AWidget: TQtHintWindow;
|
||||
begin
|
||||
System.EnterCriticalsection(CriticalSection);
|
||||
try
|
||||
if not Assigned(SavedHintHandlesList) then
|
||||
exit;
|
||||
for i := SavedHintHandlesList.Count - 1 downto 0 do
|
||||
begin
|
||||
if IsValidHintHandle(TObject(SavedHintHandlesList.Items[i])) then
|
||||
begin
|
||||
AWidget := TQtHintWindow(SavedHintHandlesList.Items[i]);
|
||||
AWidget.NeedRestoreVisible := AWidget.getVisible;
|
||||
AWidget.Hide;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
System.LeaveCriticalsection(CriticalSection);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQtWidgetSet.RestoreAllHints;
|
||||
var
|
||||
i: Integer;
|
||||
AWidget: TQtHintWindow;
|
||||
begin
|
||||
System.EnterCriticalsection(CriticalSection);
|
||||
try
|
||||
if not Assigned(SavedHintHandlesList) then
|
||||
exit;
|
||||
for i := SavedHintHandlesList.Count - 1 downto 0 do
|
||||
begin
|
||||
if IsValidHintHandle(TObject(SavedHintHandlesList.Items[i])) then
|
||||
begin
|
||||
AWidget := TQtHintWindow(SavedHintHandlesList.Items[i]);
|
||||
if AWidget.NeedRestoreVisible then
|
||||
begin
|
||||
AWidget.NeedRestoreVisible := False;
|
||||
AWidget.Show;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
System.LeaveCriticalsection(CriticalSection);
|
||||
end;
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
procedure TQtWidgetSet.ClearGlobalActions;
|
||||
begin
|
||||
{$IFDEF QT_DEBUG_GLOBALACTIONS}
|
||||
|
@ -175,7 +175,7 @@ type
|
||||
constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); virtual; overload;
|
||||
constructor CreateFrom(const AWinControl: TWinControl; AWidget: QWidgetH); virtual;
|
||||
procedure InitializeWidget; virtual;
|
||||
procedure DeInitializeWidget;
|
||||
procedure DeInitializeWidget; virtual;
|
||||
procedure RecreateWidget;
|
||||
procedure DestroyNotify(AWidget: TQtWidget); virtual;
|
||||
|
||||
@ -642,11 +642,16 @@ type
|
||||
{ TQtHintWindow }
|
||||
|
||||
TQtHintWindow = class(TQtMainWindow)
|
||||
private
|
||||
FNeedRestoreVisible: Boolean;
|
||||
protected
|
||||
function CreateWidget(const AParams: TCreateParams): QWidgetH; override;
|
||||
public
|
||||
procedure InitializeWidget; override;
|
||||
procedure DeInitializeWidget; override;
|
||||
procedure SetDefaultColorRoles; override;
|
||||
procedure setVisible(AVisible: Boolean); override;
|
||||
property NeedRestoreVisible: Boolean read FNeedRestoreVisible write FNeedRestoreVisible;
|
||||
end;
|
||||
|
||||
{ TQtStaticText }
|
||||
@ -6220,11 +6225,14 @@ begin
|
||||
{$IFDEF HASX11}
|
||||
// for X11 we must ask state of each modified window.
|
||||
AState := getWindowState;
|
||||
|
||||
IsMinimizeEvent := AState and QtWindowMinimized <> 0;
|
||||
if IsMinimizeEvent then
|
||||
begin
|
||||
CanSendEvent := IsCurrentDesktop(Widget);
|
||||
QtWidgetSet.FMinimizedByPager := not CanSendEvent;
|
||||
if IsMainForm and QtWidgetSet.FMinimizedByPager then
|
||||
QtWidgetSet.HideAllHints;
|
||||
end;
|
||||
{$ENDIF}
|
||||
if IsMainForm and CanSendEvent then
|
||||
@ -6292,8 +6300,10 @@ begin
|
||||
// pager switch !
|
||||
if (AOldState and QtWindowMinimized <> 0) and
|
||||
QtWidgetSet.FMinimizedByPager then
|
||||
QtWidgetSet.FMinimizedByPager := False
|
||||
else
|
||||
begin
|
||||
QtWidgetSet.FMinimizedByPager := False;
|
||||
QtWidgetSet.RestoreAllHints;
|
||||
end else
|
||||
{$ENDIF}
|
||||
Application.IntfAppRestore;
|
||||
{$ENDIF}
|
||||
@ -15486,6 +15496,7 @@ var
|
||||
Parent: QWidgetH;
|
||||
begin
|
||||
FHasPaint := True;
|
||||
FNeedRestoreVisible := False;
|
||||
if AParams.WndParent <> 0 then
|
||||
Parent := TQtWidget(AParams.WndParent).GetContainerWidget
|
||||
else
|
||||
@ -15495,6 +15506,22 @@ begin
|
||||
MenuBar := nil;
|
||||
end;
|
||||
|
||||
procedure TQtHintWindow.InitializeWidget;
|
||||
begin
|
||||
inherited InitializeWidget;
|
||||
{$IFDEF HASX11}
|
||||
QtWidgetSet.AddHintHandle(Self);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TQtHintWindow.DeInitializeWidget;
|
||||
begin
|
||||
{$IFDEF HASX11}
|
||||
QtWidgetSet.RemoveHintHandle(Self);
|
||||
{$ENDIF}
|
||||
inherited DeInitializeWidget;
|
||||
end;
|
||||
|
||||
procedure TQtHintWindow.SetDefaultColorRoles;
|
||||
begin
|
||||
WidgetColorRole := QPaletteToolTipBase;
|
||||
|
Loading…
Reference in New Issue
Block a user