Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 95222 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/contexts/ContextAuthority.java (+15 lines)
Lines 858-861 Link Here
858
			}
858
			}
859
		}
859
		}
860
	}
860
	}
861
    
862
    /**
863
     * <p>
864
     * Bug 95792. A mechanism by which the key binding architecture can force an
865
     * update of the contexts (based on the active shell) before trying to
866
     * execute a command. This mechanism is required for GTK+ only.
867
     * </p>
868
     * <p>
869
     * DO NOT CALL THIS METHOD.
870
     * </p>
871
     */
872
    final void updateShellKludge() {
873
        updateCurrentState();
874
        sourceChanged(ISources.ACTIVE_SHELL);
875
    }
861
}
876
}
(-)Eclipse UI/org/eclipse/ui/internal/contexts/ContextService.java (+33 lines)
Lines 127-130 Link Here
127
	public final boolean unregisterShell(final Shell shell) {
127
	public final boolean unregisterShell(final Shell shell) {
128
		return contextAuthority.unregisterShell(shell);
128
		return contextAuthority.unregisterShell(shell);
129
	}
129
	}
130
131
    /**
132
     * <p>
133
     * Bug 95792. A mechanism by which the key binding architecture can force an
134
     * update of the contexts (based on the active shell) before trying to
135
     * execute a command. This mechanism is required for GTK+ only.
136
     * </p>
137
     * <p>
138
     * DO NOT CALL THIS METHOD.
139
     * </p>
140
     */
141
    public final void updateShellKludge() {
142
        contextAuthority.updateShellKludge();
143
    }
144
145
    /**
146
     * <p>
147
     * Bug 95792. A mechanism by which the key binding architecture can force an
148
     * update of the contexts (based on the active shell) before trying to
149
     * execute a command. This mechanism is required for GTK+ only.
150
     * </p>
151
     * <p>
152
     * DO NOT CALL THIS METHOD.
153
     * </p>
154
     * 
155
     * @param shell
156
     *            The shell that should be considered active; must not be
157
     *            <code>null</code>.
158
     */
159
    public final void updateShellKludge(final Shell shell) {
160
        contextAuthority.sourceChanged(ISources.ACTIVE_SHELL,
161
                ISources.ACTIVE_SHELL_NAME, shell);
162
    }
130
}
163
}
(-)Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java (+16 lines)
Lines 25-30 Link Here
25
import org.eclipse.core.expressions.IEvaluationContext;
25
import org.eclipse.core.expressions.IEvaluationContext;
26
import org.eclipse.ui.ISourceProvider;
26
import org.eclipse.ui.ISourceProvider;
27
import org.eclipse.ui.ISourceProviderListener;
27
import org.eclipse.ui.ISourceProviderListener;
28
import org.eclipse.ui.ISources;
28
import org.eclipse.ui.handlers.IHandlerActivation;
29
import org.eclipse.ui.handlers.IHandlerActivation;
29
import org.eclipse.ui.internal.misc.Policy;
30
import org.eclipse.ui.internal.misc.Policy;
30
31
Lines 520-523 Link Here
520
	private final void updateCurrentState() {
521
	private final void updateCurrentState() {
521
		fillInCurrentState(context);
522
		fillInCurrentState(context);
522
	}
523
	}
524
    
525
    /**
526
     * <p>
527
     * Bug 95792. A mechanism by which the key binding architecture can force an
528
     * update of the handlers (based on the active shell) before trying to
529
     * execute a command. This mechanism is required for GTK+ only.
530
     * </p>
531
     * <p>
532
     * DO NOT CALL THIS METHOD.
533
     * </p>
534
     */
535
    final void updateShellKludge() {
536
        updateCurrentState();
537
        sourceChanged(ISources.ACTIVE_SHELL);
538
    }
523
}
539
}
(-)Eclipse UI/org/eclipse/ui/internal/handlers/HandlerService.java (+34 lines)
Lines 19-24 Link Here
19
import org.eclipse.core.commands.IHandler;
19
import org.eclipse.core.commands.IHandler;
20
import org.eclipse.core.expressions.Expression;
20
import org.eclipse.core.expressions.Expression;
21
import org.eclipse.core.expressions.IEvaluationContext;
21
import org.eclipse.core.expressions.IEvaluationContext;
22
import org.eclipse.swt.widgets.Shell;
22
import org.eclipse.ui.ISourceProvider;
23
import org.eclipse.ui.ISourceProvider;
23
import org.eclipse.ui.ISources;
24
import org.eclipse.ui.ISources;
24
import org.eclipse.ui.handlers.IHandlerActivation;
25
import org.eclipse.ui.handlers.IHandlerActivation;
Lines 106-109 Link Here
106
	public final void removeSourceProvider(final ISourceProvider provider) {
107
	public final void removeSourceProvider(final ISourceProvider provider) {
107
		handlerAuthority.removeSourceProvider(provider);
108
		handlerAuthority.removeSourceProvider(provider);
108
	}
109
	}
110
111
    /**
112
     * <p>
113
     * Bug 95792. A mechanism by which the key binding architecture can force an
114
     * update of the handlers (based on the active shell) before trying to
115
     * execute a command. This mechanism is required for GTK+ only.
116
     * </p>
117
     * <p>
118
     * DO NOT CALL THIS METHOD.
119
     * </p>
120
     */
121
    public final void updateShellKludge() {
122
        handlerAuthority.updateShellKludge();
123
    }
124
125
    /**
126
     * <p>
127
     * Bug 95792. A mechanism by which the key binding architecture can force an
128
     * update of the handlers (based on the active shell) before trying to
129
     * execute a command. This mechanism is required for GTK+ only.
130
     * </p>
131
     * <p>
132
     * DO NOT CALL THIS METHOD.
133
     * </p>
134
     * 
135
     * @param shell
136
     *            The shell that should be considered active; must not be
137
     *            <code>null</code>.
138
     */
139
    public final void updateShellKludge(final Shell shell) {
140
        handlerAuthority.sourceChanged(ISources.ACTIVE_SHELL,
141
                ISources.ACTIVE_SHELL_NAME, shell);
142
    }
109
}
143
}
(-)Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java (+42 lines)
Lines 31-36 Link Here
31
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.custom.StyledText;
32
import org.eclipse.swt.custom.StyledText;
33
import org.eclipse.swt.widgets.Combo;
33
import org.eclipse.swt.widgets.Combo;
34
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.swt.widgets.Event;
36
import org.eclipse.swt.widgets.Event;
36
import org.eclipse.swt.widgets.Listener;
37
import org.eclipse.swt.widgets.Listener;
Lines 40-47 Link Here
40
import org.eclipse.ui.IWindowListener;
41
import org.eclipse.ui.IWindowListener;
41
import org.eclipse.ui.IWorkbench;
42
import org.eclipse.ui.IWorkbench;
42
import org.eclipse.ui.IWorkbenchWindow;
43
import org.eclipse.ui.IWorkbenchWindow;
44
import org.eclipse.ui.contexts.IContextService;
45
import org.eclipse.ui.handlers.IHandlerService;
43
import org.eclipse.ui.internal.Workbench;
46
import org.eclipse.ui.internal.Workbench;
44
import org.eclipse.ui.internal.WorkbenchPlugin;
47
import org.eclipse.ui.internal.WorkbenchPlugin;
48
import org.eclipse.ui.internal.contexts.ContextService;
49
import org.eclipse.ui.internal.handlers.HandlerService;
45
import org.eclipse.ui.internal.misc.Policy;
50
import org.eclipse.ui.internal.misc.Policy;
46
import org.eclipse.ui.internal.util.Util;
51
import org.eclipse.ui.internal.util.Util;
47
import org.eclipse.ui.keys.IBindingService;
52
import org.eclipse.ui.keys.IBindingService;
Lines 724-729 Link Here
724
							+ potentialKeyStrokes + ")"); //$NON-NLS-1$
729
							+ potentialKeyStrokes + ")"); //$NON-NLS-1$
725
		}
730
		}
726
        
731
        
732
        /*
733
         * KLUDGE. This works around a couple of specific problems in how GTK+
734
         * works. The first problem is the ordering of key press events with
735
         * respect to shell activation events. If on the event thread a dialog
736
         * is about to open, and the user presses a key, the key press event
737
         * will arrive before the shell activation event. From the perspective
738
         * of Eclipse, this means that things like two "Open Type" dialogs can
739
         * appear if "Ctrl+Shift+T" is pressed twice rapidly. For more
740
         * information, please see Bug 95792. The second problem is simply a bug
741
         * in GTK+, for which an incomplete workaround currently exists in SWT.
742
         * This makes shell activation events unreliable. Please see Bug 56231
743
         * and Bug 95222 for more information.
744
         */
745
        if ("gtk".equals(SWT.getPlatform())) { //$NON-NLS-1$
746
            final Widget widget = event.widget;
747
748
            // Update the contexts.
749
            final ContextService contextService = (ContextService) workbench
750
                    .getAdapter(IContextService.class);
751
            if ((widget instanceof Control) && (!widget.isDisposed())) {
752
                final Shell shell = ((Control) widget).getShell();
753
                contextService.updateShellKludge(shell);
754
            } else {
755
                contextService.updateShellKludge();
756
            }
757
758
            // Update the handlers.
759
            final HandlerService handlerService = (HandlerService) workbench
760
                    .getAdapter(IHandlerService.class);
761
            if ((widget instanceof Control) && (!widget.isDisposed())) {
762
                final Shell shell = ((Control) widget).getShell();
763
                handlerService.updateShellKludge(shell);
764
            } else {
765
                handlerService.updateShellKludge();
766
            }
767
        } 
768
        
727
		KeySequence sequenceBeforeKeyStroke = state.getCurrentSequence();
769
		KeySequence sequenceBeforeKeyStroke = state.getCurrentSequence();
728
		for (Iterator iterator = potentialKeyStrokes.iterator(); iterator
770
		for (Iterator iterator = potentialKeyStrokes.iterator(); iterator
729
				.hasNext();) {
771
				.hasNext();) {

Return to bug 95222