mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 12:59:12 +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);
|
const Handler: TMethod);
|
||||||
function FindDefaultForActiveControl: TWinControl;
|
function FindDefaultForActiveControl: TWinControl;
|
||||||
procedure UpdateMenu;
|
procedure UpdateMenu;
|
||||||
|
procedure UpdateShowInTaskBar;
|
||||||
protected
|
protected
|
||||||
FActionLists: TList; // keep this TList for Delphi compatibility
|
FActionLists: TList; // keep this TList for Delphi compatibility
|
||||||
FFormBorderStyle: TFormBorderStyle;
|
FFormBorderStyle: TFormBorderStyle;
|
||||||
@ -1140,6 +1141,12 @@ type
|
|||||||
sbgSystem // show them depending on OS
|
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 }
|
||||||
|
|
||||||
TApplication = class(TCustomApplication)
|
TApplication = class(TCustomApplication)
|
||||||
@ -1207,6 +1214,7 @@ type
|
|||||||
FLastMouseControlValid: Boolean;
|
FLastMouseControlValid: Boolean;
|
||||||
FBidiMode: TBiDiMode;
|
FBidiMode: TBiDiMode;
|
||||||
FRestoreStayOnTop: TList;
|
FRestoreStayOnTop: TList;
|
||||||
|
FTaskBarBehavior: TTaskBarBehavior;
|
||||||
procedure DoOnIdleEnd;
|
procedure DoOnIdleEnd;
|
||||||
function GetActive: boolean;
|
function GetActive: boolean;
|
||||||
function GetCurrentHelpFile: string;
|
function GetCurrentHelpFile: string;
|
||||||
@ -1220,6 +1228,7 @@ type
|
|||||||
procedure SetNavigation(const AValue: TApplicationNavigationOptions);
|
procedure SetNavigation(const AValue: TApplicationNavigationOptions);
|
||||||
procedure SetShowButtonGlyphs(const AValue: TApplicationShowGlyphs);
|
procedure SetShowButtonGlyphs(const AValue: TApplicationShowGlyphs);
|
||||||
procedure SetShowMenuGlyphs(const AValue: TApplicationShowGlyphs);
|
procedure SetShowMenuGlyphs(const AValue: TApplicationShowGlyphs);
|
||||||
|
procedure SetTaskBarBehavior(const AValue: TTaskBarBehavior);
|
||||||
procedure UpdateMouseControl(NewMouseControl: TControl);
|
procedure UpdateMouseControl(NewMouseControl: TControl);
|
||||||
procedure UpdateMouseHint(CurrentControl: TControl);
|
procedure UpdateMouseHint(CurrentControl: TControl);
|
||||||
procedure SetCaptureExceptions(const AValue: boolean);
|
procedure SetCaptureExceptions(const AValue: boolean);
|
||||||
@ -1390,6 +1399,7 @@ type
|
|||||||
property MainForm: TForm read FMainForm;
|
property MainForm: TForm read FMainForm;
|
||||||
property ModalLevel: Integer read FModalLevel;
|
property ModalLevel: Integer read FModalLevel;
|
||||||
property MouseControl: TControl read FMouseControl;
|
property MouseControl: TControl read FMouseControl;
|
||||||
|
property TaskBarBehavior: TTaskBarBehavior read FTaskBarBehavior write SetTaskBarBehavior;
|
||||||
property OnActionExecute: TActionEvent read FOnActionExecute write FOnActionExecute;
|
property OnActionExecute: TActionEvent read FOnActionExecute write FOnActionExecute;
|
||||||
property OnActionUpdate: TActionEvent read FOnActionUpdate write FOnActionUpdate;
|
property OnActionUpdate: TActionEvent read FOnActionUpdate write FOnActionUpdate;
|
||||||
property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
|
property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
|
||||||
|
@ -526,6 +526,21 @@ begin
|
|||||||
NotifyCustomForms(CM_APPSHOWMENUGLYPHCHANGED);
|
NotifyCustomForms(CM_APPSHOWMENUGLYPHCHANGED);
|
||||||
end;
|
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);
|
procedure TApplication.UpdateMouseControl(NewMouseControl: TControl);
|
||||||
|
|
||||||
@ -903,9 +918,17 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TApplication.UpdateVisible;
|
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;
|
function UseAppTaskbarItem(AForm: TCustomForm): Boolean; inline;
|
||||||
begin
|
begin
|
||||||
Result := (AForm = MainForm) or (AForm.ShowInTaskBar in [stNever, stDefault]);
|
Result := (AForm = MainForm) or (AForm.ShowInTaskBar = stNever)
|
||||||
|
or ((AForm.ShowInTaskBar = stDefault) and AppUseSingleButton);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function HasVisibleForms: Boolean;
|
function HasVisibleForms: Boolean;
|
||||||
|
@ -490,6 +490,15 @@ begin
|
|||||||
|
|
||||||
Activate;
|
Activate;
|
||||||
if Application <> nil then Application.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;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -756,6 +765,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
class procedure TCustomForm.WSRegisterClass;
|
||||||
begin
|
begin
|
||||||
inherited WSRegisterClass;
|
inherited WSRegisterClass;
|
||||||
@ -1758,8 +1782,7 @@ procedure TCustomForm.SetShowInTaskbar(Value: TShowInTaskbar);
|
|||||||
begin
|
begin
|
||||||
if Value = FShowInTaskbar then exit;
|
if Value = FShowInTaskbar then exit;
|
||||||
FShowInTaskbar := Value;
|
FShowInTaskbar := Value;
|
||||||
if not (csDesigning in ComponentState) and HandleAllocated then
|
UpdateShowInTaskBar;
|
||||||
TWSCustomFormClass(WidgetSetClass).SetShowInTaskbar(Self, Value);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -2295,6 +2318,7 @@ begin
|
|||||||
|
|
||||||
Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded');
|
Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded');
|
||||||
UpdateMenu;
|
UpdateMenu;
|
||||||
|
UpdateShowInTaskBar;
|
||||||
|
|
||||||
{$IFDEF OldAutoSize}
|
{$IFDEF OldAutoSize}
|
||||||
// activate focus if visible
|
// activate focus if visible
|
||||||
|
@ -773,6 +773,13 @@ begin
|
|||||||
Enable := false;}
|
Enable := false;}
|
||||||
|
|
||||||
//debugln('SetGtkWindowShowInTaskbar ',DbgSName(AForm),' ',dbgs(Enable));
|
//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);
|
SetGtkWindowShowInTaskbar(PGtkWindow(Widget), Enable);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -168,6 +168,10 @@ begin
|
|||||||
// create a floating form
|
// create a floating form
|
||||||
P := gtk_window_new(WindowType);
|
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
|
if (ABorderStyle = bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) then
|
||||||
gtk_window_set_decorated(PGtkWindow(P), False);
|
gtk_window_set_decorated(PGtkWindow(P), False);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user