Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandra Buzila2015-01-12 09:06:28 +0000
committerArun Thondapu2015-04-23 10:24:04 +0000
commitb73210b3ae347e174d94d1d65890dbcff0242ce4 (patch)
treee0f162a58e990d58b5a35aecc2c5d25bed11e4f6 /bundles/org.eclipse.swt
parent1f910fb2129bc04b508cae95ff4a02f4aa339c24 (diff)
downloadeclipse.platform.swt-b73210b3ae347e174d94d1d65890dbcff0242ce4.tar.gz
eclipse.platform.swt-b73210b3ae347e174d94d1d65890dbcff0242ce4.tar.xz
eclipse.platform.swt-b73210b3ae347e174d94d1d65890dbcff0242ce4.zip
Bug 445456 - Ignored style hints for shells
Shells with a parent can't have any button on the titlebar except for the close one, when running Metacity. This fix enables the minimize and maximize buttons for child shells, by removing the GDK_WINDOW_TYPE_HINT_DIALOG type hint and calling the gdk_window_set_functions method when setting the decorations of a shell. The code was tested against CentOS release 6.6, Metacity 2.28.0 and gtk2-2.2423-6. Change-Id: If320be2ac9ecd7fe3090a164add1015b4ff0f228 Signed-off-by: Alexandra Buzila <abuzila@eclipsesource.com>
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java43
5 files changed, 66 insertions, 8 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 d7ff0e2f8b..f16748c0c7 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
@@ -8285,6 +8285,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1events)
}
#endif
+#ifndef NO__1gdk_1window_1set_1functions
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1functions)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1functions_FUNC);
+ gdk_window_set_functions((GdkWindow *)arg0, (GdkWMFunction)arg1);
+ OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1functions_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1window_1set_1override_1redirect
JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1override_1redirect)
(JNIEnv *env, jclass that, jintLong arg0, jboolean arg1)
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 9df99a13cf..5b8b2ceb58 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
@@ -614,6 +614,7 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1window_1set_1debug_1updates",
"_1gdk_1window_1set_1decorations",
"_1gdk_1window_1set_1events",
+ "_1gdk_1window_1set_1functions",
"_1gdk_1window_1set_1override_1redirect",
"_1gdk_1window_1set_1user_1data",
"_1gdk_1window_1shape_1combine_1region",
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 d3383477bb..cba5bbc91f 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
@@ -624,6 +624,7 @@ typedef enum {
_1gdk_1window_1set_1debug_1updates_FUNC,
_1gdk_1window_1set_1decorations_FUNC,
_1gdk_1window_1set_1events_FUNC,
+ _1gdk_1window_1set_1functions_FUNC,
_1gdk_1window_1set_1override_1redirect_FUNC,
_1gdk_1window_1set_1user_1data_FUNC,
_1gdk_1window_1shape_1combine_1region_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 54268e60df..5d59b5a0db 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
@@ -161,6 +161,12 @@ public class OS extends C {
public static final int GDK_FOCUS_CHANGE = 0xc;
public static final int GDK_FOCUS_CHANGE_MASK = 0x4000;
public static final int GDK_GC_FOREGROUND = 0x1;
+ public static final int GDK_FUNC_ALL = 1;
+ public static final int GDK_FUNC_RESIZE = 2;
+ public static final int GDK_FUNC_MOVE = 4;
+ public static final int GDK_FUNC_MINIMIZE = 8;
+ public static final int GDK_FUNC_MAXIMIZE = 16;
+ public static final int GDK_FUNC_CLOSE = 32;
public static final int GDK_GC_CLIP_MASK = 0x80;
public static final int GDK_GC_CLIP_X_ORIGIN = 0x800;
public static final int GDK_GC_CLIP_Y_ORIGIN = 0x1000;
@@ -6070,6 +6076,19 @@ public static final void gdk_window_set_decorations(long /*int*/ window, int dec
lock.unlock();
}
}
+/**
+ * @param window cast=(GdkWindow *)
+ * @param functions cast=(GdkWMFunction)
+ */
+public static final native void _gdk_window_set_functions(long /*int*/ window, int functions);
+public static final void gdk_window_set_functions(long /*int*/ window, int functions) {
+ lock.lock();
+ try {
+ _gdk_window_set_functions(window, functions);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param window cast=(GdkWindow *) */
public static final native void _gdk_window_set_events(long /*int*/ window, int event_mask);
public static final void gdk_window_set_events(long /*int*/ window, int event_mask) {
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 c6e99c999c..42160c006c 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
@@ -697,11 +697,18 @@ void createHandle (int index) {
if (parent != null) {
OS.gtk_window_set_transient_for (shellHandle, parent.topHandle ());
OS.gtk_window_set_destroy_with_parent (shellHandle, true);
- if (!isUndecorated ()) {
- OS.gtk_window_set_type_hint (shellHandle, OS.GDK_WINDOW_TYPE_HINT_DIALOG);
- } else {
- OS.gtk_window_set_skip_taskbar_hint (shellHandle, true);
- }
+ OS.gtk_window_set_skip_taskbar_hint(shellHandle, true);
+
+ /*
+ * For systems running Metacity, by applying the dialog type hint
+ * to a window only the close button can be placed on the title bar.
+ * The style hints for the minimize and maximize buttons are ignored.
+ * See bug 445456.
+ *
+ */
+// if (!isUndecorated ()) {
+// OS.gtk_window_set_type_hint (shellHandle, OS.GDK_WINDOW_TYPE_HINT_DIALOG);
+// }
}
/*
* Feature in GTK. The window size must be set when the window
@@ -1528,13 +1535,24 @@ long /*int*/ gtk_realize (long /*int*/ widget) {
long /*int*/ window = gtk_widget_get_window (shellHandle);
if ((style & SWT.SHELL_TRIM) != SWT.SHELL_TRIM) {
int decorations = 0;
+ int functions = 0;
if ((style & SWT.NO_TRIM) == 0) {
- if ((style & SWT.MIN) != 0) decorations |= OS.GDK_DECOR_MINIMIZE;
- if ((style & SWT.MAX) != 0) decorations |= OS.GDK_DECOR_MAXIMIZE;
- if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_RESIZEH;
+ if ((style & SWT.MIN) != 0) {
+ decorations |= OS.GDK_DECOR_MINIMIZE;
+ functions |= OS.GDK_FUNC_MINIMIZE;
+ }
+ if ((style & SWT.MAX) != 0) {
+ decorations |= OS.GDK_DECOR_MAXIMIZE;
+ functions |= OS.GDK_FUNC_MAXIMIZE;
+ }
+ if ((style & SWT.RESIZE) != 0) {
+ decorations |= OS.GDK_DECOR_RESIZEH;
+ functions |= OS.GDK_FUNC_RESIZE;
+ }
if ((style & SWT.BORDER) != 0) decorations |= OS.GDK_DECOR_BORDER;
if ((style & SWT.MENU) != 0) decorations |= OS.GDK_DECOR_MENU;
if ((style & SWT.TITLE) != 0) decorations |= OS.GDK_DECOR_TITLE;
+ if ((style & SWT.CLOSE) != 0) functions |= OS.GDK_FUNC_CLOSE;
/*
* Feature in GTK. Under some Window Managers (Sawmill), in order
* to get any border at all from the window manager it is necessary to
@@ -1542,8 +1560,17 @@ long /*int*/ gtk_realize (long /*int*/ widget) {
* kind of border is requested.
*/
if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_BORDER;
+ functions |= OS.GDK_FUNC_MOVE;
}
OS.gdk_window_set_decorations (window, decorations);
+
+ /*
+ * For systems running Metacity, this call forces the style hints to
+ * be displayed in a window's titlebar. Otherwise, the decorations
+ * set by the function gdk_window_set_decorations (window,
+ * decorations) are ignored by the window manager.
+ */
+ OS.gdk_window_set_functions(window, functions);
}
if ((style & SWT.ON_TOP) != 0) {
OS.gdk_window_set_override_redirect (window, true);

Back to the top