Ignore:
Timestamp:
Jul 19, 2024, 11:05:07 PM (4 months ago)
Author:
chronos
Message:
  • Fixed: Full screen mode switching.
File:
1 edited

Legend:

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

    r85 r99  
    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);
     305{$IFDEF UNIX}
     306var
     307  OldHandler: TNotifyEvent;
     308var
     309  I: Integer;
     310{$ENDIF}
    303311begin
    304312  if State then begin
     
    312320    end;
    313321    FormWindowState := Form.WindowState;
    314     Form.WindowState := wsMaximized;
    315     Form.WindowState := wsNormal;
    316     ShowWindow(Form.Handle, SW_SHOWFULLSCREEN);
    317322    {$IFDEF WINDOWS}
    318323    Form.BorderStyle := bsNone;
    319324    {$ENDIF}
     325    Form.WindowState := wsFullscreen;
     326    {$IFDEF UNIX}
     327    // Workaround on Linux, WindowState is rewriten by WMSize event to wsNormal.
     328    // We need for that even to occure
     329    OldHandler := Form.OnWindowStateChange;
     330    Form.OnWindowStateChange := WindowStateChange;
     331    FResizeEventOccured := False;
     332    for I := 0 to 10 do begin
     333      if FResizeEventOccured then Break;
     334      Application.ProcessMessages;
     335      Sleep(1);
     336    end;
     337    Form.OnWindowStateChange := OldHandler;
     338    {$ENDIF}
    320339  end else begin
    321340    FormFullScreen := False;
     341    Form.WindowState := wsNormal;
    322342    {$IFDEF WINDOWS}
    323343    Form.BorderStyle := bsSizeable;
    324344    {$ENDIF}
    325     ShowWindow(Form.Handle, SW_SHOWNORMAL);
    326345    if FormWindowState = wsNormal then begin
    327346      Form.WindowState := wsNormal;
     
    335354end;
    336355
     356procedure TPersistentForm.WindowStateChange(Sender: TObject);
     357begin
     358  Form.WindowState := wsFullscreen;
     359  FResizeEventOccured := True;
     360end;
     361
    337362end.
Note: See TracChangeset for help on using the changeset viewer.