Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-10

Window sizing on gtk

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Max Vlasov

Hi,
I noticed a little difference between gtk and win32 in handling window sizing programmatically and appreciate any advice on the subject.

On Windows it is possible to create user-drawn window that formally is not resizable and has no system decoration, but behaves like normal resizable window. So I had BorderStyle = bsNone and custom buttons and my own border for resizing. It was easy because WindowState still responds to wsMaximized in this case and borders can be also responsive by implementing WM_NCHITTEST handler. But both seems to not work on gtk (no visible change for WindowState changing and no visiting both WM_NCHitTest and CM_HITTEST handlers)

I can fix the first problem just by little extra code that switches between the current size and Bounds(0, 0, Screen.Width, Screen.Height), but the borders emulation is a harder task (I should track the areas, cursors and window sizing arithmetics, not mentioning that the program doesn't obey the system way of resizing for example frame drawing instead of window drawing).

Is there some other solution or maybe setting/option I miss? With Nchittest the question is also does it work at all on gtk? I see that there are plenty of places in lcl so not working for forms look a little strange.

Thanks

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111028/3257429d/attachment.html>

Reply by email

Max Vlasov
to Max Vlasov
Max Vlasov wrote
I can fix the first problem just by little extra code that switches between the current size and Bounds(0, 0, Screen.Width, Screen.Height),....

While trying to implement this particular workaround, noticed also a strange thing

The following "toggle maximize" code can't restore the borderless window (BorderStyle = bsNone) to the previous state (at least on Ubuntu). So looks like GTK detected that I maximize to full screen, so it hidden both toolbars, but later for some reasons don't accept
BoundsRect:=fLastRestoreRect; , the window still stays in the full-screen state. Only if I wrap the restore into Visible:=false/Visible:=true it works.

procedure TForm1.Button1Click(Sender: TObject);
begin
  if fIsMaximized then
  begin
  //  Visible:=false;;
    BoundsRect:=fLastRestoreRect;
    fIsMaximized:=false;
   // Visible:=true;
  end
  else
  begin
    fLastRestoreRect:=BoundsRect;
    BoundsRect:=Screen.WorkAreaRect;
    fIsMaximized:=true;
  end;
end;

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111028/df1e1526/attachment-0001.html>

Reply by email

Hans-Peter Diettrich
to Max Vlasov: I noticed a little difference between gtk and win32 in handling window sizing…
Hi, I noticed a little difference between gtk and win32 in handling window sizing programmatically and appreciate any advice on the subject.

You should understand that non-Windows platforms have separate window mangers, which do not allow to control forms as on Windows. The widgetsets only have control over the *client* area of a window, but not over the non-client areas.

But both seems to not work on gtk (no visible change for WindowState changing and no visiting both WM_NCHitTest and CM_HITTEST handlers)

Right, these only work on Windows. The missing NC functionality makes it e.g. impossible to drag-dock forms on Linux, by dragging their title bars, as Delphi does on Windows.

DoDi

Reply by email