terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Fix initial window size on Wayland

Open jeremypw opened this issue 1 year ago • 8 comments

Fixes #762

  • Moves window sizing code from Application to MainWindow
  • Sets size request from settings before realizing - this reliably sets the initial window dimensions
  • Resets size request to Application minimum after realizing - this allows the user to resize the window subject to hard-coded minimum dimensions.
  • Avoids a theoretically possible dereference of 'null' on new window action.

NOTE:

  1. All windows are created with the size in settings rather than following the current window size as it is simpler. If it is desired that the current window size is followed then an issue should be raised against which a PR can be produced.
  2. The size in settings is always that of the first window on closing regardless of the order of closing. Again, if that needs changing a separate issue/PR should be raised.

Should be tested on OS8/Wayland, OS8/X as well as OS7.1

jeremypw avatar Dec 19 '24 11:12 jeremypw

I think a better fix would be to use the get_monitor_at_window instead of the primary one which is

  • supported on Wayland
  • usually the primary one anyways on first launch
  • and if not it makes more sense to adjust the size according to the monitor it's actually on and not to the primary one

(Though I have to say I don't know anything about the terminal codebase 😅)

leolost2605 avatar Dec 19 '24 14:12 leolost2605

@leolost2605 I'll try it. I was assuming it was the get_geometry () that was the problem tho` - might be as well to have an ultimate hard-coded fallback still.

jeremypw avatar Dec 19 '24 19:12 jeremypw

The problem with using get_monitor_at_window () and get_primary_monitor () is that it does not work unless the window is realized (which it isn't at the moment). However if you restore the window size after realizing then setting the default dimensions does not work. In Gtk3 you can use resize () but that does not exist in Gtk4 so I do not want to introduce it here. I think therefore we will have to abandon the idea of resizing the terminal window according to the monitor size as a fallback

jeremypw avatar Dec 20 '24 11:12 jeremypw

The problem with using get_monitor_at_window () and get_primary_monitor () is that it does not work unless the window is realized (which it isn't at the moment). However if you restore the window size after realizing then setting the default dimensions does not work. In Gtk3 you can use resize () but that does not exist in Gtk4 so I do not want to introduce it here. I think therefore we will have to abandon the idea of resizing the terminal window according to the monitor size as a fallback

Where in GTK3 you can do resize (), in GTK4 setting default size after realizing will work so it can be done :)

(I don't have an opinion here just want to say that it's possible :))

leolost2605 avatar Feb 06 '25 16:02 leolost2605

For no obvious reason the zoom overlay appears (blank) on startup in this branch whereas it does not in master - investigating.

jeremypw avatar Feb 06 '25 16:02 jeremypw

Zoom_overlay problem due to a change in timing/order of events. Now fixed.

jeremypw avatar Feb 06 '25 17:02 jeremypw

Where in GTK3 you can do resize (), in GTK4 setting default size after realizing will work so it can be done :)

I am only really interested in fixing the Gtk3 version; the Gtk4 branch already has a different method of persisting window size that does not suffer from this problem.

jeremypw avatar Feb 06 '25 17:02 jeremypw

When I tested on OS8/X I now have a small terminal window

zeebok avatar Apr 16 '25 06:04 zeebok

Going to drop this as Gtk4 port is imminent.

jeremypw avatar Aug 14 '25 12:08 jeremypw