Changeset 175


Ignore:
Timestamp:
Jul 19, 2024, 8:00:37 PM (4 months ago)
Author:
chronos
Message:
  • Fixed: Workaround for fullscreen switching problems on Linux.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/PersistentForm.pas

    r148 r175  
    1616    FMinVisiblePart: Integer;
    1717    FRegistryContext: TRegistryContext;
     18    FResizeEventOccured: Boolean;
    1819    procedure LoadControl(Control: TControl);
    1920    procedure SaveControl(Control: TControl);
     21    procedure WindowStateChange(Sender: TObject);
    2022  public
    2123    FormRestoredSize: TRect;
     
    301303
    302304procedure TPersistentForm.SetFullScreen(State: Boolean);
     305var
     306  OldHandler: TNotifyEvent;
     307var
     308  I: Integer;
    303309begin
    304310  if State then begin
     
    312318    end;
    313319    FormWindowState := Form.WindowState;
    314     Form.WindowState := wsMaximized;
    315     Form.WindowState := wsNormal;
    316     ShowWindow(Form.Handle, SW_SHOWFULLSCREEN);
    317320    {$IFDEF WINDOWS}
    318321    Form.BorderStyle := bsNone;
    319322    {$ENDIF}
     323    Form.WindowState := wsFullscreen;
     324    {$IFDEF UNIX}
     325    // Workaround on Linux, WindowState is rewriten by WMSize event to wsNormal.
     326    // We need for that even to occure
     327    OldHandler := Form.OnWindowStateChange;
     328    Form.OnWindowStateChange := WindowStateChange;
     329    FResizeEventOccured := False;
     330    for I := 0 to 10 do begin
     331      if FResizeEventOccured then Break;
     332      Application.ProcessMessages;
     333      Sleep(1);
     334    end;
     335    Form.OnWindowStateChange := OldHandler;
     336    {$ENDIF}
    320337  end else begin
    321338    FormFullScreen := False;
     339    Form.WindowState := wsNormal;
    322340    {$IFDEF WINDOWS}
    323341    Form.BorderStyle := bsSizeable;
    324342    {$ENDIF}
    325     ShowWindow(Form.Handle, SW_SHOWNORMAL);
    326343    if FormWindowState = wsNormal then begin
    327344      Form.WindowState := wsNormal;
     
    335352end;
    336353
     354procedure TPersistentForm.WindowStateChange(Sender: TObject);
     355begin
     356  Form.WindowState := wsFullscreen;
     357  FResizeEventOccured := True;
     358end;
     359
    337360end.
Note: See TracChangeset for help on using the changeset viewer.