Ticket #1984: save-geometry.diff
| File save-geometry.diff, 3.4 KB (added by , 17 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/ExitAction.java
24 24 } 25 25 26 26 public void actionPerformed(ActionEvent e) { 27 if (!Main.breakBecauseUnsavedChanges()) 27 if (!Main.breakBecauseUnsavedChanges()) { 28 Main.saveGuiGeometry(); 28 29 System.exit(0); 30 } 29 31 } 30 32 } -
src/org/openstreetmap/josm/gui/MainApplication.java
55 55 @Override public void windowClosing(final WindowEvent arg0) { 56 56 if (Main.breakBecauseUnsavedChanges()) 57 57 return; 58 Main.saveGuiGeometry(); 58 59 System.exit(0); 59 60 } 60 61 }); … … 213 214 mainFrame.setVisible(true); 214 215 splash.closeSplash(); 215 216 216 if (!args.containsKey("no-fullscreen") && !args.containsKey("geometry") && Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.MAXIMIZED_BOTH))217 if (!args.containsKey("no-fullscreen") && !args.containsKey("geometry") && Main.pref.get("gui.geometry") == null && Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.MAXIMIZED_BOTH)) 217 218 mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); 218 219 219 220 EventQueue.invokeLater(new Runnable(){ -
src/org/openstreetmap/josm/Main.java
411 411 UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon")); 412 412 413 413 Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); 414 String geometry = Main.pref.get("gui.geometry"); 414 415 if (args.containsKey("geometry")) { 415 String geometry = args.get("geometry").iterator().next(); 416 geometry = args.get("geometry").iterator().next(); 417 } 418 if (geometry.length() != 0) { 416 419 final Matcher m = Pattern.compile("(\\d+)x(\\d+)(([+-])(\\d+)([+-])(\\d+))?").matcher(geometry); 417 420 if (m.matches()) { 418 421 int w = Integer.valueOf(m.group(1)); … … 427 430 y = screenDimension.height - y - h; 428 431 } 429 432 bounds = new Rectangle(x,y,w,h); 433 if(!Main.pref.get("gui.geometry").equals(geometry)) { 434 // remember this geometry 435 Main.pref.put("gui.geometry", geometry); 436 } 430 437 } else 431 438 System.out.println("Ignoring malformed geometry: "+geometry); 432 439 } … … 539 546 { 540 547 return Locale.getDefault().getLanguage() + ":"; 541 548 } 549 550 static public void saveGuiGeometry() { 551 // if the gui.geometry preference is already set, 552 // save the current window geometry 553 String curGeometryPref = pref.get("gui.geometry"); 554 if(curGeometryPref.length() != 0) { 555 Rectangle bounds = parent.getBounds(); 556 pref.put("gui.geometry", 557 (int)bounds.getWidth() + 558 "x" + (int)bounds.getHeight() + 559 "+" + (int)bounds.getX() + 560 "+" + (int)bounds.getY()); 561 } 562 } 542 563 }
