diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-08-02 10:36:18 -0400 |
---|---|---|
committer | Arun Thondapu <arunkumar.thondapu@in.ibm.com> | 2012-08-06 12:43:12 +0530 |
commit | 2c810dc09ebe584d949d1446e7fe61dd64fa3e80 (patch) | |
tree | f5a8803654756be767c989b7c19e47b11c5f7e0a | |
parent | f7c3702d11c37a529c17c656666e0253dc7c849e (diff) | |
download | eclipse.platform.swt-2c810dc09ebe584d949d1446e7fe61dd64fa3e80.tar.gz eclipse.platform.swt-2c810dc09ebe584d949d1446e7fe61dd64fa3e80.tar.xz eclipse.platform.swt-2c810dc09ebe584d949d1446e7fe61dd64fa3e80.zip |
Bug 385070 Use gtk_widget_has_focus instead of deprecated GTK_WIDGET_HAS_FOCUS
14 files changed, 54 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 1bf69d95c6..eec327c6e8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -15827,6 +15827,26 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1has_1default) } #endif +#ifndef NO__1gtk_1widget_1has_1focus +JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1has_1focus) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jboolean rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1has_1focus_FUNC); +/* + rc = (jboolean)gtk_widget_has_focus(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_has_focus) + if (fp) { + rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1has_1focus_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1widget_1hide JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1hide) (JNIEnv *env, jclass that, jintLong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h index 8783dcf1af..5e1316d614 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h @@ -206,6 +206,7 @@ #define gtk_widget_get_allocation_LIB LIB_GTK #define gtk_widget_get_tooltip_text_LIB LIB_GTK #define gtk_widget_get_visible_LIB LIB_GTK +#define gtk_widget_has_focus_LIB LIB_GTK #define gtk_widget_has_default_LIB LIB_GTK #define gtk_widget_set_tooltip_text_LIB LIB_GTK #define gtk_widget_set_has_window_LIB LIB_GTK @@ -379,6 +380,9 @@ #ifndef GTK_WIDGET_HAS_DEFAULT #define GTK_WIDGET_HAS_DEFAULT(arg0) 0 #endif +#ifndef GTK_WIDGET_HAS_FOCUS +#define GTK_WIDGET_HAS_FOCUS(arg0) 0 +#endif #ifndef GTK_WIDGET_SENSITIVE #define GTK_WIDGET_SENSITIVE(arg0) 0 #endif diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index a407f9d857..12a1623875 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -18,8 +18,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1330; -int OS_nativeFunctionCallCount[1330]; +int OS_nativeFunctionCount = 1331; +int OS_nativeFunctionCallCount[1331]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -1247,6 +1247,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1get_1visible", "_1gtk_1widget_1grab_1focus", "_1gtk_1widget_1has_1default", + "_1gtk_1widget_1has_1focus", "_1gtk_1widget_1hide", "_1gtk_1widget_1is_1composited", "_1gtk_1widget_1is_1focus", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 9e6b873f8e..bd9f5ce063 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -1255,6 +1255,7 @@ typedef enum { _1gtk_1widget_1get_1visible_FUNC, _1gtk_1widget_1grab_1focus_FUNC, _1gtk_1widget_1has_1default_FUNC, + _1gtk_1widget_1has_1focus_FUNC, _1gtk_1widget_1hide_FUNC, _1gtk_1widget_1is_1composited_FUNC, _1gtk_1widget_1is_1focus_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index 7d4ad57f19..f2dbe0a18d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -12338,6 +12338,16 @@ public static final void gtk_widget_grab_focus(int /*long*/ widget) { lock.unlock(); } } +/** @method flags=dynamic */ +public static final native boolean _gtk_widget_has_focus(int /*long*/ widget); +public static final boolean gtk_widget_has_focus(int /*long*/ widget) { + lock.lock(); + try { + return _gtk_widget_has_focus(widget); + } finally { + lock.unlock(); + } +} /** @param widget cast=(GtkWidget *) */ public static final native void _gtk_widget_hide(int /*long*/ widget); public static final void gtk_widget_hide(int /*long*/ widget) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java index 695e23ebc9..c8cf6b11d7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java @@ -612,7 +612,7 @@ int /*long*/ focusHandle () { boolean hasFocus () { if (super.hasFocus ()) return true; - if (entryHandle != 0 && OS.GTK_WIDGET_HAS_FOCUS (entryHandle)) return true; + if (entryHandle != 0 && gtk_widget_has_focus (entryHandle)) return true; return false; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index 46c7f8a438..2fdee0e79a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -2414,7 +2414,7 @@ public boolean forceFocus () { } boolean forceFocus (int /*long*/ focusHandle) { - if (OS.GTK_WIDGET_HAS_FOCUS (focusHandle)) return true; + if (gtk_widget_has_focus (focusHandle)) return true; /* When the control is zero sized it must be realized */ OS.gtk_widget_realize (focusHandle); OS.gtk_widget_grab_focus (focusHandle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java index 8a53c5cdc2..62ac399ec3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java @@ -345,7 +345,7 @@ int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) { } boolean hasFocus () { - return OS.GTK_WIDGET_HAS_FOCUS (handle); + return gtk_widget_has_focus (handle); } void hookEvents () { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java index 0aa8fbe8e1..f7dbfe5506 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java @@ -761,7 +761,7 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { * it finishes processing a button press. The fix is to give * focus to the widget before it starts processing the event. */ - if (!OS.GTK_WIDGET_HAS_FOCUS (handle)) { + if (!gtk_widget_has_focus (handle)) { OS.gtk_widget_grab_focus (handle); } return result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index bd91287d3d..8b376ae180 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -518,7 +518,7 @@ void bringToTop (boolean force) { if (activeShell == null) return; if (!display.activePending) { int /*long*/ focusHandle = OS.gtk_window_get_focus (activeShell.shellHandle); - if (focusHandle != 0 && !OS.GTK_WIDGET_HAS_FOCUS (focusHandle)) return; + if (focusHandle != 0 && !gtk_widget_has_focus (focusHandle)) return; } } /* diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index bedf924054..5b27e9ad3b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java @@ -1867,7 +1867,7 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { * it finishes processing a button press. The fix is to give * focus to the widget before it starts processing the event. */ - if (!OS.GTK_WIDGET_HAS_FOCUS (handle)) { + if (!gtk_widget_has_focus (handle)) { OS.gtk_widget_grab_focus (handle); } return result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index 002686946c..55f335308c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -1546,7 +1546,7 @@ int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ event) { int /*long*/ result = super.gtk_expose_event (widget, event); if ((style & SWT.SINGLE) != 0 && message.length () > 0) { int /*long*/ str = OS.gtk_entry_get_text (handle); - if (!OS.GTK_WIDGET_HAS_FOCUS (handle) && OS.strlen (str) == 0) { + if (!gtk_widget_has_focus (handle) && OS.strlen (str) == 0) { GdkEventExpose gdkEvent = new GdkEventExpose (); OS.memmove (gdkEvent, event, GdkEventExpose.sizeof); int /*long*/ window = paintWindow (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java index 9b3fe340f6..58842aaf64 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java @@ -1870,7 +1870,7 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { * it finishes processing a button press. The fix is to give * focus to the widget before it starts processing the event. */ - if (!OS.GTK_WIDGET_HAS_FOCUS (handle)) { + if (!gtk_widget_has_focus (handle)) { OS.gtk_widget_grab_focus (handle); } return result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java index b9923e57f7..3f019dec9f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java @@ -906,6 +906,14 @@ boolean gtk_widget_get_mapped (int /*long*/ widget) { } } +boolean gtk_widget_has_focus (int /*long*/ widget) { + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + return OS.gtk_widget_has_focus (widget); + } else { + return OS.GTK_WIDGET_HAS_FOCUS (widget); + } +} + int /*long*/ gtk_window_state_event (int /*long*/ widget, int /*long*/ event) { return 0; } |