mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 05:36:10 +02:00
improved but not fixed transient windows
git-svn-id: trunk@2058 -
This commit is contained in:
parent
44a63cfd06
commit
32858fba0c
@ -315,18 +315,13 @@ begin
|
|||||||
if (GtkWindow=nil) then exit;
|
if (GtkWindow=nil) then exit;
|
||||||
UnsetResizeRequest(PgtkWidget(GtkWindow));
|
UnsetResizeRequest(PgtkWidget(GtkWindow));
|
||||||
|
|
||||||
// Try to make all Modal forms transient to the main form
|
|
||||||
// If this is a Form, aka GTKWindow, try and keep decoration and Functions
|
|
||||||
|
|
||||||
// apart from none and sizeable, this will only work if WM supports
|
|
||||||
// motif flags properly, which very few actually do.
|
|
||||||
|
|
||||||
if ModalWindows=nil then ModalWindows:=TList.Create;
|
if ModalWindows=nil then ModalWindows:=TList.Create;
|
||||||
ModalWindows.Add(GtkWindow);
|
ModalWindows.Add(GtkWindow);
|
||||||
UpdateTransientWindows;
|
|
||||||
|
|
||||||
gtk_window_set_modal(GtkWindow, true);
|
gtk_window_set_modal(GtkWindow, true);
|
||||||
gtk_widget_show(PGtkWidget(GtkWindow));
|
gtk_widget_show(PGtkWidget(GtkWindow));
|
||||||
|
|
||||||
|
UpdateTransientWindows;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -367,7 +362,8 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
gdk_window_get_user_data(PGDKWindow(List^.Data), @Window);
|
gdk_window_get_user_data(PGDKWindow(List^.Data), @Window);
|
||||||
if GtkWidgetIsA(PGtkWidget(Window),GTK_WINDOW_TYPE)
|
if GtkWidgetIsA(PGtkWidget(Window),GTK_WINDOW_TYPE)
|
||||||
and (GTK_WIDGET_VISIBLE(PGtkWidget(Window))) then begin
|
and GTK_WIDGET_VISIBLE(PGtkWidget(Window))
|
||||||
|
then begin
|
||||||
// visible window found -> add to list
|
// visible window found -> add to list
|
||||||
New(ATransientWindow);
|
New(ATransientWindow);
|
||||||
FillChar(ATransientWindow^,SizeOf(TTransientWindow),0);
|
FillChar(ATransientWindow^,SizeOf(TTransientWindow),0);
|
||||||
@ -376,21 +372,12 @@ begin
|
|||||||
if (LCLObject<>nil) and (LCLObject is TComponent) then begin
|
if (LCLObject<>nil) and (LCLObject is TComponent) then begin
|
||||||
LCLComponent:=TComponent(LCLObject);
|
LCLComponent:=TComponent(LCLObject);
|
||||||
ATransientWindow^.Component:=LCLComponent;
|
ATransientWindow^.Component:=LCLComponent;
|
||||||
if LCLComponent is TCustomForm then begin
|
|
||||||
ATransientWindow^.IsModal:=
|
|
||||||
fsModal in TCustomForm(LCLComponent).FormState;
|
|
||||||
end else if (LCLComponent is TCommonDialog) then begin
|
|
||||||
ATransientWindow^.IsModal:=true;
|
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
if ATransientWindow^.IsModal then begin
|
|
||||||
if (ModalWindows<>nil) then
|
if (ModalWindows<>nil) then
|
||||||
ATransientWindow^.SortIndex:=ModalWindows.IndexOf(Window)
|
ATransientWindow^.SortIndex:=ModalWindows.IndexOf(Window)
|
||||||
else begin
|
else
|
||||||
ATransientWindow^.SortIndex:=-1;
|
ATransientWindow^.SortIndex:=-1;
|
||||||
writeln('WARNING: UpdateTransientWindows: unknown modal window ',HexStr(Cardinal(Window),8));
|
ATransientWindow^.IsModal:=ATransientWindow^.SortIndex>=0;
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if AllWindows=nil then AllWindows:=TList.Create;
|
if AllWindows=nil then AllWindows:=TList.Create;
|
||||||
AllWindows.Add(ATransientWindow);
|
AllWindows.Add(ATransientWindow);
|
||||||
end;
|
end;
|
||||||
@ -420,6 +407,10 @@ begin
|
|||||||
// -> break all transient window relation ships
|
// -> break all transient window relation ships
|
||||||
for i:=0 to AllWindows.Count-1 do begin
|
for i:=0 to AllWindows.Count-1 do begin
|
||||||
ATransientWindow:=PTransientWindow(AllWindows[i]);
|
ATransientWindow:=PTransientWindow(AllWindows[i]);
|
||||||
|
//write('TgtkObject.UpdateTransientWindows Untransient ',i);
|
||||||
|
//if ATransientWindow^.Component<>nil then
|
||||||
|
// write(' ',ATransientWindow^.Component.Name,':',ATransientWindow^.Component.ClassName);
|
||||||
|
//writeln('');
|
||||||
gtk_window_set_transient_for(ATransientWindow^.GtkWindow,nil);
|
gtk_window_set_transient_for(ATransientWindow^.GtkWindow,nil);
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
@ -438,20 +429,24 @@ begin
|
|||||||
|
|
||||||
// sort non modal windows for z order
|
// sort non modal windows for z order
|
||||||
// ToDo: How do we get the z order?
|
// ToDo: How do we get the z order?
|
||||||
// For now, we just keep the gtk window order
|
// For now, just use the creation order
|
||||||
|
|
||||||
// set al transient relationships
|
|
||||||
|
// set all transient relationships
|
||||||
for i:=0 to AllWindows.Count-1 do begin
|
for i:=0 to AllWindows.Count-1 do begin
|
||||||
ATransientWindow:=PTransientWindow(AllWindows[i]);
|
ATransientWindow:=PTransientWindow(AllWindows[i]);
|
||||||
|
//write('UpdateTransientWindows: ',i);
|
||||||
|
//if ATransientWindow^.Component<>nil then
|
||||||
|
// write(' Transient: ',ATransientWindow^.Component.Name,':',
|
||||||
|
// ATransientWindow^.Component.ClassName);
|
||||||
if i>0 then begin
|
if i>0 then begin
|
||||||
ParentWindow:=PTransientWindow(AllWindows[i-1])^.GtkWindow;
|
ParentWindow:=PTransientWindow(AllWindows[i-1])^.GtkWindow;
|
||||||
//writeln('UpdateTransientWindows: ',i,
|
//if PTransientWindow(AllWindows[i-1])^.Component<>nil then
|
||||||
// ' Transient: ',ATransientWindow^.Component.Name,':',
|
// write(' Parent: ',PTransientWindow(AllWindows[i-1])^.Component.Name,':',
|
||||||
// ATransientWindow^.Component.ClassName,
|
|
||||||
// ' Parent=',PTransientWindow(AllWindows[i-1])^.Component.Name,':',
|
|
||||||
// PTransientWindow(AllWindows[i-1])^.Component.ClassName);
|
// PTransientWindow(AllWindows[i-1])^.Component.ClassName);
|
||||||
end else
|
end else
|
||||||
ParentWindow:=nil;
|
ParentWindow:=nil;
|
||||||
|
//writeln('');
|
||||||
gtk_window_set_transient_for(ATransientWindow^.GtkWindow,ParentWindow);
|
gtk_window_set_transient_for(ATransientWindow^.GtkWindow,ParentWindow);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -464,6 +459,19 @@ begin
|
|||||||
AllWindows.Free;
|
AllWindows.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
procedure TgtkObject.UntransientWindow(GtkWindow: PGtkWindow);
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TgtkObject.UntransientWindow(GtkWindow: PGtkWindow);
|
||||||
|
begin
|
||||||
|
gtk_window_set_transient_for(GtkWindow,nil);
|
||||||
|
if ModalWindows<>nil then begin
|
||||||
|
ModalWindows.Remove(GtkWindow);
|
||||||
|
if ModalWindows.Count=0 then FreeAndNil(ModalWindows);
|
||||||
|
end;
|
||||||
|
UpdateTransientWindows;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TGtkObject.SendCachedLCLMessages
|
Method: TGtkObject.SendCachedLCLMessages
|
||||||
Params: None
|
Params: None
|
||||||
@ -1762,9 +1770,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
LM_DESTROY :
|
LM_DESTROY :
|
||||||
begin
|
DestroyLCLComponent(Sender);
|
||||||
DestroyLCLControl(Sender);
|
|
||||||
end;
|
|
||||||
|
|
||||||
LM_DRAGINFOCHANGED :
|
LM_DRAGINFOCHANGED :
|
||||||
Begin
|
Begin
|
||||||
@ -3428,12 +3434,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
TgtkObject.DestroyLCLControl
|
TgtkObject.DestroyLCLComponent
|
||||||
Params: Sender: TObject
|
Params: Sender: TObject
|
||||||
|
|
||||||
Destroy the widget and all associated data
|
Destroy the widget and all associated data
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TGTKObject.DestroyLCLControl(Sender : TObject);
|
procedure TGTKObject.DestroyLCLComponent(Sender : TObject);
|
||||||
var
|
var
|
||||||
handle: hwnd; // handle of sender
|
handle: hwnd; // handle of sender
|
||||||
QueueItem, OldQueueItem: PLazQueueItem;
|
QueueItem, OldQueueItem: PLazQueueItem;
|
||||||
@ -3474,8 +3480,14 @@ begin
|
|||||||
|
|
||||||
RemoveCallbacks(Sender);
|
RemoveCallbacks(Sender);
|
||||||
|
|
||||||
|
if GtkWidgetIsA(Widget,GTK_WINDOW_TYPE) then begin
|
||||||
|
writeln('tgtkObject.DestroyLCLControl Untransient ',Sender.ClassName);
|
||||||
|
UntransientWindow(PGtkWindow(Widget));
|
||||||
|
end;
|
||||||
|
|
||||||
if Sender is TControl then begin
|
if Sender is TControl then begin
|
||||||
case TControl(Sender).fCompStyle of
|
case TControl(Sender).fCompStyle of
|
||||||
|
|
||||||
csComboBox:
|
csComboBox:
|
||||||
begin
|
begin
|
||||||
SetComboBoxText(PGtkCombo(Widget),nil);
|
SetComboBoxText(PGtkCombo(Widget),nil);
|
||||||
@ -3484,14 +3496,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
if Sender is TCustomForm then begin
|
|
||||||
gtk_window_set_transient_for(PGtkWindow(Widget),nil);
|
|
||||||
if ModalWindows<>nil then begin
|
|
||||||
ModalWindows.Remove(PGtkWindow(Widget));
|
|
||||||
if ModalWindows.Count=0 then FreeAndNil(ModalWindows);
|
|
||||||
end;
|
|
||||||
UpdateTransientWindows;
|
|
||||||
end;
|
|
||||||
end
|
end
|
||||||
else if Sender is TCommonDialog then begin
|
else if Sender is TCommonDialog then begin
|
||||||
DestroyCommonDialogAddOns(TCommonDialog(Sender));
|
DestroyCommonDialogAddOns(TCommonDialog(Sender));
|
||||||
@ -5014,16 +5018,16 @@ begin
|
|||||||
if (Sender is TCustomForm) then begin
|
if (Sender is TCustomForm) then begin
|
||||||
UnshareWindowAccelGroups(SenderWidget);
|
UnshareWindowAccelGroups(SenderWidget);
|
||||||
end;
|
end;
|
||||||
|
if GtkWidgetIsA(SenderWidget,GTK_WINDOW_TYPE) then
|
||||||
|
gtk_window_set_transient_for(PGtkWindow(SenderWIdget),nil);
|
||||||
|
|
||||||
|
if not gtk_widget_visible(SenderWidget) then
|
||||||
|
exit;
|
||||||
|
|
||||||
gtk_widget_hide(SenderWidget);
|
gtk_widget_hide(SenderWidget);
|
||||||
|
|
||||||
if (Sender is TCustomForm) then begin
|
if GtkWidgetIsA(SenderWidget,GTK_WINDOW_TYPE) then
|
||||||
if ModalWindows<>nil then begin
|
UntransientWindow(PGtkWindow(SenderWIdget));
|
||||||
ModalWindows.Remove(PGtkWindow(SenderWidget));
|
|
||||||
if ModalWindows.Count=0 then FreeAndNil(ModalWindows);
|
|
||||||
end;
|
|
||||||
UpdateTransientWindows;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
//if Sender is TForm then
|
//if Sender is TForm then
|
||||||
// writeln('[TgtkObject.ShowHide] END ',Sender.ClassName,' Window=',FormWidget^.Window<>nil);
|
// writeln('[TgtkObject.ShowHide] END ',Sender.ClassName,' Window=',FormWidget^.Window<>nil);
|
||||||
@ -7043,6 +7047,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.333 2003/03/17 13:00:35 mattias
|
||||||
|
improved but not fixed transient windows
|
||||||
|
|
||||||
Revision 1.332 2003/03/15 18:32:38 mattias
|
Revision 1.332 2003/03/15 18:32:38 mattias
|
||||||
implemented transient windows for all cases
|
implemented transient windows for all cases
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user