Modify

Opened 10 years ago

Closed 10 years ago

Last modified 10 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

Description

when josm is closed fullscreen, it is not restored like that upon next startup. console prints :
Warning: Failed to restore window geometry from key 'org.openstreetmap.josm.gui.download.DownloadDialog.geometry'. Falling back to default geometry. Details: Preference with key 'org.openstreetmap.josm.gui.download.DownloadDialog.geometry' 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 10 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 10 years ago by bomm

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 'org.openstreetmap.josm.gui.download.DownloadDialog.geometry' in your preferences file?
What happens if you delete this value?

comment:2 Changed 10 years ago by richlv

org.openstreetmap.josm.gui.download.DownloadDialog.geometry=x=12,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 Changed 10 years ago by bomm

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 Changed 10 years ago by richlv

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 Changed 10 years ago by bomm

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:
http://forums.sun.com/thread.jspa?threadID=5181176
http://groups.google.com/group/de.comp.lang.java/browse_thread/thread/22bb2f61c649e83b

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 Changed 10 years ago by anonymous

Owner: changed from team to richlv
Status: newneedinfo

It reads

src/org/openstreetmap/josm/gui/MainApplication.java / 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 Changed 10 years ago by anonymous

Owner: changed from richlv to bomm
Status: needinfonew

Changed 10 years ago by bomm

Attachment: josm-maximize.patch added

comment:8 in reply to:  6 Changed 10 years ago by bomm

Owner: changed from bomm to team

Replying to anonymous:

src/org/openstreetmap/josm/gui/MainApplication.java / 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 Changed 10 years ago by bastiK

Resolution: fixed
Status: newclosed

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

comment:10 Changed 10 years ago by richlv

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 :
gui.geometry=665x424+203+182

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

comment:11 Changed 10 years ago by bomm

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 Changed 10 years ago by richlv

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.