SetSize vs GetSize

My app wants to remember its last geometry so it can restore itself to the last position and size if it is restarted.

So OnClose I GetSize and GetPosition and save the results in an init file.

OnStart I read this init file and SetSize and SetPosition to restore the geometry.

But here’s the problem: it appears every time I do this the window gets a little bigger.

The reason is that if I SetSize (x, y) and GetSize => (x’, y’) x’ - x > 0 and y’ - y > 0.

On Linux x’ - x = 8 and y’ - y = 32.

Is there a natural way for me to do the right thing?

I guess I can do the above math OnStart and use the differences to adjust the saved values OnClose.

Just wondering if there’s a cleaner way.

thanks!!!

-Jim.

Follow up: when I call GetSize OnStart I get x’ - x = 0 and y’ - y = 0 but when I call it OnClose I get x’ - x = 6 and y’ - y = 32. The problem is that I can’t tell for the general case what those differences are since the user may have resized the window.

···

On Wednesday, April 24, 2019 at 10:55:09 AM UTC-4, Demetrios Tsillas wrote:

My app wants to remember its last geometry so it can restore itself to the last position and size if it is restarted.

So OnClose I GetSize and GetPosition and save the results in an init file.

OnStart I read this init file and SetSize and SetPosition to restore the geometry.

But here’s the problem: it appears every time I do this the window gets a little bigger.

The reason is that if I SetSize (x, y) and GetSize => (x’, y’) x’ - x > 0 and y’ - y > 0.

On Linux x’ - x = 8 and y’ - y = 32.

Is there a natural way for me to do the right thing?

I guess I can do the above math OnStart and use the differences to adjust the saved values OnClose.

Just wondering if there’s a cleaner way.

thanks!!!

-Jim.

Nevermind I just discovered GetClientSize/SetClientSize which do what I want.

···

On Wednesday, April 24, 2019 at 10:55:09 AM UTC-4, Demetrios Tsillas wrote:

My app wants to remember its last geometry so it can restore itself to the last position and size if it is restarted.

So OnClose I GetSize and GetPosition and save the results in an init file.

OnStart I read this init file and SetSize and SetPosition to restore the geometry.

But here’s the problem: it appears every time I do this the window gets a little bigger.

The reason is that if I SetSize (x, y) and GetSize => (x’, y’) x’ - x > 0 and y’ - y > 0.

On Linux x’ - x = 8 and y’ - y = 32.

Is there a natural way for me to do the right thing?

I guess I can do the above math OnStart and use the differences to adjust the saved values OnClose.

Just wondering if there’s a cleaner way.

thanks!!!

-Jim.

Yep, using the client size is the right thing to do here.

The issue is that on X-windows systems the frame decorations (title bar, borders, etc.) are implemented by the window manager and are influenced by the active themes or whatnot. There are protocols where the client application (the GTK libs in our case) can ask for the WM to get or set the overall size, but the various WMs are free to interpret that request however they want, or even not at all. So there are inconsistencies. Even if you had found the magic to make it work reliably for you with calculating and using deltas, it’s possible that it would not have worked the same for a different user.

···

Robin

On Wednesday, April 24, 2019 at 8:10:48 AM UTC-7, Demetrios Tsillas wrote:

Nevermind I just discovered GetClientSize/SetClientSize which do what I want.

On Wednesday, April 24, 2019 at 10:55:09 AM UTC-4, Demetrios Tsillas wrote:

My app wants to remember its last geometry so it can restore itself to the last position and size if it is restarted.

So OnClose I GetSize and GetPosition and save the results in an init file.

OnStart I read this init file and SetSize and SetPosition to restore the geometry.

But here’s the problem: it appears every time I do this the window gets a little bigger.

The reason is that if I SetSize (x, y) and GetSize => (x’, y’) x’ - x > 0 and y’ - y > 0.

On Linux x’ - x = 8 and y’ - y = 32.

Is there a natural way for me to do the right thing?

I guess I can do the above math OnStart and use the differences to adjust the saved values OnClose.

Just wondering if there’s a cleaner way.

thanks!!!

-Jim.