diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-08-01 16:44:39 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-08-01 16:44:39 -0400 |
commit | df2d350ecfa28b694f2708b078781035f08a564f (patch) | |
tree | 73ae4c8e8cc7204ded48efc3cda693ddd8054893 | |
parent | 5c86f97b0796c62d600afd123ee8f6d67d729918 (diff) | |
download | eclipse.platform.swt-gtk_widget_has_focus_.tar.gz eclipse.platform.swt-gtk_widget_has_focus_.tar.xz eclipse.platform.swt-gtk_widget_has_focus_.zip |
Use gtk_widget_has_focus instead of deprecated GTK_WIDGET_HAS_FOCUSgtk_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 155d1a0b2c..c9f4ab1147 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 @@ -15633,6 +15633,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 11a7ba3790..86019fb7dd 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 @@ -200,6 +200,7 @@ #define gtk_window_set_skip_taskbar_hint_LIB LIB_GTK #define gtk_widget_is_composited_LIB LIB_GTK #define gtk_widget_get_tooltip_text_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 @@ -363,6 +364,9 @@ #else #define GTK_SCROLLED_WINDOW_VSCROLLBAR(arg0) (arg0)->vscrollbar #endif +#ifndef GTK_WIDGET_HAS_FOCUS +#define GTK_WIDGET_HAS_FOCUS(arg0) 0 +#endif #ifndef GTK_WIDGET_HAS_DEFAULT #define GTK_WIDGET_HAS_DEFAULT(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 4468de2f88..6b21ed555a 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 = 1320; -int OS_nativeFunctionCallCount[1320]; +int OS_nativeFunctionCount = 1321; +int OS_nativeFunctionCallCount[1321]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -1237,6 +1237,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1get_1toplevel", "_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 da5dd954ae..76930c952f 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 @@ -1245,6 +1245,7 @@ typedef enum { _1gtk_1widget_1get_1toplevel_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 b13bdeadd2..6f6ba939d7 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 @@ -12232,6 +12232,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 84c8c8fbf2..611c93c009 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 @@ -582,7 +582,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 7bdb801a71..251ef8f976 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 @@ -2346,7 +2346,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 5bd836678d..6dc6ece648 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 @@ -339,7 +339,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 2a62e480cc..753c0c1992 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 @@ -509,7 +509,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 e60becf080..fe5c95a298 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 @@ -1858,7 +1858,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 f46c23ffb9..f70c272ee8 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 @@ -1861,7 +1861,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 778e9bb987..29483d7e28 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; } |