Changeset 5286 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2012-06-19T23:49:52+02:00 (12 years ago)
Author:
bastiK
Message:

fixed: "View > Fullscreen mode" causes 2 toggles in a row, resulting in a short flicker, but otherwise no effect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/FullscreenToggleAction.java

    r5078 r5286  
    2727public class FullscreenToggleAction extends JosmAction {
    2828    private final List<ButtonModel> buttonModels = new ArrayList<ButtonModel>();
     29    private boolean selected;
    2930    private GraphicsDevice gd;
    3031    private Rectangle prevBounds;
     
    4243        Main.toolbar.register(this);
    4344        gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    44         putValue(SELECTED_KEY, Main.pref.getBoolean("draw.fullscreen", false));
     45        selected = Main.pref.getBoolean("draw.fullscreen", false);
    4546        notifySelectedState();
    4647    }
     
    6061    protected void notifySelectedState() {
    6162        for (ButtonModel model: buttonModels) {
    62             if (model.isSelected() != isSelected()) {
    63                 model.setSelected(isSelected());
     63            if (model.isSelected() != selected) {
     64                model.setSelected(selected);
    6465            }
    6566        }
     
    6768
    6869    protected void toggleSelectedState() {
    69         putValue(SELECTED_KEY, !isSelected());
    70         Main.pref.put("draw.fullscreen", isSelected());
     70        selected = !selected;
     71        Main.pref.put("draw.fullscreen", selected);
    7172        notifySelectedState();
    7273        setMode();
     
    7475
    7576    public void initial() {
    76         if (isSelected()) {
     77        if(selected)
    7778            setMode();
    78         }
    7979    }
    8080
     
    9191
    9292        frame.dispose();
    93         frame.setUndecorated(isSelected());
     93        frame.setUndecorated(selected);
    9494
    95         if (isSelected()) {
     95        if (selected) {
    9696            prevBounds = frame.getBounds();
    9797            frame.setBounds(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
     
    9999
    100100        // we cannot use hw-exclusive fullscreen mode in MS-Win, as long
    101         // as josm throws out modal dialogs, see here:
    102         // http://forums.sun.com/thread.jspa?threadID=5351882 FIXME this url does not work anymore
     101        // as josm throws out modal dialogs.
    103102        //
    104103        // the good thing is: fullscreen works without exclusive mode,
     
    107106        String exclusive = Main.pref.get("draw.fullscreen.exclusive-mode", "auto");
    108107        if ("true".equals(exclusive) || ("auto".equals(exclusive) && !(Main.platform instanceof PlatformHookWindows))) {
    109             gd.setFullScreenWindow(isSelected() ? frame : null);
     108            gd.setFullScreenWindow(selected ? frame : null);
    110109        }
    111110
    112         if (!isSelected() && prevBounds != null) {
     111        if (!selected && prevBounds != null) {
    113112            frame.setBounds(prevBounds);
    114113        }
     
    117116            wind.setVisible(true);
    118117        }
    119        
     118
    120119        // Free F10 key to allow it to be used by plugins, even after full screen (see #7502)
    121         frame.getJMenuBar().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0), "none"); 
     120        frame.getJMenuBar().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0), "none");
    122121    }
    123122
     
    125124        toggleSelectedState();
    126125    }
    127    
    128     public final boolean isSelected() {
    129         return (Boolean)getValue(SELECTED_KEY);
    130     }
    131126}
Note: See TracChangeset for help on using the changeset viewer.