Changeset 5078 in josm


Ignore:
Timestamp:
2012-03-14T00:22:50+01:00 (13 years ago)
Author:
Don-vip
Message:

fix #7502 - F10 doesn't work after entering full screen (by pressing F11)

File:
1 edited

Legend:

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

    r4982 r5078  
    1717
    1818import javax.swing.ButtonModel;
     19import javax.swing.JComponent;
     20import javax.swing.JFrame;
     21import javax.swing.KeyStroke;
    1922
    2023import org.openstreetmap.josm.Main;
    21 import org.openstreetmap.josm.tools.PlatformHookUnixoid;
    2224import org.openstreetmap.josm.tools.PlatformHookWindows;
    2325import org.openstreetmap.josm.tools.Shortcut;
     
    2527public class FullscreenToggleAction extends JosmAction {
    2628    private final List<ButtonModel> buttonModels = new ArrayList<ButtonModel>();
    27     //FIXME: replace with property Action.SELECTED_KEY when migrating to
    28     // Java 6
    29     private boolean selected;
    3029    private GraphicsDevice gd;
    3130    private Rectangle prevBounds;
     
    4342        Main.toolbar.register(this);
    4443        gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    45         selected = Main.pref.getBoolean("draw.fullscreen", false);
     44        putValue(SELECTED_KEY, Main.pref.getBoolean("draw.fullscreen", false));
    4645        notifySelectedState();
    4746    }
     
    6160    protected void notifySelectedState() {
    6261        for (ButtonModel model: buttonModels) {
    63             if (model.isSelected() != selected) {
    64                 model.setSelected(selected);
     62            if (model.isSelected() != isSelected()) {
     63                model.setSelected(isSelected());
    6564            }
    6665        }
     
    6867
    6968    protected void toggleSelectedState() {
    70         selected = !selected;
    71         Main.pref.put("draw.fullscreen", selected);
     69        putValue(SELECTED_KEY, !isSelected());
     70        Main.pref.put("draw.fullscreen", isSelected());
    7271        notifySelectedState();
    7372        setMode();
     
    7574
    7675    public void initial() {
    77         if(selected)
     76        if (isSelected()) {
    7877            setMode();
     78        }
    7979    }
    8080
    8181    protected void setMode() {
    82         Frame frame = (Frame) Main.parent;
     82        JFrame frame = (JFrame) Main.parent;
    8383
    8484        List<Window> visibleWindows = new ArrayList<Window>();
     
    9191
    9292        frame.dispose();
    93         frame.setUndecorated(selected);
     93        frame.setUndecorated(isSelected());
    9494
    95         if (selected) {
     95        if (isSelected()) {
    9696            prevBounds = frame.getBounds();
    9797            frame.setBounds(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
     
    100100        // we cannot use hw-exclusive fullscreen mode in MS-Win, as long
    101101        // as josm throws out modal dialogs, see here:
    102         // http://forums.sun.com/thread.jspa?threadID=5351882
     102        // http://forums.sun.com/thread.jspa?threadID=5351882 FIXME this url does not work anymore
    103103        //
    104104        // the good thing is: fullscreen works without exclusive mode,
     
    107107        String exclusive = Main.pref.get("draw.fullscreen.exclusive-mode", "auto");
    108108        if ("true".equals(exclusive) || ("auto".equals(exclusive) && !(Main.platform instanceof PlatformHookWindows))) {
    109             gd.setFullScreenWindow(selected ? frame : null);
     109            gd.setFullScreenWindow(isSelected() ? frame : null);
    110110        }
    111111
    112         if (!selected && prevBounds != null) {
     112        if (!isSelected() && prevBounds != null) {
    113113            frame.setBounds(prevBounds);
    114114        }
     
    117117            wind.setVisible(true);
    118118        }
     119       
     120        // 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");
    119122    }
    120123
     
    122125        toggleSelectedState();
    123126    }
     127   
     128    public final boolean isSelected() {
     129        return (Boolean)getValue(SELECTED_KEY);
     130    }
    124131}
Note: See TracChangeset for help on using the changeset viewer.