Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#3745 closed defect (fixed)

[PATCH] fullscreen geometry not restored

Reported by: richlv Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: Cc: bomm


when josm is closed fullscreen, it is not restored like that upon next startup. console prints :
Warning: Failed to restore window geometry from key ''. Falling back to default geometry. Details: Preference with key '' does not include 'x'. Can't restore window geometry from preferences.

linux, kde 3.5.10, java 1.6.0_15, josm 2255

Attachments (1)

josm-maximize.patch (9.3 KB ) - added by bomm 15 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by bomm, 15 years ago

Cc: bomm added
Owner: changed from team to richlv
Status: newneedinfo

I was not able to reproduce this with the latest version on Ubuntu 9.10 (karmic), Gnome

What is the value of '' in your preferences file?
What happens if you delete this value?

comment:2 by richlv, 15 years ago,y=60,width=1000,height=600

display resolution is 1024x768

removing the property from the preferences file makes no difference. what's interesting, no matter whether josm is closed maximised or not, this preference is not re-created in the config file.

comment:3 by bomm, 15 years ago

Do you still get the same error message or some other message with "Failed to restore window geometry"?
I think the error message is not related to the real problem.

The preference key named in the error message is for the DownloadDialog window. The geometry of the main window is stored in "gui.geometry".

On my system gui.geometry is updated when I close JOSM after changing the window size or position.
When I close JOSM after maximizing the window, the key is removed from the preferences file. (This is used as an indication to start JOSM maximized.)

comment:4 by richlv, 15 years ago

it acts a bit weird.
preferences file did not have "gui.geometry" option. started up josm - it started in a not-maximised state (but taking up all of the available screen space). i resized it to be smaller, closed - "gui.geometry" was added. starting up again opened in the previously resized size.
then i maximised it, closed - "gui.geometry" was removed. started up again - this time it started up properly maximised. closed, started again ("gui.geometry" did not appear) - again it started in a non-maximised state, and did so for all subsequent starts.

note that it does not recall previous size, it seems to take full screen space, it just is not maximised.

and yes, error message is gone and no other error messages have appeared.

comment:5 by bomm, 15 years ago

Owner: changed from richlv to team
Status: needinfonew
Summary: fullscreen geometry not restored[PATCH] fullscreen geometry not restored

I was able to reproduce the problem and (partially) analyzed it with the help of some debug output.

I observed that sometimes when JOSM calls ((JFrame)parent).getExtendedState() it returns JFrame.NORMAL although the window is maximized. In this situation parent.getBounds() returns the geometry of the maximized window and JOSM will save this geometry to the preferences. The next time JOSM is started it will create a window that occupies (nearly) the whole screen but is not in maximized state.

I'm not sure what exactly triggers this problem. I think I can sometimes reproduce it when I close JOSM immediately after starting it. Maybe it's a timing problem. Sometimes the results of getBounds() or getExtendedState() seem to be wrong.

I found questions about similar problems:

I tried to fix this by storing the bounds of the window and the current state with the help of a ComponentListener and WindowStateListener.

Additionally I added a new preferences value "gui.maximized" to store the maximized state independently from the window geometry.

When the main window is closed in maximized state it will now remember this state and the normal geometry. That means when you you start JOSM the window will be maximized and when you un-maximize the window it will have its normal size again.

With the attached patch I was no longer able to reproduce the problem even if I close JOSM immediately after starting it.

If the error should still occur, JOSM will no longer start with a full-screen window in normal state. Instead it will use the geometry from the last time the window was in normal state before closing JOSM.

comment:6 by anonymous, 15 years ago

Owner: changed from team to richlv
Status: newneedinfo

It reads

src/org/openstreetmap/josm/gui/ / line 204

String geometry = Main.pref.get("gui.geometry");

Why? This variable is not used.

BTW: It would be better to save the geometry immediately when the window is resized / moved.

comment:7 by anonymous, 15 years ago

Owner: changed from richlv to bomm
Status: needinfonew

by bomm, 15 years ago

Attachment: josm-maximize.patch added

in reply to:  6 comment:8 by bomm, 15 years ago

Owner: changed from bomm to team

Replying to anonymous:

src/org/openstreetmap/josm/gui/ / line 204

String geometry = Main.pref.get("gui.geometry");

I forgot to remove this line. I introduced this variable for debugging purposes when the maximized state depended on gui.geometry being unset.

A few lines below this I noticed another warning: main.windowState should be Main.windowState.

I updated the patch.

BTW: It would be better to save the geometry immediately when the window is resized / moved.

In this respect I did not change the current behavior .

Saving every change immediately might lead to unnecessary writes to the preferences file and I see only a minor advantage.
When I resize the window on the top I get both a moved and a resized event. As written in the discussion in the first link I provided above, you may even get events for partially (un)maximized windows.

comment:9 by bastiK, 15 years ago

Resolution: fixed
Status: newclosed

(In [2876]) fix #3745 - fullscreen geometry not restored (patch by bomm)

comment:10 by richlv, 14 years ago

snapshot 2879 now always opens fullscreen for me (even if i close it unmaximised). if i close it unmaximised, i get a string like this saved in preferences :

as i actually want it to start fullscreen, i don't care much about the issue now, but maybe somebody else does :)

comment:11 by bomm, 14 years ago

I cannot reproduce your problem with version 2890. For me it works as expected:

When I close JOSM in normal state it opens with the same window geometry.
When I close the maximized JOSM main window it opens maximized and when I un-maximize it, the normal geometry is restored.

JOSM will now always store a gui.geometry value to tht preferences file. If it was closed in maximized state this is the geometry from the last time it was in normal state.
Aditionally a value gui.maximized=true or =false is stored in preferences. This determines if JOSM should start up maximized.

What is the value of gui.maximized when you close JOSM in normal state?

comment:12 by richlv, 14 years ago

interesting. just downloaded 2906 - everything works as expected now.
thanks for the fix :)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.