mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 05:18:00 +02:00
LCL: implemented Application.TaskBarBehavior, bug #13537
git-svn-id: trunk@24682 -
This commit is contained in:
parent
240161aeb1
commit
708e6de6d9
10
lcl/forms.pp
10
lcl/forms.pp
@ -491,6 +491,7 @@ type
|
||||
const Handler: TMethod);
|
||||
function FindDefaultForActiveControl: TWinControl;
|
||||
procedure UpdateMenu;
|
||||
procedure UpdateShowInTaskBar;
|
||||
protected
|
||||
FActionLists: TList; // keep this TList for Delphi compatibility
|
||||
FFormBorderStyle: TFormBorderStyle;
|
||||
@ -1140,6 +1141,12 @@ type
|
||||
sbgSystem // show them depending on OS
|
||||
);
|
||||
|
||||
TTaskBarBehavior = (
|
||||
tbDefault, // widgetset dependent
|
||||
tbMultiButton, // show buttons for Forms with ShowTaskBar = stDefault
|
||||
tbSingleButton // hide buttons for Forms with ShowTaskBar = stDefault
|
||||
);
|
||||
|
||||
{ TApplication }
|
||||
|
||||
TApplication = class(TCustomApplication)
|
||||
@ -1207,6 +1214,7 @@ type
|
||||
FLastMouseControlValid: Boolean;
|
||||
FBidiMode: TBiDiMode;
|
||||
FRestoreStayOnTop: TList;
|
||||
FTaskBarBehavior: TTaskBarBehavior;
|
||||
procedure DoOnIdleEnd;
|
||||
function GetActive: boolean;
|
||||
function GetCurrentHelpFile: string;
|
||||
@ -1220,6 +1228,7 @@ type
|
||||
procedure SetNavigation(const AValue: TApplicationNavigationOptions);
|
||||
procedure SetShowButtonGlyphs(const AValue: TApplicationShowGlyphs);
|
||||
procedure SetShowMenuGlyphs(const AValue: TApplicationShowGlyphs);
|
||||
procedure SetTaskBarBehavior(const AValue: TTaskBarBehavior);
|
||||
procedure UpdateMouseControl(NewMouseControl: TControl);
|
||||
procedure UpdateMouseHint(CurrentControl: TControl);
|
||||
procedure SetCaptureExceptions(const AValue: boolean);
|
||||
@ -1390,6 +1399,7 @@ type
|
||||
property MainForm: TForm read FMainForm;
|
||||
property ModalLevel: Integer read FModalLevel;
|
||||
property MouseControl: TControl read FMouseControl;
|
||||
property TaskBarBehavior: TTaskBarBehavior read FTaskBarBehavior write SetTaskBarBehavior;
|
||||
property OnActionExecute: TActionEvent read FOnActionExecute write FOnActionExecute;
|
||||
property OnActionUpdate: TActionEvent read FOnActionUpdate write FOnActionUpdate;
|
||||
property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
|
||||
|
@ -526,6 +526,21 @@ begin
|
||||
NotifyCustomForms(CM_APPSHOWMENUGLYPHCHANGED);
|
||||
end;
|
||||
|
||||
procedure TApplication.SetTaskBarBehavior(const AValue: TTaskBarBehavior);
|
||||
var
|
||||
i: Integer;
|
||||
FormToUpdate: TCustomForm;
|
||||
begin
|
||||
if FTaskBarBehavior=AValue then exit;
|
||||
FTaskBarBehavior:=AValue;
|
||||
for i := 0 to Screen.CustomFormCount-1 do
|
||||
begin
|
||||
FormToUpdate := Screen.CustomForms[i];
|
||||
if FormToUpdate.ShowInTaskBar = stDefault then
|
||||
FormToUpdate.UpdateShowInTaskBar;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TApplication.UpdateMouseControl(NewMouseControl: TControl);
|
||||
|
||||
@ -903,9 +918,17 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TApplication.UpdateVisible;
|
||||
|
||||
function AppUseSingleButton: Boolean;
|
||||
begin
|
||||
Result := (TaskBarBehavior = tbSingleButton)
|
||||
or ((TaskBarBehavior = tbDefault)
|
||||
and (WidgetSet.GetLCLCapability(lcNeedMininimizeAppWithMainForm) = LCL_CAPABILITY_YES));
|
||||
end;
|
||||
|
||||
function UseAppTaskbarItem(AForm: TCustomForm): Boolean; inline;
|
||||
begin
|
||||
Result := (AForm = MainForm) or (AForm.ShowInTaskBar in [stNever, stDefault]);
|
||||
Result := (AForm = MainForm) or (AForm.ShowInTaskBar = stNever)
|
||||
or ((AForm.ShowInTaskBar = stDefault) and AppUseSingleButton);
|
||||
end;
|
||||
|
||||
function HasVisibleForms: Boolean;
|
||||
|
@ -490,6 +490,15 @@ begin
|
||||
|
||||
Activate;
|
||||
if Application <> nil then Application.Activate;
|
||||
// The button reappears in some situations (e.g. when the window gets the
|
||||
//"urgency" flag) so we hide it again here.
|
||||
// This is the most important place to invoke UpdateShowInTaskBar, since
|
||||
//invoking it anywhere else seeems basically useless/frequently reversed.
|
||||
if (ShowInTaskBar = stNever) or ((ShowInTaskBar = stDefault)
|
||||
and (Application.TaskBarBehavior = tbSingleButton)) then
|
||||
begin
|
||||
UpdateShowInTaskBar;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -756,6 +765,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomForm.UpdateShowInTaskBar;
|
||||
var
|
||||
Value: TShowInTaskBar;
|
||||
begin
|
||||
if (Application.MainForm = Self) or (not HandleAllocated) then Exit;
|
||||
Value := ShowInTaskBar;
|
||||
if (Value = stDefault) or (csDesigning in ComponentState) then
|
||||
case Application.TaskBarBehavior of
|
||||
tbSingleButton: Value := stNever;
|
||||
tbMultiButton: Value := stAlways;
|
||||
else // nothing
|
||||
end;
|
||||
TWSCustomFormClass(WidgetSetClass).SetShowInTaskbar(Self, Value);
|
||||
end;
|
||||
|
||||
class procedure TCustomForm.WSRegisterClass;
|
||||
begin
|
||||
inherited WSRegisterClass;
|
||||
@ -1758,8 +1782,7 @@ procedure TCustomForm.SetShowInTaskbar(Value: TShowInTaskbar);
|
||||
begin
|
||||
if Value = FShowInTaskbar then exit;
|
||||
FShowInTaskbar := Value;
|
||||
if not (csDesigning in ComponentState) and HandleAllocated then
|
||||
TWSCustomFormClass(WidgetSetClass).SetShowInTaskbar(Self, Value);
|
||||
UpdateShowInTaskBar;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -2295,6 +2318,7 @@ begin
|
||||
|
||||
Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded');
|
||||
UpdateMenu;
|
||||
UpdateShowInTaskBar;
|
||||
|
||||
{$IFDEF OldAutoSize}
|
||||
// activate focus if visible
|
||||
|
@ -773,6 +773,13 @@ begin
|
||||
Enable := false;}
|
||||
|
||||
//debugln('SetGtkWindowShowInTaskbar ',DbgSName(AForm),' ',dbgs(Enable));
|
||||
// The button reappears in some (still unknown) situations, but has the
|
||||
//'skip-taskbar-hint' property still set to True, so invoking the function
|
||||
//doesn't have an effect. Resetting the property makes it work.
|
||||
{$IFNDEF GTK1}
|
||||
if (not Enable) and gtk_window_get_skip_taskbar_hint(PGtkWindow(Widget)) then
|
||||
gtk_window_set_skip_taskbar_hint(PGtkWindow(Widget), False);
|
||||
{$ENDIF}
|
||||
SetGtkWindowShowInTaskbar(PGtkWindow(Widget), Enable);
|
||||
end;
|
||||
|
||||
|
@ -168,6 +168,10 @@ begin
|
||||
// create a floating form
|
||||
P := gtk_window_new(WindowType);
|
||||
|
||||
// This is done with the expectation to avoid the button blinking for forms
|
||||
//that hide it, but currently it doesn't seem to make a difference.
|
||||
gtk_window_set_skip_taskbar_hint(P, True);
|
||||
|
||||
if (ABorderStyle = bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) then
|
||||
gtk_window_set_decorated(PGtkWindow(P), False);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user